For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
HomeGuidesAPI Reference
HomeGuidesAPI Reference
  • Foundations
    • Introduction
    • Request Headers
    • User-Agent Header
    • Authentication
    • Errors
    • Data Requirements
  • Online API
    • Immediate Payment Flow
      • POSTCapture Full Payment
      • Express Checkout Payload (Capture Full Payment)
    • Deferred Payment Flow
  • Upgrading to the Clearpay Express Checkout
    • Express Checkout Overview
    • How to Integrate
    • Security
LogoLogo
Online APIImmediate Payment Flow

Capture Full Payment

POST
https://global-api-sandbox.afterpay.com/v2/payments/capture
POST
/v2/payments/capture
$curl -X POST https://global-api-sandbox.afterpay.com/v2/payments/capture \
> -H "User-Agent: User-Agent" \
> -H "Content-Type: application/json" \
> -u "<username>:<password>" \
> -d '{
> "token": "string"
>}'
1{
2 "id": "12345678",
3 "token": "ltqdpjhbqu3veqikk95g7p3fhvcchfvtlsiobah3u4l5nln8gii9",
4 "status": "APPROVED",
5 "created": "2019-01-01T00:00:00.000Z",
6 "originalAmount": {
7 "amount": "100.00",
8 "currency": "GBP"
9 },
10 "openToCaptureAmount": {
11 "amount": "0.00",
12 "currency": "GBP"
13 },
14 "paymentState": "CAPTURED",
15 "merchantReference": "merchantOrderId-1234",
16 "refunds": [],
17 "orderDetails": {
18 "consumer": {
19 "givenNames": "Joe",
20 "surname": "Consumer",
21 "email": "test@example.com"
22 }
23 },
24 "events": [
25 {
26 "id": "1OUR16OTqL3DgJ3ELlwKowU9v6K",
27 "created": "2019-01-01T00:00:00.000Z",
28 "expires": null,
29 "type": "CAPTURED",
30 "amount": {
31 "amount": "100.00",
32 "currency": "GBP"
33 }
34 }
35 ]
36}
This endpoint performs a payment capture for the full value of the payment plan. <Note title="Note"> This operation is [idempotent](/idempotent-requests) based on the token, which allows for the safe retry of requests, guaranteeing the payment operation is only performed once. Since the idempotency of this endpoint is based on the `token`, the inclusion of a `requestId` is not required. </Note> ## Approved Response (201) If payment is approved by Clearpay, returns a [Payment object](/payment-object) in response, with a `status` of "APPROVED". ## Declined Response (201) If payment is declined by Clearpay, for example, if invalid card details were entered, returns a [Payment object](/payment-object) in response, with a `status` of "DECLINED". Please advise the consumer to contact the Clearpay Customer Service team for more information. ## Connection Timeouts - Open timeout: 10 seconds - Read timeout: 70 seconds ## Errors In addition to the [PUT/POST Errors](/put-post-errors) applicable to all POST endpoints, the following errors are specific to Capture Full Payment: | HTTP Status Code | errorCode | Description | | :-- | :-- | :-- | | **402** <br />Payment Required | `invalid_token` | The checkout token is invalid, expired, or does not exist. | | **412** <br />Precondition Failed | `invalid_order_transaction_status` | The Consumer has not confirmed their payment for the order associated with this token. | | **422** <br />Unprocessable Entity | `invalid_object` | The checkout token was missing or empty. |
Was this page helpful?
Previous

Express Checkout Payload (Capture Full Payment)

Next
Built with

This endpoint performs a payment capture for the full value of the payment plan.

Note

This operation is idempotent based on the token, which allows for the safe retry of requests, guaranteeing the payment operation is only performed once.

Since the idempotency of this endpoint is based on the token, the inclusion of a requestId is not required.

Approved Response (201)

If payment is approved by Clearpay, returns a Payment object in response, with a status of “APPROVED”.

Declined Response (201)

If payment is declined by Clearpay, for example, if invalid card details were entered, returns a Payment object in response, with a status of “DECLINED”.

Please advise the consumer to contact the Clearpay Customer Service team for more information.

Connection Timeouts

  • Open timeout: 10 seconds
  • Read timeout: 70 seconds

Errors

In addition to the PUT/POST Errors applicable to all POST endpoints, the following errors are specific to Capture Full Payment:

HTTP Status CodeerrorCodeDescription
402
Payment Required
invalid_tokenThe checkout token is invalid, expired, or does not exist.
412
Precondition Failed
invalid_order_transaction_statusThe Consumer has not confirmed their payment for the order associated with this token.
422
Unprocessable Entity
invalid_objectThe checkout token was missing or empty.

Authentication

AuthorizationBasic

Basic authentication of the form Basic <base64(username:password)>.

Headers

User-AgentstringRequired
AcceptstringOptionalDefaults to application/json

Request

This endpoint expects an object.
tokenstringRequired

The token returned in the Create Checkout request.

merchantReferencestringOptional

The merchant’s order id/reference that this payment corresponds to. This will update any value previously provided in the Create Checkout request.

Response

Payment Approved or Declined - Returns a Payment object

idstring

The unique, permanent, Clearpay-generated Order ID.

tokenstring
Checkout token that was used to complete payment.
statusenum
An order status of "APPROVED" or "DECLINED".
Allowed values:
createdstringformat: "date-time"
The UTC timestamp of when the payment was completed, in ISO 8601 format.
originalAmountobject
openToCaptureAmountobject
paymentStateenum
Current state for capturing payments.
merchantReferencestring

The merchant’s order id/reference that this payment corresponds to.

refundslist of objects

An array of refunds. Note: in response to a Capture Full Payment call, this array will always be empty, since refunds cannot occur until payment is captured.

orderDetailsobject
eventslist of objects
One or more payment events that have occurred against the order.

Errors

400
Bad Request Error
401
Unauthorized Error
402
Payment Required Error
405
Method Not Allowed Error
406
Not Acceptable Error
412
Precondition Failed Error
415
Unsupported Media Type Error
422
Unprocessable Entity Error
500
Internal Server Error