Download OpenAPI specification:Download
Defihub Payment Gateway API
externalUserId and groupId fields in create order request.payWallet field in webhook payload.config option when creating order for customization of payment UI and behavior.The table below describes the possible HTTP response codes you can receive when sending an API request.
| Code | Description |
|---|---|
| 200 | OK |
| 400 | Invalid request |
| 401 | Invalid API key |
| 404 | Not found |
| 429 | Request limit reached |
| 500 | Unexpected error |
To ensure the authenticity and integrity of webhooks from Defihub Payment Gateway, verify the signature in your webhook handler:
'x-defihub-signature' header value.200 HTTP status code. Other response codes, timeouts, or network errors will cause Defihub to retry the webhook with exponential backoff.For longer async processing, respond with 200 first, then process the request in the background.
Ensure your webhook handler is idempotent and can handle duplicates. Log the event ID to avoid multiple processing.
See the code examples or the Merchant Backend Demo for more details on handling webhook requests.
| eventId required | string Unique identifier for the webhook event, used for idempotency to prevent duplicate processing |
| type required | string Value: "order.paid" Type of webhook message |
required | object The payload of the webhook message |
{- "eventId": "123e4567-e89b-12d3-a456-426614174000",
- "type": "order.paid",
- "payload": {
- "orderId": "mhvXdrZT4jP5T8vBxuvm75",
- "status": "ACTIVE",
- "externalId": "ORDER-123",
- "customData": "{\"key\":\"value\"}",
- "currencyCode": "TON",
- "paySUAmount": "1000000000",
- "feeSUAmount": "0",
- "netSUAmount": "1000000000",
- "payWallet": "UQCOU7FUd9C4nV22OcG09JMYCU3elHs_bRY_ai4LpRYFapny",
- "completedAt": "22024-05-03T11:15:00Z"
}
}| merchant-api-key required | string Merchant API key |
| externalId required | string Unique identifier for the order in the merchant's system, used to avoid duplicate orders caused by retried requests |
| payAmount required | string [ 0.01 .. 1000000 ] The amount as a string representation of a big decimal. The maximum precision (number of decimal places) is determined by the currency code. For example, TON allows up to 9 decimal places (10^-9). |
| currencyCode required | string Value: "TON" The currency code for the order amount |
| timeout required | number >= 300 The time-to-live in seconds for the order, specifying the duration within which the order must be paid. Timeout must be greater than 5 minutes. |
| description required | string A brief summary or explanation of the order |
| groupId | string An optional identifier for grouping related orders together, useful for batch processing or categorization. |
| externalUserId | string An optional identifier for the user in the merchant system, useful for filtering orders by a specific user. |
| returnUrl | string The URL to which the user will be redirected upon successful payment of the order. The redirect URL will be appended with necessary query parameters in the following format {returnUrl}?startapp={orderId}_{externalId}... e.g. https://t.me/merchant_defihubdemo_bot/success?startapp=qbnRVuJSstRfsbRxsHQtnN_1795710507605299200. Note that the sequence of these parameters will be preserved, refer to code sample in this section for details on how to parse these parameters. |
| failReturnUrl | string The URL to which the user will be redirected if the order completion is unsuccessful. The redirect URL will be appended with necessary query parameters in the following format {failReturnUrl}?startapp={orderId}_{externalId}... e.g. https://t.me/merchant_defihubdemo_bot/error?startapp=qbnRVuJSstRfsbRxsHQtnN_1795710507605299200. Note that the sequence of these parameters will be preserved, refer to code sample in this section for details on how to parse these parameters. |
| customData | string An optional custom string that will be included in webhook notifications and can be retrieved when polling the order status |
object Additional configuration settings for customizing the payment UI display and behavior for the user. |
{- "externalId": "ORDER-123",
- "payAmount": "0.010000001",
- "currencyCode": "TON",
- "timeout": 900,
- "description": "Premium for 1 month",
- "groupId": "DAILY_PACKAGE",
- "externalUserId": "190222311",
- "customData": "{\"key\":\"value\"}",
- "config": {
- "manualOpenPay": false,
- "skipTxVerified": false
}
}{- "statusCode": 200,
- "message": "",
- "data": {
- "id": "mhvXdrZT4jP5T8vBxuvm75",
- "externalId": "ORDER-123",
- "groupId": "DAILY_PACKAGE",
- "externalUserId": "190222311",
- "status": "ACTIVE",
- "currencyCode": "TON",
- "payAmount": "0.010000001",
- "paySUAmount": "1000000000",
- "createdAt": "2024-05-03T11:00:00Z",
- "expiredAt": "22024-05-03T11:15:00Z",
- "completedAt": "22024-05-03T11:15:00Z"
}
}| offset required | number Example: offset=0 Offset from where to start fetching records |
| limit required | number [ 1 .. 200 ] Example: limit=100 Number of records to fetch |
| status | string Enum: "ACTIVE" "EXPIRED" "PAID" "CANCELLED" Example: status=PAID Filter by order status. Default is all if not specified |
| groupId | string Example: groupId=DAILY_PACKAGE Filter by group id |
| externalUserId | string Example: externalUserId=190222311 Filter by external user id |
| sort | string Default: "desc" Enum: "asc" "desc" Example: sort=asc Sort order by created time |
| merchant-api-key required | string Merchant API key |
{- "statusCode": 200,
- "message": "",
- "data": [
- {
- "id": "mhvXdrZT4jP5T8vBxuvm75",
- "externalId": "ORDER-123",
- "groupId": "DAILY_PACKAGE",
- "externalUserId": "190222311",
- "status": "ACTIVE",
- "currencyCode": "TON",
- "paySUAmount": "1000000000",
- "createdAt": "2024-05-03T11:00:00Z",
- "expiredAt": "22024-05-03T11:15:00Z",
- "completedAt": "22024-05-03T11:15:00Z",
- "customData": "{\"key\":\"value\"}",
- "feeSUAmount": "0",
- "netSUAmount": "1000000000",
- "payWallet": "UQCOU7FUd9C4nV22OcG09JMYCU3elHs_bRY_ai4LpRYFapny",
- "inTxHash": "1d85b2c566e0956842df3ddd46f9be1e3bfb05f345689e29d112e11900c4613c",
- "outTxHash": "c236e38ac2fd6a68ff658c7fb1ed52720c630ff20ad0e9832dcab6b18be351f0"
}
], - "meta": {
- "total": 0
}
}| orderId required | string Example: mhvXdrZT4jP5T8vBxuvm75 Order Id |
| merchant-api-key required | string Merchant API key |
{- "statusCode": 200,
- "message": "",
- "data": {
- "id": "mhvXdrZT4jP5T8vBxuvm75",
- "externalId": "ORDER-123",
- "groupId": "DAILY_PACKAGE",
- "externalUserId": "190222311",
- "status": "ACTIVE",
- "currencyCode": "TON",
- "payAmount": "0.010000001",
- "paySUAmount": "1000000000",
- "createdAt": "2024-05-03T11:00:00Z",
- "expiredAt": "22024-05-03T11:15:00Z",
- "completedAt": "22024-05-03T11:15:00Z",
- "customData": "{\"key\":\"value\"}",
- "feeSUAmount": "0",
- "netSUAmount": "1000000000",
- "payWallet": "UQCOU7FUd9C4nV22OcG09JMYCU3elHs_bRY_ai4LpRYFapny",
- "inTxHash": "1d85b2c566e0956842df3ddd46f9be1e3bfb05f345689e29d112e11900c4613c",
- "outTxHash": "c236e38ac2fd6a68ff658c7fb1ed52720c630ff20ad0e9832dcab6b18be351f0"
}
}