PayPal
Checkout with PayPal
Checkout with PayPal is a one-time payment checkout experience.
Invoking the Checkout with PayPal Flow
Use BTPayPalDriver
and BTPayPalCheckoutRequest
to start the process. A transaction amount is required to invoke the one-time payment flow. An example integration might look like this:
- Swift
class MyViewController: UIViewController {
var braintreeClient: BTAPIClient?
func startCheckout() {
// Example: Initialize BTAPIClient, if you haven't already
braintreeClient = BTAPIClient(authorization: "<#CLIENT_AUTHORIZATION#>")!
let payPalDriver = BTPayPalDriver(apiClient: braintreeClient)
// Specify the transaction amount here. "2.32" is used in this example.
let request = BTPayPalCheckoutRequest(amount: "2.32")
request.currencyCode = "USD" // Optional; see BTPayPalCheckoutRequest.h for more options
payPalDriver.tokenizePayPalAccount(with: request) { (tokenizedPayPalAccount, error) in
if let tokenizedPayPalAccount = tokenizedPayPalAccount {
print("Got a nonce: (tokenizedPayPalAccount.nonce)")
// Access additional information
let email = tokenizedPayPalAccount.email
let firstName = tokenizedPayPalAccount.firstName
let lastName = tokenizedPayPalAccount.lastName
let phone = tokenizedPayPalAccount.phone
// See BTPostalAddress.h for details
let billingAddress = tokenizedPayPalAccount.billingAddress
let shippingAddress = tokenizedPayPalAccount.shippingAddress
} else if let error = error {
// Handle error here...
} else {
// Buyer canceled payment approval
}
}
}
}
Shipping address
Shipping addresses may or may not be collected during the Checkout with PayPal flow. However, if you choose to collect shipping addresses yourself, it can be passed along with the your server side Transaction.Sale
call. Look at the Server-side page for more information.
Country support
PayPal is available to merchants in all countries that we support and to customers in 140+ countries.
Currency presentment
The currency of the transaction is presented to the customer in the Checkout with PayPal flow. We support all currencies that PayPal REST APIs support.
See the server-side section for details on charging a transaction in a specific currency.
Next Page: Server-side →