> For the complete documentation index, see [llms.txt](https://help.unitpay.ru/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.unitpay.ru/en/payments/recurring-payments/create-subscription.md). Agents can also search and read this documentation through its [MCP server](https://help.unitpay.ru/~gitbook/mcp).

# Creating a Subscription

**This functionality is available only upon approval by the Security Department.**\
To enable subscriptions, please contact our [support team](https://help.unitpay.ru/en/support).

***

A subscription allows you to automatically charge a client’s card **without their direct involvement**.\
This is useful for **recurring payments**, such as:

* rent,
* internet access,
* mobile phone top-ups,
* other periodic services.

{% hint style="info" %}
Currently, subscriptions are supported **only for the `card` ,** `tinkoffpay` (T-Pay) and  `sbp` **payment method**.
{% endhint %}

***

### Step 1: Create an initial (setup) payment

To bind the client’s card to a subscription, pass the `subscription` parameter when initiating the payment:

* For hosted [form](https://help.unitpay.ru/en/payments/create-payment-easy): `subscription=true`
* For [API request](https://help.unitpay.ru/en/payments/create-payment): `subscription=true`

📌 It’s strongly recommended to also pass `hideOtherMethods=true` to ensure the subscription is initialized specifically via the `card` method.

**IP Address Forwarding**

* **Initial payment via API:** pass the `ip` of the user who is subscribing.
* **Initial payment via form or widget:** `ip` is not passed. The payer's `ip` will be received by the handler; save it together with the `subscriptionId`.

{% hint style="info" %}
At this stage, you can add the `preauth=1` parameter to create a payment with preauthorization. To automatically cancel the payment, specify `preauthExpireLogic=0` in the request.

See more details [here](https://help.unitpay.ru/en/payments/pre-authorization-payments.md).
{% endhint %}

### Step 2: Receive the subscription ID

After the initial payment is completed, your **payment handler will receive** the following parameter:

```
subscriptionId = <value>
```

Store this ID — it will be required for future recurring charges.

### Step 3: Trigger recurring charge

To initiate an auto-charge:

* Ensure the subscription status is **`active`**
* Use the standard API method to [create a payment](https://help.unitpay.ru/en/payments/create-payment.md)
* Pass the `subscriptionId`  via:

```
[subscriptionId]=<value>
```

The **amount and charge interval** are fully managed on your side.

{% hint style="warning" %}
In `initPayment`, pass the user's saved `ip` together with the `subscriptionId`. The IP address of the server from which the charge is made must not be passed, as it is used for payment verification.
{% endhint %}

***

{% hint style="warning" %}
**Subscription payments are not compatible with two-stage payments** (payments with preauthorization). Preauthorization is only available when creating the initial payment (step 1).
{% endhint %}

***

#### Refunding the Initial Payment

If you sell a subscription with the first month free, you may need to initially charge the customer a small amount and then refund it — for example, to verify the card or create the subscription.

Subscriptions in Unitpay do not automatically refund the initial payment. However, you can refund the initial payment yourself using the [payment refund method](https://help.unitpay.ru/en/payments/payment-refund.md) by passing the `unitpayId` received for the initial payment as the `paymentId` parameter.
