@artcoded/vendure-braintree-plugin
v1.0.3
Published
Braintree integration plugin for Vendure, adapted from the real-world-vendure plugin
Downloads
21
Readme
Acknowledgements
This plugin is a subtle adaptation of the official Braintree Vendure plugin, found in the real-world-vendure repository of Vendure.
Braintree plugin
This plugin enables payments to be processed by Braintree, a popular payment provider.
Requirements
- You will need to create a Braintree sandbox account as outlined in https://developers.braintreepayments.com/start/overview.
- Then install
braintree
and@types/braintree
from npm. This plugin was written withv3.0.0
of the Braintree lib.
Setup
- Add the plugin to your VendureConfig
plugins
array. - In the admin UI, fill in the
merchantId
,publicKey
,privateKey
andmerchantAccountId
from your Braintree account - If the account is not a sandbox but is meant for production, flag the "live" checkbox
Usage
The plugin is designed to work with the Braintree drop-in UI.
In your storefront, you'll have some code like this to submit the payment:
async function submitPayment() {
const paymentResult = await this.dropin.requestPaymentMethod();
myGraphQlClient.mutation(gql`
mutation {
addPaymentToOrder(input: $input) {
id
state
payments {
id
amount
errorMessage
method
state
transactionId
createdAt
}
}
}`, {
input: {
method: 'braintree',
metadata: paymentResult,
},
});
}