Skip to main content

Push Notifications

Payment Result Delivery in the Background

Push notifications are used to deliver the payment result in the background from the Comgate payment gateway to the merchant's server. This method utilizes an HTTP request (webhook) to a defined endpoint that notifies of a payment status change, such as successful completion, authorization, expiration, or cancellation.

Secure Verification of Payment Status

It is recommended to always verify the actual payment status by calling the API method /status. This verification ensures reliability and security, as information received via push notification may not always accurately reflect the final payment status.

Setting the Endpoint for Push Notifications

The address to which push notifications should be sent can be set in the client portal. It is recommended to set an address that supports HTTPS to ensure secure communication.

Push Notification Parameters

The payment result is delivered as an HTTP POST request with the following parameters:

ParameterTypeRequiredDescription
transIdstringYesUnique transaction ID
merchantstringYesE-shop identifier in the Comgate system
testbooleanYestrue for test payment, false for production
priceintegerYesProduct price in cents or pence
currstringYesCurrency code according to ISO 4217
labelstringYesShort product description (1-16 characters)
refIdstringYesPayment reference (e.g., variable symbol or order number)
payerIdstringNoPayer identifier in the e-shop system
payerNamestringNoPayer account name
payerAccstringNoPayer account number
methodstringNoPayment method used
accountstringNoE-shop's bank account identifier
emailstringYesPayer's contact email
phonestringNoPayer's contact phone
namestringNoProduct identifier for statistics
secretstringYesSecurity key for communication
statusstringYesCurrent transaction status (PAID, CANCELLED, AUTHORIZED)
feestringNoTransaction fee (if applicable)
fullNamestringYesPayer's full name
billingAddrCitystringNoBilling address - city
billingAddrStreetstringNoBilling address - street
billingAddrPostalCodestringNoBilling address - postal code
billingAddrCountrystringNoBilling address - country (ISO 3166 alpha-2)
deliverystringNoDelivery method (HOME_DELIVERY, PICKUP, ELECTRONIC_DELIVERY)
homeDeliveryCitystringNoDelivery address - city
homeDeliveryStreetstringNoDelivery address - street
homeDeliveryPostalCodestringNoDelivery address - postal code
homeDeliveryCountrystringNoDelivery address - country (ISO 3166 alpha-2)
categorystringNoProduct category (PHYSICAL_GOODS_ONLY, OTHER)
Warning

Results delivered via notification or URL redirection should not be considered fully trustworthy, as these methods can be prone to manipulation. It is recommended to always verify the actual payment status using the API method /status together with the received transId.

Response Parameters

ParameterTypeRequiredDescription
codeintegerYesMethod return code and error description: the system expects HTTP code 200 if the payment result was received successfully.

Push notifications expect an acknowledgment in the form of HTTP code 200. Otherwise, the notification is resent repeatedly (up to 1,000 attempts). If repeated attempts fail, an error message is generated and sent to the merchant's contact email.

Tip: If the notification receipt is not confirmed, ensure that the endpoint returns code 200. You can also set an email for error reporting in the Integration section of the client portal, where you can define multiple emails separated by semicolons.

Example Payment Result Delivery – HTTP request using cURL

curl -X POST -i --data "merchant=merchant_com&test=false&price=10000&curr=CZK&label=Beatles%20-%20Help&refId=2010102600&method=CARD&email=info%40customer.com&phone=%2B420123456789&transId=AB12-EF34-IJ56&secret=ZXhhbXBsZS5jb206QUJDeHl6&status=PAID" https://example.com/handler.php

Example Payment Result Delivery – HTTP response

HTTP/1.1 200 OK
content-type: application/x-www-form-urlencoded; charset=UTF-8

Communication between the Client's system and the payment gateway server is secured using a password and IP whitelist. Access must only be allowed from the payment gateway server's IP address. IP ranges are defined in the Security section. It is mandatory to use the HTTPS protocol to prevent password exposure in case of eavesdropping. The password is passed as a POST parameter (not a GET parameter) to avoid being logged in the web server's communication log.

The e-shop must ensure that goods (services) provided in the paid transaction (identified by the unique transaction ID) are issued to the Payer only once, even if the result of the same payment is passed to the Client's server multiple times.

Implementation and Code Example

Example of an Endpoint for Receiving Push Notifications

<?php
// Webhook endpoint for push notification
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Load data from push notification using POST (x-www-form-urlencoded) or REST (JSON)

// POST method (x-www-form-urlencoded)
parse_str(file_get_contents('php://input'), $data);

// REST method (JSON)
// $data = json_decode(file_get_contents('php://input'), true);

if (isset($data['transId'])) {
$paymentId = $data['transId'];

// Prepare headers and parameters for payment verification
$headers = [
'Content-Type: application/x-www-form-urlencoded',
'Accept: application/x-www-form-urlencoded',
];
$request_params = [
'merchant' => '123456',
'transId' => $paymentId,
'secret' => 'gx4q8OV3TJt6noJnfhjqJKyX3Z6Ych0y',
];

// Initialize cURL for API call
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://payments.comgate.cz/v1.0/status');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($request_params));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

try {
// Execute cURL request
$response = curl_exec($ch);
if ($response === false) {
throw new Exception(curl_error($ch), curl_errno($ch));
}
// Output API response for verification
print_r($response);
} catch (Exception $e) {
print_r($e->getMessage());
} finally {
curl_close($ch);
}

// Respond to push notification
http_response_code(200);
echo "OK";
} else {
http_response_code(400);
echo "Bad Request";
}
}
?>