# Webhook URL

## Description

The task of this functionality is to send data about the paid invoice to the merchant's server. This is necessary in order to automatically process the payment in the merchant's store and issue the product or service to your buyer.

The WH URL is set individually for each project as a link to the scripts and payment handlers inside the merchant's store.

Every time the invoice status changes to "Paid", the service sends a POST request to this URL in the following format:

```json
{
   "wallet":{
      "id":"47aa71e2-07a0-482e-9172-7114d7376ba0",
      "name":"usdt-tron",
      "blockchain":"tron",
      "cryptocurrency":"usdt",
      "address":"TKbstUwMzLrfTAGL4erYb7gc7ghmHQ9zG7"
   },
   "project":{
      "id":"9deea1e2-0c08-41a3-bdc2-a34eada3892d",
      "name":"My project",
      "commissionPayer":"seller",
      "commissionRate":"1"
   },
   "invoice":{
      "id":"a4c9e2ee-9a03-43e5-a1a1-00caf679d16a",
      "uid":"AFhygKX21ecd",
      "createDatetime":"2024-02-26 13:29:24",
      "timeToPayDatetime":"2024-02-27 01:29:24",
      "commissionFiatUSD":"0.05",
      "amountFiatUSD":"5.00",
      "amountFiat":"5.00",
      "calcAmountFiat":"5.02",
      "currencyFiat":"USD",
      "description":null,
      "serviceData":null,
      "status":"paid"
   },
   "payment":{
      "id":"f986ad8d-2298-473d-982a-efbc817b975d",
      "amount":"5.02000000",
      "hash":"74763b65e43bcc9492a6ce9a7f26fbfdbd7635aecd3454420b5e9534cba50ee6",
      "transactionDatetime":"2024-02-26 13:32:57"
   }
}
```

## Answer parameters

<table data-full-width="false"><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>wallet.id</code></td><td>Wallet ID in UUID format</td></tr><tr><td><code>wallet.name</code></td><td>Wallet name</td></tr><tr><td><code>wallet.blockchain</code></td><td>Crypto wallet blockchain</td></tr><tr><td><code>wallet.cryptocurrency</code></td><td>Cryptocurrency of the wallet</td></tr><tr><td><code>wallet.address</code></td><td>Crypto wallet address</td></tr><tr><td><code>project.id</code></td><td>Project ID in UUID format</td></tr><tr><td><code>project.name</code></td><td>Project name</td></tr><tr><td><code>project.commissionPayer</code></td><td>Commission payer</td></tr><tr><td><code>project.commissionRate</code></td><td>Commission amount in %</td></tr><tr><td><code>invoice.id</code></td><td>Invoice ID in UUID format</td></tr><tr><td><code>invoice.uid</code></td><td>Invoice ID (for buyer)</td></tr><tr><td><code>invoice.createDatetime</code></td><td>Date and time of invoice creation (UTC)</td></tr><tr><td><code>invoice.timeToPayDatetime</code></td><td>Date and time until which the invoice is valid (UTC)</td></tr><tr><td><code>invoice.commissionFiatUSD</code></td><td>The amount of the service commission. Calculated relative to the amount <code>invoice.amountFiatUSD</code></td></tr><tr><td><code>invoice.amountFiatUSD</code></td><td>Amount in USD currency calculated during invoice creation at the current exchange rate relative to the <code>invoice.amountFiat</code> amount</td></tr><tr><td><code>invoice.amountFiat</code></td><td>Amount in fiat currency</td></tr><tr><td><code>invoice.calcAmountFiat</code></td><td>Calculated amount in <code>invoice.currencyFiat</code> currency using the cryptocurrency exchange rate at the time of payment. This parameter may differ from the amount in <code>invoice.amountFiat</code> due to the fact that the buyer may have paid the invoice not immediately after creation, but after some time. During this time, the cryptocurrency exchange rate relative to <code>invoice.currencyFiat</code> could change in any direction</td></tr><tr><td><code>invoice.currencyFiat</code></td><td>Currency fiat</td></tr><tr><td><code>invoice.description</code></td><td>Description that was set during invoice creation</td></tr><tr><td><code>invoice.serviceData</code></td><td>Service data that was set during invoice creation</td></tr><tr><td><code>invoice.status</code></td><td>Invoice status</td></tr><tr><td><code>payment.id</code></td><td>Payment ID in UUID format</td></tr><tr><td><code>payment.amount</code></td><td>Payment amount in cryptocurrency</td></tr><tr><td><code>payment.hash</code></td><td>Transaction hash in blockchain</td></tr><tr><td><code>payment.transactionDatetime</code></td><td>Date and time of the transaction in blockchain (UTC)</td></tr></tbody></table>

## Delivery frequency

At the WH URL, the server should respond with an HTTP code of 200.

If the server response will be with HTTP code different from 200, then the service will consider the notification undelivered. In this case, the service will send repeated requests to this WH URL with the following frequency:

* 5 minutes after the last failed delivery
* After 15 minutes
* After 30 minutes
* After 1 hour
* After 3 hours
* After 6 hours
* After 12 hours
* After 24 hours

Further attempts to deliver the notification are stopped.

## Disabling WH URL

Sometimes, the WH script of an online store returns an HTTP code other than 200 even when processing a payment correctly. This leads to frequent repeated requests from our server at the intervals specified in the previous section, creating unnecessary load on both our and the client’s server.

To prevent such cases, we have implemented a WH URL deactivation mechanism in the project. To avoid this, follow these steps:

1. Modify the WH URL code so that it returns an HTTP 200 code if the payment processing in the store is successful. Test it using any emulator, such as Postman
2. Contact technical support to adjust the settings
3. Re-enable the WH URL in the project settings and save the project
