Skip to content

PayPal Braintree: INSTANTIATION_OPTION_REQUIRED when clientToken missing (cart PayPal button) #40622

@Genaker

Description

@Genaker

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 the clientErr handler).

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

No one assigned

    Labels

    Issue: ready for confirmationReported on 2.4.xIndicates original Magento version for the Issue report.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

    Type

    No type

    Projects

    Status

    Ready for Confirmation

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions