Configuration

In order to use the Drop-in UI, you'll first need to get a tokenization key from the Control Panel or generate a client token on your server.

Setup

note

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

There are several ways to include Braintree's Drop-in in your project.

CocoaPods

Ruby
Click to copy
Copied
pod 'BraintreeDropIn'

By default, Drop-in only ships with support for cards. You can include additional payment methods by adding their respective pods.

Ruby
Click to copy
Copied
pod 'Braintree/PayPal'
pod 'Braintree/Venmo'
pod 'Braintree/Apple-Pay'
pod 'Braintree/3D-Secure'

Carthage

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

You will need the following frameworks at a minimum:

Click to copy
Copied
BraintreeDropIn.framework
BraintreeUIKit.framework
BraintreeCard.framework
BraintreeCore.framework

For PayPal, you must add the following frameworks:

Click to copy
Copied
BraintreePayPal.framework
PayPalDataCollector.framework
PayPalOneTouch.framework
PayPalUtils.framework

For Apple Pay, you must add the following framework in addition to PassKit. See the Apple Pay Client-Side Implementation for more details.

Click to copy
Copied
BraintreeApplePay.framework

Client-side implementation

Import BraintreeDropIn and Braintree

Add the import statements to any class using Braintree.

Objective-C Swift
Click to copy
Copied
#import "BraintreeCore.h"
#import "BraintreeDropIn.h"

Starting Drop-in

Present BTDropInController to collect the customer's payment information and receive the nonce to send to your server.

Objective-C Swift
Click to copy
Copied
- (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) {
            NSLog(@"ERROR");
        } else if (result.cancelled) {
            NSLog(@"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];
}

Configuring payment methods

Additional steps are required for the Drop-in UI to accept payment methods other than cards. After completing the Drop-in setup instructions, follow the steps below for each payment method type.

PayPal

In order for your Drop-in to support PayPal payments, you must follow the app switch setup instructions and complete the full PayPal integration.

Venmo

To support Venmo payments in the Drop-in UI, make sure to follow the app switch setup instructions in the Client SDK Setup guide and complete the full Venmo integration.

Apple Pay

If you've included the Apple Pay pod or framework in your project, Drop-in will show Apple Pay as a payment option as long as you've completed the Apple Pay integration and the customer's device and card type are supported.

If Apple Pay is enabled and you would like to conditionally hide the Apple Pay option, you can use the following method:

Objective-C Swift
Click to copy
Copied
BTDropInRequest *request = [[BTDropInRequest alloc] init];
request.applePayDisabled = YES;
important

If your customer selected Apple Pay as their preferred payment method, then result.paymentOptionType == .ApplePay and the result.paymentMethod will be nil. Selecting Apple Pay does not display the Apple Pay sheet or create a nonce – you will still need to do that at the appropriate time in your app. Use BTApplePayClient to tokenize the customer's Apple Pay information, and see our Apple Pay Guide for more information.

3D Secure

Drop-in supports 3D Secure verification. If you're using 3D Secure, enable it in your BTDropInRequest and set an amount:

Objective-C Swift
Click to copy
Copied
BTDropInRequest *request = [[BTDropInRequest alloc] init];
request.threeDSecureVerification = YES;
request.amount = @"1.00";

Displaying the last used payment method

If your user already has an existing payment method, you may not need to show the Drop-in payment picker. You can check if they have an existing payment method using BTDropInResult:fetchDropInResultForAuthorization. A payment method will only be returned when using a client token created with a customer_id.

Objective-C Swift
Click to copy
Copied
- (void)fetchExistingPaymentMethod:(NSString *)clientToken {
    [BTDropInResult fetchDropInResultForAuthorization:clientToken handler:^(BTDropInResult * _Nullable result, NSError * _Nullable error) {
        if (error != nil) {
            NSLog(@"ERROR");
        } else {
            // Use the BTDropInResult properties to update your UI
            // result.paymentOptionType
            // result.paymentMethod
            // result.paymentIcon
            // result.paymentDescription
        }
    }];
}

Next steps

Next: Customization →

Still have questions?

If you can’t find an answer, contact our Support team.