Payment refunds
This method initiates a refund of a successful bank card payment. Pass the order_id of the original payment and a separate user_data for the refund operation. After the request is accepted, the API returns refund_order_id and status REFUND_PENDING; the final result arrives at the project notify_url.
Request format and signatures — see API request format.
How it works
- Original payment — a refund is possible for an
order_idof a payment in success status (SUCCESS, code3). The ID comes from the form or host2host (GATE) creation response. - Initiation — signed request to
init_refundwith a unique refunduser_data(different from the paymentuser_data). - Response —
refund_order_id,status9(REFUND_PENDING), andstatus_description. - Final status — callback POST JSON to
notify_url; if needed, poll status byrefund_order_idvia Payment statuses.
Interpretation of status and status_description for refunds — in Transaction statuses (REFUND, REFUND_PENDING).
Technical information
| Endpoint | https://api.1payment.com/init_refund |
| Methods | GET, POST |
| Response format | JSON |
| Callback type | payment_type — see Payment types (refund in refund notifications) |
Request parameters
Required
| Parameter | Type | Description |
|---|---|---|
partner_id | Integer | Your unique ID in the 1Payment system. |
project_id | Integer | Your project identifier. |
order_id | String | order_id of the original successful card payment. |
user_data | String | Unique refund ID on your side (different from the payment user_data). Up to 255 characters; UUID is recommended. |
sign | String | Request signature (see the "Signature" section). |
Optional
| Parameter | Type | Description |
|---|---|---|
amount | Number | Partial refund amount. Contact your 1Payment account manager to confirm partial refund availability. |
Signature generation (sign)
Signature: MD5, lowercase (hex). General rules — API request format.
Formula:
MD5(init_refund + <параметры_без_sign_в_алфавитном_порядке_через_&> + <API_KEY>)Example string before hashing:
init_refundorder_id=8p3brmb19gfg0sg8gcwhws8kgc748s87&partner_id=1234&project_id=5678&user_data=abcd1234secret_keyFor partial refunds, the passed amount is included in the signature.
Signature verification in the documentation
Signature check for {{method}}
Paste the request parameters (JSON), API key, and signature. The widget verifies them automatically.
order_id=8p3brmb19gfg0sg8gcwhws8kgc748s87&partner_id=1234&project_id=5678&user_data=abcd1234init_refundorder_id=8p3brmb19gfg0sg8gcwhws8kgc748s87&partner_id=1234&project_id=5678&user_data=abcd123411a957524c8813f24e45a9e101f4cf5eRequest examples
const crypto = require('crypto');
const axios = require('axios');
async function initCardRefund(apiKey, params) {
const sortedKeys = Object.keys(params).sort();
const queryString = sortedKeys.map((key) => `${key}=${params[key]}`).join('&');
const baseString = `init_refund${queryString}${apiKey}`;
params.sign = crypto.createHash('md5').update(baseString).digest('hex');
const response = await axios.get('https://api.1payment.com/init_refund', { params });
return response.data;
}
const apiKey = process.env.ONEPAYMENT_API_KEY;
const data = {
partner_id: 1234,
project_id: 5678,
order_id: '8p3brmb19gfg0sg8gcwhws8kgc748s87',
user_data: 'abcd1234',
};
initCardRefund(apiKey, data).then(console.log);API response
Successful response (200):
{
"refund_order_id": "crf_1p3brmb19gfg0sg8gcwhws8kgc748s87",
"status": 9,
"status_description": "REFUND_PENDING",
"status_code": 0
}| Field | Description |
|---|---|
refund_order_id | Refund ID in 1Payment; use for status polling and accounting. |
status | Numeric code (9 — refund in progress). |
status_description | REFUND_PENDING, etc. |
status_code | Decline code on refund error (see decline codes). |
Request error (400):
{
"error_code": 2
}Status notifications (callbacks)
After the refund status changes, the server sends POST JSON to the project notify_url.
| Parameter | Type | Req. | Description |
|---|---|---|---|
payment_type | String | Yes | Operation type (see Payment types). |
order_id | String | Yes | Refund identifier in 1Payment. |
project_id | Integer | Yes | Your project ID. |
status | Integer | Yes | Refund state (5 — REFUND, 9 — REFUND_PENDING, etc.). |
status_description | String | Yes | REFUND, REFUND_PENDING, FAILURE, etc. |
init_time | String | Yes | Refund creation time. |
status_time | String | Yes | Time the status was received. |
merchant_price | Number | Yes | Original payment amount for the payer. |
init_price | Number | No | Amount at initialization. |
user_price | Number | Yes | Refund debit amount. |
user_data | String | Yes | Refund ID passed in init_refund. |
original_order_id | String | No | order_id of the original payment. |
status_code | String | No | Decline error code. |
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 with & + API_KEY (without the init_refund prefix). For details, see API request format.