This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
fix: Capture-context cancel and create Payment Intent update #4156
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.
REV-3821.
When a card is declined, the Payment Intent is canceled. Previously we didn't address this concern, and I'd imagine it was something that was happening.
Now with the introduction of the
cancel_and_create_new_payment_intent()
check on/capture-context
endpoint, we call this function to reset the payment, by canceling the existing Payment Intent and creating a new one.In local testing we found that if we call Stripe to create a new PI with idempotency key, it keeps the same PI, even with canceled status. So this scenario should go through
cancel_and_create_new_payment_intent()
without idempotency key.However, when we call to cancel on an existing Payment Intent with status canceled, it errors out with -
You cannot cancel this PaymentIntent because it has a status of canceled. Only a PaymentIntent with one of the following statuses may be canceled: requires_payment_method, requires_capture, requires_confirmation, requires_action, processing.
Adding a try/except to avoid this.