Test Your Integration and Execute the Payment

DeprecatedLast updated: October 12th 2021, @ 6:58:00 pm


Important: PayPal Plus for Mexico is not available for new integrations. PayPal provides this documentation to support existing integrations.

For PayPal Plus for Brazil, see the Brazilian integration guide.

To complete the payment flow, you should issue a request to execute the payment. Payment execution can be initiated from the final order review page or in the background upon return from the hosted pages (when there is no order review page).

When you execute the payment, submit any updates to the shipping address and the shipping and handling charges with the request. Do not change item list.

The payer_id needed to execute the payment is provided in the response from the doContinue function together with the rememberedCards.

Example

The following sample shows how to issue a request to execute payment in the sandbox environment.

Request

curl -v https://api-m.sandbox.paypal.com/v1/payments/payment/<Payment-Id>/execute/ \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <Access-Token>" \
  -d '{
  "payer_id": "SUYCECXSW5XMA"
}'

Response

{
  "id": "PAY-7V4081612V751425TKS7OPEQ",
  "create_time": "2015-01-20T23:41:06Z",
  "update_time": "2015-01-20T23:43:58Z",
  "state": "approved",
  "intent": "sale",
  "payer": {
    "payment_method": "paypal",
    "payer_info": {
      "email": "test123456781111@paypal.com",
      "first_name": "Max",
      "last_name": "Santos",
      "payer_id": "SUYCECXSW5XMA",
      "shipping_address": {
        "line1": "Gregório Rolim de Oliveira, 42",
        "line2": "JD Serrano II",
        "city": "Votorantim",
        "state": "São Paulo",
        "postal_code": "18117-134",
        "country_code": "BR",
        "recipient_name": "Max Santos"
      }
    }
  },
  "transactions": [
    {
      "amount": {
        "total": "95.00",
        "currency": "BRL",
        "details": {
          "subtotal": "75.00",
          "tax": "6.00",
          "shipping": "11.00",
          "handling_fee": "1.00",
          "insurance": "1.00",
          "shipping_discount": "1.00"
        }
      },
      "description": "This is the payment transaction description",
      "item_list": {
        "items": [
          {
            "name": "handbag",
            "sku": "product34",
            "price": "75.00",
            "currency": "BRL",
            "quantity": "1",
            "description": "red diamond",
            "tax": "6.00"
          }
        ],
        "shipping_address": {
          "recipient_name": "Max Santos",
          "line1": "Gregório Rolim de Oliveira, 42",
          "line2": "JD Serrano II",
          "city": "Votorantim",
          "state": "São Paulo",
          "postal_code": "18117-134",
          "country_code": "BR"
        }
      },
      "related_resources": [
        {
          "sale": {
            "id": "2KV752851V792590K",
            "create_time": "2015-01-20T23:41:07Z",
            "update_time": "2015-01-20T23:43:58Z",
            "amount": {
              "total": "95.00",
              "currency": "BRL"
            },
            "payment_mode": "INSTANT_TRANSFER",
            "state": "completed",
            "protection_eligibility": "ELIGIBLE",
            "protection_eligibility_type": "ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE",
            "parent_payment": "PAY-7V4081612V751425TKS7OPEQ",
            "links": [
              {
                "href": "https://api-m.sandbox.paypal.com/v1/payments/sale/2KV752851V792590K",
                "rel": "self",
                "method": "GET"
              },
              {
                "href": "https://api-m.sandbox.paypal.com/v1/payments/sale/2KV752851V792590K/refund",
                "rel": "refund",
                "method": "POST"
              },
              {
                "href": "https://api-m.sandbox.paypal.com/v1/payments/payment/PAY-7V4081612V751425TKS7OPEQ",
                "rel": "parent_payment",
                "method": "GET"
              }
            ]
          }
        }
      ]
    }
  ],
  "links": [
    {
      "href": "https://api-m.sandbox.paypal.com/v1/payments/payment/PAY-7V4081612V751425TKS7OPEQ",
      "rel": "self",
      "method": "GET"
    }
  ]
}

Handling errors

When an error is thrown a response object that contains the error code and resolution is posted to the checkout page and sent to the onError callback. Sometimes the error just requires action by the payer and in those cases a message is displayed within the payment wall instructing the payer how to proceed. Those errors are still sent to the onError callback for logging and debugging purposes.

The table lists most errors and the recommended action. To resolve any errors that are not listed below, get a new ecToken from create payment and ask the payer to use a different card.

CauseAction
CHECK_ENTRY
TRY_ANOTHER_CARD
SET_INSTALLMENTS_FAIL
None.
INVALID_OR_EXPIRED_TOKEN
INTERNAL_ERROR
Get a new ecToken from create payment and start a new PayPal Plus session.
MISSING_EXPERIENCE_PROFILE_IDAll transactions must include an experience profile as described in this document.
INVALID_DATA_FIRST_NAME
INVALID_DATA_LAST_NAME
The country code is missing or invalid. Collect a valid country code, get a new ecToken from create payment and start a new PayPal Plus session.
INVALID_DATA_COUNTRY_CODE
MISSING_DATA_COUNTRY_CODE
The country code is missing or invalid. Collect a valid country code, get a new ecToken from create payment and start a new PayPal Plus session.
INVALID_DATA_ADDRESSThe shipping address provided is invalid. Collect a valid address, get a new ecToken from create payment and start a new PayPal Plus session.
Invalid payerTaxIdThe provided tax id provided in the config is not valid.
Invalid payerFirstNameNo payer first name was provided in the config.
Invalid payerLastNameNo payer last name was provided in the config.
Invalid payerEmailNo payer email was provided in the config.