Set up webhooks
If you want to receive notifications about events (e.g. change of the payment status), set up webhooks in Publisher Account:
- Open your project in Publisher Account.
- Click Project settings in the side menu and go to Webhooks.
- Set the Webhooks toggle to On.
- Specify the webhook URL.
- A secret key to sign project webhooks is generated by default. If you want to generate a new secret key, click the refresh icon.
- Click Save settings.
We recommend that you implement the following webhooks:
|User validation||Sent at different stages of the payment process to ensure the user is registered in the game.|
|Payment||Sent when an order is paid and contains payment data and transaction details.|
|Successful payment of the order||Sent when a Payment webhook has been successfully processed and contains information about purchased items and the transaction ID. Use the data from the webhook to add items to the user.|
|Refund||Sent when an order has been canceled and contains information about the details of the canceled payment and transaction details.|
|Partial refund||Sent when an order has been partially canceled and contains information about the details of the canceled payment and transaction details.|
Generation of signature
When receiving a webhook, you should ensure the security of data transmission. To achieve this, a signature must be generated from the webhook data and verified that it matches the signature sent in the HTTP request header.
To generate a signature:
- Concatenate the JSON from the request body and the project's secret key.
- Apply the SHA-1 cryptographic hash function to the string obtained in the first step.
Sending responses to webhook
To confirm receipt of the webhook, your server must return:
204HTTP-code with no message body in case of a successful response.
400HTTP-code with description of the problem if the specified user was not found or an invalid signature was passed.
Your webhook handler may also return a
5xx code in case of temporary issues on your server.
If a response was not received for the Successful payment of the order and Order cancellation webhooks or if a response with a
5xx code was received, the webhooks are resent according to the following schedule:
- 2 attempts with a 5-minute interval
- 7 attempts with a 15-minute interval
- 10 attempts with a 60-minute interval
Maximum of 20 attempts to send webhooks are made within 12 hours from the first attempt.
If for the Payment webhook a response was not received or if a response with a
5xx code was received, webhooks are also resent with an increased time interval. A maximum of 12 attempts are made within 12 hours.
Grant purchase to user
After a successful payment, implement granting the purchase to the user in the game on your side. To receive notifications about successful payments and order details, configure the following webhooks:
Found a typo or other text error? Select the text and press Ctrl+Enter.