The Payment Method API enables secure integration with PayPal's vaulting system, allowing merchants to save customer payment methods for future transactions.
Use cases
The App Switch vaulting integration supports several key scenarios where users want to save payment methods without immediate purchases. See the primary use cases.
Use case 1: Save payment method during onboarding
Let users save their PayPal Wallet during onboarding or account setup without making a purchase, so they don't have to re-enter it later when making a purchase.
Payers trigger this intent when they want to securely store a payment method, even though they're not checking out. This commonly occurs during sign-up flows and when payers create accounts with billing preferences.
Intent |
Example user phrases |
vault_paypal_payment_method |
- “Save my PayPal for later.”
- “Set up my wallet for subscriptions.”
- “I don’t want to enter this again next time.”
|
Use case 2: Purchase with saved payment method
Payers can complete purchases using their saved PayPal Wallet without re-entering payment details.
Intent |
Example user phrases |
vault_paypal_payment_method |
- "Use my saved PayPal for this purchase"
- "Pay with my stored wallet"
- "Use my default payment method"
|
Visual flow summary
The App Switch vaulting integration follows a five-step process from token creation to payment processing.
- Create a setup token →
POST /v3/vault/setup-tokens
- Redirect to approval →
links[].rel = approve
- Payer approves
- Create payment token →
POST /v3/vault/payment-tokens
- Use the token with purchase →
POST /v2/checkout/orders
Integration flow summary
This vaulting flow helps payers consent to saving a payment method.
Intent |
API endpoint |
Expected outcome |
Next step |
vault_paypal_payment_method |
POST /v3/vault/setup-tokens |
Creates a setup_token and approval URL for App Switch. |
Redirect the payer to links[].approve.href . |
Implicit |
Off-platform redirect |
Payer grants approval to vault method. |
Convert the setup token to a payment method token. |
create_payment_token |
POST /v3/vault/payment-tokens |
Returns payment_token and saves method metadata. |
Store the token securely, and display confirmation. |
Create setup token
Create a setup token using the POST /v3/vault/setup-tokens
endpoint. This generates a setup token and approval URL that helps the payer authenticate and approve vaulting their payment method.
This creates a setup token and an approval URL. The payer must authenticate and approve vaulting.
The initial POST
on setup-tokens
completes the following actions:
- Returns a
PAYER_ACTION_REQUIRED
status.
- Creates a temporary setup token.
- Redirects to the
approve
URL.
- Update
app_switch_context
for the native app.
When saving a payer's PayPal Wallet for the first time, the response returns the PayPal-generated customer.id
and setup_token_id
.
For payers with previously stored payment_sources
, pass the customer.id
in the setup-token
request. This links additional payment_sources
to the payer.
Store a merchant_customer_id
aligned with the system to simplify the mapping customer information between the system and PayPal when creating a setup token. This optional field returns the value shared in the response.
Include the following parameters in the Create Setup Token API request: payment_source.paypal
and payment_source.paypal.experience_context
.
Parameter |
Description |
Priority |
payment_source.paypal.email_address |
- Merchants can pass the payer's email in the setup token-creation request, which can be the same email used in the merchant's application.
- Including the email address helps us determine if the payer has a PayPal account and whether the app is installed, allowing for a quicker assessment of App Switch eligibility and enhancing the payer experience.
|
Optional |
payment_source.paypal.experience_context.user_action |
- The
user_action configures the PayPal Approval flow and uses the SETUP_NOW flow.
- App Switch currently only supports
SETUP_NOW flows.
SETUP_NOW is a PayPal feature that supports payers to approve and save the agreement on the PayPal review page.
|
Mandatory |
Return and cancel URLs
PayPal expects the merchant to pass payment_source.paypal.experience_context.return_url
and payment_source.paypal.experience_context.cancel_url
:
-
return_url
is the URL that tells PayPal where to send the payer after completing the approval on the PayPal app. Set the URL to the page where the payer selects the PayPal button. (Mandatory)
-
cancel_url
is the URL that tells PayPal where to send the payer when the payer cancels or doesn't complete the approval on the PayPal app. Set the URL to the page where the payer should be redirected when they cancel the approval flow. (Mandatory)
Use |
Mandatory requirements |
Merchant native apps |
- The
return_url and cancel_url must be associated with the merchant app.
- If the merchant app supports iOS v17.4 and earlier and uses ASWebAuthenticationSession, pass deep links in the
return_url and cancel_url fields. Otherwise, the payer won't return to the app as expected.
- Include the
app_url parameter. (Mandatory) This takes precedence over return_url and cancel_url .
- If PayPal determines the App Switch is eligible, we use the
app_url to return the payer to the merchant app. If not, we use the return_url and cancel_url .
|
Opt into App Switch
PayPal considers passing payment_source.paypal.experience_context.app_switch_context
as the merchant opting in to App Switch.
Native app parameters
If a payer starts from the native app, use payment_source.paypal.experience_context.app_switch_context.native_app
.
Field |
Requirement |
Priority |
os_type |
- The payer’s mobile operating system (OS) family. PayPal uses this value to assess App Switch eligibility. Accepted values:
ANDROID , IOS , and OTHER .
|
Mandatory |
os_version |
- The payer’s mobile OS version used for telemetry
|
Optional |
app_url |
- Pass
app_url as the universal link or app link associated with the merchant app. After the payer uses App Switch to approve or cancel the approval in the PayPal app, PayPal uses this URL to redirect the payer back to the merchant app.
- During an App Switch flow,
app_url takes precedence over return_url and cancel_url .
|
Mandatory |