# Set up recurring payments

This guide covers step by step what you need to do in order to start accepting recurring crypto payments with 8Pay.

We will assume you are a **streaming service provider** who offers a monthly plan of 10 USDT and wants to integrate a *Subscribe* **button** into its **website**.

### **1.** Create a plan

Go to the [Payments ](https://app.8pay.network/payments)page of the web app and click on **Create payment**.

Select *Automatic Payments* then fill the form selecting the billing model that better suits your needs. For this specific case, we need billings to be performed in advance so the *Fixed Recurring* billing model is the perfect fit.

Fill the rest of the parameters and confirm the creation through your wallet.&#x20;

<figure><img src="/files/beBy3Prl4IYdzEcwrkX2" alt="" width="375"><figcaption></figcaption></figure>

### 2. Generate a button

Go to the newly created plan's page and click on **Buttons.**

Configure the behaviour by customizing the available parameters (full details are available [here](/integrations/buttons/fixed-recurring.md)) then click on **Generate**.

The **HTML code** for the button will be automatically copied to your clipboard.

Go into your website's source code and paste it there.

![](/files/-MarfLhxqUjZ1krgmGL6)

### 3. Setup webhook

To receive notifications whenever a new event related to your plan occurs (e.g. when a customer subscribes) you can setup a webhook URL.

To do so, go to the plan page and click on **Actions** > **Webhook**.

More info on webhook notifications can be found [here](/webhook-notifications/overview.md).

### 4. Wait for customers to subscribe

Upon clicking on the button generated in step 2, customers will be redirected to 8Pay's hosted checkout page where they will be guided through the payment process.

<figure><img src="/files/A1Fsts074rJEgPVCCRYD" alt="" width="375"><figcaption></figcaption></figure>

After payment is completed, you will get a notification to the webhook configured in step 3 which will look like this:

```
{
    "id": "5ccf8bdc7707a8effa371d01452644d3a388b975290b968874d0a44ec0219226",
    "type": "fixed-recurring",
    "event": "Subscription",
    "timestamp": 1585220116,
    "transactionHash": "0xb0f21bf5d722d981330d45d8625568cd0b356e8c7c464857131a6ebf99eadf80",
    "transactionStatus": "confirmed",
    "data": {
        "planId":  "0xb7934ebf676eb81606da5dded26433ce994d9767924387d65378f263845f3af9",
        "subscriptionId": "0xf0e6a20e8069d403a538729549a17544a2bca3672312a4aed571d115e1fde7d4",
        "user": "0xB2e9F6F9414ea12A33302923A55b9B4Cf99CCD90"
    }
}
```

### 5. Bill the customers

After the current cycle is over, customers will have to be billed for the next cycle in order to continue using the service. To do so, you can use the [Javascript SDK](/integrations/javascript-sdk.md) and program a server side script that triggers billing for the subscription when it's due.

Here is a simple script used the charge the customer of a subscription:

```javascript
const Web3 = require('web3');
const EightPaySDK = require('@8pay/sdk');

const web3 = new Web3('<provider-url>');
const eightPay = new EightPaySDK(web3, EightPaySDK.Network.BSC);

const privateKey = '<private-key>';

const planId = '0xb7934ebf676eb81606da5dded26433ce994d9767924387d65378f263845f3af9';
const subscriptionIds = ['0xf0e6a20e8069d403a538729549a17544a2bca3672312a4aed571d115e1fde7d4'];

eightPay.fixedRecurring.bill(planId, subscriptionIds)
    .send({ privateKey })
```

**Notes:**

* The plan's ID can be found in the url of the plan's page.
* SDKs for different programming languages will be release in the near future. Until then, you will need to develop a custom integration to call our smart contracts directly.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.8pay.network/guides/set-up-recurring-payments.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
