Dynamic amount
The dynamic amount feature allows you to change the amount of an already created payment without having to create a new payment. It is primarily used in situations where, after payment initiation, the order content still changes in the cart (e.g. adding an item, discount, shipping change) and the e-shop wants to avoid a complete page reload and recreating the payment.
After successfully changing the amount on the API side, in the browser it is necessary to call the changePayment() method, which reloads the payment in the running Core instance and updates the displayed information in the functional modules (e.g. Apple Pay, Google Pay).
The feature is not enabled by default. To be able to use it, the dynamic amount flag must be enabled on the Comgate side for the specific shop connection. Activation is handled by the Comgate sales department.
The dynamic amount can only be changed for payments in the REQUESTED state (i.e. as long as the payer has not yet submitted the payment for processing).
Amount change flow
- The e-shop (backend) calls the Comgate REST API endpoint
/v1.0/changePricewith aserver-to-serverrequest. - Comgate verifies authorization, payment state and limits. On success, it returns
code=0. - The e-shop (frontend) calls the
changePayment(transactionId)method on the running Core instance, which reflects the new amount in Checkout.
ℹ️ The
/v1.0/changePricecall must be made from the e-shop server, not from the browser — it contains the sensitivesecretparameter.
API endpoint /v1.0/changePrice
| Attribute | Value |
|---|---|
| Method | POST |
| URL | https://payments.comgate.cz/v1.0/changePrice |
| Content-Type | application/x-www-form-urlencoded |
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
merchant | string | Yes | Merchant identifier in the Comgate system. |
secret | string | Yes | API password assigned when the connection was set up. |
transId | string | Yes | Identifier of the existing payment in the format XXXX-XXXX-XXXX. |
newPrice | int | Yes | New amount in the smallest currency unit (e.g. in hellers for CZK, cents for EUR). Must be positive. |
Amount limits
newPricemust be a positive integer.- For the
HUFcurrency, the amount must always end with two zeros (00) — HUF does not support decimal places.
Response
The response body is in application/x-www-form-urlencoded format.
- Success
- Error
code=0&message=OK
code=1400&message=Payment+is+not+in+REQUESTED+state.+Price+can+only+be+changed+for+REQUESTED+payments.
Most common error states
code | HTTP | Meaning |
|---|---|---|
0 | 200 | Change was successful. |
1100 | 418 | Unknown error. |
1400 | 400 | Transaction not found — transId does not exist. |
1400 | 403 | Web Checkout SDK is not enabled for this shop connection. |
1400 | 403 | Dynamic price change is not enabled for this shop connection. — Comgate activation required. |
1400 | 403 | Payment is not in REQUESTED state. — the amount can only be changed for an unpaid payment. |
1400 | 403 | The price is above the maximum limit! — the amount exceeds the limit. |
1400 | 403 | Amount X CUR is not supported by any available payment method. |
Implementation example
API call from the e-shop server (simple cURL example in PHP) and subsequent Checkout reload in the browser:
- PHP — backend
- JavaScript — frontend
<?php
$ch = curl_init('https://payments.comgate.cz/v1.0/changePrice');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
'merchant' => $merchantId,
'secret' => $secret,
'transId' => $transId,
'newPrice' => $newPriceInHellers, // e.g. 12500 = 125.00 CZK
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$body = curl_exec($ch);
$http = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
parse_str($body, $response);
if (($response['code'] ?? null) === '0') {
// OK — send the browser an instruction to call changePayment(transId)
}
// After a successful backend response, we call changePayment on the running Core instance.
instanceCore.changePayment('XXXX-XXXX-XXXX')
.then(() => {
console.log('Checkout reloaded with the new amount.');
})
.catch((error) => {
console.error('Failed to reload Checkout:', error);
});