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

Braintree Blue: Refactor and add payment details to failed transactions #5050

Merged
merged 1 commit into from
Mar 6, 2024

Conversation

yunnydang
Copy link
Contributor

@yunnydang yunnydang commented Feb 27, 2024

This refactors a slight portion of the transaction hash regarding the payment details object that is being returned depending on which payment method is used. Also returns the these objects on failing transactions and added small fixes to previously failing tests. Also fixes some rubocop related issues.

Local:
5816 tests, 78913 assertions, 2 failures, 30 errors, 0 pendings, 0 omissions, 0 notifications
99.4498% passed

Unit:
103 tests, 218 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Remote:
120 tests, 634 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

@yunnydang yunnydang requested a review from a team February 27, 2024 20:44
@yunnydang yunnydang self-assigned this Feb 27, 2024
Copy link
Contributor

@jcreiff jcreiff left a comment

Choose a reason for hiding this comment

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

This looks good to me, although I left one comment for your consideration.

The remote and unit tests all run successfully for me, so it appears this minor refactor should be compatible with the way the gateway has been working to this point. We'll just be getting more data surfaced on failed transactions.

Out of curiosity, what did you learn in your testing that suggested the reason for the narrow scope of the original return block?

lib/active_merchant/billing/gateways/braintree_blue.rb Outdated Show resolved Hide resolved
@yunnydang
Copy link
Contributor Author

yunnydang commented Mar 4, 2024

This looks good to me, although I left one comment for your consideration.

The remote and unit tests all run successfully for me, so it appears this minor refactor should be compatible with the way the gateway has been working to this point. We'll just be getting more data surfaced on failed transactions.

Out of curiosity, what did you learn in your testing that suggested the reason for the narrow scope of the original return block?

Thanks for the review Joe! To answer your question regarding narrowing the scope of the return block:

Essentially it was written that way so that none of the rest of the transaction hash can be built if there are failure transactions. Braintree returns a slightly different structured response on said transactions and it results in noMethodErrors on actions such as credit, void, and refund I believe when I run the entire test suite

@yunnydang yunnydang force-pushed the braintree_return_failure_transaction_hash branch 2 times, most recently from 1dd7e72 to a23317b Compare March 5, 2024 00:24
@yunnydang yunnydang requested a review from jcreiff March 5, 2024 00:25
@yunnydang
Copy link
Contributor Author

hey @jcreiff I know you approved, but I just wanted some quick re-review on this as I tweaked a little bit of things rubocop related. Thanks!

Copy link
Contributor

@jcreiff jcreiff left a comment

Choose a reason for hiding this comment

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

Thanks for cleaning up the rubocop offenses - looks good!

@yunnydang yunnydang force-pushed the braintree_return_failure_transaction_hash branch from a23317b to 9fef8cc Compare March 5, 2024 19:13
@yunnydang
Copy link
Contributor Author

yunnydang commented Mar 5, 2024

heya @jcreiff I added some more stuff to this as I remembered that we're also expecting the payment_instrument_type to be returned so it can dig into the correct object depending on payment methods. This way the response object can be actually surfaced, thanks!

also reran all the tests and its working as intended

@yunnydang yunnydang requested a review from jcreiff March 5, 2024 19:15
@yunnydang yunnydang force-pushed the braintree_return_failure_transaction_hash branch from 9fef8cc to 5d33f10 Compare March 5, 2024 19:58
Copy link
Contributor

@jcreiff jcreiff left a comment

Choose a reason for hiding this comment

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

🚢

@yunnydang yunnydang force-pushed the braintree_return_failure_transaction_hash branch from 5d33f10 to b3dd83f Compare March 6, 2024 17:44
@yunnydang yunnydang merged commit b3dd83f into master Mar 6, 2024
0 of 5 checks passed
@yunnydang yunnydang deleted the braintree_return_failure_transaction_hash branch March 6, 2024 18:43
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.

2 participants