Webhooks allow you to receive instant notifications of configured events that happen on Xsolla’s side. You can use webhooks to automate back-end and supplementary functions of your application.
Examples of events that you can be notified about:
When a configured event occurs, Xsolla notifies your system about it via webhooks. For example, you can do the following after receiving a webhook:
Below is an example of how a payment processing webhook works:
The following settings have to be applied for webhooks to work correctly:
185.30.20.0/24
, 185.30.21.0/24
, 185.30.23.0/24
.Notice
If your listener receives a webhook with an existing transaction ID, it must return the previous result for that transaction. It is not recommended to charge the user twice or create duplicate records in the database.
Note
Xsolla API accepts conventional HTTP response codes for successful and failed requests. Code 204 indicates successful processing.
As internet connections are not always 100% reliable, webhooks may be lost or delayed. To address this issue, Xsolla resends failed webhooks until your listener receives them. Webhook resends are sent within 12 hours after the previous one until your listener confirms receiving. The maximum number of retries is 12.
Note
Although connection problems may result in lost, delayed, or duplicate webhooks, the most common cause is incorrect logic on the listener side.
Digital signatures enable secure data transmission. To generate a signature:
POST /your_uri HTTP/1.1
host: your.host
accept: application/json
content-type: application/json
content-length: 165
authorization: Signature 52eac2713985e212351610d008e7e14fae46f902
{
"notification_type":"user_validation",
"user":{
"ip":"127.0.0.1",
"phone":"18777976552",
"email":"email@example.com",
"id":1234567,
"name":"Xsolla User",
"country":"US"
}
}
curl -v 'https://your.hostname/your/uri' \
-X POST \
-H 'authorization: Signature 52eac2713985e212351610d008e7e14fae46f902' \
-d '{
"notification_type":
"user_validation",
"user":
{
"ip": "127.0.0.1",
"phone": "18777976552",
"email": "email@example.com",
"id": 1234567,
"name": "Xsolla User",
"country": "US"
}
}'
Error codes for HTTP code 400:
Code | Message |
---|---|
INVALID_USER | Invalid user |
INVALID_PARAMETER | Invalid parameter |
INVALID_SIGNATURE | Invalid signature |
INCORRECT_AMOUNT | Incorrect amount |
INCORRECT_INVOICE | Incorrect invoice |
HTTP/1.1 400 Bad Request
{
"error":{
"code":"INVALID_USER",
"message":"Invalid user"
}
}