You can collect customer payment information via the client SDK in a number of ways:

Client side payment token flow Diagram demonstrating the required interaction between the client, Braintree servers and your server.

iOS SDK setup


The latest version of our Drop-in UI requires iOS 9+. You can find an example of the legacy Drop-in (iOS 8.0+) in our demo app.

These instructions are for the latest version of our iOS SDK using our new Drop-in. For instructions using a different version of our SDK, use the selector near the top of this page.

For additional requirements and installation options, see the iOS Client SDK Guide.

Using CocoaPods

Add BraintreeDropIn to your Podfile:

pod 'BraintreeDropIn'

Then run pod install.

Using Carthage

Add github "braintree/braintree-ios-drop-in" to your Cartfile, and add the frameworks to your project.

You will need the following frameworks at a minimum:


Get a client token

Client tokens are optional: Starting with v4 of our iOS SDK, you can initialize Braintree with a tokenization key instead of a client token — if you are using a tokenization key, you may skip this section.

Your server is responsible for generating a client token, which contains the authorization and configuration details that your client needs to initialize the client SDK.

Your app should request a client token from your server. This example uses our sample integration server; please adapt it to use your own backend API.

- (void)fetchClientToken {
    // TODO: Switch this URL to your own authenticated API
    NSURL *clientTokenURL = [NSURL URLWithString:@""];
    NSMutableURLRequest *clientTokenRequest = [NSMutableURLRequest requestWithURL:clientTokenURL];
    [clientTokenRequest setValue:@"text/plain" forHTTPHeaderField:@"Accept"];

    [[[NSURLSession sharedSession] dataTaskWithRequest:clientTokenRequest completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        // TODO: Handle errors
        NSString *clientToken = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

        // As an example, you may wish to present Drop-in at this point.
        // Continue to the next section to learn more...
    }] resume];

You should obtain a new client token frequently, at least once a day or as often as your app restarts. For the best experience, you should kick off this network operation before it would block a user interaction.

Try it now

We generated a demo client token for you so you can jump right in. This is for testing purposes only!

NSString *clientToken = @"CLIENT_TOKEN_FROM_SERVER";

The above demo client token is for temporary use. You must change this client token in order to process payments with your Braintree sandbox or production account.

Present Drop-in UI

At this point, you are ready to collect payment information from your customer.

Drop-in is the easiest way to get started. It provides a fully fledged payments experience out of the box. You can also choose to create a custom UI and then tokenize the payment information directly.

Add the import statements to any class using Braintree.

#import "BraintreeCore.h"
#import "BraintreeDropIn.h"
- (void)showDropIn:(NSString *)clientTokenOrTokenizationKey {
    BTDropInRequest *request = [[BTDropInRequest alloc] init];
    BTDropInController *dropIn = [[BTDropInController alloc] initWithAuthorization:clientTokenOrTokenizationKey request:request handler:^(BTDropInController * _Nonnull controller, BTDropInResult * _Nullable result, NSError * _Nullable error) {

        if (error != nil) {
        } else if (result.cancelled) {
        } else {
            // Use the BTDropInResult properties to update your UI
            // result.paymentOptionType
            // result.paymentMethod
            // result.paymentIcon
            // result.paymentDescription
    [self presentViewController:dropIn animated:YES completion:nil];

Test your integration

Create a sandbox account

If you haven't already, sign up for a free Braintree sandbox account:

Sign Up for a Braintree Sandbox Account

Log in to obtain your sandbox API credentials. You'll need your:

  • Sandbox merchant ID
  • Public key
  • Private key

Use these credentials for your development and testing.


When you go live, you will need to replace your sandbox API credentials with production API credentials.

Test values

When testing in the sandbox, be sure to use our test card numbers (e.g. 4111111111111111) and nonces (e.g. fake-valid-nonce). Real payment method data will not work in the sandbox. See our Testing page for more details.

Send payment method nonce to server

Send the resulting payment method nonce to your server (again, adapt this example to your own setup):

- (void)postNonceToServer:(NSString *)paymentMethodNonce {
    // Update URL with your server
    NSURL *paymentURL = [NSURL URLWithString:@""];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:paymentURL];
    request.HTTPBody = [[NSString stringWithFormat:@"payment_method_nonce=%@", paymentMethodNonce] dataUsingEncoding:NSUTF8StringEncoding];
    request.HTTPMethod = @"POST";

    [[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
        // TODO: Handle success and failure
    }] resume];

world.greeted = true

At this point, you should have a working client-side checkout flow. When your user provides payment information, you receive a payment method nonce and send it to your server.

Next, your server closes the loop by using the payment method nonce to create a transaction.

Next Page: Simple Server →