-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Checkout: extract calling payment processor and handling response to useProcessPayment hook #48283
Conversation
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Sections (~91 bytes added 📈 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Async-loaded Components (~48 bytes added 📈 [gzipped])
React components that are loaded lazily, when a certain part of UI is displayed for the first time. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
6c398c7
to
c26c402
Compare
c26c402
to
08c0d4e
Compare
Rebased after #48385 |
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 and works as described.
…useProcessPayment hook (#48283) * Clarify manual transaction processing in composite-checkout README * Separate payment processor response handling into own function * Export useCreatePaymentProcessorOnClick from composite-checkout * Add missing useCreatePaymentProcessorOnClick * Rethrow PaymentProcessorResponse error * Allow payment complete callback to include isComingFromUpsell * Add withPaymentCompleteCallback HOC * Clean up PaymentCompleteCallback type a bit * Remove withPaymentCompleteCallback and shouldHideUpsellNudges * Fix useCreatePaymentProcessorOnClick import * Rename onClick creator to useProcessPayment * Throw if using useStripe outside StripeHookProvider
Changes proposed in this Pull Request
When a payment method's
submitButton
prop is rendered by@automattic/composite-checkout
, it is provided with anonClick
prop that can be used to call a payment processor function and handle the response. As consumers of the package (like the one-click upsell; see #48152) might want to implement their own submit button, we should expose that automated process in its own hook.This PR creates a hook called
useProcessPayment
that does just that and adds it to the@automattic/composite-checkout
package.This PR shouldn't have any user-facing effect on checkout.
Testing instructions