# Payment status

This method returns the **current status** of an SBP payment by the identifier from the initiation response (`order_id`) or by your `user_data` if `order_id` was not stored. Use it to poll state after [form payment creation](/en/pages/sbp/init-form) or via [GATE](/en/pages/sbp/host2host), and when callback delivery fails.

## How it works

1. **Identification** — pass `order_id` (from the `init_form` / `init_payment` response) **or** `user_data` (order ID on your side).
2. **Request** — the server sends a signed request to the `status_payment` endpoint.
3. **Response** — the API returns JSON with the current `status`, amounts, timestamps, and optionally `redirect_url` or `token`.


See [Transaction statuses](/en/pages/transaction-statuses) for `status` and `status_description` codes.

## Technical details

|  |  |
|  --- | --- |
| **Endpoint** | `https://api.1payment.com/status_payment` |
| **Methods** | `GET`, `POST` |
| **Response format** | JSON |
| **Payment type in response** | For SBP, `payment_type` is `sbp` |


## Request parameters

### Required

| Parameter | Type | Description |
|  --- | --- | --- |
| `partner_id` | Integer | Your unique ID in the 1Payment system. |
| `project_id` | Integer | Your project identifier. |
| `sign` | String | Request signature (see the "Signature" section). |


### Payment identification

Pass **one** of these parameters:

| Parameter | Type | Description |
|  --- | --- | --- |
| `order_id` | String | Payment ID in 1Payment (from the initiation response). |
| `user_data` | String | Your order ID; used when `order_id` is not specified. |


## Signature generation (`sign`)

Signature: MD5, lowercase (hex). General rules — [API request format](/en/pages/init-request#request-signature-sign).

**Formula:**


```text
MD5(status_payment + <параметры_без_sign_в_алфавитном_порядке_через_&> + <API_KEY>)
```

**Example string before hashing** (lookup by `order_id`):


```text
status_paymentorder_id=8p3brmb19gfg0sg8gcwhws8kgc748s87&partner_id=1234&project_id=5678secret_key
```

### Signature verification in the documentation

## Request examples

Node.js

```javascript
const crypto = require('crypto');
const axios = require('axios');

async function getSbpPaymentStatus(apiKey, params) {
  // 1. Сортируем параметры по алфавиту
  const sortedKeys = Object.keys(params).sort();
  const queryString = sortedKeys.map((key) => `${key}=${params[key]}`).join('&');

  // 2. Подпись с префиксом status_payment
  const baseString = `status_payment${queryString}${apiKey}`;
  params.sign = crypto.createHash('md5').update(baseString).digest('hex');

  // 3. GET-запрос
  const response = await axios.get('https://api.1payment.com/status_payment', { params });
  return response.data;
}

const apiKey = process.env.ONEPAYMENT_API_KEY;
const data = {
  partner_id: 1234,
  project_id: 5678,
  order_id: '8p3brmb19gfg0sg8gcwhws8kgc748s87',
};

getSbpPaymentStatus(apiKey, data).then(console.log);
```

Python

```python
import hashlib
import os
import requests

def get_sbp_payment_status(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. Подпись status_payment
    base_string = f"status_payment{query_string}{api_key}"
    params["sign"] = hashlib.md5(base_string.encode("utf-8")).hexdigest()

    # 3. GET-запрос
    response = requests.get("https://api.1payment.com/status_payment", params=params)
    response.raise_for_status()
    return response.json()

api_key = os.environ["ONEPAYMENT_API_KEY"]
data = {
    "partner_id": 1234,
    "project_id": 5678,
    "order_id": "8p3brmb19gfg0sg8gcwhws8kgc748s87",
}
print(get_sbp_payment_status(api_key, data))
```

PHP

```php
<?php

function getSbpPaymentStatus(string $apiKey, array $params): string
{
    // 1. Сортировка параметров по алфавиту
    ksort($params, SORT_LOCALE_STRING);
    $tail = '';
    foreach ($params as $k => $v) {
        if ($k === 'sign') {
            continue;
        }
        $tail .= "{$k}={$v}&";
    }
    $tail = substr($tail, 0, -1);

    // 2. Формирование подписи (префикс status_payment)
    $params['sign'] = md5('status_payment' . $tail . $apiKey);

    // 3. Запрос к API
    $url = 'https://api.1payment.com/status_payment?' . http_build_query($params);
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($ch);
    curl_close($ch);

    return $response;
}

// Пример данных запроса
$apiKey = getenv('ONEPAYMENT_API_KEY');
$data = [
    'partner_id' => 1234,
    'project_id' => 5678,
    'order_id' => '8p3brmb19gfg0sg8gcwhws8kgc748s87',
];

echo getSbpPaymentStatus($apiKey, $data);
```

cURL

```bash
# 1–2. Подпись: md5("status_payment" + order_id=...&partner_id=1234&project_id=5678 + API_KEY)

curl -sS "https://api.1payment.com/status_payment?partner_id=1234&project_id=5678&order_id=8p3brmb19gfg0sg8gcwhws8kgc748s87&sign=PASTE_MD5_HEX"
```

## API response

Successful response (`200`):


```json
{
  "payment_type": "sbp",
  "project_id": 5678,
  "order_id": "8p3brmb19gfg0sg8gcwhws8kgc748s87",
  "user_data": "inv_12345",
  "status": 3,
  "status_description": "SUCCESS",
  "init_time": "2026-05-05T18:23:11Z",
  "status_time": "2026-05-05T18:23:42Z",
  "merchant_price": 50,
  "user_price": 48.5,
  "currency": "RUB",
  "account": "sbp"
}
```

| Field | Description |
|  --- | --- |
| `payment_type` | Payment type; for SBP — `sbp`. |
| `project_id` | Your project ID. |
| `order_id` | Payment ID in the 1Payment system. |
| `user_data` | Identifier passed when creating the payment. |
| `status` | Numeric code: `2` — pending, `3` — success, `4` — failure. |
| `status_description` | `PENDING`, `SUCCESS`, or `FAILURE`. |
| `init_time` | Payment creation time (UTC). |
| `status_time` | Current status received time (UTC). |
| `merchant_price` | Payment amount. |
| `user_price` | Partner payout. |
| `currency` | Payment currency (ISO 4217). |
| `account` | SBP account details (value `sbp`). |
| `status_code` | Decline reason code (when `status` = `4`). |
| `token` | Subscription token for recurring payments (if enabled). |
| `redirect_url` | SBP payment link if the payment is still pending and a page/QR is needed. |
| `test` | `1` for test transactions. |


Request error (`400`):


```json
{
  "error_code": 2
}
```

## Related sections

- [Form payment creation](/en/pages/sbp/init-form)
- [Host-to-host payment creation (GATE)](/en/pages/sbp/host2host)
- [Payment refunds](/en/pages/sbp/refund)
- [Transaction statuses](/en/pages/transaction-statuses)