Create payment via form
Integration through the 1Payment payment form is the simplest way to start accepting bank card payments.
How it works
The card payment process consists of four steps:
- Initialization — your server sends a request with order parameters to the 1Payment endpoint.
- Receive link — the system returns a unique URL for the payment page.
- Payment — you redirect the user to the received address; there they enter card details and confirm the payment.
- Notification (callback) — after the transaction completes, we send a payment status notification to your
notify_url.
Technical information
| Endpoint | https://api.1payment.com/init_form |
| Methods | GET, POST |
| Response format | JSON |
Request parameters
Required
These fields are required to create the payment form correctly.
| Parameter | Type | Description |
|---|---|---|
partner_id | Integer | Your unique identifier in the 1Payment system. |
project_id | Integer | Your project identifier. |
amount | Number | Payment amount in the project currency (for example, 50.00). |
user_data | String | Your internal order ID for matching the payment. |
shop_url | String | URL of the website where the payment originates. |
sign | String | Request signature (see the "Signature" section). |
Optional
Allow you to configure form behavior and pass customer data.
| Parameter | Type | Description |
|---|---|---|
description | String | Payment description for the customer on the payment form. |
success_url | String | URL to redirect the customer after successful payment. |
failure_url | String | URL to redirect the customer after an error. |
subscription | Integer | For subscription payments only: pass 1 to receive a token for recurring charges. |
token | String | Token ID to display a saved card (contact your account manager to enable this feature). |
lang | String | Form language (for example, ru, en). |
user_id | String | Internal payer ID in your system. |
Signature generation (sign)
Signature: MD5, lowercase (hex). General rules — API request format.
Formula:
MD5(init_form + <параметры_без_sign_в_алфавитном_порядке_через_&> + <API_KEY>)Example string before hashing:
init_formamount=50&description=test_payment&partner_id=1234&project_id=5678secret_keySignature 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&partner_id=1234&project_id=5678&shop_url=https://test.com&user_data=order_777init_formamount=50&description=test_payment&partner_id=1234&project_id=5678&shop_url=https://test.com&user_data=order_7778772da4f4ce287912769b3b36fce48baRequest examples
const crypto = require('crypto');
const axios = require('axios');
async function createCardForm(apiKey, params) {
// 1. Сортируем параметры по алфавиту
const sortedKeys = Object.keys(params).sort();
const queryString = sortedKeys.map((key) => `${key}=${params[key]}`).join('&');
// 2. Генерируем подпись с префиксом init_form
const baseString = `init_form${queryString}${apiKey}`;
params.sign = crypto.createHash('md5').update(baseString).digest('hex');
// 3. Отправляем POST-запрос
try {
const response = await axios.post('https://api.1payment.com/init_form', params);
return response.data; // в ответе поле url — ссылка на форму
} catch (error) {
console.error('Ошибка:', error.message);
}
}
// Пример данных запроса
const mockApiKey = process.env.ONEPAYMENT_API_KEY;
const mockData = {
partner_id: 1234,
project_id: 5678,
amount: '50.00',
user_data: 'order_777',
shop_url: 'https://test.com',
description: 'test_payment',
};
createCardForm(mockApiKey, mockData).then(console.log);API response
Successful response (200):
{
"url": "https://merchant.1payment.com/xZ5g7F"
}The url field is the payment page address to which you must redirect the payer.
Request error (400):
{
"error_code": 2
}Testing
You can use the following data to test card payments:
| Result | Card number | CARDHOLDER | EXP | CVC |
|---|---|---|---|---|
| Successful payment | 4111111111111111 | TEST | 01/01 | 123 |
| Failed payment | 4111111111111112 | TEST | 01/01 | 123 |
Status notifications (callbacks)
After the transaction status changes, our server sends a POST request in JSON format to your notify_url.
| Parameter | Type | Req. | Description |
|---|---|---|---|
payment_type | String | Yes | Payment type (card). |
order_id | String | Yes | Payment ID in the 1Payment system. |
project_id | Integer | Yes | Your project ID. |
status | Integer | Yes | Status: 2 (pending), 3 (success), 4 (declined). |
status_description | String | Yes | PENDING, SUCCESS, or FAILURE. |
init_time | String | Yes | Payment creation time. |
status_time | String | Yes | Time the final status was received. |
merchant_price | Number | Yes | Amount charged to the payer. |
init_price | Number | No | Amount at initialization. |
user_price | Number | Yes | Partner payout amount. |
currency | String | Yes | Payment currency (ISO 4217). |
account | String | Yes | Masked card number. |
user_data | String | Yes | Transaction ID passed at creation. |
sign | String | Yes | Callback signature. |
token | String | No | Saved card identifier after successful payment (if enabled). |
test | Integer | No | 1 for test payments. |
status_code | String | No | Additional decline reason code. |
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 with & + API_KEY (without the init_form prefix). For details, see API request format.