Merchant API
Availability
Braintree Auth is in closed beta.
Contact us to
express interest.
access_token, 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:
- C#
BraintreeGateway gateway = new BraintreeGateway(useAccessTokenForMerchant);
var request = new TransactionRequest {
Amount = 100.00M,
PaymentMethodNonce = nonceFromTheClient
};
Result<transaction> result = gateway.Transaction.Sale(request);
string transactionId = result.Target.Id;Creating a customer
Here's how you would create a customer for a merchant:
- C#
BraintreeGateway gateway = new BraintreeGateway(useAccessTokenForMerchant);
var createRequest = new CustomerRequest() {
FirstName = "Joe",
LastName = "Brown",
Email = "joe@example.com",
Phone = "312.555.1111"
};
Result<customer> result = gateway.Customer.Create(createRequest);
string customerId = result.Target.Id;Authentication errors
The merchant has the right to revoke an
authorization grant
at any time. If this occurs, you will receive a
Braintree.Exceptions.AuthenticationException
when attempting to take any action on the merchant’s behalf.