The PaymentMethod represents a reusable and structured model for storing payment method details.
It is designed to simplify integration with external Payment Service Providers (PSPs). It holds information about the PSP and the actual method used.
Representations
PaymentMethod
id ​String​ | Unique identifier of the PaymentMethod. |
version ​Int​ | Current version of the PaymentMethod. |
key ​String​ | User-defined unique identifier of the PaymentMethod. MinLength:Â2 ​MaxLength: 256 ​Pattern: ^[A-Za-z0-9_-]+$ ​ |
name ​ | Name of the PaymentMethod. |
customer ​ | Reference to a Customer associated with the PaymentMethod. If businessUnit is set, the Customer is an Associate of the Business Unit. |
businessUnit ​ | Reference to a BusinessUnit associated with the PaymentMethod. Only available for B2B-enabled Projects. |
method ​String​ | Payment Method used for the Payment—for example, a credit card or cash advance. |
paymentInterface ​String​ | Payment service that processes the Payment—for example, a PSP. |
interfaceAccount ​String​ | Account or instance of the payment interface when multiple accounts are used (per interface). |
token ​ | Tokenized representation of the PaymentMethod used by the payment interface. |
paymentMethodStatus ​ | Status of the PaymentMethod. Default:ÂActive ​ |
default ​Boolean​ | Indicates if the PaymentMethod is the default. The default applies per Customer, Business Unit, or the combination of both (Associate). Default:Âfalse ​ |
custom ​CustomFields​ | Custom Fields of the PaymentMethod. |
createdAt ​DateTime​ | Date and time (UTC) the PaymentMethod was initially created. |
createdBy ​BETACreatedBy​ | IDs and references that created the PaymentMethod. |
lastModifiedAt ​DateTime​ | Date and time (UTC) the PaymentMethod was last updated. |
lastModifiedBy ​BETA | IDs and references that last modified the PaymentMethod. |
PaymentMethodDraft
key ​String​ | User-defined unique identifier for the PaymentMethod. MinLength:Â2 ​MaxLength: 256 ​Pattern: ^[A-Za-z0-9_-]+$ ​ |
name ​ | Name of the PaymentMethod. |
customer ​ | Reference to a Customer the PaymentMethod should belong to. If businessUnit is set, the Customer must be an Associate of the Business Unit. |
businessUnit ​ | Reference to a BusinessUnit the PaymentMethod should belong to. Only available for B2B-enabled Projects. |
method ​String​ | Payment method to use for the Payment—for example, a credit card or cash advance. |
paymentInterface ​String​ | Payment service that processes the Payment—for example, a PSP. |
interfaceAccount ​String​ | Account or instance of the payment interface when multiple accounts are used (per interface). |
token ​ | Tokenized representation of the PaymentMethod used by the payment interface. |
paymentMethodStatus ​ | Status of the PaymentMethod. Default:ÂActive ​ |
default ​Boolean​ | Set to
true if the PaymentMethod should be the default.The default applies per Customer, Business Unit, or the combination of both (Associate). Default:Âfalse ​ |
custom ​ | Custom Fields for the PaymentMethod. |
PaymentMethodPagedQueryResponse
limit ​Int​ | Number of results requested. Default: 20 ​Minimum: 0 ​Maximum: 500 ​ |
offset ​Int​ | Number of elements skipped. Default: 0 ​Maximum: 10000 ​ |
count ​Int​ | Actual number of results returned. |
total ​Int​ | 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 withTotal=false .
When the results are filtered with a Query Predicate, total is subject to a limit. |
results ​Array of PaymentMethod​ | PaymentMethods matching the query. |
PaymentMethodReference
id ​String​ | Unique identifier of the referenced PaymentMethod. |
typeId ​ | payment-method Type of referenced resource. |
obj ​ | Contains the representation of the expanded PaymentMethod. Only present in responses to requests with Reference Expansion for PaymentMethods. |
PaymentMethodStatus
Active
The PaymentMethod is active.
Inactive
The PaymentMethod is inactive.
PaymentMethodToken
The token value is sensitive, and we recommend that it is not logged when being handled in API Extensions.
value ​String​ | Tokenized representation of the Payment Method. It is displayed in the following instances:
It is masked in the following instances:
|
Get PaymentMethod
Get PaymentMethod by ID
id
.view_payment_methods:{projectKey}
region String ​ | Region in which the Project is hosted. |
projectKey String ​ | key of the Project. |
id String ​ | id of the PaymentMethod. |
expand | The parameter can be passed multiple times. |
application/json
curl --get https://api.{region}.commercetools.com/{projectKey}/payment-methods/{id} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}"
{
"id": "c7555392-a14c-48c8-9021-73d5d302b562",
"key": "my-payment-method",
"version": 1,
"versionModifiedAt": "2025-01-20T16:38:00.292Z",
"lastMessageSequenceNumber": 1,
"createdAt": "2025-01-20T16:38:00.292Z",
"lastModifiedAt": "2025-01-20T16:38:00.292Z",
"customer": {
"id": "c7555392-a14c-48c8-9021-73d5d302b565",
"typeId": "customer"
},
"businessUnit": {
"key": "my-bu",
"typeId": "business-unit"
},
"token": {
"value": "PSPToken"
},
"method": "Card",
"paymentInterface": "Adyen",
"interfaceAccount": "adyen-merchant-eu",
"default": true,
"name": {
"en": "my custom localised name"
},
"customFields": null,
"paymentMethodStatus": "Active"
}
Get PaymentMethod by Key
key
.view_payment_methods:{projectKey}
region String ​ | Region in which the Project is hosted. |
projectKey String ​ | key of the Project. |
key String ​ | key of the PaymentMethod. |
expand | The parameter can be passed multiple times. |
application/json
curl --get https://api.{region}.commercetools.com/{projectKey}/payment-methods/key={key} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}"
{
"id": "c7555392-a14c-48c8-9021-73d5d302b562",
"key": "my-payment-method",
"version": 1,
"versionModifiedAt": "2025-01-20T16:38:00.292Z",
"lastMessageSequenceNumber": 1,
"createdAt": "2025-01-20T16:38:00.292Z",
"lastModifiedAt": "2025-01-20T16:38:00.292Z",
"customer": {
"id": "c7555392-a14c-48c8-9021-73d5d302b565",
"typeId": "customer"
},
"businessUnit": {
"key": "my-bu",
"typeId": "business-unit"
},
"token": {
"value": "PSPToken"
},
"method": "Card",
"paymentInterface": "Adyen",
"interfaceAccount": "adyen-merchant-eu",
"default": true,
"name": {
"en": "my custom localised name"
},
"customFields": null,
"paymentMethodStatus": "Active"
}
Query PaymentMethods
Retrieves all PaymentMethods in the Project.
view_payment_methods:{projectKey}
region String ​ | Region in which the Project is hosted. |
projectKey String ​ | key of the Project. |
where | The parameter can be passed multiple times. |
sort | The parameter can be passed multiple times. |
expand | The parameter can be passed multiple times. |
limit Int ​ | Number of results requested. Default: 20 ​Minimum: 0 ​Maximum: 500 ​ |
offset Int ​ | Number of elements skipped. Default: 0 ​Maximum: 10000 ​ |
withTotal Boolean ​ | Controls the calculation of the total number of query results. Set to false to improve query performance when the total is not needed.Default: true ​ |
var.<varName> String ​ | Predicate parameter values. The parameter can be passed multiple times. |
PaymentMethodPagedQueryResponse
asapplication/json
curl --get https://api.{region}.commercetools.com/{projectKey}/payment-methods -i \
--header "Authorization: Bearer ${BEARER_TOKEN}"
{
"limit": 20,
"offset": 0,
"count": 1,
"total": 1,
"results": [
{
"id": "c7555392-a14c-48c8-9021-73d5d302b562",
"key": "my-payment-method",
"version": 1,
"versionModifiedAt": "2025-01-20T16:38:00.292Z",
"lastMessageSequenceNumber": 1,
"createdAt": "2025-01-20T16:38:00.292Z",
"lastModifiedAt": "2025-01-20T16:38:00.292Z",
"customer": {
"id": "c7555392-a14c-48c8-9021-73d5d302b565",
"typeId": "customer"
},
"businessUnit": {
"key": "my-bu",
"typeId": "business-unit"
},
"token": {
"value": "PSPToken"
},
"method": "Card",
"paymentInterface": "Adyen",
"interfaceAccount": "adyen-merchant-eu",
"default": true,
"name": {
"en": "my custom localised name"
},
"customFields": null,
"paymentMethodStatus": "Active"
}
]
}
Check if PaymentMethod exists
Check if PaymentMethod exists by ID
id
.
Returns a 200 OK
status if the PaymentMethod exists; otherwise, returns a Not Found.view_payment_methods:{projectKey}
region String ​ | Region in which the Project is hosted. |
projectKey String ​ | key of the Project. |
id String ​ | id of the PaymentMethod. |
curl --head https://api.{region}.commercetools.com/{projectKey}/payment-methods/{id} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}"
Check if PaymentMethod exists by Key
key
.
Returns a 200 OK
status if the PaymentMethod exists; otherwise, returns a Not Found.view_payment_methods:{projectKey}
region String ​ | Region in which the Project is hosted. |
projectKey String ​ | key of the Project. |
key String ​ | key of the PaymentMethod. |
curl --head https://api.{region}.commercetools.com/{projectKey}/payment-methods/key={key} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}"
Check if PaymentMethod exists by Query Predicate
200 OK
status if any PaymentMethods match the query predicate; otherwise, returns a Not Found.view_payment_methods:{projectKey}
region String ​ | Region in which the Project is hosted. |
projectKey String ​ | key of the Project. |
where | The parameter can be passed multiple times. |
curl --head https://api.{region}.commercetools.com/{projectKey}/payment-methods -i \
--header "Authorization: Bearer ${BEARER_TOKEN}"
Create PaymentMethod
manage_payment_methods:{projectKey}
region String ​ | Region in which the Project is hosted. |
projectKey String ​ | key of the Project. |
expand | The parameter can be passed multiple times. |
application/json
application/json
curl https://api.{region}.commercetools.com/{projectKey}/payment-methods -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" \
--header 'Content-Type: application/json' \
--data-binary @- << DATA
{
"key" : "my-payment-method",
"customer" : {
"id" : "c7555392-a14c-48c8-9021-73d5d302b565",
"typeId" : "customer"
},
"businessUnit" : {
"key" : "my-bu",
"typeId" : "business-unit"
},
"token" : {
"value" : "PSPToken"
},
"method" : "Card",
"paymentInterface" : "Adyen",
"interfaceAccount" : "adyen-merchant-eu",
"default" : true,
"name" : {
"en" : "my custom localised name"
},
"paymentMethodStatus" : "Active"
}
DATA
{
"id": "c7555392-a14c-48c8-9021-73d5d302b562",
"key": "my-payment-method",
"version": 1,
"versionModifiedAt": "2025-01-20T16:38:00.292Z",
"lastMessageSequenceNumber": 1,
"createdAt": "2025-01-20T16:38:00.292Z",
"lastModifiedAt": "2025-01-20T16:38:00.292Z",
"customer": {
"id": "c7555392-a14c-48c8-9021-73d5d302b565",
"typeId": "customer"
},
"businessUnit": {
"key": "my-bu",
"typeId": "business-unit"
},
"token": {
"value": "PSPToken"
},
"method": "Card",
"paymentInterface": "Adyen",
"interfaceAccount": "adyen-merchant-eu",
"default": true,
"name": {
"en": "my custom localised name"
},
"customFields": null,
"paymentMethodStatus": "Active"
}
Update PaymentMethod
Update PaymentMethod by ID
manage_payment_methods:{projectKey}
region String ​ | Region in which the Project is hosted. |
projectKey String ​ | key of the Project. |
id String ​ | id of the PaymentMethod. |
expand | The parameter can be passed multiple times. |
application/json
version ​Int​ | Expected version of the PaymentMethod on which the changes should be applied.
If the expected version does not match the actual version, a ConcurrentModification error will be returned. |
actions ​Array of PaymentMethodUpdateAction​ | Update actions to be performed on the PaymentMethod. |
application/json
curl https://api.{region}.commercetools.com/{projectKey}/payment-methods/{id} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" \
--header 'Content-Type: application/json' \
--data-binary @- << DATA
{
"version" : 1,
"actions" : [ {
"action" : "setPaymentMethodStatus",
"paymentMethodStatus" : "Active"
} ]
}
DATA
{
"id": "c7555392-a14c-48c8-9021-73d5d302b562",
"key": "my-payment-method",
"version": 1,
"versionModifiedAt": "2025-01-20T16:38:00.292Z",
"lastMessageSequenceNumber": 1,
"createdAt": "2025-01-20T16:38:00.292Z",
"lastModifiedAt": "2025-01-20T16:38:00.292Z",
"customer": {
"id": "c7555392-a14c-48c8-9021-73d5d302b565",
"typeId": "customer"
},
"businessUnit": {
"key": "my-bu",
"typeId": "business-unit"
},
"token": {
"value": "PSPToken"
},
"method": "Card",
"paymentInterface": "Adyen",
"interfaceAccount": "adyen-merchant-eu",
"default": true,
"name": {
"en": "my custom localised name"
},
"customFields": null,
"paymentMethodStatus": "Active"
}
Update PaymentMethod by Key
manage_payment_methods:{projectKey}
region String ​ | Region in which the Project is hosted. |
projectKey String ​ | key of the Project. |
key String ​ | key of the PaymentMethod. |
expand | The parameter can be passed multiple times. |
application/json
version ​Int​ | Expected version of the PaymentMethod on which the changes should be applied.
If the expected version does not match the actual version, a ConcurrentModification error will be returned. |
actions ​Array of PaymentMethodUpdateAction​ | Update actions to be performed on the PaymentMethod. |
application/json
curl https://api.{region}.commercetools.com/{projectKey}/payment-methods/key={key} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}" \
--header 'Content-Type: application/json' \
--data-binary @- << DATA
{
"version" : 1,
"actions" : [ {
"action" : "setPaymentMethodStatus",
"paymentMethodStatus" : "Active"
} ]
}
DATA
{
"id": "c7555392-a14c-48c8-9021-73d5d302b562",
"key": "my-payment-method",
"version": 1,
"versionModifiedAt": "2025-01-20T16:38:00.292Z",
"lastMessageSequenceNumber": 1,
"createdAt": "2025-01-20T16:38:00.292Z",
"lastModifiedAt": "2025-01-20T16:38:00.292Z",
"customer": {
"id": "c7555392-a14c-48c8-9021-73d5d302b565",
"typeId": "customer"
},
"businessUnit": {
"key": "my-bu",
"typeId": "business-unit"
},
"token": {
"value": "PSPToken"
},
"method": "Card",
"paymentInterface": "Adyen",
"interfaceAccount": "adyen-merchant-eu",
"default": true,
"name": {
"en": "my custom localised name"
},
"customFields": null,
"paymentMethodStatus": "Active"
}
Update actions
Set Key
action ​String​ | "setKey" |
key ​String​ | Value to set. If empty, any existing value will be removed. MinLength:Â2 ​MaxLength: 256 ​Pattern: ^[A-Za-z0-9_-]+$ ​ |
{
"action": "setKey",
"key": "payment-method-key"
}
Set Name
action ​String​ | "setName" |
name ​ | Value to set. If empty, any existing value will be removed. |
{
"action": "setName",
"name": {
"de": "German name",
"en": "English name"
}
}
Set Method
action ​String​ | "setMethod" |
method ​String​ | New payment method—for example, a credit card or cash advance. If empty, any existing value will be removed. |
{
"action": "setMethod",
"method": "newMethod"
}
Set Default
action ​String​ | "setDefault" |
default ​Boolean​ | Value to set. |
{
"action": "setDefault",
"default": true
}
Set PaymentMethodStatus
action ​String​ | "setPaymentMethodStatus" |
paymentMethodStatus ​ | Value to set. |
{
"action": "setPaymentMethodStatus",
"paymentMethodStatus": "Active"
}
Set PaymentInterface
action ​String​ | "setPaymentInterface" |
paymentInterface ​String​ | New payment service that processes the Payment—for example, a PSP. If empty, any existing value will be removed. |
{
"action": "setPaymentInterface",
"paymentInterface": "newInterface"
}
Set InterfaceAccount
action ​String​ | "setInterfaceAccount" |
interfaceAccount ​String​ | New account or instance of the payment interface. If empty, any existing value will be removed. |
{
"action": "setInterfaceAccount",
"interfaceAccount": "newInterfaceAccount"
}
Set Custom Type
action ​String​ | "setCustomType" |
type ​ | Defines the Type that extends the PaymentMethod with Custom Fields.
If absent, any existing Type and Custom Fields are removed from the PaymentMethod. |
fields ​ | Sets the Custom Fields fields for the PaymentMethod. |
{
"action": "setCustomType",
"type": {
"id": "{{type-id}}",
"typeId": "type"
},
"fields": {
"exampleStringField": "TextString"
}
}
Set CustomField
action ​String​ | "setCustomField" |
name ​String​ | Name of the Custom Field to add, update, or remove. |
value ​ | If value is absent or null , this field will be removed if it exists.
Trying to remove a field that does not exist will fail with an InvalidOperation error.
If value is provided, it is set for the field defined by name . |
{
"action": "setCustomField",
"name": "exampleStringField",
"value": "TextString"
}
Delete PaymentMethod
Delete PaymentMethod by ID
manage_payment_methods:{projectKey}
region String ​ | Region in which the Project is hosted. |
projectKey String ​ | key of the Project. |
id String ​ | id of the PaymentMethod. |
version Int ​ | Last seen version of the resource. |
expand | The parameter can be passed multiple times. |
application/json
curl -X DELETE https://api.{region}.commercetools.com/{projectKey}/payment-methods/{id}?version={version} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}"
{
"id": "c7555392-a14c-48c8-9021-73d5d302b562",
"key": "my-payment-method",
"version": 1,
"versionModifiedAt": "2025-01-20T16:38:00.292Z",
"lastMessageSequenceNumber": 1,
"createdAt": "2025-01-20T16:38:00.292Z",
"lastModifiedAt": "2025-01-20T16:38:00.292Z",
"customer": {
"id": "c7555392-a14c-48c8-9021-73d5d302b565",
"typeId": "customer"
},
"businessUnit": {
"key": "my-bu",
"typeId": "business-unit"
},
"token": {
"value": "PSPToken"
},
"method": "Card",
"paymentInterface": "Adyen",
"interfaceAccount": "adyen-merchant-eu",
"default": true,
"name": {
"en": "my custom localised name"
},
"customFields": null,
"paymentMethodStatus": "Active"
}
Delete PaymentMethod by Key
manage_payment_methods:{projectKey}
region String ​ | Region in which the Project is hosted. |
projectKey String ​ | key of the Project. |
key String ​ | key of the PaymentMethod. |
version Int ​ | Last seen version of the resource. |
expand | The parameter can be passed multiple times. |
application/json
curl -X DELETE https://api.{region}.commercetools.com/{projectKey}/payment-methods/key={key}?version={version} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}"
{
"id": "c7555392-a14c-48c8-9021-73d5d302b562",
"key": "my-payment-method",
"version": 1,
"versionModifiedAt": "2025-01-20T16:38:00.292Z",
"lastMessageSequenceNumber": 1,
"createdAt": "2025-01-20T16:38:00.292Z",
"lastModifiedAt": "2025-01-20T16:38:00.292Z",
"customer": {
"id": "c7555392-a14c-48c8-9021-73d5d302b565",
"typeId": "customer"
},
"businessUnit": {
"key": "my-bu",
"typeId": "business-unit"
},
"token": {
"value": "PSPToken"
},
"method": "Card",
"paymentInterface": "Adyen",
"interfaceAccount": "adyen-merchant-eu",
"default": true,
"name": {
"en": "my custom localised name"
},
"customFields": null,
"paymentMethodStatus": "Active"
}