-
Notifications
You must be signed in to change notification settings - Fork 201
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
Use shared configuration for shortcode- and block-based checkout flows #1585
Conversation
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.
Nice improvement! The refactor looks good in general, and I've verified that the "stripe.js" front-end script asset loads only on shortcode cart/checkout, not for the block 👍
I was originally seeing an error in the Checkout block due to publicKey
being passed, since we do actually still want the (reverted) change here.
With that change, payments (incl. 3DS) work with new and saved cards, with both shortcode and blocks. However, Apple Pay in the Cart and Checkout blocks is failing for me, with this error:
Unhandled Promise Rejection: ReferenceError: Can't find variable: wc_stripe_payment_request_params
(I can test some more cases tomorrow.)
Ugh, sorry about this 🤦 I've pushed a fix in cc9e6e6 and ran some tests to verify that it fixes the issue. Sorry about that! |
Instead of not loading the shortcode JS when a Block is present on the current page, we now load the shortcode JS when a cart or checkout shortcode is present on the page.
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.
Appears to work well 👍 – I'll do just a bit more testing in a bit.
Minor note: In general, are there known cases in which getStripeServerData()
will be null, and all the optional chaining would make a difference? Looks like it was added to many of the calls but not all – is there a rule here?
Not any known cases; at least not in terms of a successful flow. That said, Darren mentioned in #1467 (comment) on the original Blocks support PR that this function could potentially return So I guess you're mostly wondering if it'd be better to have the front-end crash if we change something during development rather than handle the error gracefully without any notification that's what happened? |
Well I meant in terms of a possible flow, not necessarily successful. I'm fine with the optional chaining but was mostly wondering why it's in some places and not others, and if there's a pattern there – this example (among others) was left alone:
|
Thanks for calling out the lack of optional chaining Paul! I've fixed all instances I could find in df49b46 🙂 |
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.
All LGTM 🎉 – tested most of the cases in the testing instructions (though not every single permutation) and some others, and tried various config like PRB settings, inline form, disallowing prepaid cards.
Changes proposed in this Pull Request:
Issue: Link to the GitHub issue this PR addresses (if appropriate).
Fixes #1516
Testing instructions
Rather convoluted; test all the general payment flows, e.g.
Things to watch out for:
grunt
.