Fix StripeCreditCard#try_void with Elements/V2 API#75
Merged
spaghetticode merged 1 commit intoJul 17, 2020
Merged
Conversation
`Payment::Cancellation#cancel` calls StripeCreditCard#try_void`. When not using Payment Intents (ie. when using Elements or V2 API), after calling `try_void`, the former makes the following call: payment.send(:handle_void_response, response) which is already called by `payment.void_transaction!`, making the two incompatible, as `#handle_void_response` cannot be called twice here - it would raise the error: NoMethodError: undefined method `success?' for true:TrueClass Under the hood `#void_transaction!` calls `payment_method.void`, so the new code is rather equivalent to the previous one. The only relevant feature we're losing is that `#void_transaction!` wraps the call in a `protect_from_connection_error` block. The modified integration spec verifies that an order created with Elements can be cancelled without raising the error mentioned above.
98154b6 to
3156c01
Compare
Member
|
@spaghetticode do you think there is a way to maintain the |
Member
Author
|
@aldesantis I share your same feeling. I was a bit hesitant is adding |
Member
|
@spaghetticode yeah, I think that makes sense. Let's move forward without it and at some point we should probably extract it directly in the core. |
aldesantis
approved these changes
Jul 17, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Payment::Cancellation#cancelcalls StripeCreditCard#try_void`.When not using Payment Intents (ie. when using Elements or V2 API), after calling
try_void, the former makes the following call:which is already called by
payment.void_transaction!, making the two incompatible, as#handle_void_responsecannot be called twice here - it would raise the error:Under the hood
#void_transaction!callspayment_method.void, so the new code is rather equivalent to the previous one. The only relevant feature we're losing is that#void_transaction!wraps the call in aprotect_from_connection_errorblock.The modified integration spec verifies that an order created with Elements can be canceled without raising the error mentioned above.