Test Your Integration and Execute the Payment

Last updated: Aug 15th, 7:35am

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

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

    Response

      1{
      2 "id": "PAY-7V4081612V751425TKS7OPEQ",
      3 "create_time": "2015-01-20T23:41:06Z",
      4 "update_time": "2015-01-20T23:43:58Z",
      5 "state": "approved",
      6 "intent": "sale",
      7 "payer": {
      8 "payment_method": "paypal",
      9 "payer_info": {
      10 "email": "test123456781111@paypal.com",
      11 "first_name": "Max",
      12 "last_name": "Santos",
      13 "payer_id": "SUYCECXSW5XMA",
      14 "shipping_address": {
      15 "line1": "Gregório Rolim de Oliveira, 42",
      16 "line2": "JD Serrano II",
      17 "city": "Votorantim",
      18 "state": "São Paulo",
      19 "postal_code": "18117-134",
      20 "country_code": "BR",
      21 "recipient_name": "Max Santos"
      22 }
      23 }
      24 },
      25 "transactions": [
      26 {
      27 "amount": {
      28 "total": "95.00",
      29 "currency": "BRL",
      30 "details": {
      31 "subtotal": "75.00",
      32 "tax": "6.00",
      33 "shipping": "11.00",
      34 "handling_fee": "1.00",
      35 "insurance": "1.00",
      36 "shipping_discount": "1.00"
      37 }
      38 },
      39 "description": "This is the payment transaction description",
      40 "item_list": {
      41 "items": [
      42 {
      43 "name": "handbag",
      44 "sku": "product34",
      45 "price": "75.00",
      46 "currency": "BRL",
      47 "quantity": "1",
      48 "description": "red diamond",
      49 "tax": "6.00"
      50 }
      51 ],
      52 "shipping_address": {
      53 "recipient_name": "Max Santos",
      54 "line1": "Gregório Rolim de Oliveira, 42",
      55 "line2": "JD Serrano II",
      56 "city": "Votorantim",
      57 "state": "São Paulo",
      58 "postal_code": "18117-134",
      59 "country_code": "BR"
      60 }
      61 },
      62 "related_resources": [
      63 {
      64 "sale": {
      65 "id": "2KV752851V792590K",
      66 "create_time": "2015-01-20T23:41:07Z",
      67 "update_time": "2015-01-20T23:43:58Z",
      68 "amount": {
      69 "total": "95.00",
      70 "currency": "BRL"
      71 },
      72 "payment_mode": "INSTANT_TRANSFER",
      73 "state": "completed",
      74 "protection_eligibility": "ELIGIBLE",
      75 "protection_eligibility_type": "ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE",
      76 "parent_payment": "PAY-7V4081612V751425TKS7OPEQ",
      77 "links": [
      78 {
      79 "href": "https://api-m.sandbox.paypal.com/v1/payments/sale/2KV752851V792590K",
      80 "rel": "self",
      81 "method": "GET"
      82 },
      83 {
      84 "href": "https://api-m.sandbox.paypal.com/v1/payments/sale/2KV752851V792590K/refund",
      85 "rel": "refund",
      86 "method": "POST"
      87 },
      88 {
      89 "href": "https://api-m.sandbox.paypal.com/v1/payments/payment/PAY-7V4081612V751425TKS7OPEQ",
      90 "rel": "parent_payment",
      91 "method": "GET"
      92 }
      93 ]
      94 }
      95 }
      96 ]
      97 }
      98 ],
      99 "links": [
      100 {
      101 "href": "https://api-m.sandbox.paypal.com/v1/payments/payment/PAY-7V4081612V751425TKS7OPEQ",
      102 "rel": "self",
      103 "method": "GET"
      104 }
      105 ]
      106}

      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.

      Cause Action
      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_ID All 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_ADDRESS The shipping address provided is invalid. Collect a valid address, get a new ecToken from create payment and start a new PayPal Plus session.
      Invalid payerTaxId The provided tax id provided in the config is not valid.
      Invalid payerFirstName No payer first name was provided in the config.
      Invalid payerLastName No payer last name was provided in the config.
      Invalid payerEmail No payer email was provided in the config.

      If you accept cookies, we’ll use them to improve and customize your experience and enable our partners to show you personalized PayPal ads when you visit other sites. Manage cookies and learn more