One-time Payments
This guide shows you how to integrate PayPal One-time Payments using the PayPal JS v6 SDK's session-based checkout flow.
Pay with PayPal's One-time payments is a one-click solution that accelerates your buyer's checkout experience by skipping manual data entry. Buyers can use PayPal to check out anywhere in their shopping journey.
Unlike Vaulted Payments, One-time payments do 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 One-time payments, view the Checkout with Vault integration guide.
PayPal's One-time Payments support:
- Selecting or adding shipping addresses in the PayPal account
- Selecting or adding funding instruments to the PayPal account
- Two-factor authentication support (currently only for US, UK, CA, DE, AT, and AU)
Typical use cases for the One-time payments flow:
- Checkout from Cart or Product pages
- Checkout page replacement
Prerequisites
Before you invoke the one-time payments flow, make sure you have:
- A Braintree client token or client authorization for your merchant account.
- A button element on your page with an ID you can reference in a click handler, for example
paypal-button. - Access to the Braintree JavaScript client so you can create a braintree.paypalCheckoutV6 instance.
Invoke one-time payments with the PayPal JS v6 SDK
This section covers the PayPal Checkout v6 integration (braintree.paypalCheckoutV6), a session-based alternative to the braintree.paypalCheckout and paypal.Buttons() pattern described in the Web SDK v3 docs. See Client-Side Implementation for the full v6 setup.
Initialize the Braintree client and PayPal Checkout v6 instance, load the PayPal SDK, then create a one-time payment session with createOneTimePaymentSession and start it when the buyer clicks your PayPal button.
- Async/Await
async function setupPayPalCheckoutV6() {
try {
const client = await braintree.client.create({ authorization: "CLIENT-TOKEN" });
const paypal = await braintree.paypalCheckoutV6.create({ client: client });
await paypal.loadPayPalSDK();
const session = paypal.createOneTimePaymentSession({
amount: "10.00",
currency: "USD",
intent: "capture",
onApprove: async function (data) {
const payload = await paypal.tokenizePayment({ payerID: data.payerId, orderID: data.orderId });
console.log("Nonce:", payload.nonce);
},
});
document.getElementById("paypal-button").addEventListener("click", function () {
session.start();
});
} catch (err) {
// Handle error
}
}The onApprove callback receives the approved buyer's orderId and payerId. Call tokenizePayment to exchange them for a payment method nonce, then send the nonce to your server and use a Braintree server SDK to call Transaction.sale.
After the buyer approves the payment, check your browser console to confirm the nonce logs, because the sample's onApprove callback logs it with console.log("Nonce:", payload.nonce).
See the PayPal Checkout v6 client reference for more information on the options available.