-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
composite-checkout: Throw early in useProcessPayment if processor not…
… found (#96737) * Throw early in useProcessPayment if processor not found useProcessPayment creates the callback sent to every payment method inside a `CheckoutProvider` when rendering `CheckoutSubmitButton`. It uses the payment processor ID of the currently selected payment method to find the payment processor function and then call it. If the function cannot be found, it throws an error. However, the error it throws is inside the callback, which is an async function, and errors thrown inside async functions do not trigger React Error boundaries (see facebook/react#14981). Therefore, any errors thrown here will be displayed in the JS console but never shown to the user or logged. In this change, we modify useProcessPayment to call usePaymentProcessor to find its processor function at render time instead of during the async callback. If the function is not found, this will cause an error to be thrown during render, allowing Error Boundaries to catch it. * Make sure tests have paymentProcessors during render * Make sure existing-credit-card test also has paymentProcessors set
- Loading branch information
1 parent
ff4ed83
commit 634dcfe
Showing
4 changed files
with
35 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters