> This page is for Afterpay Online Developer, version Main (default).
> For other versions, use one of these documentation indexes:
> - Main (default): https://developers.afterpay.com/afterpay-online-developer/main/llms.txt
> - v1: https://developers.afterpay.com/afterpay-online-developer/v-1/llms.txt
> - Chinese: https://developers.afterpay.com/afterpay-online-developer/chinese/llms.txt

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

# Get Payment By Order ID

GET https://global-api-sandbox.afterpay.com/v2/payments/{orderId}

This endpoint retrieves an individual payment along with its order details.

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


Reference: https://developers.afterpay.com/afterpay-online-developer/api-reference/reference/payments/get-payment-by-order-id

## 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, for which a Payment event has been completed.

### Headers

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

## Response

### 200

Returns a Payment object in response.

- `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` (Money, optional) — Total amount charged to the customer for the order.
- `openToCaptureAmount` (Money, optional) — Remaining amount that can be captured. Will always be zero for Immediate Payment Flow orders.
- `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 Refund, 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.
- `orderDetails` (Order-Details, optional) — The details of the order bound to the payment.
- `events` (list of Payment-Event, optional) — One or more payment events that have occurred against the order.
- `agreements` (list of BillingAgreementResponse, optional) — List of billing agreements created if any (field omitted if empty)

## Errors

### 404 Not Found Error

No Afterpay Order was found matching the `orderId` provided. Error code `not_found`.

- `any`

## Types

### Money

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`

### Refund

To guarantee safe retries, the merchant should offer their refund ID or reference, aligning with their internal records Unique values for the `requestID` and `merchantReference` are required to guarantee safe retries. It is recommended that the merchant generates a UUID for each unique refund request. The `refundMerchantReference` is a unique reference that when provided, will appear in the daily settlement file as "Payment Event Id". In most cases, this would hold the same value as the `merchantReference`.

- `amount` (Money, 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 |
- `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).

### Order-Details

This comprehensive schema is designed to store an entire transaction's detail, covering crucial aspects like consumer information, billing and shipping details, courier particulars, item list, discounts, tax, and shipping amount.

- `consumer` (Consumer, optional) — The customer who placed or is placing the order.
- `billing` (Contact, optional) — The customer's billing address.
- `courier` (Shipping-Courier, optional) — The customer's chosen shipping courier.
- `items` (list of Item, optional) — An array of order items.
- `discounts` (list of Discount, optional) — An array of discounts.
- `taxAmount` (Money, optional) — The included tax amount, after applying all discounts.
- `shippingAmount` (Money, optional) — The shipping price charged to the customer.

### Payment-Event

Each payment event has a unique ID, creation timestamp, and type (e.g., "AUTH_APPROVED", "AUTH_DECLINED"). For "AUTH_APPROVED" events, an expiration timestamp is provided. The "payment event merchant reference" field, which can be used for payment capture events.

- `id` (string, optional)
- `created` (string, optional)
- `expires` (string, optional)
- `type` (enum, optional)
  - Allowed values: `AUTH_APPROVED`, `AUTH_DECLINED`, `CAPTURED`, `CAPTURE_DECLINED`, `VOIDED`, `EXPIRED`
- `amount` (Money, 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 |
- `paymentEventMerchantReference` (string, optional)

### BillingAgreementResponse

Response type for billing agreements

- `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 AgreementEventResponse, optional) — List of events associated with this agreement
- `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

### Consumer

The consumer data model is used for gathering essential user information. It captures details such as the individual's first name, represented by `givenNames`, and their last name, captured under `surname`. In addition, it stores the user's contact number under `phoneNumber` and their email address under `email`. These fields collectively provide indispensable contact and identification details for a user.

- `email` (string, required)
- `givenNames` (string, optional) — The consumer's first name
- `surname` (string, optional) — The consumer's last name
- `phoneNumber` (string, optional)

### Contact

This data model is used for storing an individual's contact information. Mandatory fields such as **name**, **line1**, **area1**, **region**, **postcode**, and **countryCode** help in capturing vital information about a user's location. The `line2` and `area2` fields provide additional space for extended addresses, while `phoneNumber` can be used to store the user's contact number. The `area1`, `area2` and `region` properties feature localized terminology based on country. Refer to the property descriptions for insights on each country's specific usage

- `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.

### Shipping-Courier

Essential information for tracking a shipment. The `shippedAt` key represents the date and time when the item was shipped. This value follows the ISO 8601 standard format for date and time representations. The `name` field indicates the courier service employed to handle the shipment (e.g. FEDEX, UPS). For orders that are picked up in-store (also known as Buy-Online-Pickup-Instore), please use "INSTORE_PICKUP" as the `name` field value. The `tracking` key represents a unique tracking number provided by the courier service to monitor the shipment's progress. It's a valuable tool for customers and businesses to track and trace their packages. The `priority` field tracks the shipping speed or service level associated with the delivery.

- `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`

### Item

This data model is used to store crucial product details. The `price.amount` field represents the unit price of the individual item. The `quantity` field shows the number of units of the item. The `name` field denotes the name of the product, while `sku` holds the Stock Keeping Unit identifier. 100 is the maximum number of item objects in the items array. It is crucial that the `price.amount` represents the unit price of the individual item. **Never** populate the `price.amount` by multiplying the quantity by the unit cost. Always enter the price for a single unit to maintain data accuracy.

- `name` (string, required) — Product name
- `quantity` (integer, required)
- `price` (Money, 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 |
- `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.

### Discount

A discount applied to an order.

- `displayName` (string, optional) — A display name for the discount. Limited to 128 characters.
- `amount` (Money, optional) — The discount amount.

### AgreementEventResponse

Response type for agreement events

- `type` (enum, optional) — Type of event
  - Allowed values: `CAPTURE`, `VOID`
- `created` (string, optional) — Timestamp when the event occurred
- `amount` (Money, optional) — Amount associated with the event
- `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

## Examples

**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": "San Francisco",
      "region": "CA",
      "postcode": "94121",
      "countryCode": "US",
      "phoneNumber": "2120000000"
    },
    "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",
      "area1": "San Francisco",
      "region": "CA",
      "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"

headers = {
    "User-Agent": "User-Agent"
}

response = requests.get(url, headers=headers, auth=("<username>", "<password>"))

print(response.json())
```

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

const options = {
  method: 'GET',
  headers: {'User-Agent': 'User-Agent', Authorization: `Basic ${credentials}`}
};

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"
	"net/http"
	"io"
)

func main() {

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

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("User-Agent", "User-Agent")
	req.SetBasicAuth("<username>", "<password>")

	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")

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

request = Net::HTTP::Get.new(url)
request["User-Agent"] = 'User-Agent'
request.basic_auth("<username>", "<password>")

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.get("https://global-api-sandbox.afterpay.com/v2/payments/orderId")
  .header("User-Agent", "User-Agent")
  .basicAuth("<username>", "<password>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://global-api-sandbox.afterpay.com/v2/payments/orderId', [
  'headers' => [
    '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");
client.Authenticator = new HttpBasicAuthenticator("<username>", "<password>");
var request = new RestRequest(Method.GET);
request.AddHeader("User-Agent", "User-Agent");

IRestResponse response = client.Execute(request);
```

```swift
import Foundation

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

let headers = [
  "User-Agent": "User-Agent",
  "Authorization": "Basic \(credentials)"
]

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

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()
```