> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.afterpay.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.afterpay.com/_mcp/server.

# Capture Payment

POST https://global-api-sandbox.afterpay.com/v2/payments/{orderId}/capture
Content-Type: application/json

This endpoint captures a full or partial payment that has been authorized. Any amounts successfully captured will be settled from Afterpay to the merchant's nominated bank account on the following day. Records of all payments captured against an order are returned in the events list as events of type, "CAPTURED".

**Note:** Authorization expires after 13 days and then the transaction is automatically voided. Voided transactions are frozen and cannot be captured, reopened or changed in any way. In this case your only option is to use the v2/checkouts endpoint to create a new order.

This operation is idempotent based on the `requestId` (if provided), which allows the safe retry of multiple requests. This safe retry guarantees the payment operation only occurs once.

**Connection Timeouts**
| Timeout | Time (Seconds) |
|---------|----------------|
| Open    | 10             |
| Read    | 70             |


Reference: https://developers.afterpay.com/afterpay-online-developer/api-reference/reference/payments/capture-payment

## Authentication

- `Authorization` header (basic auth, required) — Basic authentication of the form `Basic <base64(username:password)>`.

## Servers

- `https://global-api-sandbox.afterpay.com` (Sandbox, default)
- `https://global-api.afterpay.com` (Production)

## Request

### Path parameters

- `orderId` (string, required) — The unique ID of the Afterpay Order, returned as the `id` property of the Auth response.

### Headers

- `Accept` (string, optional, default: application/json)

### Body (application/json)

This endpoint expects an object.

- `requestId` (string, optional) — A unique request ID, required for idempotent retries.
- `merchantReference` (string, optional) — The reference/ order id that this payment corresponds to in the merchant's system. Note: Providing a new value will update any value previously set in the Create Checkout request.
- `amount` (object, optional) — Object containing amount and currency. Where a Money object is included in an API request, it will be validated according to the specification above. Invalid Money objects will trigger a **422 Unprocessable Entity response**. The following is a list of common examples: | Example | errorCode | message | | ------------------------------------------------------------------------------- | ---------------------- | ------------------------------------------------------------------------- | | `amount` is omitted or null | invalid\_object | \{Money object}.amount Amount field required | | `amount` has more than 2 decimal places | invalid\_object amount | must be a valid ISO 4217 format value | | `amount` includes a thousands separator comma, for example: "1,000" | invalid\_amount | Amount must be a valid ISO 4217 format value | | `amount` is not a decimal number, for example: "FREE", "\$2" or an empty string | invalid\_object | \{Money object}.amount Amount field must be a valid ISO 4217 format value | | `currency` is omitted or null | invalid\_object | \{Money object}.currency Currency field required | | `currency` is not a valid currency code, not all uppercase or an empty string | invalid\_object | \{Money object}.currency Currency not supported for this merchant | | `currency` is supported by Afterpay, but not valid for the Merchant account | unsupported\_currency | An error occurred |
  - `amount` (string, required) — The amount as a string representation of a decimal number, rounded to 2 decimal places.
  - `currency` (enum, required) — The currency in ISO 4217 format. The value provided must correspond to the currency of the merchant account making the request.
    - Allowed values: `AUD`, `NZD`, `USD`, `CAD`, `GBP`
- `paymentEventMerchantReference` (string, optional) — A unique reference for the individual payment capture event. If provided, the value will appear in the daily settlement file as "Payment Event ID"

## Response

### 201

If successful, returns an updated copy of the Payment object, with the newly captured payment appended to the `events` array as a Payment Event object with a `type` of "CAPTURED".

- `id` (string, optional) — The unique, permanent, Afterpay generated Order ID.
- `token` (string, optional) — The token obtained from the checkout call
- `status` (enum, optional) — represents the status of the order
  - Allowed values: `APPROVED`, `DECLINED`
- `created` (string, optional) — The UTC timestamp of when the payment was completed.
- `originalAmount` (object, optional) — Total amount charged to the customer for the order.
  - `amount` (string, required) — The amount as a string representation of a decimal number, rounded to 2 decimal places.
  - `currency` (enum, required) — The currency in ISO 4217 format. The value provided must correspond to the currency of the merchant account making the request.
    - Allowed values: `AUD`, `NZD`, `USD`, `CAD`, `GBP`
- `openToCaptureAmount` (object, optional) — Remaining amount that can be captured. Will always be zero for Immediate Payment Flow orders.
  - `amount` (string, required) — The amount as a string representation of a decimal number, rounded to 2 decimal places.
  - `currency` (enum, required) — The currency in ISO 4217 format. The value provided must correspond to the currency of the merchant account making the request.
    - Allowed values: `AUD`, `NZD`, `USD`, `CAD`, `GBP`
- `paymentState` (enum, optional) — is the current state for capturing payments
  - Allowed values: `AUTH_APPROVED`, `AUTH_DECLINED`, `PARTIALLY_CAPTURED`, `CAPTURED`, `CAPTURE_DECLINED`, `VOIDED`
- `merchantReference` (string, optional) — is the merchant's order id/reference that the payment corresponds to.
- `refunds` (list of object, optional) — 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.
  - `amount` (object, optional) — Object containing amount and currency. Where a Money object is included in an API request, it will be validated according to the specification above. Invalid Money objects will trigger a **422 Unprocessable Entity response**. The following is a list of common examples: | Example | errorCode | message | | ------------------------------------------------------------------------------- | ---------------------- | ------------------------------------------------------------------------- | | `amount` is omitted or null | invalid\_object | \{Money object}.amount Amount field required | | `amount` has more than 2 decimal places | invalid\_object amount | must be a valid ISO 4217 format value | | `amount` includes a thousands separator comma, for example: "1,000" | invalid\_amount | Amount must be a valid ISO 4217 format value | | `amount` is not a decimal number, for example: "FREE", "\$2" or an empty string | invalid\_object | \{Money object}.amount Amount field must be a valid ISO 4217 format value | | `currency` is omitted or null | invalid\_object | \{Money object}.currency Currency field required | | `currency` is not a valid currency code, not all uppercase or an empty string | invalid\_object | \{Money object}.currency Currency not supported for this merchant | | `currency` is supported by Afterpay, but not valid for the Merchant account | unsupported\_currency | An error occurred |
    - `amount` (string, required) — The amount as a string representation of a decimal number, rounded to 2 decimal places.
    - `currency` (enum, required) — The currency in ISO 4217 format. The value provided must correspond to the currency of the merchant account making the request.
      - Allowed values: `AUD`, `NZD`, `USD`, `CAD`, `GBP`
  - `merchantReference` (string, optional) — The merchant’s internal refund id/reference. This must be included along with the `requestId` to utilise idempotency. Max length 85 (varchar).
  - `refundId` (string, optional) — The unique, permanent, Afterpay-generated Refund ID.
  - `refundMerchantReference` (string, optional) — A unique reference for the individual refund event. Max length 128 (varchar).
  - `refundedAt` (string, optional)
  - `requestId` (string, optional) — Unique ID required for safe retries. Max length 64 (varchar).
- `orderDetails` (object, optional) — The details of the order bound to the payment.
  - `consumer` (object, optional) — The customer who placed or is placing the order.
    - `email` (string, required)
    - `givenNames` (string, optional) — The consumer's first name
    - `surname` (string, optional) — The consumer's last name
    - `phoneNumber` (string, optional)
  - `billing` (object, optional) — The customer's billing address.
    - `name` (string, required)
    - `line1` (string, required) — First line of the address
    - `area1` (string, required) — - AU: Suburb - NZ: Town or City - UK: Postal Town - US: City - Canada: City
    - `region` (string, required) — - AU: State - NZ: Region - UK: County - US: State - CA: Province or Territory
    - `postcode` (string, required)
    - `countryCode` (enum, required)
      - Allowed values: `AU`, `NZ`, `US`, `CA`, `GB`
    - `line2` (string, optional) — Second line of the address
    - `area2` (string, optional) — - NZ: suburb - UK: village or local area.
    - `phoneNumber` (string, optional) — The phone number, in [E.123](https://en.wikipedia.org/wiki/E.123) format.
  - `courier` (object, optional) — The customer's chosen shipping courier.
    - `shippedAt` (string, optional) — The date and time when the order was shipped, in ISO 8601 format.
    - `name` (string, optional) — The name of the courier.
    - `tracking` (string, optional) — The tracking number provided by the courier.
    - `priority` (enum, optional) — The shipping priority.
      - Allowed values: `STANDARD`, `EXPRESS`
  - `items` (list of object, optional) — An array of order items.
    - `name` (string, required) — Product name
    - `quantity` (integer, required)
    - `price` (object, required) — Object containing amount and currency. Where a Money object is included in an API request, it will be validated according to the specification above. Invalid Money objects will trigger a **422 Unprocessable Entity response**. The following is a list of common examples: | Example | errorCode | message | | ------------------------------------------------------------------------------- | ---------------------- | ------------------------------------------------------------------------- | | `amount` is omitted or null | invalid\_object | \{Money object}.amount Amount field required | | `amount` has more than 2 decimal places | invalid\_object amount | must be a valid ISO 4217 format value | | `amount` includes a thousands separator comma, for example: "1,000" | invalid\_amount | Amount must be a valid ISO 4217 format value | | `amount` is not a decimal number, for example: "FREE", "\$2" or an empty string | invalid\_object | \{Money object}.amount Amount field must be a valid ISO 4217 format value | | `currency` is omitted or null | invalid\_object | \{Money object}.currency Currency field required | | `currency` is not a valid currency code, not all uppercase or an empty string | invalid\_object | \{Money object}.currency Currency not supported for this merchant | | `currency` is supported by Afterpay, but not valid for the Merchant account | unsupported\_currency | An error occurred |
      - `amount` (string, required) — The amount as a string representation of a decimal number, rounded to 2 decimal places.
      - `currency` (enum, required) — The currency in ISO 4217 format. The value provided must correspond to the currency of the merchant account making the request.
        - Allowed values: `AUD`, `NZD`, `USD`, `CAD`, `GBP`
    - `sku` (string, optional) — Product SKU. Limited to 128 characters.
    - `pageUrl` (string, optional)
    - `imageUrl` (string, optional) — A URL for a web-optimized photo of the item, suitable for use directly as the src attribute of an img tag.
    - `categories` (list of list of string, optional) — An array of arrays to accommodate multiple categories that apply to the item. Each array represents a hierarchical path to a category, with the left-most category being the top-level parent category.
    - `estimatedShipmentDate` (string, optional) — The estimated date when the order will be shipped, in YYYY-MM or YYYY-MM-DD format.
    - `preorder` (boolean, optional, default: false) — If this item is not expected to be fulfilled immediately, and therefore should be marked as a preorder at checkout, set to `true`. Set to `false` otherwise.
  - `discounts` (list of object, optional) — An array of discounts.
    - `displayName` (string, optional) — A display name for the discount. Limited to 128 characters.
    - `amount` (object, optional) — The discount amount.
      - `amount` (string, required) — The amount as a string representation of a decimal number, rounded to 2 decimal places.
      - `currency` (enum, required) — The currency in ISO 4217 format. The value provided must correspond to the currency of the merchant account making the request.
        - Allowed values: `AUD`, `NZD`, `USD`, `CAD`, `GBP`
  - `taxAmount` (object, optional) — The included tax amount, after applying all discounts.
    - `amount` (string, required) — The amount as a string representation of a decimal number, rounded to 2 decimal places.
    - `currency` (enum, required) — The currency in ISO 4217 format. The value provided must correspond to the currency of the merchant account making the request.
      - Allowed values: `AUD`, `NZD`, `USD`, `CAD`, `GBP`
  - `shippingAmount` (object, optional) — The shipping price charged to the customer.
    - `amount` (string, required) — The amount as a string representation of a decimal number, rounded to 2 decimal places.
    - `currency` (enum, required) — The currency in ISO 4217 format. The value provided must correspond to the currency of the merchant account making the request.
      - Allowed values: `AUD`, `NZD`, `USD`, `CAD`, `GBP`
- `events` (list of object, optional) — One or more payment events that have occurred against the order.
  - `id` (string, optional)
  - `created` (string, optional)
  - `expires` (string, optional)
  - `type` (enum, optional)
    - Allowed values: `AUTH_APPROVED`, `AUTH_DECLINED`, `CAPTURED`, `CAPTURE_DECLINED`, `VOIDED`, `EXPIRED`
  - `amount` (object, optional) — Object containing amount and currency. Where a Money object is included in an API request, it will be validated according to the specification above. Invalid Money objects will trigger a **422 Unprocessable Entity response**. The following is a list of common examples: | Example | errorCode | message | | ------------------------------------------------------------------------------- | ---------------------- | ------------------------------------------------------------------------- | | `amount` is omitted or null | invalid\_object | \{Money object}.amount Amount field required | | `amount` has more than 2 decimal places | invalid\_object amount | must be a valid ISO 4217 format value | | `amount` includes a thousands separator comma, for example: "1,000" | invalid\_amount | Amount must be a valid ISO 4217 format value | | `amount` is not a decimal number, for example: "FREE", "\$2" or an empty string | invalid\_object | \{Money object}.amount Amount field must be a valid ISO 4217 format value | | `currency` is omitted or null | invalid\_object | \{Money object}.currency Currency field required | | `currency` is not a valid currency code, not all uppercase or an empty string | invalid\_object | \{Money object}.currency Currency not supported for this merchant | | `currency` is supported by Afterpay, but not valid for the Merchant account | unsupported\_currency | An error occurred |
    - `amount` (string, required) — The amount as a string representation of a decimal number, rounded to 2 decimal places.
    - `currency` (enum, required) — The currency in ISO 4217 format. The value provided must correspond to the currency of the merchant account making the request.
      - Allowed values: `AUD`, `NZD`, `USD`, `CAD`, `GBP`
  - `paymentEventMerchantReference` (string, optional)
- `agreements` (list of object, optional) — List of billing agreements created if any (field omitted if empty)
  - `token` (string, required) — Unique token identifying the agreement
  - `type` (enum, required) — Type of agreement
    - Allowed values: `BILLING`
  - `status` (enum, required) — Current status of the agreement
    - Allowed values: `ACTIVE`, `CANCELLED`, `EXPIRED`, `PENDING_RENEWAL`, `PENDING_RENEWAL_EXPIRED`
  - `created` (string, required) — Timestamp when the agreement was created
  - `merchantReference` (string, optional, nullable) — Merchant's reference for this agreement
  - `cancelled` (string, optional) — If present, indicates when the agreement was cancelled
  - `expires` (string, optional) — If present, indicates when the agreement's status will become EXPIRED, preventing a client from using it to create payments
  - `events` (list of object, optional) — List of events associated with this agreement
    - `type` (enum, optional) — Type of event
      - Allowed values: `CAPTURE`, `VOID`
    - `created` (string, optional) — Timestamp when the event occurred
    - `amount` (object, optional) — Amount associated with the event
      - `amount` (string, required) — The amount as a string representation of a decimal number, rounded to 2 decimal places.
      - `currency` (enum, required) — The currency in ISO 4217 format. The value provided must correspond to the currency of the merchant account making the request.
        - Allowed values: `AUD`, `NZD`, `USD`, `CAD`, `GBP`
    - `status` (enum, optional) — Status of the agreement at the time of the event
      - Allowed values: `APPROVED`, `DECLINED`
    - `merchantReference` (string, optional, nullable) — Merchant's reference associated with this event
    - `orderId` (double, optional) — Order ID associated with this event
  - `requestId` (string, optional, nullable) — Unique identifier for the request
  - `consumerReference` (string, optional, nullable) — Reference identifier for the consumer
  - `email` (string, optional, nullable) — Masked email address of the consumer

## Errors

### 404 Not Found Error

No numeric `orderId` was provided, or an invalid string was provided. Error code `not_found`.

- `any`

### 410 Gone Error

Payment has already been fully captured for this order, or partially captured with the remainder voided. Error code `payment_captured`.

- `any`

### 412 Precondition Failed Error

| errorCode | Description | | --- | --- | | error | A numeric `orderId` was provided, but did not match any valid order. | | invalid_state | The order was declined by Afterpay; no payment can be captured for this order. | | payment_voided | The auth for this order has already been completely voided. | | payment_expired | The auth for this order has expired; no further payment can be captured. |

- `any`

### 422 Unprocessable Entity Error

| errorCode | Description | | --- | --- | | invalid_object | The `amount` was missing or invalid, or the `paymentEventMerchantReference` exceeded 128 characters. | | invalid_amount | The `amount` was less than the minimum capture amount, or more than the `openToCaptureAmount`. |

- `any`

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "id": "300000016189",
  "token": "002.6bjbsaowxvfqam2nw4u3xudppheuh4gsuat3n2w3f6t44euzgy",
  "status": "APPROVED",
  "created": "2024-03-11T20:11:42.487Z",
  "originalAmount": {
    "amount": "37.00",
    "currency": "USD"
  },
  "openToCaptureAmount": {
    "amount": "0.00",
    "currency": "USD"
  },
  "paymentState": "CAPTURED",
  "merchantReference": "updated-k6-reference-utaddnpx",
  "refunds": [],
  "orderDetails": {
    "consumer": {
      "email": "test@example.com"
    },
    "billing": {
      "name": "Joe Customer",
      "line1": "1004 New Avenue",
      "area1": "Melbourne",
      "region": "VIC",
      "postcode": "94121",
      "countryCode": "AU",
      "phoneNumber": "2120000000",
      "countrycode": "US"
    },
    "courier": {
      "shippedAt": "2024-01-01T08:00:00Z",
      "name": "FedEx",
      "tracking": "000 000 000 000",
      "priority": "STANDARD"
    },
    "items": [
      {
        "name": "Blue Carabiner",
        "quantity": 1,
        "price": {
          "amount": "40.00",
          "currency": "USD"
        },
        "sku": "12341234"
      }
    ],
    "shipping": {
      "name": "Joe Customer",
      "line1": "1004 New Avenue",
      "postcode": "94121",
      "countrycode": "US",
      "phoneNumber": "2120000000"
    },
    "categories": {
      "name": "Jeans",
      "sku": "123412345",
      "quantity": 1,
      "price": {
        "amount": "20.00",
        "currency": "USD"
      },
      "categories": null
    }
  },
  "events": [
    {
      "id": "2dYbLXpOtEPQbg1DT7x9D8R4oCY",
      "created": "2024-03-11T20:11:43.897Z",
      "type": "CAPTURED",
      "amount": {
        "amount": "37.00",
        "currency": "USD"
      },
      "paymentEventMerchantReference": "k6-gsrdqspusf"
    }
  ],
  "discounts": [],
  "shippingAmount": {
    "amount": "10.00",
    "currency": "USD"
  },
  "taxAmount": {
    "amount": "0.00",
    "currency": "USD"
  }
}
```

**SDK Code**

```python
import requests

url = "https://global-api-sandbox.afterpay.com/v2/payments/orderId/capture"

payload = {}
headers = {
    "User-Agent": "User-Agent"
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers, auth=("<username>", "<password>"))

print(response.json())
```

```javascript
const url = 'https://global-api-sandbox.afterpay.com/v2/payments/orderId/capture';
const credentials = btoa("<username>:<password>");

const options = {
  method: 'POST',
  headers: {
    'User-Agent': 'User-Agent',
    Authorization: `Basic ${credentials}`,
    'Content-Type': 'application/json'
  },
  body: '{}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://global-api-sandbox.afterpay.com/v2/payments/orderId/capture"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("User-Agent", "User-Agent")
	req.SetBasicAuth("<username>", "<password>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://global-api-sandbox.afterpay.com/v2/payments/orderId/capture")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["User-Agent"] = 'User-Agent'
request.basic_auth("<username>", "<password>")
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://global-api-sandbox.afterpay.com/v2/payments/orderId/capture")
  .header("User-Agent", "User-Agent")
  .basicAuth("<username>", "<password>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://global-api-sandbox.afterpay.com/v2/payments/orderId/capture', [
  'body' => '{}',
  'headers' => [
    'Content-Type' => 'application/json',
    'User-Agent' => 'User-Agent',
  ],
    'auth' => ['<username>', '<password>'],
]);

echo $response->getBody();
```

```csharp
using RestSharp;
using RestSharp.Authenticators;

var client = new RestClient("https://global-api-sandbox.afterpay.com/v2/payments/orderId/capture");
client.Authenticator = new HttpBasicAuthenticator("<username>", "<password>");
var request = new RestRequest(Method.POST);
request.AddHeader("User-Agent", "User-Agent");

request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let credentials = Data("<username>:<password>".utf8).base64EncodedString()

let headers = [
  "User-Agent": "User-Agent",
  "Authorization": "Basic \(credentials)",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://global-api-sandbox.afterpay.com/v2/payments/orderId/capture")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```