It is a good idea to create an IPN listener page on your website and then specify the URL of the listener page in a "Integration → API" section in your Cryptopay account.
It is also important to note that you should use only https URL. Cryptopay then sends a secure POST request containing payment details of all transaction-related events to the URL.
Handling callbacks correctly is crucial to make sure your integration’s business logic works as expected. It is highly recommended to validate payment statuses and callbacks before acting on it inside your system.
The IPN listener page contains a custom script or a program that gets messages, validates them with Cryptopay, and then passes them to various backend applications for processing.
Take a look at examples of callbacks:
— for an invoice — here.
— for a channel — here.
— for a coin withdrawal — here.
Acknowledge events immediately
If your callbacks script performs complex logic, or makes network calls, it’s possible that the script would time out before Cryptopay sees its complete execution. Ideally, your callback handler code (notification of an event by returning a 200 status code) is separate from any other logic you do for that event.
Handle duplicate events
Callback endpoints might occasionally receive the same event more than once. We advise you to guard against duplicated event receipts. One way of doing this is logging the events you’ve processed, and then not processing the logged ones.
Retry logic
Cryptopay IPN server expects to get a 200 status code from you within 10 seconds. If the response code is different from 200 or a deadline is exceeded, we deliver your callbacks for up to one and a half days with an exponential backoff:
30 + num ^ 4 + num seconds where num is 0 to 19 retry