Make 'retry' property on errors from checkoutAfterProcessingWithSuccess/Error observers default to true if it's undefined #3261
Conversation
Size Change: +179 B (0%) Total Size: 1.11 MB
ℹ️ View Unchanged
|
feels weird to treat undefined as true, why not make sure payment methods return the correct value? What's the behavior we're aiming for here?
|
Maybe, based on that, we can decide to rename this variable to make it obvious. |
The idea is to provide good defaults, so there is less risk for payment methods to introduce bugs (like #3221). I don't have any data supporting why the default should be true instead of false, so I'm happy to be proven wrong, but at least for Stripe and WC Payments we needed to support retrying after an error, and I can imagine that's the most common behavior among other payment methods. In any case,
Correct, that's the behavior we are trying to achieve: always retry unless Note: If we were to rename |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this makes sense in the broader terms, maybe we can change the wording from 'undefined' to saying it defaults to true.
I'd probably also wait and see what Darren has to say about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, I do wonder if we should add a shouldRetry
function to the useEmitResponse
hook to include this check and logic centralized there? That way the condition could just be:
if ( shouldRetry( response ) )
Which is a bit clear and keeps the actual default coercion logic in the useEmitResponse
hook?
I'm going to pre approve anyways - up to you Albert whether you modify for the above or not.
Fixes #3221.
Errors in WC Payments were not recoverable because the
retry
property was not specified in the error response, so it was consideredfalse
. This behavior was a bit inconsistent in our codebase, becauseretry
needed to be truthy inCHECKOUT_AFTER_PROCESSING_WITH_SUCCESS
, but was allowed to be undefined inCHECKOUT_AFTER_PROCESSING_WITH_ERROR
.This PR updates the Checkout Provider so if retry is undefined, it treats it as if it was
true
.How to test the changes in this Pull Request:
4000 0027 6000 3184
, but in the validation popup, press onFail authentication
orCancel
.Place Order
button doesn't stay disabled and you can resubmit the order.Changelog