Invoice Webhook Guide

Creating an Invoice

Use this endpoint to create a new invoice.

Endpoint: POST /invoice

Required scopes: invoice

Parameters

ParameterTypeDescription
currencystringCurrency for the invoice.
amountnumberInvoice amount.
payment_idstringYour unique payment identifier (must be unique within the merchant/invoices).
commentstringInvoice description. (Will be publicly visible)
url_successstringURL to redirect after successful payment.
url_callbackstringWebhook URL for payment notifications. (Optional)
merchant_idintegerYour merchant ID. (You must create a merchant here)
lifetimenumberInvoice validity period in seconds. (Optional)
additional_datastringCustom data for your reference. (Optional)

Example Response

{
    "invoice": {
        "invoice_id": 12345,
        "user_id": 12345,
        "merchant_id": 12345,
        "invoice_date": 1735689600,
        "expires_at": 1735689600,
        "amount": 12345,
        "status": "not_paid",
        "paid_date": 0,
        "payer_user_id": 0,
        "payment_id": "UniquePaymentID12345",
        "additional_data": "{\"UserID_TG\": 123456789012345}",
        "comment": "После оплаты вы получите ничего",
        "url_success": "https://yourweb.site/thanks",
        "url_callback": "https://yourweb.site/api/callback",
        "resend_attempts": 0,
        "is_test": 0,
        "url": "https://lzt.market/invoice/12345/"
    },
    "system_info": {
        "visitor_id": 12345,
        "time": 1735689600
    }
}

Webhook Callback

When an invoice is paid, a POST request will be sent to the url_callback specified during invoice creation.

Webhook Headers

HeaderDescription
x-secret-keyContains your merchant token which must be verified

Webhook Payment Statuses

StatusDescription
paidInvoice is paid.
not_paidInvoice is not paid.

Webhook Payload

The webhook will send a POST request with the following data:

{
  "invoice_id": 12345,
  "user_id": 12345,
  "merchant_id": 12345,
  "invoice_date": 1735689600,
  "expires_at": 1735689600,
  "amount": 100,
  "status": "paid",
  "paid_date": 1735689600,
  "payer_user_id": 111333,
  "payment_id": "UniquePaymentID12345",
  "additional_data": "{\"UserID_TG\": 123456789012345}",
  "comment": "This text will be publicly visible",
  "url_success": "https://yourweb.site/thanks",
  "url_callback": "https://yourweb.site/api/callback",
  "is_test": 1,
  "payer_username": "Username"
}

Verifying Webhooks

You must verify that the x-secret-key header matches with your merchant token to ensure the webhook was sent by our server.