Skip to main content

Update Payment Rules

Replaces the store's checkout payment rules, invoice payment rules, or both. Rules are applied in the order you send them.

HTTP Request​

  • URL: /paymentRules
  • Method: PUT
  • Headers:
    • accessToken: Required. Your API access token.
    • Content-Type: application/json
  • Required scope: READ_WRITE_PAYMENT

Request Body​

The request body is a JSON object with the following fields. Send at least one of them.

FieldTypeRequiredDescription
rulesArrayNoThe full list of checkout payment rules. Send an empty list to remove them all.
invoiceRulesArrayNoThe full list of invoice payment rules. Send an empty list to remove them all.

Rule Object​

FieldTypeRequiredDescription
idStringNoID of an existing rule, to keep its ID. Leave out for a new rule.
nameStringYesName of the rule.
activeBooleanNoWhether the rule is applied. Default is true.
conditionsObjectNoWhen the rule applies. See Conditions Object.
actionObjectYesWhat the rule does. See Action Object.
action.typeStringYeshide, surcharge or rename.

cURL Example​

curl --location --request PUT '<BASE_URL>/paymentRules' \
--header 'accessToken: <ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"rules": [
{
"id": "6712b0c4e5a1f2d3c4b5a697",
"name": "Card fee for B2C",
"conditions": { "audiences": ["b2c"] },
"action": {
"type": "surcharge",
"targets": [{ "method": "67644189a909f37370551d41", "types": ["card"] }],
"surcharge": { "percent": 3, "label": "Card processing fee" }
}
},
{
"name": "Rename PO for B2B",
"conditions": { "audiences": ["b2b"] },
"action": {
"type": "rename",
"targets": [{ "method": "67644189a909f37370551d44" }],
"label": "Pay on account"
}
}
]
}'

Response​

  • 200 OK: The payment rules were updated successfully.
  • 401 Unauthorized: The access token is missing or invalid.
  • 403 Forbidden: The access token does not have the required scope.
  • 400 Bad Request: The request body is empty, or a rule is missing its name or action.type.

Sample JSON Response​

{
"success": true,
"message": "Payment rules updated successfully",
"data": {
"rules": [
{
"id": "6712b0c4e5a1f2d3c4b5a697",
"name": "Card fee for B2C",
"active": true,
"conditions": {
"audiences": [
"b2c"
],
"companies": [],
"companyGroups": [],
"customers": [],
"orderTotal": {
"min": null,
"max": null,
"byCurrency": {}
},
"cart": {
"mode": "contains",
"target": null,
"products": [],
"categories": [],
"productGroups": []
},
"shippingMethods": [],
"currencies": []
},
"action": {
"type": "surcharge",
"targets": [
{
"method": "67644189a909f37370551d41",
"types": [
"card"
]
}
],
"surcharge": {
"percent": 3,
"fixed": 0,
"fixedByCurrency": {},
"label": "Card processing fee"
}
}
},
{
"id": "6712b1d8e5a1f2d3c4b5a6a2",
"name": "Rename PO for B2B",
"active": true,
"conditions": {
"audiences": [
"b2b"
],
"companies": [],
"companyGroups": [],
"customers": [],
"orderTotal": {
"min": null,
"max": null,
"byCurrency": {}
},
"cart": {
"mode": "contains",
"target": null,
"products": [],
"categories": [],
"productGroups": []
},
"shippingMethods": [],
"currencies": []
},
"action": {
"type": "rename",
"targets": [
{
"method": "67644189a909f37370551d44",
"types": []
}
],
"label": "Pay on account"
}
}
],
"invoiceRules": []
}
}

Response Details​

FieldTypeDescription
successBooleanWhether the request was successful.
messageStringConfirmation message.
data.rulesArrayThe saved checkout rules. See Payment Rule Data.
data.invoiceRulesArrayThe saved invoice rules. See Payment Rule Data.

Notes​

  • A list you leave out of the request is not changed. Within a list you send, rules you leave out are removed. To change one rule, get the current list with Get Payment Rules, edit it and send the full list back.
  • Surcharge amounts cannot be negative, and currency codes are saved in upper case.
  • For invoice rules, cart and shipping method conditions are cleared, and fees apply to the whole payment method.