> For the complete documentation index, see [llms.txt](https://docs.xpayconnect.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.xpayconnect.io/documentation/eng/orders/create-crypto.md).

# Create Order (PAYIN-CRYPTO)

> Method: **POST**
>
> Path: **/merchant/createOrder**

Used for the `usdt_trc20`, `usdt_erc20`, `usdt_ton`, `usdt_bep20`, `ton`, `btc`, `ltc`, `eth`, `bnb` methods. Supports two modes for specifying the amount:

* **In rubles** — the merchant passes `amount` in RUB, the system converts it to crypto at the current rate
* **In cryptocurrency** — the merchant passes `amount` already in the desired crypto (USDT / BTC / LTC / TON), no conversion is performed

***

## Request Parameters

| Field                      | Type          | Required | Description                                                                                                                                                                          |
| -------------------------- | ------------- | :------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **amount**                 | number        |     ✓    | Payment amount. Interpreted according to the `currency` field                                                                                                                        |
| **type**                   | string (enum) |     ✓    | [Crypto method](/documentation/eng/reference/payment-methods.md#krypto-metody): `usdt_trc20`, `usdt_erc20`, `usdt_ton`, `usdt_bep20`, `ton`, `btc`, `ltc`, `eth`, `bnb`              |
| **merchant\_id**           | string        |     ✓    | Unique merchant name                                                                                                                                                                 |
| **order\_id**              | string        |     —    | Unique identifier on the merchant's side (external\_id). We recommend a UUID (v4 or v7). If not provided — generated by the system                                                   |
| **currency**               | string        |     —    | Currency of the amount. `RUB` (default) — amount in rubles, will be converted. `USDT` / `BTC` / `LTC` / `ETH` / `BNB` / `TON` — amount already in crypto, no conversion is performed |
| **success\_callback\_url** | string        |     —    | URL for receiving a webhook upon payment confirmation                                                                                                                                |
| **client\_id**             | string        |     —    | Client ID in the merchant's system                                                                                                                                                   |

{% hint style="warning" %}
The `amountUp`, `amountDown`, and `convertToUsdt` parameters are **not applicable** to crypto methods and are ignored.
{% endhint %}

***

## Mode 1 — Amount in Rubles

The merchant passes `amount` in rubles (or without `currency` — default `RUB`). The system automatically calculates the final crypto amount at the current rate.

```json
{
    "order_id": "01a00c1a-9f0e-7e42-b8a5-2a1c3d4e5f6a",
    "amount": 2300,
    "type": "usdt_trc20",
    "success_callback_url": "http://test.com/api/order/success",
    "merchant_id": "exMerchant",
    "client_id": "99999999"
}
```

{% tabs %}
{% tab title="JavaScript" %}

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

const apiKey = 'YOUR_API_KEY';
const body = {
    order_id: '01a00c1a-9f0e-7e42-b8a5-2a1c3d4e5f6a',
    amount: 2300,
    type: 'usdt_trc20',
    success_callback_url: 'http://test.com/api/order/success',
    merchant_id: 'exMerchant',
    client_id: '99999999',
};

const bodyStr = JSON.stringify(body);
const xApiKey = crypto.createHash('sha256').update(`${apiKey}|${bodyStr}`).digest('hex');

const { data } = await axios.post('https://api.xpayconnect.io/merchant/createOrder', body, {
    headers: {
        'Content-Type': 'application/json',
        'client-api-key': apiKey,
        'x-api-key': xApiKey,
    },
});
```

{% endtab %}

{% tab title="Python" %}

```python
import hashlib
import json
import requests

api_key = 'YOUR_API_KEY'
body = {
    'order_id': '01a00c1a-9f0e-7e42-b8a5-2a1c3d4e5f6a',
    'amount': 2300,
    'type': 'usdt_trc20',
    'success_callback_url': 'http://test.com/api/order/success',
    'merchant_id': 'exMerchant',
    'client_id': '99999999',
}

body_str = json.dumps(body, separators=(',', ':'))
x_api_key = hashlib.sha256(f'{api_key}|{body_str}'.encode()).hexdigest()

resp = requests.post('https://api.xpayconnect.io/merchant/createOrder', json=body, headers={
    'Content-Type': 'application/json',
    'client-api-key': api_key,
    'x-api-key': x_api_key,
})
data = resp.json()
```

{% endtab %}

{% tab title="PHP" %}

```php
$apiKey = 'YOUR_API_KEY';
$body = [
    'order_id' => '01a00c1a-9f0e-7e42-b8a5-2a1c3d4e5f6a',
    'amount' => 2300,
    'type' => 'usdt_trc20',
    'success_callback_url' => 'http://test.com/api/order/success',
    'merchant_id' => 'exMerchant',
    'client_id' => '99999999',
];

$bodyStr = json_encode($body, JSON_UNESCAPED_UNICODE);
$xApiKey = hash('sha256', $apiKey . '|' . $bodyStr);

$ch = curl_init('https://api.xpayconnect.io/merchant/createOrder');
curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => $bodyStr,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
        'client-api-key: ' . $apiKey,
        'x-api-key: ' . $xApiKey,
    ],
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
```

{% endtab %}
{% endtabs %}

***

## Mode 2 — Amount in Cryptocurrency

The merchant passes `amount` already in the desired crypto, specifying `currency` for the corresponding coin. No conversion from rubles is performed — the system issues an address for exactly the specified amount.

| type         | currency | What amount means              |
| ------------ | -------- | ------------------------------ |
| `usdt_trc20` | `USDT`   | Amount in USDT (TRC20 network) |
| `usdt_erc20` | `USDT`   | Amount in USDT (ERC20 network) |
| `usdt_ton`   | `USDT`   | Amount in USDT (TON network)   |
| `usdt_bep20` | `USDT`   | Amount in USDT (BEP20 network) |
| `btc`        | `BTC`    | Amount in BTC                  |
| `ltc`        | `LTC`    | Amount in LTC                  |
| `eth`        | `ETH`    | Amount in ETH                  |
| `bnb`        | `BNB`    | Amount in BNB (BEP20 network)  |
| `ton`        | `TON`    | Amount in TON                  |

**Request examples:**

{% tabs %}
{% tab title="USDT TRC20" %}

```json
{
    "order_id": "01a00c1a-9f0e-7e42-b8a5-2a1c3d4e5f6a",
    "amount": 29.37,
    "type": "usdt_trc20",
    "currency": "USDT",
    "success_callback_url": "http://test.com/api/order/success",
    "merchant_id": "exMerchant",
    "client_id": "99999999"
}
```

{% endtab %}

{% tab title="BTC" %}

```json
{
    "order_id": "01a00c1a-9f0e-7e42-b8a5-2a1c3d4e5f6a",
    "amount": 0.00031,
    "type": "btc",
    "currency": "BTC",
    "success_callback_url": "http://test.com/api/order/success",
    "merchant_id": "exMerchant",
    "client_id": "99999999"
}
```

{% endtab %}

{% tab title="LTC" %}

```json
{
    "order_id": "01a00c1a-9f0e-7e42-b8a5-2a1c3d4e5f6a",
    "amount": 0.42,
    "type": "ltc",
    "currency": "LTC",
    "success_callback_url": "http://test.com/api/order/success",
    "merchant_id": "exMerchant",
    "client_id": "99999999"
}
```

{% endtab %}

{% tab title="TON" %}

```json
{
    "order_id": "01a00c1a-9f0e-7e42-b8a5-2a1c3d4e5f6a",
    "amount": 12.5,
    "type": "ton",
    "currency": "TON",
    "success_callback_url": "http://test.com/api/order/success",
    "merchant_id": "exMerchant",
    "client_id": "99999999"
}
```

{% endtab %}

{% tab title="USDT ERC20" %}

```json
{
    "order_id": "01a00c1a-9f0e-7e42-b8a5-2a1c3d4e5f6a",
    "amount": 29.37,
    "type": "usdt_erc20",
    "currency": "USDT",
    "success_callback_url": "http://test.com/api/order/success",
    "merchant_id": "exMerchant",
    "client_id": "99999999"
}
```

{% endtab %}

{% tab title="USDT TON" %}

```json
{
    "order_id": "01a00c1a-9f0e-7e42-b8a5-2a1c3d4e5f6a",
    "amount": 29.37,
    "type": "usdt_ton",
    "currency": "USDT",
    "success_callback_url": "http://test.com/api/order/success",
    "merchant_id": "exMerchant",
    "client_id": "99999999"
}
```

{% endtab %}

{% tab title="USDT BEP20" %}

```json
{
    "order_id": "01a00c1a-9f0e-7e42-b8a5-2a1c3d4e5f6a",
    "amount": 29.37,
    "type": "usdt_bep20",
    "currency": "USDT",
    "success_callback_url": "http://test.com/api/order/success",
    "merchant_id": "exMerchant",
    "client_id": "99999999"
}
```

{% endtab %}

{% tab title="ETH" %}

```json
{
    "order_id": "01a00c1a-9f0e-7e42-b8a5-2a1c3d4e5f6a",
    "amount": 0.012,
    "type": "eth",
    "currency": "ETH",
    "success_callback_url": "http://test.com/api/order/success",
    "merchant_id": "exMerchant",
    "client_id": "99999999"
}
```

{% endtab %}

{% tab title="BNB" %}

```json
{
    "order_id": "01a00c1a-9f0e-7e42-b8a5-2a1c3d4e5f6a",
    "amount": 0.085,
    "type": "bnb",
    "currency": "BNB",
    "success_callback_url": "http://test.com/api/order/success",
    "merchant_id": "exMerchant",
    "client_id": "99999999"
}
```

{% endtab %}
{% endtabs %}

***

## Response

```json
{
    "ok": true,
    "id": "lux01993328-a828-7581-b3a9-e712a6a0e88c",
    "payment_id": "01a00c1a-9f0e-7e42-b8a5-2a1c3d4e5f6a",
    "status": "pending",
    "usdtAmount": 29.37,
    "usdtAmountAfterFee": 25.5,
    "amountAfterFee": 2001,
    "currency": "RUB",
    "payment_details": {
        "address": "TQjmBeKxGm7tGBqBkn5W7vDoRHYiQB9j1o",
        "bank": "USDT",
        "holder_name": "TRC20",
        "type": "usdt_trc20",
        "amount": "2300",
        "cryptoAmount": "29.37"
    }
}
```

| Field                  | Type             | Description                                                                                                                                                                                                                                |
| ---------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **ok**                 | boolean          | `true` when payment details are successfully provided                                                                                                                                                                                      |
| **id**                 | string (uuid)    | Unique identifier in the internal system (internal\_id)                                                                                                                                                                                    |
| **payment\_id**        | string           | The **order\_id** passed by the merchant at creation, or generated by the system                                                                                                                                                           |
| **status**             | string (enum)    | Payment status: `pending`, `success`, `error`                                                                                                                                                                                              |
| **usdtAmount**         | number, nullable | Crypto amount before fee deduction. For `usdt_trc20` — in USDT; for other methods — USDT equivalent, if available at the time of the response                                                                                              |
| **usdtAmountAfterFee** | number, nullable | Crypto amount to be credited to the merchant's balance after fee deduction                                                                                                                                                                 |
| **amountAfterFee**     | number           | Ruble equivalent after fee (when requested in crypto — converted back)                                                                                                                                                                     |
| **currency**           | string           | Currency of the original request: `RUB` or crypto (`USDT`, `BTC`, `LTC`, `TON`)                                                                                                                                                            |
| **payment\_details**   | object           | Payment details                                                                                                                                                                                                                            |
| ↳ **address**          | string           | Crypto wallet address for the transfer                                                                                                                                                                                                     |
| ↳ **bank**             | string           | Cryptocurrency name (`USDT`, `BTC`, `LTC`, `TON`)                                                                                                                                                                                          |
| ↳ **holder\_name**     | string           | Network (`TRC20`, `TON`, `BTC`, `LTC`)                                                                                                                                                                                                     |
| ↳ **type**             | string (enum)    | [Crypto method](/documentation/eng/reference/payment-methods.md#krypto-metody)                                                                                                                                                             |
| ↳ **amount**           | string           | Original request amount (in rubles or in crypto — depends on the mode)                                                                                                                                                                     |
| ↳ **cryptoAmount**     | string, nullable | Exact cryptocurrency amount the client must send. If the amount has not yet been calculated synchronously — the field will be `null`; the actual value can be retrieved via [`GET /merchant/order/:id`](/documentation/eng/orders/info.md) |

{% hint style="info" %}
The `exchangeRate` field is **absent** from the response — for crypto methods the rate is already embedded in `cryptoAmount`. The client must transfer exactly `cryptoAmount` to the `address`.
{% endhint %}

***

## Payment Methods

The full list of crypto methods is on a separate page: [Payment Methods → Crypto](/documentation/eng/reference/payment-methods.md#krypto-metody).
