This plugin enables payments to be processed by Braintree, a popular payment provider.
braintree and @types/braintree from npm. This plugin was written with v3.x of the Braintree lib.
plugins array:
Merchant ID, Public Key & Private Key from your Braintree sandbox account.The plugin is designed to work with the Braintree drop-in UI. This is a library provided by Braintree which will handle the payment UI for you. You can install it in your storefront project with:
The high-level workflow is:
generateBraintreeClientToken mutation which is exposed by this plugin."paymentMethodRequestable" event which emitted by the Dropin.requestPaymentMethod() method to get the required payment metadata.addPaymentToOrder mutation. The metadata should be an object of type { nonce: string; }Here is an example of how your storefront code will look. Note that this example is attempting to be framework-agnostic, so you'll need to adapt it to fit to your framework of choice.
Braintree has a vault feature which allows the secure storage of customer's payment information. Using the vault allows you to offer a faster checkout for repeat customers without needing to worry about how to securely store payment details.
To enable this feature, set the storeCustomersInBraintree option to true.
Since v1.8, it is possible to override vaulting on a per-payment basis by passing includeCustomerId: false to the generateBraintreeClientToken
mutation:
as well as in the metadata of the addPaymentToOrder mutation:
BraintreePluginOptions(options: BraintreePluginOptions) => Type<BraintreePlugin>