Skip to content

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

  1. Request — your server sends a signed request to init_invoice with amount and invoice_user_data.
  2. Response — the API returns invoice_id and payment page url.
  3. Payment — redirect the payer to url or share the link another way.
  4. Notification (callback) — on final invoice status, POST JSON is sent to the project invoice_notify_url.

status code meanings — in Transaction statuses.

Technical details

Endpointhttps://api.1payment.com/init_invoice
MethodsGET, POST
Response formatJSON

Request parameters

Required

ParameterTypeDescription
partner_idIntegerYour unique ID in the 1Payment system.
project_idIntegerYour project identifier.
amountNumberInvoice amount in project currency (e.g. 50).
invoice_user_dataStringYour internal invoice ID (unique on the partner side).
signStringRequest signature (see "Signature" section).

Optional

ParameterTypeDescription
descriptionStringPayment description shown to the bank.
payment_form_descriptionStringPayment description shown to the payer on the payment form.
success_urlStringPayer return URL after successful payment.
failure_urlStringPayer 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_key

If 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.

Parameter string: amount=50&description=test_payment&invoice_user_data=inv_12345&partner_id=1234&project_id=5678
String for MD5: init_invoiceamount=50&description=test_payment&invoice_user_data=inv_12345&partner_id=1234&project_id=5678
Expected signature: e65714bdce70f68c92553ed3c2ecbb47
Signature does not match

Request 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"
}
FieldDescription
invoice_idInvoice ID in the 1Payment system.
urlPayment 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).

ParameterTypeReq.Description
typeStringYesNotification type; for invoices — invoice.
invoice_idStringYesInvoice ID in the 1Payment system.
order_idStringNoOn successful payment — transaction ID that paid the invoice.
project_idIntegerYesYour project ID.
statusIntegerYes3 — invoice paid, 4 — payment waiting period expired.
init_timeStringYesInvoice creation time.
vaild_tillStringYesInvoice expiry time (field name as in API).
amountNumberYesInvoice amount.
currencyStringYesInvoice currency (ISO 4217).
invoice_user_dataStringYesInvoice ID sent at creation.
signStringYesCallback 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.

Was this article helpful?