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 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.

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) 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.

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.

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.

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 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:

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 })


  • 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.

Last updated