Checkout Transactions API
Trigger payments without using the Checkout UI.
The Checkout Transactions API lets you initiate payments managed by Checkout without using the Checkout UI. For example, you can leverage the Checkout Transactions API to process recurring payments for subscription-based orders.
A Transaction represents a request to the payment Connector to initiate the payment and send payment information for a specific Cart to the payment service provider (PSP).
The Checkout's payment lifecycle applies also to payments triggered with the Checkout Transactions API.
Use the Checkout Transactions API to trigger only payments managed by Checkout.
Scope
| Scope | Permission granted |
|---|---|
manage_checkout_transactions:{projectKey} | Manage Transactions |
view_checkout_transactions:{projectKey} | View Transactions |
Representations
Transaction
Information for the request to the payment Connector to initiate the payment for a specific Cart.
idString | Unique identifier of the Transaction. |
versionInt | Current version of the Transaction. |
keyString | User-defined unique identifier of the Transaction. MinLength:2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$ |
application | Application for which the payment must be executed. |
transactionItemsArray of TransactionItem | Transaction Item associated with the Transaction. MinItems:1MaxItems: 1 |
cart | Reference to the Cart for which the payment must be executed. |
transactionStatus | Status of the Transaction. |
order | Reference to the Order created from the Cart when the Transaction is completed. |
createdAtDateTime | Date and time (UTC) the Transaction was initially created. |
lastModifiedAtDateTime | Date and time (UTC) the Transaction was last updated. |
TransactionDraft
keyString | User-defined unique identifier of the Transaction. MinLength:2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$ |
application | Application for which the payment is executed. |
transactionItemsArray of TransactionItemDraft | Transaction Item associated with the Transaction. MinItems:1MaxItems: 1 |
cart | Cart for which the payment must be executed. |
TransactionItem
Payment information related to the Transaction.
paymentIntegration | Reference to the Payment Integration to use to execute the payment. |
amount | Money value of the Transaction Item. |
payment | Reference to the Payment associated with the Transaction Item. |
TransactionItemDraft
paymentIntegration | Resource Identifier of the Payment Integration to use to execute the payment. |
amount | Money value of the Transaction Item. |
TransactionStatus
The state of the Transaction and the related errors in case of a failed Transaction.
state | State of the Transaction. |
errorsArray of TransactionError | Errors returned if the Transaction is in the |
TransactionState
The state of the Transaction.
InitialThe Transaction has started. The payment Connector is requesting the PSP to execute the payment for the Cart.
PendingThe Transaction is in progress. The PSP is processing the payment.
CompletedThe Transaction completed successfully. The PSP processed the payment and Checkout created an Order from the Cart.
FailedThe Transaction failed.
TransactionError
A single error on the Transaction. Multiple errors may be included in the Transaction Status.
codeString | Error identifier. |
messageString | Plain text description of the cause of the error. |
Get Transaction
Get Transaction by ID
Returns a Transaction with a given id. Specific Error Codes:
view_checkout_transactions:{projectKey}manage_projects:{projectKey}regionString | |
projectKeyString | Identifier of your Checkout entity and |
idString |
|
application/jsoncurl --get https://checkout.{region}.commercetools.com/{projectKey}/transactions/{id} -i \--header "Authorization: Bearer ${BEARER_TOKEN}"
{"id": "6d95b6c6-5ef0-4091-8478-b26077ca2b2f","version": 1,"key": "transaction-key","application": {"typeId": "application","id": "a84d4fe7-ae82-4c3f-8c6c-435e54204fdd"},"cart": {"typeId": "cart","id": "a0e60229-441c-44b0-952b-981a67cbd8c4"},"order": {"typeId": "order","id": "39ccda28-47f9-41bf-8dde-e1d720c19000"},"transactionItems": [{"paymentIntegration": {"typeId": "payment-integration","id": "4c24762b-87df-4bd3-898a-bafed913a9ca"},"amount": {"centAmount": 1000,"currencyCode": "EUR"},"payment": {"typeId": "payment","id": "d1fec278-22c2-4a1d-8190-8f1e8af5ccfb"}}],"transactionStatus": {"state": "Failed","errors": [{"code": "PaymentRejected","message": "Payment d1fec278-22c2-4a1d-8190-8f1e8af5ccfb has been rejected."}]},"createdAt": "1970-01-01T00:00:00.001Z","lastModifiedAt": "1970-01-01T00:00:00.001Z"}
Get Transaction by Key
Returns a Transaction with a given key. Specific Error Codes:
view_checkout_transactions:{projectKey}manage_projects:{projectKey}regionString | |
projectKeyString | Identifier of your Checkout entity and |
keyString |
|
application/jsoncurl --get https://checkout.{region}.commercetools.com/{projectKey}/transactions/key={key} -i \--header "Authorization: Bearer ${BEARER_TOKEN}"
{"id": "6d95b6c6-5ef0-4091-8478-b26077ca2b2f","version": 1,"key": "transaction-key","application": {"typeId": "application","id": "a84d4fe7-ae82-4c3f-8c6c-435e54204fdd"},"cart": {"typeId": "cart","id": "a0e60229-441c-44b0-952b-981a67cbd8c4"},"order": {"typeId": "order","id": "39ccda28-47f9-41bf-8dde-e1d720c19000"},"transactionItems": [{"paymentIntegration": {"typeId": "payment-integration","id": "4c24762b-87df-4bd3-898a-bafed913a9ca"},"amount": {"centAmount": 1000,"currencyCode": "EUR"},"payment": {"typeId": "payment","id": "d1fec278-22c2-4a1d-8190-8f1e8af5ccfb"}}],"transactionStatus": {"state": "Failed","errors": [{"code": "PaymentRejected","message": "Payment d1fec278-22c2-4a1d-8190-8f1e8af5ccfb has been rejected."}]},"createdAt": "1970-01-01T00:00:00.001Z","lastModifiedAt": "1970-01-01T00:00:00.001Z"}
Create Transaction
Creates a Transaction on Checkout. Specific Error Codes:
manage_checkout_transactions:{projectKey}manage_projects:{projectKey}regionString | |
projectKeyString | Identifier of your Checkout entity and |
application/jsonapplication/jsoncurl https://checkout.{region}.commercetools.com/{projectKey}/transactions -i \--header "Authorization: Bearer ${BEARER_TOKEN}" \--header 'Content-Type: application/json' \--data-binary @- << DATA{"key" : "transaction-key","application" : {"typeId" : "application","id" : "a84d4fe7-ae82-4c3f-8c6c-435e54204fdd"},"cart" : {"typeId" : "cart","id" : "a0e60229-441c-44b0-952b-981a67cbd8c4"},"transactionItems" : [ {"paymentIntegration" : {"typeId" : "payment-integration","id" : "4c24762b-87df-4bd3-898a-bafed913a9ca"},"amount" : {"centAmount" : 1000,"currencyCode" : "EUR"}} ]}DATA
{"id": "6d95b6c6-5ef0-4091-8478-b26077ca2b2f","version": 1,"key": "transaction-key","application": {"typeId": "application","id": "a84d4fe7-ae82-4c3f-8c6c-435e54204fdd"},"cart": {"typeId": "cart","id": "a0e60229-441c-44b0-952b-981a67cbd8c4"},"order": {"typeId": "order","id": "39ccda28-47f9-41bf-8dde-e1d720c19000"},"transactionItems": [{"paymentIntegration": {"typeId": "payment-integration","id": "4c24762b-87df-4bd3-898a-bafed913a9ca"},"amount": {"centAmount": 1000,"currencyCode": "EUR"},"payment": {"typeId": "payment","id": "d1fec278-22c2-4a1d-8190-8f1e8af5ccfb"}}],"transactionStatus": {"state": "Failed","errors": [{"code": "PaymentRejected","message": "Payment d1fec278-22c2-4a1d-8190-8f1e8af5ccfb has been rejected."}]},"createdAt": "1970-01-01T00:00:00.001Z","lastModifiedAt": "1970-01-01T00:00:00.001Z"}