Preparing the payment for execution

How to make a payment ready to be executed on Paypal

Problem

Your customer has approved the payment on Paypal – i.e. through PayPal checkout — and has been redirected to your client. You need to make sure it's ready to be executed.

Solution

To enable the payment execution with PayPal, you need to update the PayPal payment object. To do that, send a PATCH request to the /api/paypal_payments/:id endpoint, filling the payment_payer_id with the payer ID you just received from the client – see PayPal documentation for any reference.

Example

The following request updates the PayPal payment source identified by the "qaZPVIyoeg" ID with the payer ID received from the client:

curl -g -X PATCH \
  'http://yourdomain.commercelayer.io/api/paypal_payments/qaZPVIyoeg' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
  "data": {
    "type": "paypal_payments",
    "id": "qaZPVIyoeg",
    "attributes": {
      "paypal_payer_id": "aaabbbccc123"
    }
  }
}

More to read

Placing the order

Last updated