availability

Braintree Auth is in closed beta. Contact us to express interest.

Once you have an accessToken, you are ready to perform actions on behalf of that merchant.

The only difference between the API to perform actions on behalf of a merchant and for a merchant performing their own actions is that the gateway object used to make API calls must be instantiated with an access token instead of a client ID and secret.

Creating a transaction

This is how to create a transaction using an access token:

const gateway = new braintree.BraintreeGateway({
  accessToken: useAccessTokenForMerchant
});

gateway.transaction.sale({
  amount: "10.00",
  paymentMethodNonce: nonceFromTheClient,
}, (err, result) => {
  const transactionId = result.transaction.id
});
This code snippet creates a gateway instance using the latest version of the Node SDK. Learn more.

Creating a customer

Here's how you would create a customer for a merchant:

const gateway = new braintree.BraintreeGateway({
  accessToken: useAccessTokenForMerchant
});

gateway.customer.create({
  firstName: "Joe",
  lastName: "Brown",
  email: "joe@example.com",
  phone: "312-555-1234"
}, (err, response) => {
  const customerId = response.customer.id;
});
This code snippet creates a gateway instance using the latest version of the Node SDK. Learn more.

Authentication errors

The merchant has the right to revoke an authorization grant at any time. If this occurs, you will receive a exceptions.AuthenticationError when attempting to take any action on the merchant’s behalf.

Next Page: Multi-currency →