PayPal Mobile Checkout
BraintreePayPalNativeCheckout module has been deprecated. The
BraintreePayPalNativeCheckout module will be supported for critical bugs for 1 year
and will then be transitioned to an unsupported state after July 2025. In its place, we recommend
integrating the BraintreePayPal module. Merchants are recommended to proactively
migrate from the BraintreePayPalNativeCheckout module to the
BraintreePayPal module before July 2025 in order to ensure a seamless migration
experience. In order to migrate to the BraintreePayPal module, follow the steps
within the
Checkout with PayPal page.
- In-person point of sale (PoS) transactions
- Multi-seller payments
Setup
Before you can add the PayPal Mobile Checkout, you will need to:
- Create, verify, and link your PayPal account in the Braintree Control Panel
- Obtain either a client token or tokenization key and setup your client
Using a custom UI
PayPal Mobile Checkout is currently only available via a custom UI and cannot be used with the Drop-in UI. Implement a custom button to start the PayPal Native UI flow.
- 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: .touchUpInside)
self.view.addSubview(customPayPalButton)
}
func customPayPalButtonTapped(button: UIButton) {
// Launch the PayPal Mobile Checkout flow
}Get the SDK
The PayPal Mobile Checkout module of the Braintree SDK can be pulled into your app via all of the currently supported package managers.
Cocoapods
In your Podfile, add the dependency for the PayPal Mobile Checkout module:
- Ruby
pod 'Braintree/PayPalNativeCheckout'Swift Package Manager
Include the BraintreeeCore, BraintreePayPalNativeCheckout,
BraintreePayPal and PayPalDataCollector frameworks.
Carthage
Include the BraintreeCore, BraintreePayPalNativeCheckout,
BraintreePayPal and PayPalDataCollector frameworks.
Invoking the PayPal Native UI Flow
Create BTAPIClient with a client token or tokenization key. Use
BTPayPalNativeCheckoutClient and either a BTPayPalNativeCheckoutRequest or
BTPayPalNativeVaultRequest to make your call to
BTPayPalNativeCheckoutClient.tokenize(request:completion:) to launch the PayPal Mobile
Checkout flow. An amount is required to invoke the one-time payment flow. An example integration
might look like this:
- Swift
import UIKit
import BraintreePayPalNativeCheckout
class MyViewController: UIViewController {
var apiClient: BTAPIClient!
var payPalNativeCheckoutClient: BTPayPalNativeCheckoutClient!
override func viewDidLoad() {
super.viewDidLoad()
self.apiClient = BTAPIClient(authorization: <#CLIENT_AUTHORIZATION#>)
self.payPalNativeCheckoutClient = BTPayPalNativeCheckoutClient(apiClient: apiClient)
}
private func payPalButtonTapped() {
// One time checkout
let request = BTPayPalNativeCheckoutRequest(amount: <#AMOUNT_STRING#>)
// OR
// Billing agreements
let request = BTPayPalNativeVaultRequest()
// Configure other values on 'request' as needed.
payPalNativeCheckoutClient.tokenize(request) { payPalNativeCheckoutNonce, error in
if let payPalNativeCheckoutNonce = payPalNativeCheckoutNonce {
// send payPalNativeCheckoutNonce.nonce to server
} else {
// handle error
}
}
}
}