Create invoice
The method lets you create an invoice (payment bill) and get a link to the payment form. Send the request to the init_invoice endpoint. After payment or invoice expiry, the final status is sent to invoice_notify_url configured in project settings.
Request format and signature — in API request format.
How it works
- Request — your server sends a signed request to
init_invoicewith amount andinvoice_user_data. - Response — the API returns
invoice_idand payment pageurl. - Payment — redirect the payer to
urlor share the link another way. - Notification (callback) — on final invoice status, POST JSON is sent to the project
invoice_notify_url.
status code meanings — in Transaction statuses.
Technical details
| Endpoint | https://api.1payment.com/init_invoice |
| Methods | GET, POST |
| Response format | JSON |
Request parameters
Required
| Parameter | Type | Description |
|---|---|---|
partner_id | Integer | Your unique ID in the 1Payment system. |
project_id | Integer | Your project identifier. |
amount | Number | Invoice amount in project currency (e.g. 50). |
invoice_user_data | String | Your internal invoice ID (unique on the partner side). |
sign | String | Request signature (see "Signature" section). |
Optional
| Parameter | Type | Description |
|---|---|---|
description | String | Payment description shown to the bank. |
payment_form_description | String | Payment description shown to the payer on the payment form. |
success_url | String | Payer return URL after successful payment. |
failure_url | String | Payer return URL after payment error. |
Signature generation (sign)
Signature: MD5, lowercase (hex). General rules — API request format.
Formula:
MD5(init_invoice + <parameters_without_sign_in_alphabetical_order_joined_by_&> + <API_KEY>)Example string before hashing (as in archived documentation, minimal example without invoice_user_data):
init_invoiceamount=50&description=test_payment&partner_id=1234&project_id=5678secret_keyIf you send invoice_user_data, success_url, and other fields, they are included in the signature string in alphabetical order.
Signature verification in the documentation
Signature check for {{method}}
Paste the request parameters (JSON), API key, and signature. The widget verifies them automatically.
amount=50&description=test_payment&invoice_user_data=inv_12345&partner_id=1234&project_id=5678init_invoiceamount=50&description=test_payment&invoice_user_data=inv_12345&partner_id=1234&project_id=5678e65714bdce70f68c92553ed3c2ecbb47Request examples
const crypto = require('crypto');
const axios = require('axios');
async function createInvoice(apiKey, params) {
// 1. Сортируем параметры по алфавиту
const sortedKeys = Object.keys(params).sort();
const queryString = sortedKeys.map((key) => `${key}=${params[key]}`).join('&');
// 2. Подпись с префиксом init_invoice
const baseString = `init_invoice${queryString}${apiKey}`;
params.sign = crypto.createHash('md5').update(baseString).digest('hex');
// 3. GET-запрос
const response = await axios.get('https://api.1payment.com/init_invoice', { params });
return response.data;
}
const apiKey = process.env.ONEPAYMENT_API_KEY;
const data = {
partner_id: 1234,
project_id: 5678,
amount: 50,
description: 'test_payment',
invoice_user_data: 'inv_12345',
};
createInvoice(apiKey, data).then(console.log);API response
Successful response (200):
{
"invoice_id": "inv_dp2eqgnyt008ocg88wwsw00oksgs8s88",
"url": "https://merchant.1payment.com/xZ5g7F"
}| Field | Description |
|---|---|
invoice_id | Invoice ID in the 1Payment system. |
url | Payment form link; redirect the payer to this URL. |
Request error (400):
{
"error_code": 2
}Status notifications (callbacks)
After the invoice reaches a final status, a POST JSON notification is sent to your invoice_notify_url (from project settings).
| Parameter | Type | Req. | Description |
|---|---|---|---|
type | String | Yes | Notification type; for invoices — invoice. |
invoice_id | String | Yes | Invoice ID in the 1Payment system. |
order_id | String | No | On successful payment — transaction ID that paid the invoice. |
project_id | Integer | Yes | Your project ID. |
status | Integer | Yes | 3 — invoice paid, 4 — payment waiting period expired. |
init_time | String | Yes | Invoice creation time. |
vaild_till | String | Yes | Invoice expiry time (field name as in API). |
amount | Number | Yes | Invoice amount. |
currency | String | Yes | Invoice currency (ISO 4217). |
invoice_user_data | String | Yes | Invoice ID sent at creation. |
sign | String | Yes | Callback signature. |
Important: your server must return HTTP 200 OK. Otherwise the system retries the callback once per minute for 10 minutes.
Callback signature verification: MD5 of all parameters in alphabetical order joined by & + API_KEY (without the init_invoice prefix). Details — in API request format.