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
  • Online API
    • API Environments
    • Direct Payment Flow
    • REST
    • HTTPS
    • Request Headers
    • Dates
    • Pagination
    • Authentication
    • Idempotent Requests
    • Timeouts
    • API Simulator
    • JavaScript afterpay.js
      • POSTCapture Payment
      • PUTUpdate Shipping Courier
      • GETGet Payment By Order ID
      • GETGet Payment By Token
      • GETList Payments
      • POSTCreate Refund
    • Errors
LogoLogo
Online APIPayments

Capture Payment

POST
https://global-api-sandbox.afterpay.com/v1/payments/capture
POST
/v1/payments/capture
$curl -X POST https://global-api-sandbox.afterpay.com/v1/payments/capture \
> -H "User-Agent: User-Agent" \
> -H "Content-Type: application/json" \
> -u "<username>:<password>" \
> -d '{
> "token": "string"
>}'
This endpoint performs a direct payment capture and is the equivalent of capturing a credit card. This operation is [idempotent](/v-1/idempotent-requests) based on the token, which allows for the safe retry of requests, guaranteeing the payment operation is only performed once. <Note title="Note"> Since the idempotency of this endpoint is based on the `token`, the inclusion of a `requestId` is not required. </Note> ## Successful Response (201) If payment is approved by Clearpay, returns a [Payment object](/v-1/payment-object) in response. <Note title="Note"> The [Payment object](/v-1/payment-object) is only returned if the payment is approved by Clearpay and successfully captured. If the payment is declined or fails, an error object is returned. See the Errors section below. </Note> ## Connection Timeouts | Timeout | Time (Seconds) | | :------ | :------------- | | Open | 10 | | Read | 70 | ## Errors In addition to the [PUT/POST Errors](/v-1/put-post-errors) applicable to all POST endpoints, the following errors are specific to Capture Payment: | HTTP Status Code | errorCode | Description | | :-- | :-- | :-- | | **402** <br />Payment Required | `declined` | The consumer's payment has been declined. For example, invalid card details were entered during the Clearpay screenflow. Please advise the consumer to contact the Clearpay Customer Service team for more information. | | **412** <br />Precondition Failed | `invalid_token` | The order 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. |
Was this page helpful?
Previous

Update Shipping Courier

Next
Built with

This endpoint performs a direct payment capture and is the equivalent of capturing a credit card.

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

Note

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

Successful Response (201)

If payment is approved by Clearpay, returns a Payment object in response.

Note

The Payment object is only returned if the payment is approved by Clearpay and successfully captured. If the payment is declined or fails, an error object is returned. See the Errors section below.

Connection Timeouts

TimeoutTime (Seconds)
Open10
Read70

Errors

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

HTTP Status CodeerrorCodeDescription
402
Payment Required
declinedThe consumer’s payment has been declined. For example, invalid card details were entered during the Clearpay screenflow. Please advise the consumer to contact the Clearpay Customer Service team for more information.
412
Precondition Failed
invalid_tokenThe order 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.

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 Order request.

merchantReferencestringOptional

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