Handling callbacks
Overview
Introduction
A callback is a system message sent from the ecommpay payment platform to the merchant's web service. It contains information about a specific event in the payment platform that usually takes place in the context of processing a payment or storing customer payment data.
Callbacks allow merchants to receive information about various events. Along with that, the callback payload as well as the conditions of sending callbacks can be flexibly configured: you can define what data the callback should contain as well as specify in what cases, in what format, and where it should be sent. This article covers general information about callbacks, the procedure and special aspects of working with them.
A callback is a system message with information about a specific event sent from the ecommpay payment platform to the merchant's web service. This article covers general information about callbacks, the procedure and special aspects of working with them.
Callback types
Callbacks can be roughly divided into two groups: prescriptive (that require certain actions from the web service side) and informational (that are sent for informational purposes).
Callbacks can be roughly divided into two groups: prescriptive and informational.
Prescriptive callbacks are triggered by the necessity of a certain action: for example, specific data has to be sent to the payment platform, the customer must be provided with specific information or redirected to third-party services, and so on. Such callbacks always contain intermediate information, and you cannot opt out of receiving them since timely response to this category of callbacks is indispensable for payments to be processed correctly.
Prescriptive callbacks are triggered by the necessity of a certain action: for example, specific data has to be sent to the payment platform, the customer must be provided with specific information or redirected to third-party services, and so on. Such callbacks always contain intermediate information, and you cannot opt out of receiving them.
Informational callbacks are triggered by such events as the change of the payment status or the generation of the payment card token. These callbacks can contain intermediate or final payment information, and you can opt out of receiving them (selectively or fully).
Common use cases
Callbacks are typically triggered by the following events.
- Payment status has changed.
In this case, callbacks can contain intermediate or final information about payment processing.
- Actions on the web service side are required.
In this case, callbacks usually contain information for redirecting customers, displaying specific information to them, or specifying additional data necessary for payment processing.
- Payment card token has been generated or deleted.
In this case, callbacks contain information about events related to payment card tokens (such as token generation or deletion).
Setup and configuration
Configuring for projects
Callbacks for the merchant's production projects are usually set up during the integration of the web service with the ecommpay payment platform. Along with that, to change callback settings, you can always use the capabilities of Dashboard (details), specify certain parameters in payment requests, and when necessary, contact the ecommpay technical support specialists.
The following properties can be configured on the part of the merchant:
Callbacks for the merchant's production projects are usually set up during the integration of the web service with the ecommpay payment platform. Along with that, you can use the capabilities of Dashboard and the Gate API and contact our technical support to configure the following properties:
- Requirement for sending callbacks.
Callbacks can be triggered by all events or only by the events that correspond to the specified set of conditions. Such conditions include certain event types, payment methods as well as types and statuses of payments and operations. For example, callbacks can be disabled for the completed payouts and enabled for the declined ones. This allows you to promptly receive only the necessary information.
Callbacks can be triggered by all events or only by the events that correspond to the specified set of conditions. Such conditions include certain event types, payment methods as well as types and statuses of payments and operations.
- URLs for delivering callbacks.
Callbacks triggered by different events can be sent to different web service URLs with regard to the event type, the payment method, the payment type and status. For example, callbacks with final information about declined payments can be sent to one URL, while callbacks with final information about completed payments can be sent to another URL.
Callbacks triggered by different events can be sent to different web service URLs with regard to the event type, the payment method, the payment type and status.
- Delay time for sending callbacks.
If necessary, callbacks can be sent with a delay of up to 600 seconds (inclusive), for example, to streamline the handling of these callbacks on the web service side.
If necessary, callbacks can be sent with a delay of up to 600 seconds (inclusive).
- Set of parameters.
For more convenient handling of callbacks on the web service side, you can vary their payload by adding and removing parameters, changing their names, and setting the requirement to include parameters with empty values. At the same time, you cannot change the callback structure and remove required parameters.
Bear in mind that certain parameters can be required for all or only specific types of callbacks. The required parameters are always included in callbacks, while the optional ones are only sent in cases when the corresponding information has been received, or when sending such parameters with empty values has been set up.
Thus, callbacks triggered by the same events can include different information depending on the settings.
You can vary the callback payload by adding and removing parameters, changing their names, and setting the requirement to include parameters with empty values. At the same time, you cannot change the callback structure and remove required parameters.
Managing callbacks for individual payments
When processing payments via Gate, you can set up the URLs where callbacks will be delivered to, the requirement, and the delay time for sending callbacks. To do this, use the following parameters when sending payment requests:
merchant_callback_url
(passed in thegeneral
object)—the callback URL for this specific request;force_disable
(passed in thecallback
object)—an indicator for disabling callbacks (possible values:true
, for disabling callbacks with information about the given payment, andfalse
, for enabling these callbacks).delay
(passed in thecallback
object)—the delay time for sending callbacks, in seconds (possible values are 0 to 600; for example42
);
To learn if these parameters can be used in requests to certain endpoints, see the Gate API specification.
Use
Handling callbacks
A callback is an HTTP POST message sent to the URL provided by the merchant. The procedure of responding to each callback on the web service side consists of the following steps:
The procedure of responding to each callback on the web service side consists of the following steps:
- Accept and verify the callback.
Callbacks should be accepted only if they have been sent from the payment platform's IP addresses provided by the ecommpay technical support specialists. Along with that, it is recommended not to limit the waiting time for callbacks since different events can occur at different times while callbacks can be sent with a specified delay.
The callback sender and data integrity should be validated by way of verifying the signature included in every callback. For more information, see Signature generation and verification.
Callbacks should be accepted only if they have been sent from the payment platform IP addresses provided by the ecommpay technical support specialists, and the waiting time for callbacks should not be limited. Along with that, data integrity should be validated by way of verifying the signature included in every callback.
- Confirm the callback receipt.
For confirming the receipt of callbacks, synchronous HTTP responses should be sent to the payment platform with the corresponding response codes. If no errors have been detected upon the receipt, the response code should be
200 OK
. In other cases, the response code should correspond to the error type: for example, useHTTP 400 Bad Request
if a parameter string could not be converted into an array orHTTP 500 Internal Server Error
if the callback has been received at an incorrect URL of the web service.For confirming the receipt of callbacks, synchronous HTTP responses should be sent to the payment platform with the corresponding response codes. If no errors have been detected upon the receipt, the response code should be
200 OK
. In other cases, the response code should correspond to the error type: for example,HTTP 400 Bad Request
.If the
200 OK
response has not been received from the web service, the callback will be sent again regardless of the error type. - Perform the required actions.
Upon the receipt of prescriptive callbacks, the actions that are stated in these callbacks as required should be performed; and upon the receipt of informational callbacks, the actions that correspond to the aspects of the web service operation should be performed (for example, customer notification).
Resending callbacks
If the information about a callback receipt error has been communicated to the payment platform or the callback receipt has not been confirmed, this callback is sent again. Keep in mind that the data in such callbacks can change due to the changes of the corresponding information in the payment platform: for example, if a payment status changes, all subsequent callbacks contain the newly assigned status.
Generally, resending callbacks is carried out as follows:
If the information about a callback receipt error has been communicated to the payment platform or the callback receipt has not been confirmed, this callback is sent again. Resending callbacks is carried out as follows:
- 6 attempts at an increasing interval of 10 to 60 seconds. The interval increases by 10 seconds at each attempt.
- 58 attempts at an increasing interval of 84 seconds to 2.5 hours.
The interval, measured in seconds, is increased according to the formula
70 + 10 × 1.12n − 4
where n is the sequence number of the attempt. - 56 attempts every 4 hours until a total of 120 attempts is reached. After that, callbacks triggered by the given event are no longer sent.
This order can slightly change depending on the load on servers and communication channels, but in general the time span for automatic callback delivery attempts does not exceed 11 days. You can change this order via the ecommpay technical support specialists.
You can change this order via the ecommpay technical support specialists.
In addition to automatic resending of callbacks, you can also initiate one-time resending via Dashboard and Telegram bot if necessary.
Troubleshooting
There can be cases when callbacks are not received at the specified URLs for various reasons. These situations and the ways to resolve them can be divided into the following groups:
- There are no callbacks triggered by any of the events.
This can happen because certain requests and events have not been initiated in the platform, or issues with communication channels have been detected, or the web service URLs are invalid, or callbacks have been disabled in the project.
In such cases, it is recommended to proceed as follows:
- Ensure that the correct requests (i.e. they do not disable callbacks) were sent from the web service and accepted in the platform. It may be necessary to send a test request, for example, to generate a payment card token.
- If requests are accepted in the platform, but callbacks are still not received, check if the URLs for delivering callbacks are correct. If problems are found, fix the URLs or replace them with the correct ones—on your own via Dashboard, or with the help of the ecommpay technical support specialists.
- If the previous steps did not help, contact the ecommpay technical support specialists.
- There are no callbacks triggered by specific event types.
This can happen for the following reasons: there are no events of such types, web service URLs are invalid, or callbacks have been disabled for such event types.
In such cases, it is recommended to proceed as follows:
- Ensure that the events of the types for which callbacks are not received have been initiated. You can do this by using payment information tabs in the Dashboard interface.
- Check the correctness of the URLs for receiving callbacks triggered by the corresponding event types. If problems are found, fix the URLs or replace them by the correct ones—on your own via Dashboard, or with the help of the ecommpay technical support specialists.
- If the previous steps did not help, contact the ecommpay technical support specialists.
- There are no callbacks for a specific operation.
This can happen because the
callback
object in the request for processing the operation contains theforce_disable
parameter with thetrue
value.In this case, you can check the operation status via Gate using requests for checking current payment information (details), Dashboard, and Telegram bot.
There can be cases when callbacks are not received at the specified URLs for various reasons: for example, certain requests and events have not been initiated in the platform, or issues with communication channels have been detected, or the web service URLs are invalid. The merchant can handle such situations as follows:
- Ensure that callbacks are not disabled for the whole project in use or for certain event types in the project.
- Ensure that the correct requests (i.e. they do not disable callbacks) were sent from the web service and accepted in the platform. It may be necessary to send a test request.
- Check if the URLs for delivering callbacks are correct. If problems are found, fix the URLs or replace them by the correct ones—on your own via Dashboard, or with the help of the ecommpay technical support specialists.
- If the previous steps did not help, contact the ecommpay technical support specialists.
Callback parameters
Callback parameters for payments and operations
The set of parameters sent in callbacks with payments and operations information can be standard or customised for separate projects. The following table contains the standard set of parameters.
Parameter | Description | tree |
---|---|---|
account |
Object with the customer's payment details (for example, the details of a payment card, an account, or a digital wallet). | 10 |
card_holder |
Cardholder's name. Example: |
10-10 10 |
expiry_month |
Payment card expiration month. Example: |
10-20 10 |
expiry_year |
Payment card expiration year. Example: |
10-30 10 |
id |
Saved payment data identifier used in the payment platform (details). Example: |
10-40 10 |
number |
Masked number or another identifier of the customer's payment instrument (for example, a payment card, an account, or a digital wallet). Example: |
10-50 10 |
token |
Payment card token if it has been generated during the request execution (details). |
10-60 10 |
type |
Payment card brand that was used in the processing of the payment: amex , mastercard , maestro , visa and others |
10-70 10 |
acs |
Object with information about the result of the customer's 3‑D Secure authentication. | 20 |
acs_url |
URL of the page to which the customer is redirected for the 3‑D Secure authentication (ACS page). |
20-10 20 |
md |
Merchant data received from a global card network during the customer's 3‑D Secure authentication. |
20-20 20 |
pa_req |
PAReq (Payer Authentication Request) message received during the customer's 3‑D Secure authentication 3‑D Secure. | 20-30 20 |
avs_data |
Object with information about the Address Verification Service check (AVS, details) | 30 |
avs_post_code |
Customer's postal code passed for performing the AVS check. Example: |
30-10 30 |
avs_street_address |
Customer's address passed for performing the AVS check. Example: |
30-20 30 |
avs_result |
Code of the AVS check result (details). Example: |
40 |
bank |
Object with information about the issuer of the payment card used during payment processing. | 50 |
name |
Issuer's name in the payment platform. Example: |
50-10 50 |
customer |
Object with customer information. | 70 |
billing |
Object with information about the customer's billing address received in the payment platform during payment processing. | 70-10 70 |
address |
Street name specified in the customer's billing address. Example: |
70-10-10 70-10 |
city |
City name specified in the customer's billing address. Example: |
70-10-20 70-10 |
country |
ISO 3166-1 alpha-2 code of the country specified in the customer's billing address. Example: |
70-10-30 70-10 |
postal |
Postal code specified in the customer's billing address. Example: |
70-10-40 70-10 |
region |
Name of the state, province, or region specified in the customer's billing address. Example: |
70-10-50 70-10 |
city |
Name of the customer's city. Example: |
70-20 70 |
country |
Code of the customer's country in the ISO 3166-1 alpha-2 format. Example: |
70-30 70 |
day_of_birth |
Customer's birth date in the format of DD-MM-YYYY. Example: |
70-40 70 |
first_name |
Customer's name. Example: |
70-50 70 |
id |
Customer's identifier within the merchant's project. Example: |
70-60 70 |
ip_address |
Customer's IP address relevant for the given operation. Example: |
70-70 70 |
last_name |
Customer's last name. Example: |
70-80 70 |
middle_name |
Customer's middle name. Example: |
70-90 70 |
phone |
Customer's phone number that contains 4 to 24 digits. Example: |
70-100 70 |
decision |
String with information about payment processing admissibility assessment performed on the payment platform side. | 80 |
decision_message |
Array of records with information about payment processing admissibility assessment performed on the payment platform side. Example: |
90 |
display_data |
Object with information that should be displayed to the customer. This object usually contains the data received from a provider or a payment system. The specifics of what information has to be displayed for various payment methods are usually described in the articles about these methods. Example: |
100 |
errors |
Array of error messages received during request execution. | 110 |
ErrorItem |
Object with information about the error that occurred during request execution. | 110-10 110 |
code |
Error code. Example: |
110-10-10 110-10 |
description |
Error reason details. Example: |
110-10-10 110-10 |
field |
Name of the parameter that was erroneously specified (if such parameter is identified). | 110-10-20 110-10 |
message |
Error code description. Example: |
110-10-30 110-10 |
interface_type |
Object with information about the way the payment was initiated. | 120 |
id |
Indicator of the interface that was used for sending the initial request:
|
120-10 120 |
user |
Details about an account of the Dashboard user who sent the initial request. Example: |
120-20 120 |
operation |
Object with information about the operations related to the payment. | 130 |
code |
Code of the operation status (details). Example: |
130-10 130 |
created_date |
Date and time of the operation creation. Example: |
130-20 130 |
date |
Date and time of the latest change of the operation status in the payment platform. Example: |
130-30 130 |
eci |
Indicator of the customer's 3‑D Secure authentication result (details). Example: |
130-40 130 |
id |
Operation identifier in the payment platform. Example: |
130-50 130 |
message |
Description of the operation status code (details). Example: |
130-60 130 |
provider |
Object with the payment result information received from a provider or a payment system. | 130-70 130 |
auth_code |
Authorisation code received from a provider or a payment system. Example: |
130-70-10 130-70 |
date |
Date and time of the payment processing completion on a provider or a payment system side. Example: |
130-70-20 130-70 |
endpoint_id |
CRC32 identifier of the payment gateway of a provider or a payment system. Example: |
130-70-30 130-70 |
id |
Identifier of a provider or a payment system in the payment platform. Example: |
130-70-40 130-70 |
payment_id |
Payment identifier on a provider or a payment system side. Example: |
130-70-50 130-70 |
recurring_retry |
Object with the information about retrying the debit operation executed as part of the regular COF purchase (details). | 130-75 130 |
next_retry_date |
Date and time of the next scheduled retry attempt. Example: |
130-75-10 130-75 |
next_retry_exists |
Indicator that shows whether the next scheduled attempt is available.
This parameter is required if the |
130-75-20 130-75 |
retry_count |
Identifier of the retry attempt for the specific debit operation (an integer from 1 to 7). Example: |
130-75-30 130-75 |
trigger_operation_id |
Identifier of the retried debit operation in the payment platform. Example: |
130-75-40 130-75 |
request_id |
Identifier of the latest request within the operation in the payment platform. |
130-80 130 |
status |
Operation status (according to the payment model). Example: |
130-90 130 |
sum_converted |
Object with information about the operation amount and currency after conversion (learn more about currency conversion). | 130-100 130 |
amount |
Operation amount. Specified in minor currency units (if they are applicable) or in major currency units. Example: |
130-100-10 130-100 |
currency |
Operation currency code in the ISO 4217 alpha-3 format. Example: |
130-100-20 130-100 |
sum_initial |
Object with information about the operation amount and currency sent in the request. | 130-110 130 |
amount |
Initial operation amount in minor currency units. Example: |
130-110-10 130-110 |
currency |
Code of the initial operation currency in the ISO 4217 alpha-3 format. Example: |
130-110-20 130-110 |
type |
Operation type (according to the payment model). Example: |
130-120 130 |
payment |
Object with essential payment details. | 140 |
cascading_with_redirect |
Indicator of the requirement to obtain customer's confirmation of an additional purchase attempt in case of the 3‑D Secure failure (details):
|
140-10 140 |
date |
Date and time of the latest payment status update in the payment platform. Example: |
140-20 140 |
description |
Payment description sent in the initial request. Example: |
140-30 140 |
id |
Payment identifier sent in the initial request. Example: |
140-40 140 |
is_new_attempts_available |
Indicator of the additional purchase attempt availability (details):
|
140-50 140 |
method |
Payment method code (details). Example: |
140-60 140 |
merchant_refund_id |
Refund identifier in the merchant's web service. Example: |
140-61 140 |
OperationFee |
Object with information about the fee amount. | 140-70 140 |
amount |
Fee amount in minor currency units if this amount is included in the total operation amount. | 140-70-10 140-70 |
currency |
Code of the charged fee currency in the ISO 4217 alpha-3 format. | 140-70-20 140-70 |
sum_with_surcharge |
Total amount of the operation and the fee surcharge in minor currency units. | 140-70-30 140-70 |
surcharge_amount |
Fee amount added to the payment amount in minor currency units (applicable to microfinancing organisations). | 140-70-40 140-70 |
surcharge_currency |
Code of the currency in which the fee added to the payment amount was charged (specified in the ISO 4217 alpha-3 format). | 140-70-50 140-70 |
region |
Code of the region of operation processing (details). Example: |
140-80 140 |
status |
Payment status (according to the payment model). Example: |
140-90 140 |
sum |
Object with payment amount and currency details. | 140-100 140 |
amount |
Payment amount with regard to all processed operations in minor currency units. Example: |
140-100-10 140-100 |
currency |
Payment code sent in the initial request in the ISO 4217 alpha-3 format. Example: |
140-100-20 140-100 |
timeout_attempts |
Time allocated for a purchase retry attempt (details), in seconds. Example: |
140-110 140 |
type |
Payment type (according to the payment model). Example: |
140-120 140 |
scheme_id |
Identifier of the operation that initialised a COF payment. Assigned by the global card scheme (Mastercard, Visa). Can be passed when the COF payment is registered in the European Economic Area. Example: |
210 |
project_id |
Merchant's project identifier in the payment system. Example: |
150 |
provider_extra_fields |
Object with the details received from a payment system or a provider. | 160 |
recurring |
Object with a COF purchase data (details) | 170 |
currency |
Code of the COF purchase currency in the ISO 4217 alpha-3 format. Example: |
170-10 170 |
id |
Identifier of the record of a series of funds debiting (details) in the payment platform. Example: |
170-20 170 |
register_payment_id |
Identifier of the record of a series of funds debiting (details) in the merchant's web service. Example: |
170-30 170 |
status |
Status of the record of a series of funds debiting (details):
|
170-40 170 |
type |
COF purchase type (details):
|
170-50 170 |
valid_thru |
Expiration date of the record about a series of funds debiting (details). Example: |
170-60 170 |
redirect_data |
Object with data for customer redirection. | 180 |
body |
Data for customer redirection. | 180-10 180 |
method |
Method required for sending the redirection request: POST or GET . |
180-20 180 |
url |
URL to which the customer should be redirected. | 180-30 180 |
signature |
Callback signature (details). | 190 |
Callback parameters for tokens
The set of parameters sent in callbacks triggered by actions with tokens (for example, creating or deleting a token) can be standard or customised for separate projects. The following table contains the standard set of parameters.
Parameter | Description | |
---|---|---|
general |
Object with general identification information from the initial tokenisation request. | 1 |
project_id |
Merchant's project identifier in the payment platform. Example: |
1-11 |
customer_id |
Customer identifier in the merchant's project. Example: |
1-21 |
signature |
Callback signature. | 1-31 |
request |
Object with the initial request information. | 2 |
id |
Initial request identifier. |
2-12 |
action |
Type of the initial request:
Callbacks can be sent without this parameter if a token was revoked due to its expiration that leads to automatic sending of the callback. |
2-22 |
status |
Request status:
|
2-32 |
errors |
Array with information about the errors that occurred during the request execution. This array is not sent in case of a successful request processing. |
2-42 |
ErrorItem |
Object with information about an error that occurred during the request execution. | 2-4-12-4 |
code |
Code of the error that occurred during the request execution. Example: |
2-4-1-12-4-1 |
message |
Error code description. Example: |
2-4-1-22-4-1 |
field |
Name of the parameter in the initial request where an error occurred. This name is sent if the corresponding parameter is identified. | 2-4-1-32-4-1 |
token |
Payment card token. |
3 |
token_created_at |
Date and time of the token generation. Example: |
4 |
token_status |
Token status:
|
5 |
Related topics
During the work with callbacks, the following information can come in handy:
- Interaction concepts—the section with general information about the interaction with the payment platform via Gate.
- Signature generation and verification—the section with information about the work with data signing.
- Information of operations performing—the section with information about the error codes used in the payment platform.
- Monitoring and performing payments—the section with information about processing and monitoring payments and operations via Dashboard.
- Managing Telegram support bot—the section with information about processing payment and operations with the help of the Telegram bot.
- Using tokens—the section with information about working with card tokens.
- API Reference—the Gate API interface specification.