# Get started with PayPal REST APIs
Source: https://docs.paypal.ai/developer/how-to/api/get-started
Current PayPal APIs use REST, authenticate with OAuth 2.0 access tokens, and return HTTP response codes and JSON responses. You can test US integrations with a PayPal Developer account.
To try these REST APIs without a PayPal Developer account, you can use Postman. Learn more about this in our Postman guide.
To explore PayPal's REST API descriptions, generate code for your API clients, and import OpenAPI documents into compatible third-party tools, see the PayPal REST API specifications on GitHub.
> **Important:** You need a PayPal Business account to:
>
> * Go live with integrations.
> * Test integrations outside of the US.
## 1. Get your client ID and client secret
PayPal integrations use a client ID and client secret to authenticate API calls:
* A client ID identifies an app. You need a client ID to get a PayPal payment button and standard credit and debit card fields.
* A client secret authenticates a client ID. To call PayPal APIs, you exchange your client ID and client secret for an access token. Keep your client secret safe.
Here's how to get your client ID and client secret:
1. Select Log in to Dashboard and log in to your account or sign up for a new account.
2. Select **Apps & Credentials**.
3. New accounts come with a default application in the **REST API apps** section. To create a new project, select **Create App**.
4. Copy the client ID and client secret for your app.
## 2. Get an access token
You exchange your client ID and client secret for an access token, which you use for authentication when calling PayPal REST APIs.
You can call the PayPal OAuth API in any language. The following examples show you how to get your access token using cURL or Postman.
- Automatically canceled: Certain conditions automatically canceled the agreement, such as payment failures or account issues.
- Logic error: The application implemented faulty logic that tried to modify an agreement without checking its status. | - Transaction failure: Transactions for the canceled agreement cannot proceed, potentially leading to failed payments and disrupted user subscriptions or services.
- Integration failures: Recurring logic based on this agreement might break, causing administrators or payers to make multiple calls attempting to resolve actions on a non-existent agreement.
- Customer dissatisfaction: Users affected by the cancellation might experience service interruption, thereby reducing trust and satisfaction. | - Check the agreement status: Ensure that you check the status of a billing agreement before beginning operations, such as by retrieving agreement details and verifying the cancellation status.
- Implement error handling: Manage errors by informing the payer or system about the current status of the billing agreement and providing appropriate options or messages.
- Update business logic: Ensure that your application logic correctly tracks the status of an agreement and attempts only valid operations. |
# Cannot pay self
Source: https://docs.paypal.ai/developer/how-to/api/troubleshooting/common-errors/cannot-pay-self
Returns from the Payments V1 API.
`CANNOT_PAY_SELF` indicates that the payment request is attempting to send money to the same account initiating the transaction.
| Cause | Impact | Resolution |
| :--------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| - Duplicate reference: The transaction or billing agreement attempts to reference the sender and receiver of payment as the same entity, which is invalid. | - Disrupted transactions: PayPal prevents the transaction from being processed to avoid misuse or fraud stemming from potential self-payment. | - Confirm separation: Ensure that the sender and receiver are different entities.
- Review API request: Ensure you use distinct PayPal account IDs or email addresses for the sender and receiver.
- Implement validation checks: Ensure that your application checks to prevent users from setting up billing agreements with duplicate entities.
- Debug application code: Review and debug the code to correct issues leading to payer and payee using the same account. |
# Currency mismatch
Source: https://docs.paypal.ai/developer/how-to/api/troubleshooting/common-errors/currency-mismatch
Returns from the Payments V2 API.
`CURRENCY_MISMATCH` indicates a discrepancy between the currencies specified within different components in the transaction request. Typically, that means the currency used in the payment request does not match the currency expected or configured in the transaction.
| Cause | Impact | Resolution |
| :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| - Mismatch in account: The currency specified in the transaction request does not match the currency configured for the merchant account or the payment method.
- Mismatch in transaction: The currency used in the transaction does not match the currency settings of the payer or payee accounts.
- Mismatch in request: The currency specified in one field of the API request does not match another field in the API request, such as between the payment amount and the transaction currency. | - Failed payment attempt: The transaction cannot be processed, leading to a failed payment attempt.
- Payer dissatisfaction: Failed payment attempts can cause delays and inconvenience for the payer and the merchant as PayPal does not complete the payment until you resolve the currency issue. | - Verify fields: Check the API request to ensure that all relevant fields consistently use the same currency.
- Verify configuration: Ensure that you configure the merchant account to accept payments in the specified currency and adjust settings as necessary.
- Match between accounts: Ensure that the currency settings align between payer and payee accounts.
- Verify payment method support: Confirm that the payment method [supports the specified currency](https://developer.paypal.com/docs/reports/reference/paypal-supported-currencies/).
- Verify transaction match: Ensure that the currency used in the transaction matches the currency expected by the payment method. |
# Currency not allowed
Source: https://docs.paypal.ai/developer/how-to/api/troubleshooting/common-errors/currency-not-allowed
Returns from the Payments V1 API.
`CURRENCY_NOT_ALLOWED` indicates that PayPal does not support the currency specified in the transaction request.
| Cause | Impact | Resolution |
| :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| - Unsupported currency: PayPal does not support the specified currency for the transaction.
- Unconfigured account: The merchant's PayPal account is not configured to accept payments in the specified currency.
- Region restrictions: The region or transaction type may have restrictions on certain currencies.
- Disabled currency: PayPal may support the currency but the account or payment method disabled it. | - Failed payment attempt: PayPal cannot process the transaction with the specified currency.
- Inconvenience: Failed payment attempts using an unsupported currency can cause inconvenience for the merchant and the payer, especially if the payer prefers to pay in a specific currency. | - Verify supported currencies: Change the currency code in your API request to a [supported currency](https://developer.paypal.com/docs/reports/reference/paypal-supported-currencies/) for your location or account.
- Configure account: Ensure that you have configured or enabled your PayPal account to accept payments in the desired currencies. |
# Duplicate transactions
Source: https://docs.paypal.ai/developer/how-to/api/troubleshooting/common-errors/duplicate-transaction
Returns from the Payments V2 API.
`DUPLICATE_TRANSACTION` indicates that a transaction with identical details has already been processed, and has been flagged to prevent duplicate charges.
| Cause | Impact | Resolution |
| :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| - Network latency or delays: Issues in network or server communication could result in a resending of the transaction request.
- Payer actions: A payer might inadvertently submit the payment information multiple times, such as by clicking the payment button more than once.
- Server error: The client-side application did not receive a response and retried the transaction. | - Customer dissatisfaction: Needing to perform additional steps to confirm the transaction status, or being unsure whether the transaction succeeded, can lead to customer confusion or frustration. | - Check transaction status: Verify whether the original transaction succeeded by checking the transaction history in your PayPal account or through the API.
- Implement idempotency: Use unique identifiers, such as an idempotency key, for each transaction request to ensure that retries do not result in duplicate transactions.
- Improve user feedback: Provide clear feedback to payers about their transaction status to prevent them from resubmitting the payment.
- Implement error handling: Implement error handling and network retry logic to manage connectivity issues without resubmitting identical requests. |
# Merchant not enabled for reference transaction
Source: https://docs.paypal.ai/developer/how-to/api/troubleshooting/common-errors/merchant-not-enabled-for-reference-transaction
Returns from the Payments V1 API.
`MERCHANT_NOT_ENABLED_FOR_REFERENCE_TRANSACTION` indicates that the merchant account is not configured to perform reference transactions.
| Cause | Impact | Resolution |
| :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| - Unconfigured account: The merchant account is not configured or approved to handle reference transactions. Reference transactions require specific permissions and account settings that PayPal does not enable by default on all accounts.
- Failed attempt: The merchant attempts a reference transaction without enabling the necessary permissions or account settings. | - Failed payment attempt: The merchant cannot process reference transactions for recurring billing, subscriptions, or other post-payment transactions.
- Business disruptions: Services that depend on automated billing fail to operate. | - [Contact customer support](https://www.paypal.com/us/cshelp/contact-us): Send a request to customer support to enable reference transactions for your account. Enabling reference transactions may require you to provide additional information about your account.
- Review account settings: Configure your account settings to support reference transactions.
- For more information, see [Initiate future transactions](https://developer.paypal.com/docs/checkout/advanced/customize/reference-transactions/). |
# Not authorized
Source: https://docs.paypal.ai/developer/how-to/api/troubleshooting/common-errors/not-authorized
The Orders v2 API returns a `403 Not Authorized` error when the API caller or the payee does not have permission. Review the common causes and how to fix them.
If an issue persists or you have further questions, contact [PayPal Support](https://www.paypal.com/us/cshelp/technical).
- The payee ignored account restrictions or limits.
- The payee did not verify their email address. | PayPal stops the payment and blocks the transaction. This slows the purchase. |
- Tell the payee to check their email, link and confirm a bank account or card, and send required documents.
- Help them remove account restrictions or limits. Have them resolve any issues or contact PayPal support.
- Tell the payee to follow the steps in the PayPal email. |
- Another account used its info to make the request for the payee.
- The payee did not agree to let the API caller finish the payment. |
- The payee blocks the helper account from processing payments.
- Customers cannot finish PayPal payments on the website. | - Enter the payee account in the `payee` field in the `purchase_units` object of the Orders API request. Enter correct info and give the API caller permission.
- For PayPal Complete Payments, give the API caller consent to collect partner fees for the payee. Add `PARTNER_FEE` during sign-up.
- If you already added permission or this issue persists, contact PayPal support. |
- The PayPal account doesn't have the permission you need.
- The API caller used expired or invalid OAuth access tokens.
- The account tries things it is not allowed to do, like a personal account using business tools.
- The API caller uses the wrong sandbox login info in a live environment or the other way around. | The payment stops, and the customer cannot finish the order. This can cause lost sales. | - Make sure the resource ID belongs to the PayPal account making the API call. If not, give the right permission.
- Use login info for the correct sandbox or live environment and get it from the PayPal Developer Dashboard.
- Ask for the right access when making tokens.
- Renew access tokens often and handle token expiration in the PayPal Developer Dashboard.
- Use the correct API endpoints for your environment. For sandbox, use `https://api.sandbox.paypal.com`. For live, use `https://api.paypal.com`.
- Make sure the PayPal account supports the requested API operations. Some features only work for business accounts or special integrations, like payouts. |
# Common errors overview
Source: https://docs.paypal.ai/developer/how-to/api/troubleshooting/common-errors/overview
Troubleshooting is an important part of integrating with the PayPal Orders API. The following provides explanations and solutions to help you quickly find and fix issues in your integration.
| Issue | Action |
| :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `AMOUNT_MISMATCH` | Ensure the total amount equals the sum of line items, taxes, and discounts. The API returns this error if the sale amounts are not reflected in the request. |
| `CARD_EXPIRED` | Show the error to the payer and ask them to use a different card. |
| `CANNOT_BE_NEGATIVE` | Enter a positive amount with no more than two decimal places. |
| `CANNOT_BE_ZERO_OR_NEGATIVE` | Enter a positive, non-zero amount with no more than two decimal places. |
| `CURRENCY_NOT_SUPPORTED` | Use a PayPal-supported currency. Make sure the receiving PayPal account accepts the currency. For a list of supported currencies, see [Currency codes](https://developer.paypal.com/docs/api/rest/reference/currency-codes/currency-codes/). |
| `DECIMAL_PRECISION` | Round the amount to 2 decimal places and try again. If the issue persists, contact [PayPal support](https://www.paypal.com/us/cshelp/technical) and provide the `debug_id` from the API response. |
| `DECIMALS_NOT_SUPPORTED` | Adjust the amount to match the number of decimal places the currency supports. |
| `DUPLICATE_INVOICE_ID` | Use a different `invoice_id`. If you must reuse the same `invoice_id` and the issue persists, contact [PayPal support](https://www.paypal.com/us/cshelp/technical). |
| `INCOMPATIBLE_PARAMETER_VALUE` | Make sure the parameters in the API request match the expected data types. For more information, see [Authentication](https://developer.paypal.com/api/rest/authentication/). |
| `INVALID_PARAMETER_SYNTAX` | Make sure the API request JSON is correct and follows the PayPal API request format. If the issue persists, contact [PayPal support](https://www.paypal.com/us/cshelp/technical) and provide the `debug_id` from the API response. |
| `INVALID_PARAMETER_VALUE` | Enter a valid parameter value. |
| `INVALID_RESOURCE_ID` | Check the resource ID and try again. If the resource ID belongs to a different PayPal account, check the scopes and permissions for the receiving account. |
| `INVALID_STRING_LENGTH` | Make sure text fields are not too long and include all required data. For string length requirements, see the [Orders API](https://developer.paypal.com/docs/api/orders/v2/#orders_create). |
| `ITEM_TOTAL_MISMATCH` | Make sure the item totals match the quantity total. |
| `MAX_NUMBER_OF_PAYMENT_ATTEMPTS_EXCEEDED` | Ask the payer to use a different payment method. |
| `MISSING_REQUIRED_PARAMETER` | Make sure the JSON follows the PayPal API request format and includes all [required parameters](https://developer.paypal.com/docs/api/orders/v2/#orders_create). If the issue persists, contact [PayPal support](https://www.paypal.com/us/cshelp/technical) and provide the `debug_id` from the API response. |
| `ORDER_ALREADY_AUTHORIZED` | To proceed, [call capture](https://developer.paypal.com/docs/api/orders/v2/#orders_capture) because the funds are authorized. If the authorization is more than 3 days old, reauthorize the funds before capturing. |
| `ORDER_ALREADY_CAPTURED` | No action needed. Use a `GET` call on the order ID to get the capture ID or PayPal transaction ID. For multi-capture or split shipments, use `intent=AUTHORIZE`. See [Capture authorized payment](https://developer.paypal.com/docs/api/payments/v2/#authorizations_capture) for more information. |
| `ORDER_NOT_APPROVED` | Ask the payer to complete PayPal checkout again to approve the order. Redirect them to the `'rel':'approve'` URL in the HATEOAS links from the create order call or provide a valid `payment_source` in the request. |
| `PAYEE_ACCOUNT_RESTRICTED` | Contact PayPal customer support to lift restrictions on the receiving account. If you are a marketplace, ask the seller to resolve restrictions with PayPal. |
| `PAYEE_NOT_CONSENTED` | Make sure the API caller has consent to collect partner fees for the payee. Add `PARTNER_FEE` to the capabilities during [signup](https://developer.paypal.com/docs/multiparty/seller-onboarding/before-payment/#generate-a-signup-link). If `PARTNER_FEE` is already added or the issue persists, contact [PayPal support](https://www.paypal.com/us/cshelp/technical). |
| `PAYEE_NOT_ENABLED_FOR_CARD_PROCESSING` | Contact [PayPal support](https://www.paypal.com/us/cshelp/technical) to check the merchant or payee account configuration. |
| `PAYER_ACTION_REQUIRED` | Redirect the payer to the `'rel':'payer-action'` HATEOAS link before authorizing or capturing the order. Some payment methods require a webhook subscription to notify you of background payer actions before capture succeeds. |
| `PERMISSION_DENIED` | Make sure you have the correct permissions and scopes for the resource. If the resource ID belongs to another account, grant the necessary permissions. |
| `POSTAL_CODE_REQUIRED` | Add a postal code to the request and try again. |
| `REDIRECT_PAYER_FOR_ALTERNATE_FUNDING` | Redirect the payer to choose a different payment method. In PayPal, the payer can add a new payment method to their wallet or use a different card. |
| `REFERENCED_CARD_EXPIRED` | Ask the payer to update their card information. Otherwise, future attempts will fail. |
| `SHIPPING_ADDRESS_INVALID` | Fix the shipping address and try again. If using saved payment details, ask the payer for the correct shipping address. |
| `TOKEN_ID_NOT_FOUND` | Validate the payment token. If your PayPal account is making API calls for another account, make sure the recipient account grants the necessary permissions. |
| `UNPROCESSABLE_ENTITY` | Contact [PayPal support](https://www.paypal.com/us/cshelp/technical) with the `debug_id` or `correlation_id` from the response header. For legacy integrations, check the body or response parameters. |
| `VALIDATION_ERROR` | Tell the payer the card number is incorrect and ask them to enter the correct number. |
## HTTP status codes and error messages
The following table lists the most common HTTP status codes and error messages returned by the [Orders v2 API](https://developer.paypal.com/docs/api/orders/v2/#errors).
| HTTP status code | Error message | Error code |
| :-------------------------- | :--------------------------------------------------------------------------------------------------- | :----------------------- |
| `400 Bad Request` | The request has the wrong format. | `INVALID_REQUEST` |
| `401 Unauthorized` | Authentication failed because the authorization header is missing, or the credentials are not valid. | `AUTHENTICATION_FAILURE` |
| `403 Forbidden` | Authorization failed because of lack of permissions. | `NOT_AUTHORIZED` |
| `404 Not Found` | The specified resource does not exist. | `RESOURCE_NOT_FOUND` |
| `422 Unprocessable Entity` | The requested action could not be performed, won't work, or failed business rules. | `UNPROCESSABLE_ENTITY` |
| `500 Internal Server Error` | An internal server error occurred. | `INTERNAL_SERVER_ERROR` |
| `503 Service Unavailable` | The service is unavailable. | `SERVICE_UNAVAILABLE` |
## Error samples
The following examples show common error scenarios for the Orders v2 API. Each sample includes a request and the corresponding error response.
### Internal server error (500)
The Orders v2 API returns a `500` status code when the server encounters an unexpected condition. The following sample shows a response when the server has an underlying issue or does not handle an internal exception.
#### Create order request
```bash theme={null}
curl -v -X POST https://api-m.sandbox.paypal.com/v2/checkout/orders/ \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-d '{
"intent": "CAPTURE",
"purchase_units": [
{
"reference_id": "d9f80740-38f0-11e8-b467-0ed5f89f7b",
"amount": {
"currency_code": "USD",
"value": "10.00"
}
}
],
"payment_source": {
"paypal": {
"address": {
"address_line_1": "2211 N First Street",
"address_line_2": "17.3.160",
"admin_area_1": "CA",
"admin_area_2": "San Jose",
"postal_code": "95131",
"country_code": "US"
},
"email_address": "johndoe@paypal.com",
"payment_method_preference": "IMMEDIATE_PAYMENT_REQUIRED",
"experience_context": {
"return_url": "https://example.com/returnUrl",
"cancel_url": "https://example.com/cancelUrl"
}
}
}
}'
```
#### Error response
```json theme={null}
{
"name": "INTERNAL_SERVER_ERROR",
"message": "An internal server error has occurred.",
"debug_id": "90957fca61718",
"links": [
{
"href": "https://developer.paypal.com/api/orders/v2/#error-INTERNAL_SERVER_ERROR",
"rel": "information_link",
"method": "GET"
}
]
}
```
### Unprocessable entity error (422)
The Orders v2 API returns a `422` status code when an order fails business validation. For example, this can happen if the payer uses an expired payment card.
The following sample shows a create order request with an expired card and the resulting error response.
#### Create order request
```bash theme={null}
curl -v -X POST https://api-m.sandbox.paypal.com/v2/checkout/orders/ \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-d '{
"intent": "AUTHORIZE",
"purchase_units": [
{
"reference_id": "d9f80740-38f0-11e8-b467-0ed5f89f718b",
"amount": {
"currency_code": "USD",
"value": "100.00"
}
}
],
"payment_source": {
"card": {
"number": "4111111111111111",
"expiry": "2010-02",
"name": "John Doe",
"billing_address": {
"address_line_1": "2211 N First Street",
"address_line_2": "17.3.160",
"admin_area_1": "CA",
"admin_area_2": "San Jose",
"postal_code": "95131",
"country_code": "US"
},
"stored_credential": {
"payment_initiator": "MERCHANT",
"payment_type": "ONE_TIME",
"usage": "SUBSEQUENT"
}
}
}
}'
```
#### Error response
```json theme={null}
{
"name": "UNPROCESSABLE_ENTITY",
"details": [
{
"field": "/payment_source/card/expiry",
"location": "body",
"issue": "CARD_EXPIRED",
"description": "The card is expired."
}
],
"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
"debug_id": "866780170332c",
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-CARD_EXPIRED",
"rel": "information_link",
"method": "GET"
}
]
}
```
### Bad request (400)
The Orders v2 API returns a `400` status code when a request includes an incorrect or unsupported value. The following sample shows a create order request with an invalid `usage_pattern` and the resulting error response.
#### Create order request
```bash theme={null}
curl -v -X POST https://api-m.sandbox.paypal.com/v2/checkout/orders/ \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-d '{
"intent": "CAPTURE",
"purchase_units": [
{
"reference_id": "PUHF",
"amount": {
"currency_code": "USD",
"value": "10.00"
}
}
],
"payment_source": {
"paypal": {
"attributes": {
"customer": {
"id": "jd120252fg4dm"
},
"vault": {
"confirm_payment_token": "ON_ORDER_COMPLETION",
"usage_type": "MERCHANT",
"usage_pattern": "IMM3DI4T3"
}
}
}
}
}'
```
#### Error response
```json theme={null}
{
"name": "INVALID_REQUEST",
"message": "Request is not well-formed, syntactically incorrect, or violates schema.",
"debug_id": "10398537340c8",
"details": [
{
"field": "/payment_source/paypal/attributes/vault/usage_pattern",
"value": "IMM3DI4T3",
"location": "body",
"issue": "INVALID_PARAMETER_VALUE",
"description": "A parameter value is not valid."
}
],
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-INVALID_PARAMETER_VALUE",
"rel": "information_link"
}
]
}
```
### Forbidden (403)
The Orders v2 API returns a `403` status code when the API caller or payee does not have the required permissions for the request. The following sample shows a create order request that sets `items.category` to `DONATION` without the necessary permissions.
#### Create order request
```bash theme={null}
curl -v -X POST https://api-m.sandbox.paypal.com/v2/checkout/orders/ \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-d '{
"intent": "CAPTURE",
"purchase_units": [
{
"amount": {
"currency_code": "USD",
"value": "5.00",
"breakdown": {
"item_total": {
"currency_code": "USD",
"value": "5.00"
}
}
},
"items": [
{
"name": "Donation to WWF",
"unit_amount": {
"currency_code": "USD",
"value": "5.00"
},
"quantity": "1",
"category": "DONATION"
}
]
}
]
}'
```
#### Error response
```json theme={null}
{
"name": "NOT_AUTHORIZED",
"details": [
{
"issue": "PERMISSION_DENIED_FOR_DONATION_ITEMS",
"description": "The API Caller or Payee have not been granted appropriate permissions to send 'items.category' as 'DONATION'. Please speak to your account manager if you want to process these type of items."
}
],
"message": "Authorization failed due to insufficient permissions.",
"debug_id": "90957fca61718",
"links": [
{
"href": "https://developer.paypal.com/api/orders/v2/#error-PERMISSION_DENIED_FOR_DONATION_ITEMS",
"rel": "information_link",
"method": "GET"
}
]
}
```
# Resource not found
Source: https://docs.paypal.ai/developer/how-to/api/troubleshooting/common-errors/resource-not-found
A `RESOURCE_NOT_FOUND` error occurs when the specified resource does not exist. The following issues can cause this error.
If an issue persists or you have further questions, contact [PayPal Support](https://www.paypal.com/us/cshelp/technical).
- You used a resource ID in the API request that does not exist in the system.
- The API caller does not have permission to access the resource. | PayPal stops the payment and does not process the order. This slows down the purchase. | - Check that the resource ID in the API request is correct and exists in the system. Fix any typos or mistakes.
- Make sure the API caller has permission to access the resource. Update permissions if needed. |
# Unprocessable entity
Source: https://docs.paypal.ai/developer/how-to/api/troubleshooting/common-errors/unprocessable-entity
PayPal cannot process your request because it is incorrect or fails business rules. The issues below can cause an `UNPROCESSABLE_ENTITY` error.
If an issue persists or you have further questions, contact [PayPal support](https://www.paypal.com/us/cshelp/technical).
- Oversight: The payer misunderstood the current agreement status.
- Business logic error: The system that is integrated with the API improperly checked the agreement status before attempting operations. | - Operations failure: The payer potentially cannot perform operations, such as processing payments, on the canceled agreement.
- Service disruption: Unintended or improperly communicated canceled billing agreements can disrupt service or billing processes.
- Payer dissatisfaction: Repeated transaction failures can lead to frustration and confusion among payers. | - Verify agreement status: Confirm the canceled status of the billing agreement.
- Review business logic: Ensure that the integrated system properly checks the status before attempting operations.
- Communicate with payers: Inform the payer about the unintended canceled billing agreement to resolve issues.
- Create a new billing agreement. |
- Improper billing agreement: The API request uses a missing billing agreement.
- Permission issue: The requesting account lacks permissions to manage the billing agreement.
| - Disrupted workflows: Workflows that use the billing agreement ID can be disrupted, which can lead to failures in other business operations.
| - Verify billing agreement ID: Ensure the accuracy of the billing agreement ID in the API request.
- Check agreement status: Confirm that the billing agreement ID belongs to an active billing agreement.
- Elevate permission: Ensure that the requesting account holds appropriate permissions to manage the billing agreement. |
- Disrupted revenue: Failed processes can lead to disruption of automated systems that use billing agreements and ongoing subscriptions. | - Confirm separation: Ensure that the sender and receiver are different entities.
- Review API request: Ensure you use distinct PayPal account IDs or email addresses for the sender and receiver.
- Implement validation checks: Ensure that your application checks to prevent users from setting up billing agreements with duplicate entities.
- Verify account details: Ensure that your application uses the correct account details for transactions and billing agreements.
- Implement retry mechanism: Develop business logic that waits a short period before attempting the request again, gradually increasing the wait time with each attempt. |
- An expired card cannot be used for payments.
- The payer must use a different card or payment method. | PayPal stops the payment. The payer cannot finish the purchase. This can cause lost sales. | - Show an error message that the card is expired.
- Ask the payer to use a different card or payment method.
- Help the payer switch payment methods and finish the payment. |
- Region limitations: The region from which the API was initiated may not support the currency code.
- Account restrictions: The merchant account may have restrictions or limitations on supported currencies. | - Process failure: The billing agreement fails due to the use of unsupported currencies.
- Revenue loss: Subscriptions or recurring payments do not proceed due to this error, causing delays or issues for the payer. | - Verify currency support: Confirm that PayPal supports the currency code.
- Verify currency settings: Confirm that your PayPal business account can use the necessary [currencies](https://developer.paypal.com/docs/reports/reference/paypal-supported-currencies/).
- Cross-check regional restrictions: Ensure that your region does not restrict the currency used in your transaction or billing agreement.
- Change currency codes: Change the currency code used in your API request to a supported currency for your location or account. |
- Reused invoice ID: The transaction or billing agreement uses a processed invoice ID typically due to a logic error or failure to manually update the ID. | - Rejected requests: The system prevents the completion of billing operations, potentially affecting liquidity and payer satisfaction. | - [Contact customer support](https://www.paypal.com/us/cshelp/contact-us): If your workflow requires duplicate invoice IDs, contact customer support.
- Confirm invoice usage: Confirm the use of unique invoice IDs in your billing agreements and transactions.
- Implement invoice ID mechanisms: Develop logic that generates a unique invoice ID for each transaction and billing agreement.
- Incorporate logs: Track and verify invoice IDs in the application to prevent reuse and assist with future debugging. |
- Expired card: The payer used an expired or canceled payment instrument, such as a credit card.
- Declined transaction: The bank or card issuer declined the transaction due to reasons such as suspected fraud or account restrictions.
- Potential risk: The payer account may have insufficient funds, may pose a risk, or may have encountered a compliance issue.
- Incorrect billing information: The user entered incorrect information, such as CVV, expiration date, or account number. | - Payment failure: The payer cannot complete the payment, potentially affecting their access to services or products.
- Payer dissatisfaction: Repeated transaction failures can lead to frustration among payers.
- Revenue loss: The merchant may experience a loss of revenue due to unsuccessful transactions. | - Verify payment method: Ensure that the payer uses a valid, active, and sufficiently funded payment method.
- Fund availability: Confirm with the payer that their account holds sufficient funds or is within their credit limit.
- Contact financial institution: Encourage payers to contact their bank or card issuer to resolve any temporary holds or restrictions.
- Update billing instrument: If the payer used an expired or invalid instrument, ask the payer to update their payment information. |
- Permission issue: The requesting account lacks permissions to manage reference transactions.
| - Disrupted workflows: The merchant cannot process future payments from the payer without manually acquiring authorization again.
- Disrupted revenue: Additional authorization requests can impact post-purchase revenue streams. | - Contact customer support: Send a request to customer support to enable reference transactions for your account. Enabling reference transactions may require you to provide additional information about your account. For more information, see [Initiate future transactions](https://developer.paypal.com/docs/checkout/advanced/customize/reference-transactions/).
- Verify configurations: Ensure that you configured your account settings to support reference transactions. PayPal may request additional information regarding your account to enable this feature. For more information, see [Initiate future transactions](https://developer.paypal.com/docs/checkout/advanced/customize/reference-transactions/). |
- Improper configuration: The merchant account settings do not include necessary features, configurations, or permissions.
- Account restrictions or limitations: The merchant account may have restrictions or limitations based on their account type or region. | - Process failure: The merchant cannot create or manage their billing agreement.
- Revenue loss: Subscriptions, recurring payments, or other functionality reliant on channel-initiated billing do not proceed due to this error. | - Contact customer support: Work with customer support or your account manager to inquire about enabling channel-initiated billing support.
- Review account settings: Ensure that your account settings support the desired billing features. |
- You can only authorize an order once with `intent="AUTHORIZE"`.
- Duplicate requests may happen if you missed the first response.
- Network issues or delays may cause missed responses. | PayPal declines the second authorization. You cannot split the authorization into parts. | - Authorize the full order amount in one request, then make multiple captures if needed.
- Set `final_capture="false"` in capture requests for split shipments.
- Use PayPal webhooks to track order status.
- If your API call times out, contact PayPal support. |
- You can only capture an order once with `intent="SALE"`.
- Duplicate requests may happen if you missed the first capture response. | If you only captured part of the amount, you cannot capture the rest unless you create a new order.
- If you meant to capture once, there is no payer impact. | - Use `intent="AUTHORIZE"` if you need to capture more than once.
- For single captures, make sure you record the API response to avoid duplicates.
- Use PayPal webhooks to track payment status. |
- The request may not include a valid `payment_source`. | PayPal declines the payment. The payment does not go through. This can delay the purchase. | - Send the payer to the approval URL (`rel:approve`) from the Create Order call.
- Make sure the request includes a valid `payment_source`. |
- Account closure: The payer or PayPal closed the account due to policy violations or other administrative reasons. | - Billing agreement failure: This error prevents payers from creating or processing billing agreements and their associated transactions.
- Service operations: Merchants and payers can experience service loss, which can cause revenue loss. | - [Contact customer support](https://www.paypal.com/us/cshelp/contact-us): Work with customer support to resolve the issue.
- Settle account: Resolve debts or disputes that led to the account lock or closure, then retry the billing agreement. |
- Account limitations: The payer's account may have limitations or restrictions.
- Unverified account: The payer uses an unverified account or did not perform required updates, which prevents payments.
- Payment method issue: The payer used an expired or canceled payment instrument, such as a credit card.
- Account restrictions: The payer account encounters a compliance issue or external issue that restricts payment processing. | - Payment failure: The payer cannot complete the payment, potentially affecting their access to services or products.
- Payer dissatisfaction: Repeated transaction failures can lead to frustration among payers.
- Revenue loss: The merchant may experience a loss of revenue due to unsuccessful transactions. | - Check account status: Verify that both the payer's and merchant's PayPal accounts are in good standing without any limitations or restrictions.
- Verify payment method: Ensure that the payer uses a valid, active, and sufficiently funded payment method.
- Configure alternative payment options: Suggest that the payer use a different payment method.
Update account info: Ensure that the payer includes up-to-date account information, such as billing address and linked payment methods. |
- The payee has not finished onboarding for PayPal Complete Payments. | PayPal stops the payment. The payer cannot finish the purchase. This can cause lost sales.
- All payers trying to pay this payee will see this error. | - Make sure the payee finished onboarding and enabled card payments.
- If the payee manages onboarding, ask them to contact PayPal to turn on card payments. |
- Processing delay: Multiple requests can delay planned modifications or renewals of a resource. | - Verify request status: Check the status of the previous request to ensure its completion before initiating a new request.
- Queue requests: Process requests sequentially in a queue, allowing each request to complete before initiating the next request.
- Implement error handling: Develop business logic to handle this error and respond appropriately, such as notifying users of the delay or logging the error for further analysis. |
- Send the payer to PayPal checkout to pick another payment method.
- If the problem continues, ask the payer to use a different payment method or contact PayPal. |
- Payment method issue: The payment instrument, such as a credit card, is expired or canceled.
- Account limitations: The payer's PayPal account might have limitations or restrictions.
- Unsupported method: The transaction does not support the selected payment method. | - Incomplete transactions: The payer cannot complete the transaction with the selected payment method.
- User experience impact: Reselecting a payment method can add additional steps for the user and delay transaction processing. | - Change payment method: Inform the user to change their payment method, then retry the transaction.
- Implement alternative payment mechanism: If supported, develop business logic that redirects users to alternative payment methods, then retry the transaction. |
- The payer must use a different card or payment method. | PayPal stops the payment. The payer cannot finish the purchase. This can cause lost sales. | - Turn on Real-Time Account Updater (RTAU) to keep card expiration dates up to date.
- Show an error message if the saved card is expired.
- Update the saved payment token after you get a new one.
- Give the payer clear steps to finish the payment. |
- The address format is wrong.
- System issues prevent the address from being sent correctly. | PayPal declines the payment. The payment does not go through. This can delay the purchase. | - Check that all required address fields are filled in.
- Use address validation tools to fix the format.
- Make sure your system sends all address fields in the API request. |
- Missing fields: The API request does not contain required shipping address fields.
- Validation failure: The address does not match the standards or validation rules set by PayPal or the postal service of the specified country.
- Mismatch: The country code and the country name provided may mismatch, causing the error. | - Process failure: The billing agreement, transaction, or subscription setup will not proceed.
- Workflow disruption: Delays in processing payments or setting up recurring billing agreements can impact payer satisfaction and business operations. | - Verify fields: Verify that all required fields in the shipping address use correct formatting.
- Match address: Ensure that the address fields, such as street, city, state, postal code, and country, match the expected format for the specified country.
- Verify country code: Ensure that the country code matches the country name, using address validation tools or services to confirm its accuracy.
- Revise address: Contact the payer to correct or confirm the address details. |
- The token may be wrong, mistyped, or the caller does not have permission. | PayPal stops the payment. The payer cannot finish the purchase. This can cause lost sales. | - Make sure the receiving account gave the needed permissions.
- Check that the token ID is correct.
- If the token is wrong or expired, create a new token. |
- Insufficient funds: The payer's account may not have enough funds or credit to cover the transaction amount.
- Account limitations: The payer's PayPal account might have limitations or restrictions.
- Risk factors: If PayPal detects any potential risks based on merchant history or if there's high risk associated with the transaction, PayPal will refuse the transaction. | - Payment failure: The payer's failure to complete the payment can potentially affect their access to services or products.
- Payer dissatisfaction: Repeated transaction failures can lead to payer frustration.
- Revenue loss: The merchant may experience a loss of revenue due to unsuccessful transactions. | - Verify payment method: Ensure that the payer uses a valid, active, and sufficiently funded payment method.
- Check account status: Verify that both the payer's and merchant's PayPal accounts operate in good standing without any limitations or restrictions.
- Correct API request: Double-check the API request parameters to ensure they are correct and complete. |
- Disabled currency: The payee did not enable the specified currency in their account settings.
- Region limitations: Certain regions do not make available specific currencies for the merchant account, resulting in a currency mismatch during a transaction. | - Process failure: The merchant cannot create or manage their billing agreement.
- Impacted business operations: PayPal does not record failed transactions, which prevents tracking of fund transfer issues and could impact subscription services or billing agreements. | - Confirm that PayPal supports the currency code.
- Configure account: Ensure that you have enabled the specified currency in your account settings to accept payment from the payee account.
- Currency conversion: Consider using a supported currency or handle currency conversion with PayPal currency conversion services. |
# Unsupported payee currency
Source: https://docs.paypal.ai/developer/how-to/api/troubleshooting/common-errors/unsupported-payee-currency
Returns from the Payments V1 API.
`UNSUPPORTED_PAYEE_CURRENCY` indicates that the payee's PayPal account does not support the currency specified in the transaction, and the payee cannot accept payments.
| Cause | Impact | Resolution |
| :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| - Account restrictions: The payee account restrictions permit only transactions in certain currencies.
- Disabled currency: The payee did not enable the specified currency in their account settings.
- Region limitations: Certain regions do not make available specific currencies for the merchant account, resulting in a currency mismatch during a transaction. | - Failed payment attempt: The transaction cannot be completed using the specified currency.
- Customer dissatisfaction: Unprocessable payments can cause inconvenience for both the payer and payee. | - Verify supported currencies: Change the currency code in your API request to a [supported currency](https://developer.paypal.com/docs/reports/reference/paypal-supported-currencies/) for the payee account.
- Contact payee: Communicate with the payee to confirm their account settings and the currencies they enabled. |
# Validation error
Source: https://docs.paypal.ai/developer/how-to/api/troubleshooting/common-errors/validation-error
You get a validation error when the API request contains invalid, missing, or incorrectly formatted data. This error can return from the [Orders v2](https://developer.paypal.com/docs/api/orders/v2/) or [Payments v1](https://developer.paypal.com/docs/api/payments/v1/) APIs.
If an issue persists or you have further questions, contact [PayPal support](https://www.paypal.com/us/cshelp/technical).
| Cause | Impact | Resolution |
| :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| - Required fields are missing or contain incorrect values.
- Field values do not match expected data types.
- Currency codes are invalid or the amount formatting is incorrect.
- The request body is not properly formatted as JSON.
- The transaction is blocked based on the account's status or configuration.
- An incorrect or outdated API version is used. Some validation rules may change between versions. | The payment process stops, and the payer cannot complete the purchase. This can result in lost sales if not fixed quickly. | - Check the error details in the API response to find the exact field and issue.
- Ensure all required fields are there and contain valid data in the correct format and type.
- Update the request with correct data and resend it to allow the payment to process. |
# Handling payment failures with PayPal
Source: https://docs.paypal.ai/developer/how-to/api/troubleshooting/handling-payment-failures-with-paypal
Detect and respond to payment failures using PayPal's Orders v2 API and Subscriptions API. This guide explains common failure reasons, how to surface errors to buyers, best practices for retrying or recovering failed payments, and how to leverage PayPal's intelligent retry mechanism.
## Key concepts
* Payment failures can happen for many reasons, such as declined cards, expired payment methods, insufficient funds, risk restrictions, or business validation errors.
* PayPal's APIs (Orders v2 and Subscriptions) return clear error codes and messages in their responses.
* Proper handling improves user experience, reduces lost sales, and ensures smooth subscription renewals.
* Some payment failures are asynchronous, meaning they might not be immediately apparent during the initial transaction.
## Common payment failure scenarios
Here are some of the most frequent failure reasons and how to handle them:
| Error Code / Issue | What It Means | What To Do |
| :----------------------------------------- | :-------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------------------------------------------------- |
| `INSTRUMENT_DECLINED` | Payment method was declined. | Prompt the buyer to select a different payment method. Restart the payment flow using `actions.restart()`. |
| `CARD_EXPIRED` | Card is expired. | Inform the buyer and ask for a new card. |
| `AMOUNT_MISMATCH`, `ITEM_TOTAL_MISMATCH` | Totals do not add up. | Fix item or amount totals in your API request and retry. |
| `CURRENCY_NOT_SUPPORTED` | Unsupported currency. | Use a supported currency or update your PayPal account settings. |
| `ORDER_NOT_APPROVED` | Buyer did not approve the order. | Redirect the buyer to approve the order again. |
| `MAX_NUMBER_OF_PAYMENT_ATTEMPTS_EXCEEDED` | Too many failed attempts. | Ask the buyer to use a different payment method or contact PayPal support. |
| `REDIRECT_PAYER_FOR_ALTERNATE_FUNDING` | Funding source failed, alternate source needed. | Prompt the buyer to choose a different payment method. |
| `VALIDATION_ERROR`, `UNPROCESSABLE_ENTITY` | Invalid or missing data. | Show a clear error, ask the buyer to correct the information, and retry. |
| `PAYMENT_DENIED` | The payment was denied by PayPal. | Investigate the reason for denial and contact PayPal support if needed. Prompt the buyer to use a different payment method. |
| `PAYER_CANNOT_PAY` | The payer is unable to pay using the selected payment method. | Prompt the buyer to select a different payment method or contact PayPal support. |
| `CANNOT_BILL_PAST_DUE_BALANCE` | The subscription is suspended because the past due balance exceeds the maximum allowed. | Contact PayPal support to resolve the suspension or prompt the buyer to pay the outstanding balance. |
| `REJECTED_DUE_TO_RISK_REVERSAL` | The payment was rejected due to a risk reversal, such as a chargeback or dispute. | Investigate the reason for the reversal and contact PayPal support if needed. |
| `TRANSACTION_REFUSED` | The transaction was refused by the processor. | Prompt the buyer to use a different payment method or contact their bank. |
| `INVALID_ACCOUNT_STATUS` | The payer's account is in an invalid state, such as locked or inactive. | Prompt the buyer to contact PayPal support to resolve their account issue. |
| `INVALID_REQUEST` | The request was malformed or missing required parameters. | Review the request parameters and ensure they are valid. |
| `AUTHENTICATION_FAILURE` | Authentication failed due to invalid credentials. | Verify your API credentials and ensure they are correct. |
| `NOT_AUTHORIZED` | You are not authorized to perform this action. | Check your account permissions and ensure you have the necessary privileges. |
| `RESOURCE_NOT_FOUND` | The requested resource was not found. | Verify the resource ID and ensure it exists. |
| `UNPROCESSABLE_ENTITY` | The request was well-formed but could not be processed due to semantic errors. | Review the request data and ensure it is valid and consistent. |
See the [Orders v2 API Troubleshooting Guide](https://developer.paypal.com/api/rest/integration/orders-api/troubleshooting/) and the [Subscriptions API documentation](https://developer.paypal.com/docs/subscriptions/) for a more comprehensive list of error codes.
## Detect and handle payment failures
### 1. Check API responses
* Always inspect responses from the Orders API (create, authorize, or capture endpoints) or the Subscriptions API (create, update, or activate subscription endpoints).
* If the response contains an error code, use it to determine the next step.
**Example: Handling a Declined Payment in JavaScript (Orders API)**
| Current color | Current button | New button | New color | |
|---|---|---|---|---|
| Gold |
|
→ |
|
Blue |
| Blue |
|
→ |
|
Blue |
| Silver |
|
→ |
|
White |
| White |
|
→ |
|
White |
| Black |
|
→ |
|
Black |
| Parameter | Required | Description |
|---|---|---|
clientId |
conditional |
string. Your PayPal client ID. Use this for most integrations. Mutually exclusive with |
clientToken |
conditional |
string. A secure, browser-safe token that your server generates using your PayPal client ID and secret. Required for PayPal payment vaulting and Fastlane integrations. This token expires after 15 minutes and is bound to your domain for security. You must generate a new token when needed. Mutually exclusive with |
components |
no |
string\[]. An array of SDK components to load for your integration. Each component enables specific payment functionality. Available components:
Default: |
pageType |
no |
string. The type of page where the SDK is being initialized. This helps PayPal optimize the payment experience and provide better analytics. Accepted values:
|
locale |
no |
string. The locale for the UI components, specified as a BCP-47 language tag, for example, `"en-US"`, `"fr-FR"`, `"de-DE"`. If not specified, the SDK automatically detects the buyer's locale from their browser settings. |
clientMetadataId |
no |
string. A unique identifier for tracking and debugging. You can generate this using |
merchantId |
yes for partners |
string. A unique identifier for the seller you're processing payments for. |
partnerAttributionId |
no |
string. PayPal issues this |