PayPal
Checkout with PayPal
Checkout with PayPal is a one-time payment checkout experience that gives you more control over the entire checkout process. It offers a streamlined checkout flow that keeps customers local to your website during the payment authorization process.
Unlike the Vault flow, Checkout with PayPal does not provide the ability to store a customer's PayPal account in the Vault. If you want to store a customer’s PayPal account within a Vault during Checkout, view the Checkout with Vault integration guide. However, if you are located in a country that supports PayPal One Touch™, your customer can make repeat purchases without re-entering their user credentials after their initial purchase.
Checkout with PayPal supports the following features:
- Select or add shipping addresses in the PayPal account
- Select or add funding instruments in the PayPal account
- Two factor authentication support (currently only for US, UK, CA, DE, AT, and AU)
Typical use cases for the Checkout With PayPal flow:
- Checkout from Cart/Product pages
- Checkout page replacement
Invoking the Checkout with PayPal flow
To invoke Express Checkout you must ensure singleUse
, amount
, and currency
are passed in your client options.
- HTML
<script type="text/javascript">
braintree.setup('CLIENT-TOKEN-FROM-SERVER', 'custom', {
paypal: {
container: 'paypal-container',
singleUse: true, // Required
amount: 10.00, // Required
currency: 'USD', // Required
locale: 'en_US',
enableShippingAddress: true,
shippingAddressOverride: {
recipientName: 'Scruff McGruff',
streetAddress: '1234 Main St.',
extendedAddress: 'Unit 1',
locality: 'Chicago',
countryCodeAlpha2: 'US',
postalCode: '60652',
region: 'IL',
phone: '123.456.7890',
editable: false
}
},
onPaymentMethodReceived: function (obj) {
doSomethingWithTheNonce(obj.nonce);
}
});
</script>
If you are using an Activity and your Activity's launch mode is singleTop
, singleTask
, or singleInstance
you will also need to override onNewIntent
:
Use the onShippingChange
function from the PayPal JS SDK setup method to listen for shipping changes that occur within the PayPal pop-up; then, use the updatePayment
, part of the Braintree JS SDK's paypalCheckoutInstance
, to update the PayPal checkout flow with modified order line items or shipping options. Note that updatePayment
replaces use of actions.order.patch
.
Use the paypalCheckoutInstance
in the onApprove
function of the PayPal JS SDK setup method to tokenize the PayPal account. After the customer completes the consent flow and the PayPal pop-up closes, successful tokenization will return a payment method nonce.
Send the nonce to your server and use a Braintree server SDK to call Transaction.sale
to create a transaction.
See our JavaScript PayPal client reference for more information on the options available in the Checkout with PayPal flow.
Country support
PayPal is available to merchants in all countries that we support and to customers in 140+ countries. Ensure you are using a desired locale
code as outlined in our JavaScript PayPal client reference.
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.