Use the PayPal JavaScript SDK v6 to save a buyer’s Venmo information when they complete a one-time payment. PayPal stores the buyer’s information in a secure data store called a vault. When a returning buyer selects Venmo at checkout, they can pay with their saved account without re-entering credentials or payment details. With this integration you can:Documentation Index
Fetch the complete documentation index at: https://docs.paypal.ai/llms.txt
Use this file to discover all available pages before exploring further.
- Collect and securely store a buyer’s Venmo account at checkout
- Retrieve a vault token after a successful capture
- Use
clientIdauthentication (the standard path for saving to the vault)
Prerequisites
To save Venmo accounts with a one-time purchase, you need:- Complete the steps in get started to get:
- An app in the PayPal Developer Dashboard with Save payment methods enabled
- A client ID
- A client secret
- Sandbox Venmo buyer and seller accounts
- A server-side environment that can make HTTPS requests to the PayPal API
Key concepts
The following concepts are central to the vault-with-purchase flow.Use clientId
The PayPal JavaScript SDK v6 initializes with your clientId. Your clientId is safe to expose in the browser and is the standard authentication path for Venmo one-time payments, vaulting, and return-buyer flows. Only Fastlane integrations require the alternate clientToken authentication path.
Vault attributes
Use the following vault attributes to support saving Venmo accounts with a purchase:store_in_vault: "ON_SUCCESS"saves the payment method when the order is successfully captured.usage_type: "MERCHANT"indicates that the merchant manages the vault.customer_type: "CONSUMER"identifies the buyer as a consumer to present a consumer vaulting experience.permit_multiple_payment_tokens: falseprevents creating duplicate vault tokens for the same Venmo account.
Vault token
After a successful capture, retrieve the vault token ID by callingGET /v2/checkout/orders/:id. Link the token at payment_source.venmo.attributes.vault.id to the customer ID and store it on your server side for future use.
Integration flow
The following steps describe the end-to-end vault-with-purchase flow.- The page loads, and the SDK script fires
onPayPalWebSdkLoaded(). - The SDK initializes with
createInstance({ clientId }). - The buyer selects the Venmo button, which calls
session.start(). - The client calls
POST /api/orderswithpaymentMethod: "venmo". - The server creates the order with
store_in_vault: "ON_SUCCESS"in the Venmo payment source. - The buyer authenticates in the Venmo app.
onApprovefires, and the client callsPOST /api/orders/:id/capture.- The client calls
GET /api/orders/:idand retrieves the vault token.
Set up your front end
To set up the front end:- Load the SDK
- Add a Venmo button to your page
- Initialize an SDK instance with your
clientId - Create a payment session that supports saving the buyer’s Venmo information with the purchase
- Create a client-side order helper that communicates with your back end
Load the SDK
Add the SDK script tag to your page. Theonload callback fires when the script is ready.
Add the button element to the page
Place the custom element where you want the button to render:Initialize the SDK
After the SDK loads, use yourclientId to create an instance and register the Venmo payments component.
Create a payment session
Set up a one-time payment session that includes vault support. TheonApprove callback captures the order and retrieves the vault token.
The SDK uses presentationMode: "auto" to determine whether to use a popup or redirect to display the payment interface based on the buyer’s device and browser.
Create an order (client)
This helper calls your server to create an order and returns theorderId for the SDK to start the checkout flow.
Set up your back end
Your server handles authentication, order creation with vault attributes, order capture, and vault token retrieval.Environment variables
Paste the following variables in an environment (.env) file in your project root. Replace your_client_id and your_client_secret with your app’s client ID and client secret.
Server setup
Set up an Express server with JSON parsing and static file serving.Get an access token
The order and capture endpoints need a server-side access token. This helper fetches one from the OAuth endpoint:Create an order with vault attributes
This endpoint creates an order withstore_in_vault: "ON_SUCCESS" in the Venmo payment source, which tells the system to save the buyer’s payment method to the vault after a successful capture. The permit_multiple_payment_tokens: false attribute prevents creating duplicate vault tokens when the same Venmo account is used across multiple sessions.
Capture the order
After the buyer approves payment, call the Orders API to capture the funds.Retrieve the vault token
Fetch the completed order to extract the vault token from the response. The token is atpayment_source.venmo.attributes.vault.id. When you have the token, store it in your database, linked to the customer’s account. After you do that, returning customers can check out without re-entering payment details.
Troubleshooting
Use this section to diagnose errors in the vault-with-purchase flow.onPayPalWebSdkLoaded doesn’t fire
- Cause: The script tag doesn’t include the
onloadattribute, or the script URL points to the wrong environment, for example, sandbox instead of production. - Fix: Add
onload="onPayPalWebSdkLoaded()"to the script tag. Usesandbox.paypal.comfor testing. Remove thesandbox.subdomain for the production environment.
createInstance throws or returns an error
- Cause: The
clientIddoesn’t match the app, the app doesn’t have Save payment methods enabled, or thecomponentsarray doesn’t include"venmo-payments". - Fix: Verify that the
clientIdmatches the app in the PayPal Developer Dashboard. Verify the toggle is set to Save payment methods on under the app’s features. Includecomponents: ["venmo-payments"]in thecreateInstancecall.
The popup is blocked
- Cause: Your code calls
session.start(), but the user has not selected a payment method. Browsers block popups that don’t originate from a user action. - Fix: Call
session.start()inside the button’sclickevent listener without anyawaitcalls before it. Move async work, such as order creation, into thecreateOrdercallback thatsession.start()accepts as its second argument.
onApprove fires with missing vault token
- Cause: Your server created the order without
store_in_vault: "ON_SUCCESS"in the payment source, or the capture failed before vaulting could complete. - Fix: Confirm that the server-side order body includes the full
attributes.vaultblock. Check the capture response for errors before callingGET /api/orders/:id. The vault token appears after a successful capture.
Order creation returns a 401 or 403
- Cause: The server-side access token expired, the credentials are wrong, or your server fetched the token from the wrong environment endpoint.
- Fix: Confirm
PAYPAL_CLIENT_IDandPAYPAL_CLIENT_SECRETmatch the app in the Developer Dashboard. For testing, fetch the token fromapi-m.sandbox.paypal.com. Remove thesandbox.subdomain for the production environment.