# Create payment via form Integration through the 1Payment payment form is the simplest way to start accepting payments via **SberPay**. You do not need to manage Deep Links and App-to-App flows yourself — 1Payment handles the technical part. ## How it works The SberPay payment flow consists of four steps: 1. **Initialization** — your server sends a request with order parameters to the 1Payment endpoint. 2. **Receive link** — the system returns a unique URL of the payment page. 3. **Payment** — you redirect the user to the received address; on the form they confirm the payment via SberPay. 4. **Notification (callback)** — after the transaction completes, we send a payment status notification to your `notify_url`. ## Technical details | | | | --- | --- | | **Endpoint** | `https://api.1payment.com/init_form` | | **Methods** | `GET`, `POST` | | **Response format** | JSON | | **Payment type** | The request must include `payment_type=sberpay` | ## 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 (for example, `50.00`). | | `payment_type` | String | For SberPay payments, always pass `sberpay`. | | `user_data` | String | Your internal order ID for matching the payment. | | `shop_url` | String | URL of the site where the purchase is made. | | `user_id` | String | Payer ID in your system. Required to identify the payer unambiguously: the 1Payment internal anti-fraud system uses it. Pass a correct value — the same ID for the same payer in every payment. | | `sign` | String | Request signature (see the Signature section). | ### Optional Configure form behavior and pass customer data. | 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. | | `phone` | String | Payer phone number. | | `email` | String | Payer email address. | | `success_url` | String | URL to redirect the customer after successful payment. | | `failure_url` | String | URL to redirect the customer after a failed payment. | | `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`). | | `subscribe` | Integer | Pass `1` to create a subscription for recurring payments. | ## Signature (`sign`) Signature: MD5, lowercase (hex). General rules — [API request format](../init-request.md#подпись-запроса-sign). **Formula:** ```text MD5(init_form + + ) ``` **Example string before hashing:** ```text init_formamount=50&description=test_payment&partner_id=1234&payment_type=sberpay&project_id=5678&shop_url=test.com&user_data=order_777&user_id=payer_42secret_key ``` ### Verify signature in the documentation {% signatureVerifier method="init_form" preset="sberpay_init_form" /%} ## Request examples {% codeTabs %} {% tab label="Node.js" %} ```javascript const crypto = require('crypto'); const axios = require('axios'); async function createSberpayForm(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', payment_type: 'sberpay', user_data: 'order_777', user_id: 'payer_42', shop_url: 'test.com', description: 'test_payment', }; createSberpayForm(mockApiKey, mockData).then(console.log); ``` {% /tab %} {% tab label="Python" %} ```python import hashlib import os import requests def create_sberpay_form(api_key: str, params: dict) -> dict: # 1. Сортировка параметров по алфавиту sorted_keys = sorted(params.keys()) query_string = "&".join(f"{k}={params[k]}" for k in sorted_keys) # 2. Формирование подписи (префикс init_form) base_string = f"init_form{query_string}{api_key}" params["sign"] = hashlib.md5(base_string.encode("utf-8")).hexdigest() # 3. Запрос к API response = requests.post("https://api.1payment.com/init_form", data=params) response.raise_for_status() return response.json() # в ответе поле url — ссылка на форму # Пример данных запроса api_key = os.environ["ONEPAYMENT_API_KEY"] data = { "partner_id": 1234, "project_id": 5678, "amount": "50.00", "payment_type": "sberpay", "user_data": "order_777", "user_id": "payer_42", "shop_url": "test.com", "description": "test_payment", } print(create_sberpay_form(api_key, data)) ``` {% /tab %} {% tab label="PHP" %} ```php $v) { if ($k === 'sign') { continue; } $tail .= "{$k}={$v}&"; } $tail = substr($tail, 0, -1); // 2. Формирование подписи (префикс init_form) $params['sign'] = md5('init_form' . $tail . $apiKey); // 3. Запрос к API $ch = curl_init('https://api.1payment.com/init_form'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); return $response; // JSON с полем url } // Пример данных запроса (обязательные поля) $apiKey = getenv('ONEPAYMENT_API_KEY'); $data = [ 'partner_id' => 1234, 'project_id' => 5678, 'amount' => '50.00', 'payment_type' => 'sberpay', 'user_data' => 'order_777', 'user_id' => 'payer_42', 'shop_url' => 'test.com', 'description' => 'test_payment', ]; echo createSberpayForm($apiKey, $data); ``` {% /tab %} {% tab label="cURL" %} ```bash # 1–2. Подпись: md5("init_form" + amount=50&description=test_payment&partner_id=1234&payment_type=sberpay&project_id=5678&shop_url=test.com&user_data=order_777&user_id=payer_42 + API_KEY) # 3. GET-запрос (можно также POST с теми же полями) curl -sS "https://api.1payment.com/init_form?partner_id=1234&project_id=5678&amount=50.00&payment_type=sberpay&user_data=order_777&user_id=payer_42&shop_url=test.com&description=test_payment&sign=PASTE_MD5_HEX" ``` {% /tab %} {% /codeTabs %} ## API response Successful response (`200`): ```json { "url": "https://merchant.1payment.com/xZ5g7F" } ``` The `url` field is the payment page address to which you must redirect the payer. Request error (`400`): ```json { "error_code": 2 } ``` ## 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 (`sberpay`). | | `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 | Payment amount. | | `user_price` | Number | Yes | Partner payout amount. | | `currency` | String | Yes | Payment currency (ISO 4217). | | `account` | String | Yes | Technical marker (`sberpay`). | | `user_data` | String | Yes | Transaction ID passed at creation. | | `sign` | String | Yes | Callback signature. | | `token` | String | No | Subscription identifier after successful payment with `subscribe=1`. | | `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). See [API request format](../init-request.md#колбеки-уведомления) for details. ## Related sections - [Create payment via host2host (GATE)](./host2host.md) - [Payment statuses](./status.md) - [Payment refunds](./refund.md) - [Create subscription payment](./recurring.md) - [Transaction statuses](../transaction-statuses.md) - [Error codes (API)](../error-codes-api.md) - [Error codes (declines)](../decline-error-codes.md)