Key differences between PayPal and cards integrations
- Saving a card requires no payer interaction.
- Saving a PayPal Wallet requires payers to approve a billing agreement once.
- Calls to save PayPal or cards require different fields in the request body.
- Cards integrations support cards with the following verification methods:
- no verification
- smart authorization
- 3D Secure
Country availability
Supported countries
Supported countries
- Australia
- Austria
- Belgium
- Bulgaria
- Canada
- China
- Cyprus
- Czech Republic
- Denmark
- Estonia
- Finland
- France
- Germany
- Hong Kong
- Hungary
- Ireland
- Italy
- Japan
- Latvia
- Liechtenstein
- Lithuania
- Luxembourg
- Malta
- Netherlands
- Norway
- Poland
- Portugal
- Romania
- Singapore
- Slovakia
- Slovenia
- Spain
- Sweden
- United Kingdom
- United States
Prerequisites
Complete the steps in Get started to get the following information:- Your business sandbox account login and password.
- Your app’s client ID and client secret. Exchange these for an OAuth access token.
Enable your business account
Tip: You can continue to test this integration in the sandbox while waiting for PayPal to approve your eligibility.
- Go to paypal.com and sign in with your business account.
- Go to Account Settings > Payment Preferences > Save PayPal and Venmo payment methods.
- In the Save PayPal and Venmo payment methods section, select Get Started.
- When you submit business profile details, PayPal reviews your eligibility to save PayPal and Venmo accounts.
- After PayPal reviews your eligibility, you’ll see one of the following statuses:
- Success
- Need more information
- Denied
Enable your developer dashboard
Enable your sandbox and live business accounts to save payment methods:- Log in to the Developer Dashboard.
- Under Apps & Credentials > REST API apps, select your app name.
- Scroll down to Features and ensure Vault is selected.
Important: If you’re already using the Billing Agreements API, contact PayPal customer support to save payment methods with the Payment Method Tokens API.
Create setup token for PayPal
Before you create a setup token, a payer must:- Log in to their PayPal account
- Approve a billing agreement
POST
call on the setup-tokens
endpoint to complete the following actions:
- Receive a
PAYER_ACTION_REQUIRED
status - Create a temporary setup token
- Redirect the payer after they approve or deny the billing agreement
Get setup token request
- Change
ACCESS-TOKEN
to your sandbox access token. - Change
REQUEST-ID
to a set of unique alphanumeric characters such as a timestamp. - Set the
payment_source
topaypal
. Complete the rest of the source object for your use case and business. - Update the
return_url
value with the URL where the payer is redirected if they approve the flow. - Update the
cancel_url
value with the URL where the payer is redirected if they cancel the flow. - Optional: For existing customers, pass the
customer.id
to link additional information such aspayment_source
to the customer. For new customers, the customer ID is returned in the setup token response.
PayPal setup token response
A successful request returns the following:- An HTTP response code of
200
or201
. Returns200
for an idempotent request. - When saving a payer’s PayPal Wallet for first time, the response to the
setup-token
request returns the PayPal-generatedcustomer.id
and thesetup_token_id
. - A status of
PAYER_ACTION_REQUIRED
. - The following HATEOAS links:
Rel | Method | Description |
---|---|---|
approve | GET | Take your payer through a PayPal-hosted approval flow. |
confirm | POST | Use an approved setup token to save the PayPal Wallet and generate a payment token. |
self | GET | View the state of your setup token and payment method details. |
Create setup token for card
The Payment Method Tokens API can create a setup token for cards that have:- No verification - checks that card data is formatted correctly when passed to the API.
- Smart authorization - runs a zero-value or minimal-value authorization to validate the card is real and active.
- 3D Secure verification - requires two-factor authentication where the cardholder must authenticate before the transaction.
- Change
ACCESS-TOKEN
to your sandbox access token. - Change
REQUEST-ID
to a set of unique alphanumeric characters such as a time stamp. - Use the card as the payment source and complete the rest of the source object for your use case and business.
- Pass the
verification_method
parameter withSCA_WHEN_REQUIRED
for PayPal to automatically trigger the appropriate verification method for the card. - Update the
return_url
value with the URL where the payer is redirected after they approve the flow. - Update the
cancel_url
value with the URL where the payer is redirected after they cancel the flow. - Optional: For existing customers, pass the
customer.id
to link additional information such aspayment_source
to the customer. For new customers, the customer ID is returned in the setup token response.
Cards setup token response
A successful request returns the following:- An HTTP response code of
200
or201
. Returns200
for an idempotent request. - When saving a card for the first time for a payer, the response to the setup token request returns the
customer.id
and thesetup_token_id
. - A status of
PAYER_ACTION_REQUIRED
. - The following HATEOAS links:
Rel | Method | Description | Verification methods |
---|---|---|---|
approve | GET | Take the payer through the card approval flow. | 3D secure only |
confirm | POST | Use an approved setup token to save the card and generate a payment token. | All methods |
self | GET | View the state of your setup token and payment source data. | All methods |
Swap setup token for payment token
Exchange a temporary setup token for a permanent payment token.Swap setup token call
Copy and modify the following code:- Change
ACCESS-TOKEN
to your sandbox access token. - Change
REQUEST-ID
to a unique alphanumeric set of characters such as a time stamp. - Use
token
as thepayment_source
and complete the rest of the source object for your use case and business. - Pass the ID of the setup token you obtained from the previous step in the
payment_source
parameter. Set the type asSETUP_TOKEN
.
Swap setup token response
A successful request returns:- An HTTP response code of
200
or201
. Returns200
for an idempotent request id
of the payment token and associated payment method information.- The following HATEOAS links:
Rel | Method | Description |
---|---|---|
self | GET | Retrieve data about the saved payment method |
delete | DELETE | Delete the payment token |
Use saved payment token for purchase
After you create a payment method token, use the token instead of the payment method to create a purchase and capture the payment with the Orders API. You can use the payment method token to create an order on behalf of the payer when the payer isn’t present. You can store a merchant customer ID to help match your customer information across your system and PayPal. This is an optional field that returns the value shared in the response.Call the Orders v2 API with saved payment token
Copy and modify the following code:- Change
ACCESS-TOKEN
to your sandbox access token. - Change
REQUEST-ID
to a set of unique alphanumeric characters such as a time stamp. - Set the
payment_source
tocard
orpaypal
. - For
vault_id
, enter the ID of the payment method token you received in the previous step.
Optional: Retrieve saved payment token
If you stored the payment token the payer created on your site, skip this step. To make a payment on behalf of the payer, retrieve the payment token they created. You’ll need the customer ID that you assigned to this payer when saving the payment method. Copy and modify the following code:- Change
ACCESS-TOKEN
to your sandbox access token - Pass the PayPal-generated
customer_id
to retrieve the payment token details associated with the payer.
payment_tokens.id
, you can use the payment method token with checkout to create an order.