-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Summary
PayPal_Braintree/js/paypal/button.js calls braintree.create({ authorization: buttonConfig.clientToken }) in loadSDK without validating clientToken. When the token is missing (failed generation, misconfiguration, or edge cases), the Braintree JS SDK throws:
- Code:
INSTANTIATION_OPTION_REQUIRED - Message:
options.authorization is required when instantiating a client. - Console:
paypalCheckout error(logged at theclientErrhandler).
express-paypal.js already guards with if (!this.clientToken) { return; } before initializing PayPal buttons; the shared cart/minicart button.js path does not.
Package
Composer: paypal/module-braintree-core (module PayPal_Braintree).
File: view/frontend/web/js/paypal/button.js — method loadSDK.
Suggested fix
At the start of loadSDK, return early when !buttonConfig || !buttonConfig.clientToken, consistent with express-paypal.js initPayPalButtons.
Notes
Merchants should still fix root causes (Braintree credentials, token generation) when the token is routinely empty; the guard prevents a hard client-side error and matches existing patterns in the same integration.
Related: quality-patches PR (vendor patch) to follow.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status