Braintree provides complementary client and server SDKs to complete your integration:
- The client SDKs enable you to collect payment method (e.g. credit card, PayPal) details
- The server SDKs manage all requests to the Braintree gateway
Before we get started, there are two key concepts to introduce: the client token and the payment method nonce.
A client token is a signed data blob that includes configuration and authorization information required by the Braintree client SDK. These should not be reused; a new client token should be generated for each request that's sent to Braintree. For security, we will revoke client tokens if they are reused excessively within a short time period.
Your server is responsible for generating the client token, which contains all of the necessary configuration information to set up the client SDKs. When your server provides a client token to your client, it authenticates the application to communicate directly to Braintree.
Your client is responsible for obtaining the client token from your server and initializing the client SDK. If this succeeds, the client will generate a payment method nonce.
The payment method nonce is a string returned by the client SDK to represent a payment method. This string is a reference to the customer payment method details that were provided in your payment form and should be sent to your server where it can be used with the server SDKs to create a new transaction request.
Your server integration doesn't need to know the payment method type (e.g. credit card, PayPal account, Bitcoin) that is represented in the nonce. This means that your first integration should continue to work with few or no code changes when new payment method types are introduced.
- Your app or web front-end requests a client token from your server in order to initialize the client SDK
- Your server generates and sends a client token back to your client with the server SDK
- Once the client SDK is initialized and the customer has submitted payment information, the SDK communicates that information to Braintree, which returns a payment method nonce
- You then send the payment nonce to your server
- Your server code receives the payment method nonce from your client and then uses the server SDK to create a transaction or perform other Braintree functions detailed in the guides
Still have questions?
If you can’t find an answer, contact our Support team.