-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Wallets] Display payment declines on the checkout and re-enable the Place order button after closing the modal #3187
Conversation
// We need to unset the redirect URL otherwise WC core will redirect the the previous checkout redirectURL. | ||
// For Wallet payment methods, that will include the #wc-stripe-wallet-... hash and cause the modal to show again. | ||
checkoutStore.__internalSetRedirectUrl( null ); | ||
checkoutStore.__internalSetIdle(); |
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 branch uses a number of functions marked as internal. I'm not sure if that's not a good idea but this was the only way I could get the payment form to unblock and for the payment elements to be reusable.
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.
It works as described, but I agree the internal functions are not ideal... maybe we can get some guidance from @woocommerce/rubik?
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'm struggling to understand this, what would cause this flow to trigger? a failed express payment?
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'm struggling to understand this, what would cause this flow to trigger?
So the set up is a little unorthodox.
When you click the place order button, the process payment request on the server responds with a redirect URL that triggers a modal to be shown.
Wechat.mov
When you close that modal, or if payment fails (and Stripe auto close the modal) we needed to reinit the checkout because it was stuck in the "complete" status from the previous request. This code is essentially doing that.
- We need to set the URL to
null
because otherwise calling__internalSetIdle()
would cause WC core to redirect the "currentURL" which was the last URL response. I've lost the copy of the stacktrace I had that indicated this but let me know if you want it I should be able to find it again. - I then set the status to idle so the checkout can be resubmitted. Without this the checkout remained completed and the place order button was disabled.
So, this function is called when the modal is closed so the customer can reattempt checkout.
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.
Thanks for working on this @james-allan.
I found a problem with reading window.wc.wcBlocksData
in the utils.js
... getting the constants after checking wcSettings.wcBlocksConfig
in each function seems like the easiest solution 🤷🏼
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.
Thanks @james-allan... it works perfectly now 🚢
Fixes #3168
Changes proposed in this Pull Request:
This PR fixes 2 issues with Wallet payment methods (Cash App and WeChat).
With this PR if you fail the wallet payment it will now leave you on the checkout and display the error received from Stripe. If you close the modal, the block checkout is reinitialised so you can reattempt payment.
Testing instructions
7. On develop the Place Order button remains disabled. It's not possible to place the order until you reload the page.
8. On this branch the place order button should be ready to go again.
develop
develop
you would be redirected to the order received page. Where you would need to re-navigate to the checkout to reattempt payment.changelog.txt
andreadme.txt
(or does not apply)Post merge