-
Notifications
You must be signed in to change notification settings - Fork 219
Rollback checkout status to started instead of pristine in case of error #5318
Conversation
cc @peterlama you did a lot of debugging in #5296 do you think this solutions cover all of its basis, do you happen to have another approach in mind? @mikejolley you wrote the original code so it's worth giving this another look? |
Size Change: +200 B (0%) Total Size: 841 kB
ℹ️ View Unchanged
|
@senadir Setting the status to started seems like a good solution to me! Although, I wonder if the status should only be started if a saved payment method is selected? I noticed a check for that here: payment-method-data-context.tsx#L234 |
After much consideration, I'm not sure |
@senadir As long as we have a way to distinguish |
28a8c8c
to
ee764e3
Compare
@@ -66,6 +67,8 @@ export interface PaymentMethodDataContextState { | |||
export type PaymentMethodCurrentStatusType = { | |||
// If true then the payment method state in checkout is pristine. | |||
isPristine: boolean; | |||
// If true then the payment method state in checkout is modified, but isn't doing anyting. |
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 find this comment confusing, especially the but isn't doing anyting.
part. It's unclear to me what part is not doing anything? Does this idle state for a payment menthod happen when at the same time with this idle status?
@@ -222,7 +222,7 @@ export const PaymentMethodDataProvider = ( { | |||
// When checkout is returned to idle, set payment status to pristine but only if payment status is already not finished. |
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.
This comment also needs updated, just replace pristine with idle here set payment status to pristine but only
. It might help to leave some comment with the reason why this is necessary
When checkouts runs into an error (local validation for example), its status is rolled back to pristine, causing payment saved data to unload. For some reasoning, fixing errors and hitting submit again doesn't reset saved payment methods, @alexflorisca and I had two solutions:
Fixes #5296
Testing
How to test the changes in this Pull Request:
Changelog