Skip to main content

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).

Warning

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.

Note

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

  1. The e-shop (backend) calls the Comgate REST API endpoint /v1.0/changePrice with a server-to-server request.
  2. Comgate verifies authorization, payment state and limits. On success, it returns code=0.
  3. The e-shop (frontend) calls the changePayment(transactionId) method on the running Core instance, which reflects the new amount in Checkout.

ℹ️ The /v1.0/changePrice call must be made from the e-shop server, not from the browser — it contains the sensitive secret parameter.

API endpoint /v1.0/changePrice

AttributeValue
MethodPOST
URLhttps://payments.comgate.cz/v1.0/changePrice
Content-Typeapplication/x-www-form-urlencoded

Request parameters

ParameterTypeRequiredDescription
merchantstringYesMerchant identifier in the Comgate system.
secretstringYesAPI password assigned when the connection was set up.
transIdstringYesIdentifier of the existing payment in the format XXXX-XXXX-XXXX.
newPriceintYesNew amount in the smallest currency unit (e.g. in hellers for CZK, cents for EUR). Must be positive.

Amount limits

  • newPrice must be a positive integer.
  • For the HUF currency, 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.

code=0&message=OK

Most common error states

codeHTTPMeaning
0200Change was successful.
1100418Unknown error.
1400400Transaction not foundtransId does not exist.
1400403Web Checkout SDK is not enabled for this shop connection.
1400403Dynamic price change is not enabled for this shop connection. — Comgate activation required.
1400403Payment is not in REQUESTED state. — the amount can only be changed for an unpaid payment.
1400403The price is above the maximum limit! — the amount exceeds the limit.
1400403Amount 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
$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)
}