Client-Side Implementation
Important
The SSL certificates for Braintree Mobile (iOS and Android) SDKs are set to expire on March 30, 2026. This will impact existing versions of the SDK in published versions of your app. To reduce the impact, upgrade the
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.
Setup
Before you can add PayPal:- Integrate the Braintree iOS SDK into your app
- Create, verify, and link your PayPal account in the Braintree Control Panel
Get the SDK
CocoaPods
Include Braintree in your podfile:
- Ruby
pod 'Braintree'Swift Package Manager
Include the BraintreePayPal and PayPalDataCollector frameworks.
Carthage
Include the BraintreeCore,BraintreePayPal, BraintreeDataCollector, and PPRiskMagnes frameworks.
Showing a PayPal button
Initiaiting the PayPal authorization flow will present and dismiss an
ASWebAuthenticationSession from your top-most view.
Using our Custom UI
You can implement a custom UI, such as your own PayPal button.
- Swift
var braintreeClient: BTAPIClient!
override func viewDidLoad() {
super.viewDidLoad()
self.braintreeClient = BTAPIClient(authorization: "<#CLIENT_AUTHORIZATION#>")
let customPayPalButton = UIButton(frame: CGRect(x: 0, y: 0, width: 60, height: 120))
customPayPalButton.addTarget(self, action: #selector(customPayPalButtonTapped(button:)), for: UIControlEvents.touchUpInside)
self.view.addSubview(customPayPalButton)
}
func customPayPalButtonTapped(button: UIButton) {
let payPalClient = BTPayPalClient(apiClient: self.braintreeClient)
// Important! Choose either Vault or Checkout flow
// Start the Vault flow, or...
let vaultRequest = BTPayPalVaultRequest()
payPalClient.tokenize(vaultRequest) { (tokenizedPayPalAccount, error) in
// ...
}
// ...start the Checkout flow
let checkoutRequest = BTPayPalCheckoutRequest(amount: "1.00")
payPalClient.tokenize(checkoutRequest) { (tokenizedPayPalAccount, error) in
// ...
}
}Collecting additional data
You can gather additional data about your customers as they complete the payment process.
Note
See
Braintree iOS Client SDK PayPal header files
for in-depth documentation and additional custom PayPal integration options.
Important
The SSL certificates for Braintree Mobile (iOS and Android) SDKs are set to expire on March 30, 2026. 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.
Next: Choose your integration
The rest of your configuration will be determined by how you'd like to use PayPal.- Want a checkout from your cart or product page? Use One-Time Payments.
- Need a combination of features and Pay Later offers? Use Use Vaulted Payments.
- Want one-click payments for repeat customers? Have a subscription model? Use Recurring Payments.