Please sign in to comment.
[FIX] payment_stripe_sca: better error handling
In some cases, Stripe will return the result of a transaction with a faulty HTTP Status (e.g. 4XX statuses) - not because the request was malformed, but because the payment failed. It is a bit unfortunate that Stripe would not differentiate between payment status and request validity, but that's the state of things. This commit ensures that such a response will be logged correctly, by making the call to `raise_for_status` conditionnal on the response object's status code and internal structure, forwarding the response's json to the validation flow if the status is in the 4XX range and a `code` key is found in the response, as described in https://stripe.com/docs/error-codes While testing this fix, it became apparent that some error message processing in the frontend was not correctly handled as well - instead of purely rejecting the promise, a failed payment should still send its payload to the backend, to allow the server to put the transaction in the correct state according to the response.
- Loading branch information
Showing with 16 additions and 16 deletions.