Enabling the auto-capture

How to enable the auto-capture option for a selected payment method

Problem

You want to enable the auto capture option for a payment method, in order to automatically settle the payment upon authorization.

Solution

To enable the auto-capture option you need to send a PATCH request to the /api/payment_method/:id endpoint, setting the auto_capture attribute to true.

Example

The following request updates the payment method identified by the "hJGrTfdaEW " ID to enable the auto-capture:

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

When the auto-capture is enabled, only the authorization is handled by the payment gateway's APIs. If the authorization succeeds, a successful capture is automatically generated by Commerce Layer and the order is marked as paid.

Additional notes

Gateways support

Payment instruments support

Order cancellation

More to read

Last updated