# Preparing the payment for execution

## Problem

Your customer has approved the payment on Paypal – i.e. through [PayPal checkout](https://developer.paypal.com/docs/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](https://developer.paypal.com/docs/integration/direct/payments/paypal-payments/#execute-payment) for any reference.

### Example

{% tabs %}
{% tab title="Request" %}
The following request updates the PayPal payment source identified by the "qaZPVIyoeg" ID with the payer ID received from the client:

<pre class="language-javascript"><code class="lang-javascript">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": {
<strong>      "paypal_payer_id": "aaabbbccc123"
</strong>    }
  }
}
</code></pre>

{% endtab %}

{% tab title="Response" %}
On success, the API responds with a `200 OK` status code, returning the updated PayPal payment object:

<pre class="language-javascript"><code class="lang-javascript">{
  "data": {
    "id": "qaZPVIyoeg",
    "type": "paypal_payments",
    "links": {
      "self": "https://yourdomain.commercelayer.io/api/paypal_payments/qaZPVIyoeg"
    },
    "attributes": {
      "return_url": "https://checkout.yourdomain.com/jNbQLhMeqo/paypal",
      "cancel_url": "https://checkout.yourdomain.com/jNbQLhMeqo",
      "note_to_payer": null,
<strong>      "paypal_payer_id": "aaabbbccc123",
</strong>      "name": "aaabbbccc123",
      "paypal_id": "PAYID-xxxxyyyyzzzz",
      "status": "created",
      "approval_url": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&#x26;token=EC-123abc456",
      "payment_instrument":{...},
      "created_at": "2018-01-01T12:00:00.000Z",
      "updated_at": "2018-01-01T12:00:00.000Z",
      "reference": null,
      "reference_origin": null,
      "metadata": {}
    },
    "relationships": {
      "order": {
        "links": {
          "self": "https://commerce-layer.commercelayer.co/api/paypal_payments/qaZPVIyoeg/relationships/order",
          "related": "https://commerce-layer.commercelayer.co/api/paypal_payments/qaZPVIyoeg/order"
        }
      }
    },
    "meta": {
      "mode": "test"
    }
  }
}
</code></pre>

{% endtab %}
{% endtabs %}

## More to read

See our documentation if you need more information on how to [update a PayPal payment](https://app.gitbook.com/s/RWJeylueWkzLadK710XZ/paypal_payments/update). See our Checkout guide for more details on how to place an order.

{% content-ref url="../../checkout/placing-the-order" %}
[placing-the-order](https://docs.commercelayer.io/how-tos/placing-orders/checkout/placing-the-order)
{% endcontent-ref %}
