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.
Configuration
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.
Requirements
- Xcode 12+
- A minimum deployment target of iOS 12.0
- Swift 5.1+ (or Objective-C)
Setup
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 Manager
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).
CocoaPods
- Ruby
pod 'BraintreeDropIn'
Client-side implementation
Import BraintreeDropIn
Add the following import statement to any class using Braintree.
- Swift
import BraintreeDropIn
Starting Drop-in
Present BTDropInController to collect the customer's payment
information and receive the nonce to send to your server.
- 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 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 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. Venmo also requires version
4.29.0 or higher of the Braintree iOS SDK.
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.
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.
Conditionally disabling payment methods
Once you have enabled PayPal, Venmo, or Apple Pay, you have the option to conditionally hide these
payment methods from your checkout.
PayPal
- Swift
let request = BTDropInRequest()
request.paypalDisabled = true
Venmo
- Swift
let request = BTDropInRequest()
request.venmoDisabled = true
Apple Pay
- Swift
let request = BTDropInRequest()
request.applePayDisabled = true
3D Secure
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 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:mostRecentPaymentMethod. A payment method will
only be returned when using a client token created with a
customer_id
.
- 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 Permissions
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 steps
- Read the Set Up Your Server guide to learn about our server SDKs and how to send a nonce to your server
- Explore the ways to customize the appearance and functionality of Drop-in
- Learn how to manage different payment methods