# Subscriptions/Recurring Payments

Following are the APIs that are required to create, debit, and cancel a subscription.

1. Create subscription - You can refer to the link given below to know the parameters required for creating a subscription:\
   \
   <https://docs.rocketfuel.inc/developer-guides/api-reference/generate-invoice-link><br>
2. Request a debit of funds for the subscription&#x20;

{% hint style="info" %}
Reminder emails are sent to the shoppers to make the pre-payment for the subscriptions with the invoice link or maintain the exchange balance equal to the bill amount.&#x20;
{% endhint %}

<mark style="color:green;">`POST`</mark> `/subscription/debit`

#### Request Body

| Name                                             | Type   | Description |
| ------------------------------------------------ | ------ | ----------- |
| merchantAuth<mark style="color:red;">\*</mark>   | String |             |
| merchantId<mark style="color:red;">\*</mark>     | String |             |
| orderId                                          | String |             |
| items                                            | Array  |             |
| subscriptionId<mark style="color:red;">\*</mark> | String |             |
| amount<mark style="color:red;">\*</mark>         | Number |             |
| currency<mark style="color:red;">\*</mark>       | String |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{

status: 200,

result: {

data: [{

      transactionId: response.id,

      amount: response.localAmount,

      currency: response.localCurrency,

      rateDivisor: response.rateDivisor,

      orderId: response.meta.offerId,

      status: response.status,

      userId,

      merchantId,

subscriptionId

}],

errors: [],

}
```

{% endtab %}
{% endtabs %}

3\. To cancel a subscription

<mark style="color:green;">`POST`</mark> `/subscription/cancel`

#### Request Body

| Name           | Type   | Description |
| -------------- | ------ | ----------- |
| merchantId     | String |             |
| merchantAuth   | String |             |
| subscriptionId | String |             |

{% tabs %}
{% tab title="200: OK " %}

```javascript
{

status: 200,

result: { success: true }

}
```

{% endtab %}

{% tab title="400: Bad Request " %}

```javascript
{

  "ok": false,

  "statusCode": 400,

  "data": {

}

"message": "Subscription not found"

}
```

{% endtab %}

{% tab title="500: Internal Server Error " %}

```javascript
{
  "ok": false,

  "statusCode": 500,
  "data": {

}

"message": "Internal server error"

  }
```

{% endtab %}
{% endtabs %}
