Payments
A Payment represents a series of logically connected financial transactions like reserving, charging, or refunding money.
A Payment holds information about the payment service provider (PSP), the payment method used, any related transactions, and the current state of the Payment. An Order or a Cart can reference a set of Payments using the PaymentInfo object. A Payment can also reference a Customer, or an anonymous session.
The actual financial process is carried out by an external PSP, which is connected to Composable Commerce by PSP-specific integrations.
If you are using Checkout for your checkout solution, the Checkout Payment Intents API lets you request the PSP to perform actions throughout the financial process, such as payment capture, refund, and authorization cancellation.
Representations
Payment
idString | Unique identifier of the Payment. |
versionInt | Current version of the Payment. |
keyString | User-defined unique identifier of the Payment. MinLength:2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$ |
customer | Reference to a Customer associated with the Payment. |
anonymousIdString | Anonymous session associated with the Payment. |
interfaceIdString | Identifier used by the payment service that processes the Payment (for example, a PSP).
The combination of |
amountPlanned | |
paymentMethodInfo | Information regarding the payment interface (for example, a PSP), and the specific payment method used. |
paymentStatus | Current status of the Payment. |
transactionsArray of Transaction | Financial transactions of the Payment. Each Transaction has a TransactionType and a TransactionState. |
interfaceInteractionsArray of CustomFields | Represents information exchange with the payment service, for example, a PSP. An interaction may be a request sent, or a response or notification received from the payment service. |
custom | Custom Fields for the Payment. |
createdAt | Date and time (UTC) the Payment was initially created. |
createdByBETA | IDs and references that created the Payment. |
lastModifiedAt | Date and time (UTC) the Payment was last updated. |
lastModifiedByBETA | IDs and references that last modified the Payment. |
PaymentDraft
keyString | User-defined unique identifier for the Payment. MinLength:2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$ |
customer | Reference to a Customer associated with the Payment. |
anonymousIdString | Anonymous session associated with the Payment. |
interfaceIdString | Identifier used by the payment service that processes the Payment (for example, a PSP).
The combination of |
amountPlanned | |
paymentMethodInfo | Information regarding the payment interface (for example, a PSP), and the specific payment method used. |
paymentStatus | Current status of the Payment. |
transactionsArray of TransactionDraft | Financial transactions of the Payment. Each Transaction has a TransactionType and a TransactionState. |
interfaceInteractionsArray of CustomFieldsDraft | Represents information exchange with the payment service, for example, a PSP. An interaction may be a request sent, or a response or notification received from the payment service. |
custom | Custom Fields for the Payment. |
PaymentPagedQueryResponse
PagedQueryResult with results containing an array of Payment.
limitInt | Number of results requested. Default:20Maximum: 500 |
countInt | Actual number of results returned. |
totalInt | Total number of results matching the query.
This number is an estimation that is not strongly consistent.
This field is returned by default.
For improved performance, calculating this field can be deactivated by using the query parameter |
offsetInt | Number of elements skipped. Default:0Maximum: 10 000 |
resultsArray of Payment | Payments matching the query. |
PaymentReference
idString | Unique identifier of the referenced Payment. |
typeId | "payment"References a Payment. |
obj | Contains the representation of the expanded Payment. Only present in responses to requests with Reference Expansion for Payments. |
PaymentResourceIdentifier
ResourceIdentifier of a Payment. Either id or key is required. If both are set, an InvalidJsonInput error is returned.
PaymentMethodInfo
paymentInterfaceString | Payment service that processes the Payment (for example, a PSP).
Once set, it cannot be changed.
The combination of |
methodString | Payment method used, for example, credit card, or cash advance. |
name | Localizable name of the payment method. |
PaymentStatus
interfaceCodeString | External reference that identifies the current status of the Payment. |
interfaceTextString | Text describing the current status of the Payment. |
state |
PaymentStatusDraft
interfaceCodeString | External reference that identifies the current status of the Payment. |
interfaceTextString | Text describing the current status of the Payment. |
state | ResourceIdentifier to a State. |
Transaction
Represents a financial transaction typically created as a result of a notification from the payment service.
idString | Unique identifier of the Transaction. |
timestamp | Date and time (UTC) the Transaction took place. |
type | Type of the Transaction. For example, |
amount | Money value of the Transaction. |
interactionIdString | Identifier used by the interface that manages the Transaction (usually the PSP).
If a matching interaction was logged in the |
state | State of the Transaction. |
custom | Custom Fields defined for the Transaction. |
TransactionDraft
timestamp | Date and time (UTC) the Transaction took place. |
type | Type of the Transaction. |
amount | Money value for the Transaction. |
interactionIdString | Identifier used by the payment service that manages the Transaction. Can be used to correlate the Transaction to an interface interaction. |
state | State of the Transaction. Default:Initial |
custom | Custom Fields of the Transaction. |
TransactionType
AuthorizationFinancially reliable reservation of an amount. Typically does not indicate an actual transfer of money.
CancelAuthorizationExplicit cancellation of an authorized amount before its expiry.
ChargeCollection of money from the customer. Can use an authorized amount or be directly executed.
RefundExplicit transfer of money back to the customer.
ChargebackCustomer-initiated transfer of money back to the customer.
TransactionState
Transactions can be in one of the following States:
InitialInitial State. The payment service has not accepted the Transaction yet.
PendingThe payment service has accepted the Transaction, but it is not completed yet.
SuccessThe payment service has confirmed the successful completion of the Transaction.
FailureTransaction has unrecoverably failed.
Get Payment
Get Payment by ID
view_payments:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
idString |
|
expand | The parameter can be passed multiple times. |
application/jsoncurl --get https://api.{region}.commercetools.com/{projectKey}/payments/{id} -i \--header "Authorization: Bearer ${BEARER_TOKEN}"
{"id": "776f9240-09e1-4416-a34f-32fa80f0333f","version": 1,"key": "123456","interfaceId": "789011","amountPlanned": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "USD","centAmount": 1000},"paymentMethodInfo": {"paymentInterface": "STRIPE","method": "CREDIT_CARD","name": {"en": "Credit Card"}},"paymentStatus": {},"transactions": [{"id": "14748fe6-7f77-456a-96c8-913b1e4bbc9a","timestamp": "2015-10-20T08:54:24.000Z","type": "Charge","amount": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "USD","centAmount": 1000},"state": "Pending"}],"interfaceInteractions": [],"createdAt": "2015-10-20T08:54:11.480Z","lastModifiedAt": "2015-10-20T08:54:11.480Z"}
Get Payment by Key
view_payments:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
keyString |
|
expand | The parameter can be passed multiple times. |
application/jsoncurl --get https://api.{region}.commercetools.com/{projectKey}/payments/key={key} -i \--header "Authorization: Bearer ${BEARER_TOKEN}"
{"id": "776f9240-09e1-4416-a34f-32fa80f0333f","version": 1,"key": "123456","interfaceId": "789011","amountPlanned": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "USD","centAmount": 1000},"paymentMethodInfo": {"paymentInterface": "STRIPE","method": "CREDIT_CARD","name": {"en": "Credit Card"}},"paymentStatus": {},"transactions": [{"id": "14748fe6-7f77-456a-96c8-913b1e4bbc9a","timestamp": "2015-10-20T08:54:24.000Z","type": "Charge","amount": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "USD","centAmount": 1000},"state": "Pending"}],"interfaceInteractions": [],"createdAt": "2015-10-20T08:54:11.480Z","lastModifiedAt": "2015-10-20T08:54:11.480Z"}
Query Payments
view_payments:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
where | The parameter can be passed multiple times. |
sort | The parameter can be passed multiple times. |
expand | The parameter can be passed multiple times. |
limitInt | Number of results requested. Default: 20 |
offsetInt | Number of elements skipped. Default: 0 |
withTotalBoolean | Controls the calculation of the total number of query results. Set to Default: true |
var.<varName>String | Predicate parameter values. The parameter can be passed multiple times. |
application/jsoncurl --get https://api.{region}.commercetools.com/{projectKey}/payments -i \--header "Authorization: Bearer ${BEARER_TOKEN}"
{"limit": 20,"offset": 0,"count": 1,"total": 1,"results": [{"id": "459e32dc-74ef-4189-bbd0-932275bb027c","version": 1,"key": "123456","interfaceId": "78901","amountPlanned": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "USD","centAmount": 1000},"paymentMethodInfo": {"paymentInterface": "STRIPE","method": "CREDIT_CARD","name": {"en": "Credit Card"}},"paymentStatus": {},"transactions": [{"id": "2e318aa5-8af4-4db1-909d-e7142f7d174f","timestamp": "2015-10-20T08:51:56.000Z","type": "Charge","amount": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "USD","centAmount": 1000},"state": "Pending"}],"interfaceInteractions": [],"createdAt": "2015-10-20T08:51:43.082Z","lastModifiedAt": "2015-10-20T08:51:43.082Z"}]}
Check if Payment exists
Check if Payment exists by ID
Checks if a Payment exists for a given id. Returns a 200 OK status if the Payment exists or a 404 Not Found otherwise.
view_payments:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
idString |
|
curl --head https://api.{region}.commercetools.com/{projectKey}/payments/{id} -i \--header "Authorization: Bearer ${BEARER_TOKEN}"
Check if Payment exists by Key
Checks if a Payment exists for a given key. Returns a 200 OK status if the Payment exists or a 404 Not Found otherwise.
view_payments:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
keyString |
|
curl --head https://api.{region}.commercetools.com/{projectKey}/payments/key={key} -i \--header "Authorization: Bearer ${BEARER_TOKEN}"
Check if Payment exists by Query Predicate
Checks if a Payment exists for a given Query Predicate. Returns a 200 OK status if any Payments match the Query Predicate or a 404 Not Found otherwise.
view_payments:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
where | The parameter can be passed multiple times. |
curl --head https://api.{region}.commercetools.com/{projectKey}/payments -i \--header "Authorization: Bearer ${BEARER_TOKEN}"
Create Payment
Creating a Payment produces the PaymentCreated Message.
manage_payments:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
expand | The parameter can be passed multiple times. |
application/jsonapplication/jsoncurl https://api.{region}.commercetools.com/{projectKey}/payments -i \--header "Authorization: Bearer ${BEARER_TOKEN}" \--header 'Content-Type: application/json' \--data-binary @- << DATA{"key" : "123456","interfaceId" : "789011","amountPlanned" : {"currencyCode" : "USD","centAmount" : 1000},"paymentMethodInfo" : {"paymentInterface" : "STRIPE","method" : "CREDIT_CARD","name" : {"en" : "Credit Card"}},"transactions" : [ {"timestamp" : "2015-10-20T08:54:24.000Z","type" : "Charge","amount" : {"currencyCode" : "USD","centAmount" : 1000},"state" : "Pending"} ]}DATA
{"id": "776f9240-09e1-4416-a34f-32fa80f0333f","version": 1,"key": "123456","interfaceId": "789011","amountPlanned": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "USD","centAmount": 1000},"paymentMethodInfo": {"paymentInterface": "STRIPE","method": "CREDIT_CARD","name": {"en": "Credit Card"}},"paymentStatus": {},"transactions": [{"id": "14748fe6-7f77-456a-96c8-913b1e4bbc9a","timestamp": "2015-10-20T08:54:24.000Z","type": "Charge","amount": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "USD","centAmount": 1000},"state": "Pending"}],"interfaceInteractions": [],"createdAt": "2015-10-20T08:54:11.480Z","lastModifiedAt": "2015-10-20T08:54:11.480Z"}
Update Payment
Update Payment by ID
manage_payments:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
idString |
|
expand | The parameter can be passed multiple times. |
application/jsonversionInt | Expected version of the Payment on which the changes should be applied. If the expected version does not match the actual version, a ConcurrentModification error will be returned. |
actionsArray of PaymentUpdateAction | Update actions to be performed on the Payment. |
application/jsoncurl https://api.{region}.commercetools.com/{projectKey}/payments/{id} -i \--header "Authorization: Bearer ${BEARER_TOKEN}" \--header 'Content-Type: application/json' \--data-binary @- << DATA{"version" : 1,"actions" : [ {"action" : "transitionState","state" : {"typeId" : "state","id" : "18748fe6-7f77-456a-96c8-913b1e4bbc9c"}} ]}DATA
{"id": "776f9240-09e1-4416-a34f-32fa80f0333f","version": 1,"key": "123456","interfaceId": "789011","amountPlanned": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "USD","centAmount": 1000},"paymentMethodInfo": {"paymentInterface": "STRIPE","method": "CREDIT_CARD","name": {"en": "Credit Card"}},"paymentStatus": {},"transactions": [{"id": "14748fe6-7f77-456a-96c8-913b1e4bbc9a","timestamp": "2015-10-20T08:54:24.000Z","type": "Charge","amount": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "USD","centAmount": 1000},"state": "Pending"}],"interfaceInteractions": [],"createdAt": "2015-10-20T08:54:11.480Z","lastModifiedAt": "2015-10-20T08:54:11.480Z"}
Update Payment by Key
manage_payments:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
keyString |
|
expand | The parameter can be passed multiple times. |
application/jsonversionInt | Expected version of the Payment on which the changes should be applied. If the expected version does not match the actual version, a ConcurrentModification error will be returned. |
actionsArray of PaymentUpdateAction | Update actions to be performed on the Payment. |
application/jsoncurl https://api.{region}.commercetools.com/{projectKey}/payments/key={key} -i \--header "Authorization: Bearer ${BEARER_TOKEN}" \--header 'Content-Type: application/json' \--data-binary @- << DATA{"version" : 1,"actions" : [ {"action" : "transitionState","state" : {"typeId" : "state","id" : "18748fe6-7f77-456a-96c8-913b1e4bbc9c"}} ]}DATA
{"id": "776f9240-09e1-4416-a34f-32fa80f0333f","version": 1,"key": "123456","interfaceId": "789011","amountPlanned": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "USD","centAmount": 1000},"paymentMethodInfo": {"paymentInterface": "STRIPE","method": "CREDIT_CARD","name": {"en": "Credit Card"}},"paymentStatus": {},"transactions": [{"id": "14748fe6-7f77-456a-96c8-913b1e4bbc9a","timestamp": "2015-10-20T08:54:24.000Z","type": "Charge","amount": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "USD","centAmount": 1000},"state": "Pending"}],"interfaceInteractions": [],"createdAt": "2015-10-20T08:54:11.480Z","lastModifiedAt": "2015-10-20T08:54:11.480Z"}
Update actions
Set Key
actionString | "setKey" |
keyString | Value to set.
If 2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$ |
{"action": "setKey","key": "String"}
Change AmountPlanned
Can be used to update the Payment if a customer changes the Cart, or adds or removes a CartDiscount during checkout.
actionString | "changeAmountPlanned" |
amount | New value to set. |
{"action": "changeAmountPlanned","amount": {"currencyCode": "EUR","centAmount": 4000}}
Set Customer
actionString | "setCustomer" |
customer | Value to set. If empty, any existing reference is removed. |
{"action": "setCustomer","customer": {"typeId": "customer","id": "{{customer-id}}"}}
Set AnonymousId
If the Payment is already associated with a Customer, an InvalidOperation error is returned.
actionString | "setAnonymousId" |
anonymousIdString | Value to set. If empty, any existing value will be removed. |
{"action": "setAnonymousId","anonymousId": "anonymousId"}
Set InterfaceId
actionString | "setInterfaceId" |
interfaceIdString | Value to set.
Once set, the |
{"action": "setInterfaceId","interfaceId": "InterfaceID"}
Set MethodInfoInterface
actionString | "setMethodInfoInterface" |
interfaceString | Value to set.
Once set, the |
{"action": "setMethodInfoInterface","interface": "MethodInfoInterfaceString"}
Set MethodInfoMethod
actionString | "setMethodInfoMethod" |
methodString | Value to set. If empty, any existing value will be removed. |
{"action": "setMethodInfoMethod","method": "MethodInfoMethodString"}
Set MethodInfoName
actionString | "setMethodInfoName" |
name | Value to set. If empty, any existing value will be removed. |
{"action": "setMethodInfoName","name": {"de": "MethodInfoNameStringDE","en": "MethodInfoNameStringEN"}}
Set StatusInterfaceCode
Produces the PaymentStatusInterfaceCodeSet Message.
actionString | "setStatusInterfaceCode" |
interfaceCodeString | Value to set. If empty, any existing value will be removed. |
{"action": "setStatusInterfaceCode","interfaceCode": "InterfaceCodeString"}
Set StatusInterfaceText
actionString | "setStatusInterfaceText" |
interfaceTextString | Value to set. If empty, any existing value will be removed. |
{"action": "setStatusInterfaceText","interfaceText": "InterfaceTextString"}
Transition State
If the Payment has no current State, initial must be true for the new State.
If the existing State has transitions set, the new State must be a valid transition.
If the existing State has no transitions set, no validations are performed when transitioning to the new State.
Transitioning the State of a Payment produces the PaymentStatusStateTransition Message.
actionString | "transitionState" |
state | ResourceIdentifier to a State. |
forceBoolean | Set to false |
{"action": "transitionState","state": {"typeId": "state","id": "{{paymentStateId}}"}}
Add Transaction
Adding a Transaction to a Payment generates the PaymentTransactionAdded Message.
actionString | "addTransaction" |
transaction | Value to append to the |
{"action": "addTransaction","transaction": {"type": "Authorization","amount": {"centAmount": 4000,"currencyCode": "EUR"}}}
Change TransactionState
Changing the TransactionState generates the PaymentTransactionStateChanged Message.
actionString | "changeTransactionState" |
transactionIdString | Unique identifier of the Transaction. |
state | New TransactionState. |
{"action": "changeTransactionState","transactionId": "{{transactionId}}","state": "Failure"}
Change TransactionTimestamp
actionString | "changeTransactionTimestamp" |
transactionIdString | Unique identifier of the Transaction. |
timestamp | Timestamp of the Transaction as reported by the payment service. |
{"action": "changeTransactionTimestamp","transactionId": "{{transactionId}}","timestamp": "2018-10-12T14:00:00.000Z"}
Change TransactionInteractionId
actionString | "changeTransactionInteractionId" |
transactionIdString | Unique identifier of the Transaction. |
interactionIdString | New value to set. |
{"action": "changeTransactionInteractionId","transactionId": "{{transactionId}}","interactionId": "{{newInteractionId}}"}
Add InterfaceInteraction
Adding a Payment interaction generates the PaymentInteractionAdded Message.
actionString | "addInterfaceInteraction" |
type | ResourceIdentifier of a Type. |
fields | Custom Fields as per FieldDefinitions of the Type. |
{"action": "addInterfaceInteraction","type": {"typeId": "type","id": "{{type-id}}"}}
Set Custom Type
actionString | "setCustomType" |
type | Defines the Type that extends the Payment with Custom Fields. If absent, any existing Type and Custom Fields are removed from the Payment. |
fields | Sets the Custom Fields fields for the Payment. |
{"action": "setCustomType","type": {"id": "{{type-id}}","typeId": "type"},"fields": {"exampleStringField": "TextString"}}
Set CustomField
actionString | "setCustomField" |
nameString | Name of the Custom Field. |
value | If |
{"action": "setCustomField","name": "exampleStringField","value": "TextString"}
Set Transaction Custom Type
actionString | "setTransactionCustomType" |
transactionIdString | Unique identifier of the Transaction. If the specified |
type | Defines the Type that extends the Transaction with Custom Fields. If absent, any existing Type and Custom Fields are removed from the Transaction. |
fields | Sets the Custom Fields fields for the Transaction. |
{"action": "setTransactionCustomType","type": {"id": "{{type-id}}","typeId": "type"},"fields": {"exampleStringField": "TextString"},"transactionId": "transactionIdTest"}
Set Transaction CustomField
actionString | "setTransactionCustomField" |
transactionIdString | Unique identifier of the Transaction. |
nameString | Name of the Custom Field. |
value | If |
{"action": "setTransactionCustomField","name": "exampleStringField","value": "TextString","transactionId": "transactionIdTest"}
Delete Payment
Delete Payment by ID
manage_payments:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
idString |
|
versionInt | Last seen version of the resource. |
expand | The parameter can be passed multiple times. |
dataErasureBoolean | To erase all related personal data in compliance with GDPR, set to Default: false |
application/jsoncurl -X DELETE https://api.{region}.commercetools.com/{projectKey}/payments/{id}?version={version} -i \--header "Authorization: Bearer ${BEARER_TOKEN}"
{"id": "776f9240-09e1-4416-a34f-32fa80f0333f","version": 1,"key": "123456","interfaceId": "789011","amountPlanned": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "USD","centAmount": 1000},"paymentMethodInfo": {"paymentInterface": "STRIPE","method": "CREDIT_CARD","name": {"en": "Credit Card"}},"paymentStatus": {},"transactions": [{"id": "14748fe6-7f77-456a-96c8-913b1e4bbc9a","timestamp": "2015-10-20T08:54:24.000Z","type": "Charge","amount": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "USD","centAmount": 1000},"state": "Pending"}],"interfaceInteractions": [],"createdAt": "2015-10-20T08:54:11.480Z","lastModifiedAt": "2015-10-20T08:54:11.480Z"}
Delete Payment by Key
manage_payments:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
keyString |
|
versionInt | Last seen version of the resource. |
expand | The parameter can be passed multiple times. |
dataErasureBoolean | To erase all related personal data in compliance with GDPR, set to Default: false |
application/jsoncurl -X DELETE https://api.{region}.commercetools.com/{projectKey}/payments/key={key}?version={version} -i \--header "Authorization: Bearer ${BEARER_TOKEN}"
{"id": "776f9240-09e1-4416-a34f-32fa80f0333f","version": 1,"key": "123456","interfaceId": "789011","amountPlanned": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "USD","centAmount": 1000},"paymentMethodInfo": {"paymentInterface": "STRIPE","method": "CREDIT_CARD","name": {"en": "Credit Card"}},"paymentStatus": {},"transactions": [{"id": "14748fe6-7f77-456a-96c8-913b1e4bbc9a","timestamp": "2015-10-20T08:54:24.000Z","type": "Charge","amount": {"type": "centPrecision","fractionDigits": 2,"currencyCode": "USD","centAmount": 1000},"state": "Pending"}],"interfaceInteractions": [],"createdAt": "2015-10-20T08:54:11.480Z","lastModifiedAt": "2015-10-20T08:54:11.480Z"}