Transaction API
Release date: July 16, 2021
Overview
Affirm has moved to the new Transactions API, an improved post-origination API. Transactions was initially utilized to support Affirm Connect, a unified interface to process online payments financed by  installment loans serviced by Affirm and leases serviced by a lease-to-own (LTO) provider in partnership with Affirm. 
While there are some similar functionalities to the Charges API, Transactions includes additional features such as Split Capture, idempotency, and expanded error handling. Additionally,  the api/v1/transaction endpoint lets you programmatically authorize, capture, refund, or void various payment options processed by Affirm.
What's changed?
This section provides details on the differences between the Transactions and Charges APIs. 
GET Read Charge →  GET Read Transaction
- Charges URL : GET /api/v2/charges/<charge_id>
- Transactions URL : GET /api/v1/transactions/<id>
Note that the
idused in this endpoint is returned from theTransactionsobject retrieved from theAuthorize Transactionsresponse.
New query parameters
| Key | Example | Description | 
|---|---|---|
| expand | expand=checkoutOr expand=checkout,events | Possible comma-delimited values: events,checkout | 
Returns the Transaction object.
POST Authorize Charge →  POST Authorize Transaction
- Charges URL : POST /api/v2/charges
- Transactions URL : POST /api/v1/transactions
Request header parameters
| Key | Data type | Description | 
|---|---|---|
| Idempotency-Keyoptional | string | Identifying string used to get idempotent responses. This is a new field. | 
Request body parameters
| Key | Data type | Description | 
|---|---|---|
| transaction_idrequired | string | The checkout_idgenerated on the client.This is named the checkout_tokenin theChargesendpoint. | 
| expandoptional | string | Possible comma-delimited values: events,checkoutThis is a new field. | 
| order_idoptional | string | The merchant's internal order ID. | 
| reference_idoptional | string | The merchant’s reference ID. This is a new field. | 
Returns the Transaction object.
POST Capture Charge →  POST Capture Transaction
Charges URL : POST /api/v2/charges/<charge_id>/capture
Transactions URL : POST /api/v1/transactions/<id>/capture
Request header parameters
| Key | Data type | Description | 
|---|---|---|
| Idempotency-Keyoptional | string | Identifying string used to get idempotent responses. This is a new field. | 
Request body parameters
Note that the request body must be
null,an empty json object, or a json object with the key/value pairs in the table below. TheChargesAPI accepted an empty string.
| Key | Data type | Description | 
|---|---|---|
| amountoptional | integer | The amount to capture. This is a new field used for Split Capture. | 
| order_idoptional | string | The merchant’s internal order ID. | 
| reference_idoptional | string | The merchant’s reference ID. This is named the merchant_transaction_idin theChargesendpoint. | 
| shipping_carrieroptional | string | The merchant’s shipping carrier. | 
| shipping_confirmationoptional | string | The merchant’s tracking number. | 
| metadataoptional | object | Optional data object for your reference. This is a new field. | 
Returns the transaction event object.
The following returned fields have been removed for the Transactions endpoint:
| Key | Data type | Description | 
|---|---|---|
| order_idoptional | string | An order ID included in the checkout or authorization request. | 
| transaction_id | string | The ID for the request. | 
POST Refund Charge →  POST Refund Transaction
Charges URL : POST /api/v2/charges/<charge_id>/refund
Transactions URL : POST /api/v1/transactions/<id>/refund
Request header parameters
| Key | Data type | Description | 
|---|---|---|
| Idempotency-Keyoptional | string | Identifying string used to get idempotent responses. This is a new field. | 
Request body parameters
| Key | Data type | Description | 
|---|---|---|
| amountoptional | integer | The amount to be refunded. | 
| reference_idoptional | string | The merchant’s reference ID. This is a new field. | 
| transaction_event_countoptional | integer | The number of transaction events. This is a new field. | 
| metadataoptional | object | An optional data object for your reference. This is a new field. | 
Returns the transaction event object.
The following returned fields have been removed for the Transactions endpoint:
| Key | Data type | Description | 
|---|---|---|
| transaction_id | string | The ID for the request. | 
POST Update Charge →  POST Update Transaction
Charges URL : POST /api/v2/charges/<charge_id>/update' Transactions URL : POST /api/v1/transactions/`
Request header parameters
| Key | Data type | Description | 
|---|---|---|
| Idempotency-Keyoptional | string | Identifying string used to get idempotent responses. This is a new field. | 
Request body parameters
| Key | Data type | Description | 
|---|---|---|
| order_idoptional | string | Identifies the merchant's order ID. | 
| reference_idoptional | string | The merchant’s reference ID. This is a new field. | 
| shipping_carrieroptional | string | The shipping carrier used to ship the items. | 
| shippingconfirmation _optional | string | The tracking number of the shipment. | 
Expanded error handling
We've expanded error handling for Transactions. See Errors in our API Reference for additional information.