Drop-in UI

Setup and Integration

Important
The SSL certificates for all Braintree SDKs are set to expire by June 30, 2025. This will impact existing versions of the SDK in published versions of your app. To reduce the impact, upgrade the iOS SDK to version 6.17.0+ for the new SSL certifications. If you do not decommission your app versions that include the older SDK versions or force upgrade your app with the updated certificates by the expiration date, 100% of your customer traffic will fail.

ConfigurationAnchorIcon

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

RequirementsAnchorIcon

  • Xcode 12+
  • A minimum deployment target of iOS 12.0
  • Swift 5.1+ (or Objective-C)
It goes without saying, but we'll say it anyway: we always recommend using the latest versions of our SDKs. In order to communicate securely with the Braintree gateway, you must use at least version 7.0.0 of the iOS Drop-in SDK.

SetupAnchorIcon

Drop-in requires a minimum deployment target of iOS 12+ and Xcode 12+. There are several ways to include Braintree's Drop-in in your project.

Swift Package ManagerAnchorIcon

To add the BraintreeDropIn package to your Xcode project, select File > Swift Packages > Add Package Dependency and enter https://github.com/braintree/braintree-ios-drop-in as the repository URL. Tick the checkbox for BraintreeDropIn. If you look at your app target, you will see that the BraintreeDropIn library is automatically linked as a framework to your app (see General > Frameworks, Libraries, and Embedded Content).

CocoaPodsAnchorIcon

  1. Ruby
pod 'BraintreeDropIn'

Client-side implementationAnchorIcon

Import BraintreeDropInAnchorIcon

Add the following import statement to any class using Braintree.
  1. Swift
import BraintreeDropIn

Starting Drop-inAnchorIcon

Present BTDropInController to collect the customer's payment information and receive the nonce to send to your server.
  1. Swift
func showDropIn(clientTokenOrTokenizationKey: String) {
    let request = BTDropInRequest()
    let dropIn = BTDropInController(authorization: clientTokenOrTokenizationKey, request: request) { (controller, result, error) in
        if (error != nil) {
            print("ERROR")
        } else if (result?.isCanceled == true) {
            print("CANCELED")
        } else if let result = result {
            // Use the BTDropInResult properties to update your UI
            // result.paymentMethodType
            // result.paymentMethod
            // result.paymentIcon
            // result.paymentDescription
        }
        controller.dismiss(animated: true, completion: nil)
    }
    self.present(dropIn!, animated: true, completion: nil)
}

Configuring payment methodsAnchorIcon

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.

PayPalAnchorIcon

In order for your Drop-in to support PayPal payments, you must complete the full PayPal integration.

VenmoAnchorIcon

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. Venmo also requires version 4.29.0 or higher of the Braintree iOS SDK.

Apple PayAnchorIcon

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.
Important
If your customer selects Apple Pay, then result.paymentMethodType will be .applePay and 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.
If using a client token with a customer id, the Apple Pay card will not automatically be vaulted. You can use the payment method nonce to create a payment method on your server.

Conditionally disabling payment methodsAnchorIcon

Once you have enabled PayPal, Venmo, or Apple Pay, you have the option to conditionally hide these payment methods from your checkout.

PayPalAnchorIcon

  1. Swift
let request = BTDropInRequest()
request.paypalDisabled = true

VenmoAnchorIcon

  1. Swift
let request = BTDropInRequest()
request.venmoDisabled = true

Apple PayAnchorIcon

  1. Swift
let request = BTDropInRequest()
request.applePayDisabled = true

3D SecureAnchorIcon

Drop-in supports 3D Secure 2 verification. To use 3D Secure in your integration, make sure app switch is set up and then follow our implementation guide. Once you have added 3D Secure to Drop-in, you will need to complete the server-side implementation for 3D Secure.

Displaying the most recently added payment methodAnchorIcon

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:mostRecentPaymentMethod. A payment method will only be returned when using a client token created with a customer_id.
  1. Swift
BTDropInResult.mostRecentPaymentMethod(forClientToken: clientToken) { result, error in
    if (error != nil) {
        print("ERROR")
    } else if let result = result {
        // Use the BTDropInResult properties to update your UI
        // result.paymentMethodType
        // result.paymentMethod
        // result.paymentIcon
        // result.paymentDescription
    }
})

Location PermissionsAnchorIcon

The Braintree iOS SDK uses device and browser location data for fraud detection when available (i.e. when location permissions have already been requested by your app and granted by the user). While you do not need to request location data from users in order to use Braintree, Apple requires a NSLocationWhenInUseUsageDescription key in your Info.plist if your app contains code referencing location APIs. If your app does not request location data, you will still need to include a NSLocationWhenInUseUsageDescription plist entry.

Next stepsAnchorIcon

If you accept cookies, we’ll use them to improve and customize your experience and enable our partners to show you personalized PayPal ads when you visit other sites. Manage cookies and learn more