Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom fields for TrustCommerce #3313

Merged

Conversation

jasonxp
Copy link
Contributor

@jasonxp jasonxp commented Aug 27, 2019

Also fix some tests that previously failed.

Unit:
4236 tests, 70441 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications
100% passed

Remote:
17 tests, 67 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

@jasonxp jasonxp requested review from a team August 27, 2019 05:34
@jasonxp jasonxp force-pushed the ce-96-trust-commerce-custom-fields branch from 4a0482d to dd8e364 Compare August 27, 2019 05:37
@@ -463,7 +483,7 @@ def authorization_from(action, data)
end

def split_authorization(authorization)
authorization.split('|')
authorization&.split('|')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a null safety check that fixed an error that occurred when the authorization was nil.

@jasonxp jasonxp force-pushed the ce-96-trust-commerce-custom-fields branch from dd8e364 to 1b57682 Compare August 27, 2019 05:42
Copy link
Contributor

@molbrown molbrown left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Copy link
Contributor

@leila-alderman leila-alderman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made several suggestions and added a few general questions throughout. Enjoyed the opportunity to learn more about implementing custom fields!

# To confirm that the field values are being stored with the transactions, add a custom
# field in your account in the Vault UI, then examine the transactions after running the
# test suite.
custom_fields = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💙the clarifying comments!

@jasonxp jasonxp force-pushed the ce-96-trust-commerce-custom-fields branch from 1b57682 to c7471a3 Compare August 28, 2019 04:59
@jasonxp
Copy link
Contributor Author

jasonxp commented Aug 28, 2019

@leila-alderman All feedback has been addressed with the latest commit.

@@ -5,6 +5,7 @@ def setup
@gateway = TrustCommerceGateway.new(fixtures(:trust_commerce))

@credit_card = credit_card('4111111111111111')
@bad_credit_card = credit_card('4111111111111112')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The standard variable name for this seems to be @declined_card.
(Within the Active Merchant code base, there are 33 instances of bad_credit_card and over 400 instances of declined_card.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the variable name here indicates its use in the tests, and can't quite see impact/value in making additional changes to match a majority of other, similar variable names in different tests. Let me know if you think otherwise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you feel that declined_card isn't as descriptive of its use in the tests?

Having generally seen declined_card used as the variable name in Active Merchant tests, I just noticed the different name and had to do a quick check to see whether it was trying to accomplish the same thing. I think it's cleaner, simpler, and clearer to stick to the same variable name that's widely used throughout. I'm generally a big fan of consistency. 😀

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, in this case I think bad_credit_card is more descriptive. "Declined" suggests to me that there was or at least will be an attempted transaction by the gateway. This card is used in a test that generates a format error, without the gateway attempting to transact.

I agree consistency is generally good, but I do think there is a tradeoff when it comes to making revisions to address minutia. Time and focus is extremely valuable as well, and I think that we could be sacrificing too much of them if we get in the habit of worrying about this level of detail (matching variable names in other test files).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would tend to disagree. I noticed that this variable name was different than what I was accustomed to seeing and had to spend more time tracking it down and clarifying whether it was the same as declined_card or if it was indicating something else. I feel that maintaining consistency saves time long term, and I also feel that accurate and effective code lies in the details and that this would be a pretty quick and easy change to make.

All that said, those are just my opinions, and this is your PR. Thanks for being open to discussion on these issues!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for that perspective. I would have understood the use from the variable name and definition, so it's interesting to learn that wouldn't be the case for everyone. My general thought is mainly that I wouldn't expect people to spend time searching for stats on which similar local/instance variable names are more commonly used in other files in the codebase, as I wouldn't see that as an effective use of time relative to the value it would provide. It could be a slippery slope of time consumption if we held variable name popularity across files as a standard. I'm happy to change the name here since you've already done that legwork while working to understand the code.

@jasonxp jasonxp force-pushed the ce-96-trust-commerce-custom-fields branch 3 times, most recently from dc3114c to e96e571 Compare August 29, 2019 18:03
Also fix some tests that previously failed.

Unit:
4236 tests, 70441 assertions, 0 failures, 0 errors, 0 pendings, 2 omissions, 0 notifications
100% passed

Remote:
17 tests, 67 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

CE-96
@jasonxp jasonxp force-pushed the ce-96-trust-commerce-custom-fields branch from e96e571 to faa6ed6 Compare August 29, 2019 18:04
@jasonxp jasonxp merged commit faa6ed6 into activemerchant:master Aug 29, 2019
@jasonxp jasonxp deleted the ce-96-trust-commerce-custom-fields branch August 29, 2019 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants