# Introduction

### What is 8Pay?

The 8pay project is a groundbreaking payment protocol that aims to bridge the gap between fiat currency and cryptocurrencies. By leveraging automated smart contracts and a permissionless design, 8pay empowers crypto assets with enhanced functionality while maintaining the core principles of decentralization. The protocol enables seamless **single, recurring and on-demand payments**, making cryptocurrencies suitable for everyday transactions.

The adoption of cryptocurrencies by merchants and businesses has faced various challenges, including the absence of repeat payment options commonly found in traditional financial systems. 8pay addresses these issues by providing the same level of convenience without the need for custody of funds or compromising user privacy.

With 8pay, a wide range of services, from settling utility bills to ordering replenishment-based services, becomes easily payable with cryptocurrencies. Designed for both business-to-business (B2B) and business-to-consumer (B2C) applications, 8pay offers a user-friendly web and mobile app that facilitates payment management through smart contracts. The protocol supports stablecoins, the native 8PAY token, and many selected tokens, providing flexibility and compatibility.

One of the notable advantages of integrating 8pay's technology is its accessibility and user-friendliness. Merchants can effortlessly create and manage payments using the 8pay app, share payment links and buttons seamlessly, and connect with advanced features through API or SDK integration. Users, on the other hand, can set spending limits, authorize payments, all while retaining control over their personal information and funds. Additionally, users can lock 8PAY tokens in their wallet to benefit from a discount on transaction fees.


# Features

Before diving into the integration process, it's essential to understand the available features offered by 8Pay. These options provide flexibility for merchants to cater to different payment scenarios. Here's a quick rundown of each one.

### **One Time**

The One Time feature is designed for non-subscription transactions, making it ideal for e-commerce purchases. Additionally, it offers the convenient functionality of splitting payments across multiple recipients. This empowers merchants to effortlessly handle transactions involving multiple parties.

### **Fixed Recurring**

The Fixed Recurring feature enables merchants to set up recurring payments of a fixed amount at regular intervals. Users are charged the fixed amount at the subscription time and at the start of each billing period. This payment type is ideal for services like gym memberships or streaming services.

### **Variable Recurring**

The Variable Recurring feature allows for recurring payments of variable amounts at consistent intervals. This is particularly useful for businesses that offer curation-based services or content subscriptions. Merchants can set a maximum deduction amount, providing flexibility while ensuring customers are charged fairly. Users are charged the variable amount at the end of each billing period.

### **On demand**

The On Demand feature facilitates customizable recurring transactions. Buyers and sellers can establish a recurring payment agreement, with the option for users to exit the arrangement at any time. Similar to a bank direct debit, this feature grants the merchant the ability to withdraw funds from the user's wallet based on agreed-upon terms, offering convenience and flexibility.

### **Scheduled Payments**

Scheduled Payments empower users to automate their payments, ensuring funds are sent at specific times without the need for manual intervention. Whether it's a one-time scheduled payment or at regular intervals, such as monthly payrolls, this feature streamlines the payment process, enhancing convenience, efficiency, and helping users stay on top of their financial obligations.

### **Invest (Dollar Cost Averaging)**

The Invest feature allows users to automate their crypto investments through regular purchases over time. By employing Dollar Cost Averaging (DCA), users can mitigate market volatility by spreading out their investment costs. This approach enables users to gradually build their crypto portfolio and potentially benefit from long-term growth.

### **Streaming Donations**

Streamers can leverage the Streaming Donations feature to expand their donation options by accepting cryptocurrencies on popular platforms like Twitch and YouTube. By offering viewers the ability to donate in cryptocurrencies, content creators can enhance their revenue streams and engage with their audience in new and exciting ways.

### **Shopify**

The Shopify integration empowers store owners to accept cryptocurrencies as a form of payment. By integrating 8Pay with their Shopify stores, businesses can tap into the growing crypto market and offer customers a new and convenient way to make purchases. This integration expands payment options and enables merchants to cater to crypto-savvy customers.

### **WooCommerce**

The 8Pay WooCommerce plugin seamlessly incorporates cryptocurrency payments into online stores powered by WooCommerce. With this plugin, store owners can expand their payment options and cater to customers who prefer using popular cryptocurrencies. It simplifies the process of accepting crypto payments, enhancing the overall shopping experience.


# Chains

8Pay is a versatile payment solution that supports multiple blockchain networks, providing users with flexibility and accessibility. With multi-chain compatibility, you can easily adapt to different blockchain environments and cater to a broader range of customers, all while enjoying the benefits of decentralized finance and borderless transactions.

### Supported chains

* **BNB Chain**
* **Ethereum**
* **BNB Chain Testnet** (Sandbox)


# Payment flow

8Pay provides a comprehensive payment solution that caters to both single payments and recurring payments, offering flexibility and convenience to users and merchants alike.

### Single Payments

In the case of single payments through 8Pay, users have the option to connect their personal wallet and transfer funds directly to the merchant. This means that when making a single payment, the funds are securely transferred directly from the user's wallet to the merchant's wallet. To initiate this process, users can simply click on the "Pay with wallet" button during checkout and choose their preferred wallet from the available options.

<div><figure><img src="/files/Q3EJQ5k2KDyqKetgMEiQ" alt=""><figcaption></figcaption></figure> <figure><img src="/files/P1LJmTGr8mGe3nR48jzd" alt=""><figcaption></figcaption></figure></div>

Additionally, 8Pay provides another option for making single payments without the need to connect a personal wallet. Users can choose to send the funds from an exchange or any other platform where they hold their funds, even if they don't have direct access to a wallet. This allows users who prefer not to connect their personal wallets to still make single payments using their existing cryptocurrency holdings.

By leveraging this additional option, users can conveniently make single payments without the need to handle their own wallets or interact directly with the blockchain. Instead, they can rely on the 8Pay platform to facilitate the transfer of funds from their exchange account or other platforms to the merchant's wallet, ensuring a secure and efficient payment process.

With the direct transfer of funds or the alternative option for using existing holdings from external platforms, users can have confidence that their payments reach the intended merchant securely and without the complexity of managing their own wallets. This payment flow provides flexibility, convenience, and control over the funds being transferred, enabling users to make seamless transactions with ease and security.

### Recurring Payments

To subscribe to a recurring payment, users can easily initiate the process by clicking on the "Subscribe" button provided. This action prompts the user to interact with their personal wallet, where they can authorize and confirm the subscription.

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

By clicking on the "Subscribe" button, users are seamlessly directed to their wallet interface, where they can authorize the recurring payment. This interaction with the wallet ensures a secure and transparent process, as the user retains full control over their wallet and funds.

Once the user has confirmed the subscription from their wallet, the recurring payment is initiated, and the funds will be automatically transferred from the user's wallet to the merchant's wallet according to the predefined schedule.


# Sandbox Environment

The Sandbox Environment provided by 8Pay allows developers to safely and securely test their integrations on the Binance Smart Chain Testnet. It offers a controlled environment that simulates blockchain interactions without using real funds or affecting the live network.

By utilizing the Sandbox Environment, developers can experiment with various functionalities and test their integration's behavior in a risk-free environment. It enables comprehensive testing of payment transactions, recurring payments, and other features supported by 8Pay's platform.

To access the Sandbox Environment, developers can select the BNB Chain Testnet option, either through the 8Pay app or by using the appropriate chain parameter in API requests. This flexibility caters to different testing preferences and allows developers to choose the method that best suits their needs.

With the Sandbox Environment, developers can confidently refine their integrations, identify and resolve any issues, and ensure seamless functionality before deploying to the live blockchain. It provides a valuable testing ground for developers to optimize their integration and deliver a robust experience to their users.


# Fees

8Pay offers multiple payment options, each with a different commission depending on tier level.&#x20;

There are 4 tiers level (**Base, Silver, Gold** and **Platinum**) based on the amount of 8PAY tokens staked. The higher the tier, the greater the discount. Users can check their current tier, upgrade or downgrade it as needed by visiting the following link: <https://app.8pay.network/tiers>.

Please note that Autobiller and Scheduled Payments features are subject to an extra fee, charged over Gas Wallet, to cover commissions paid by 8Pay. This extra cost depends on the chain and network conditions and it’s equivalent to the cost of sending a standard transaction over the network at that time.<br>

<figure><img src="/files/HNXQu97389RwFuh42Xah" alt=""><figcaption></figcaption></figure>


# Set up single payments

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

We will assume you are the seller of a product called "**Beauty Cream"** which goes for *10 USDT* and want to integrate a *Pay* **button** into your **website**.

### **1.** Create a payment

Go to the [Home ](https://app.8pay.network/home)page of the app and click on **Receive**.

Fill the required parameters then click on *Create payment*.&#x20;

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

### 2. Embed the button

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

Once you have created the payment, you have 3 ways to share or embed it: **QR code**, **Link** or **HTML button**. For the purpose of this tutorial, we will use the HTML button so click on *Embed payment button*.

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/-MeW_KxsVpg5rLwlbQHB)

### 3. Receive payments

Congratulations! Your 8Pay integration is now complete. Upon clicking on the button you just embedded, your customers will go through the 8Pay's checkout page to complete the payment process.


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

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


# Setup automatic buy (DCA) on Dex

The 8Pay DCA feature allows users to automate their cryptocurrency investments using a Dollar Cost Averaging strategy. Dollar Cost Averaging involves making regular investments over time, regardless of market conditions, to mitigate the impact of volatility and potentially benefit from long-term growth.

### Create Investment

To create a DCA investment, users need to follow these steps:

1. Go to the [Invest](https://app.8pay.network/invest) section.
2. Select *Input Token* and insert *Input Amount.* Users can choose the token they want to invest with and specify the amount they want to allocate for each investment.
3. Set Swap Frequency: Users can define the frequency at which the swaps will occur. For example, if a user chooses a monthly frequency, the DCA will execute a swap every month based on the specified parameters.
4. Define Output Tokens and Percentages: Users can select one or more output tokens to receive as a result of each swap. They can allocate a percentage for each output token. For example, a user may want to allocate 50% of their investment to BTC and 50% to ETH.

Once the investment is created, 8Pay will automatically execute the swaps according to the defined parameters. 8Pay will swap the specified amount of the input token for the output tokens based on the percentages set by the user.

### DEX

The decentralized exchanges (DEX) used for token swaps depend on the blockchain on which the investment is created. Here are the DEX used for each chain:

* BNB Chain: *PancakeSwap*
* Ethereum: *Uniswap*

These DEX platforms are carefully chosen to ensure efficient and secure token exchanges, providing users with a seamless experience for their Dollar Cost Averaging investment strategy.

### Example

Here's an example to illustrate how the DCA feature works.

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

John sets up a monthly investment of 1000 USDT. He wants to allocate 50% of the investment to BTC and the remaining 50% to ETH. 8Pay will automatically execute the swaps each month, converting $500 into BTC and $500 into ETH. This allows John to gradually build his crypto portfolio over time, spreading out his investments and potentially benefiting from the long-term growth of both BTC and ETH.

By using the 8Pay DCA feature, users can take advantage of automated, regular investments in the cryptocurrency market while implementing a proven investment strategy. It provides convenience, reduces the impact of market volatility, and enables users to gradually build their crypto portfolio over time.

Please note that the availability of specific tokens and the supported swap pairs are listed in the select menu, offering a variety of options to choose from.


# Overview

## How to integrate?

Integrating with 8Pay opens up a world of possibilities for your business. Whether you're an e-commerce store owner, a content creator, or a service provider, 8Pay offers a range of powerful features to enhance your payment experience. From one-time payments to recurring subscriptions, automated scheduled payments and donations on popular streaming platforms, 8Pay has got you covered. With seamless integrations like embedding buttons, connecting with Shopify or WooCommerce, and leveraging the Javascript SDK, you can easily start accepting cryptocurrency payments, expand your customer base, and streamline your financial operations. Get ready to unlock the potential of crypto payments with 8Pay's flexible and user-friendly integration options.

### Buttons

Integrate 8Pay effortlessly by adding a button to your website. Simply copy and paste the HTML code generated from the web app or customize it to suit your specific billing model requirements.

{% content-ref url="/pages/-MamchUa8\_fpKYSMQXM-" %}
[Buttons](/integrations/buttons)
{% endcontent-ref %}

### Shopify

Enable cryptocurrency payments on your Shopify store by creating an app, granting permission, and securely linking it with 8Pay. Copy and paste the access token into the 8Pay app to start accepting crypto payments seamlessly.

{% content-ref url="/pages/gqK6TmJjE8NY4R587W1k" %}
[Shopify](/integrations/shopify)
{% endcontent-ref %}

### WooCommerce

Expand your WooCommerce store's payment options by installing the 8Pay WooCommerce plugin. Select the desired chains and tokens to receive payments, and empower your customers to make purchases using cryptocurrencies.

{% content-ref url="/pages/-MdaheYC-ltd-xjBVpvQ" %}
[Woocommerce](/integrations/woocommerce)
{% endcontent-ref %}

### Streaming Donations

Streamers can effortlessly receive crypto donations by creating a donation link to share on platforms like Twitch and YouTube. Connect with your audience and accept contributions in cryptocurrencies hassle-free.

{% content-ref url="/pages/wUKHp4yOs3KMVCeT7bjb" %}
[Streaming Donations](/integrations/streaming-donations)
{% endcontent-ref %}

### Javascript SDK

Utilize the powerful Javascript SDK provided by 8Pay to programmatically interact with their smart contracts. Manage your subscriptions, trigger billings, or terminate them with ease, all through streamlined SDK integration.

{% content-ref url="/pages/-MamNcJZs71Wh\_VPQart" %}
[JavaScript SDK](/integrations/javascript-sdk)
{% endcontent-ref %}


# Short URLs

In this section, we'll explore how 8Pay uses short URLs to simplify the integration of its versatile billing models into various applications and platforms. These short URLs streamline the process, making it easier for users to access and interact with different billing models.

### One Time/Wallet-to-Wallet

When users visit a one-time Short URL, user have two payment options

* Connecting a wallet to send a transaction to OneTime contract
* Sending the amount to an intermediary 8Pay wallet (**Wallet-to-Wallet**)

The Wallet-to-Wallet option is especially useful if the funds are sent from an exchange or a third party wallet that the user does not control.&#x20;

It requires an additional fee due to more network costs, that we'll call **Service Fee** from now on.

The creator of the Short URL has the flexibility to decide whether he wants to charge the payer for the Service Fee or deduct the amount from the receivers. This can be achieved by checking a specific checkbox while creating the Short URL from the web-app or, if you're using the API, through the *chargeReceiversForServiceFee* parameter.&#x20;

<figure><img src="/files/jILrA40V8zP6WH8xjfJP" alt="" width="563"><figcaption></figcaption></figure>

{% content-ref url="/pages/-MaSzrWdLzHtcb0RPola" %}
[Short Urls](/api/one-time/short-urls)
{% endcontent-ref %}

### Fixed Recurring

{% content-ref url="/pages/-MahDh5K5UdY-O7bu8dW" %}
[Short Urls](/api/fixed-recurring/short-urls)
{% endcontent-ref %}

### On Demand

{% content-ref url="/pages/-Mam2vBRJ1od\_luAqzrG" %}
[Short Urls](/api/variable-recurring/short-urls)
{% endcontent-ref %}

### On Demand

{% content-ref url="/pages/-Mam7-L4WA3IxK6AHJK7" %}
[Short Urls](/api/on-demand/short-urls)
{% endcontent-ref %}


# Buttons

One way of integrating with 8Pay is by embedding a button into your **website.**

Embedding a button is a very simple step that only requires copy-pasting **HTML code** into the source code of your website. The code snippet for a button can be **generated automatically** form the web app or customized editing the **template** of each billing model to fit your use case.

### Templates

{% content-ref url="/pages/-MamezKJKYJ39NkwjiHv" %}
[One Time](/integrations/buttons/one-time)
{% endcontent-ref %}

{% content-ref url="/pages/-Mamevqba5LddpHshz5W" %}
[Fixed Recurring](/integrations/buttons/fixed-recurring)
{% endcontent-ref %}

{% content-ref url="/pages/-Mamf0ZZCWU7pzROObcn" %}
[Variable Recurring](/integrations/buttons/variable-recurring)
{% endcontent-ref %}

{% content-ref url="/pages/-Mamf3PHN8wwRT06lrVK" %}
[On Demand](/integrations/buttons/on-demand)
{% endcontent-ref %}


# One Time

The available parameters are:

* **chain** *(string)* - chain used for the payment
* **description** *(string)* - payment's description
* **receivers** *(array)* - array of beneficiaries
* **amounts** *(array)* - array of amounts to send to the respective receivers
* **token** *(string)* - token symbol
* **category** *(string)* - category of the payment
* **tag** *(string)* - label used for identification or classification (*optional*)
* **callbackSuccess** *(string)* - redirect url after success (*optional*)
* **callbackError** *(string)* - redirect url after failure (*optional*)
* **webhook** *(string)* - url for server-side notification (*optional*)
* **extra** *(string)* - json object containing extra parameters that will be sent to webhook (*optional*)

The following data will be appended to the `callbackSuccess` url as query parameters:

* **user** *(string)* - address of the user who completed the payment
* **transactionHash** *(string)* - hash of the transaction

### **Example button**

```markup
<form action="https://checkout.8pay.network/" method="POST">
    <input type="hidden" name="type" value="one_time">
    <input type="hidden" name="chain" value="bsc">
    <input type="hidden" name="description" value="Ebook">
    <input type="hidden" name="token" value="8PAY">
    <input type="hidden" name="receivers[0]" value="0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff">
    <input type="hidden" name="receivers[1]" value="0x5B848132d3a0111d4daB7060b6051961013C71c7">
    <input type="hidden" name="amounts[0]" value="5">
    <input type="hidden" name="amounts[1]" value="2">
    <input type="hidden" name="category" value="Shop">
    <input type="hidden" name="tag" value="ebook_859294">
    <input type="hidden" name="extra[banner]" value="BR69">
    <input type="hidden" name="extra[traffic]" value="facebook">
    <input type="hidden" name="callbackSuccess" value="https://www.google.com/">
    <input type="hidden" name="callbackError" value="https://www.google.com/">
    <input type="image" src="https://cdn.8pay.network/img/buttons/pay_in_crypto_blue.png" border="0" name="submit" alt="8PAY">
</form>
```


# Fixed Recurring

The available parameters are:

* **chain** *(string)* - chain used for the payment
* **planId** *(string)* - if od the plan
* **callbackSuccess** *(string)* - redirect url after success (*optional*)
* **callbackError** *(string)* - redirect url after failure (*optional*)
* **extra** *(string)* - json object containing extra parameters that will be sent to webhook (*optional*)

The following data will be appended to the `callbackSuccess` url as query parameters:

* **user** *(string)* - address of the user who completed the payment
* **transactionHash** *(string)* - hash of the transaction

### **Example button**

```markup
<form action="https://checkout.8pay.network/" method="POST">
    <input type="hidden" name="type" value="fixed_recurring">
    <input type="hidden" name="chain" value="bsc">
    <input type="hidden" name="planId" value="0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7">
    <input type="hidden" name="extra[banner]" value="BR69">
    <input type="hidden" name="extra[traffic]" value="facebook">
    <input type="hidden" name="callbackSuccess" value="https://www.google.com/">
    <input type="hidden" name="callbackError" value="https://www.google.com/">
    <input type="image" src="https://cdn.8pay.network/img/buttons/pay_in_crypto_blue.png" border="0" name="submit" alt="8PAY">
</form>
```


# Variable Recurring

The available parameters are:

* **chain** *(string)* - chain used for the payment
* **planId** *(string)* - if od the plan
* **callbackSuccess** *(string)* - redirect url after success (*optional*)
* **callbackError** *(string)* - redirect url after failure (*optional*)
* **extra** *(string)* - json object containing extra parameters that will be sent to webhook (*optional*)

The following data will be appended to the `callbackSuccess` url as query parameters:

* **user** *(string)* - address of the user who completed the payment
* **transactionHash** *(string)* - hash of the transaction

### **Example button**

```markup
<form action="https://checkout.8pay.network/" method="POST">
    <input type="hidden" name="type" value="variable_recurring">
    <input type="hidden" name="chain" value="bsc">
    <input type="hidden" name="planId" value="0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7">
    <input type="hidden" name="extra[banner]" value="BR69">
    <input type="hidden" name="extra[traffic]" value="facebook">
    <input type="hidden" name="callbackSuccess" value="https://www.google.com/">
    <input type="hidden" name="callbackError" value="https://www.google.com/">
    <input type="image" src="https://cdn.8pay.network/img/buttons/pay_in_crypto_blue.png" border="0" name="submit" alt="8PAY">
</form>
```


# On Demand

The available parameters are:

* **chain** *(string)* - chain used for the payment
* **planId** *(string)* - if od the plan
* **callbackSuccess** *(string)* - redirect url after success (*optional*)
* **callbackError** *(string)* - redirect url after failure (*optional*)
* **extra** *(string)* - json object containing extra parameters that will be sent to webhook (*optional*)

The following data will be appended to the `callbackSuccess` url as query parameters:

* **user** *(string)* - address of the user who completed the payment
* **transactionHash** *(string)* - hash of the transaction

### **Example button**

```markup
<form action="https://checkout.8pay.network/" method="POST">
    <input type="hidden" name="type" value="on_demand">
    <input type="hidden" name="chain" value="bsc">
    <input type="hidden" name="planId" value="0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7">
    <input type="hidden" name="extra[banner]" value="BR69">
    <input type="hidden" name="extra[traffic]" value="facebook">
    <input type="hidden" name="callbackSuccess" value="https://www.google.com/">
    <input type="hidden" name="callbackError" value="https://www.google.com/">
    <input type="image" src="https://cdn.8pay.network/img/buttons/pay_in_crypto_blue.png" border="0" name="submit" alt="8PAY">
</form>
```


# Shopify

This tutorial provides Shopify store owners with a concise and straightforward guide to set up cryptocurrency payment acceptance. In just a few steps, users can integrate their Shopify store with 8Pay and start accepting cryptocurrencies as a form of payment. This seamless integration allows businesses to tap into the growing crypto market and offer customers a new and convenient way to make purchases.

1. **Go to your Shopify "Apps", click "Develop Apps", and "Create an App".**

<figure><img src="/files/aHcF06Oj6kQGZJmbQCdh" alt=""><figcaption></figcaption></figure>

If it is your first time creating an App on your store, you must enable the "Custom App Development" as shown below.

<figure><img src="/files/2zMclFIjqhfP1cRNfGzY" alt="" width="540"><figcaption></figcaption></figure>

<figure><img src="/files/RILgKAl55AwdTCqt7933" alt="" width="429"><figcaption></figcaption></figure>

Enter the App name and the developer's email.

<figure><img src="/files/saccUlmcJjQfy6eZjnaD" alt="" width="540"><figcaption></figcaption></figure>

In the Configuration tab, choose *Admin API integration*.&#x20;

Give *Read* and *Write* permission to Orders and Scripts, then click *Save*.

Be sure to select the following permission:

* *`write_orders`*
* `read_orders`
* *`write_script_tags`*
* *`read_script_tags`*

<figure><img src="/files/abXTwzYfVtpu9Y4nyZCH" alt="" width="540"><figcaption></figcaption></figure>

Go to the API credentials tab and press *Install App*.

<figure><img src="/files/6UG0KAgalz8C1vD3pU3T" alt="" width="540"><figcaption></figcaption></figure>

Once your App is installed, you can get your **Access Token** that you will need it in the next step.

<figure><img src="/files/st7356df2AzZfJKeJWwl" alt="" width="540"><figcaption></figcaption></figure>

2. **Connect the App to 8PAY**

Go to the [Shopify](https://app.8pay.network/shopify) section and click *Connect* in the top right corner.

<figure><img src="/files/VnfWEeKHHZXptCnKeMSc" alt=""><figcaption></figcaption></figure>

Fill the form with the following fields:

1. Insert your ".myshopify.com" domain (custom domains will not work, be sure to get your ".myshopify.com" if you are using a custom one). To get it, click on setting under your Shopify Admin page and you will find it on the top left corner of the Settings page.
2. Insert your App Access Token.
3. Click Connect

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

3. **Activate the payment method on Shopify**

Go to Shopify Settings > Payment > Manual Payment Methods.&#x20;

<figure><img src="/files/iLLuKCaHqkMLARtcz1kD" alt="" width="380"><figcaption></figcaption></figure>

Add a Custom payment method called "**8PAY - Pay with Crypto"** and click on *Activate.*

**Note: be sure to put the EXACT Payment Method Name otherwise the App will not work.**

<figure><img src="/files/xIJaUy3Wlpi6CX8l1d7X" alt="" width="540"><figcaption></figcaption></figure>


# Woocommerce

The WooCommerce 8Pay Payment Gateway plugin allows merchants to receive crypto payments on their stores.

## Ensure Compatibility with WooCommerce 8.3+

As of WooCommerce version 8.3, the default checkout experience has shifted from classic shortcodes to a new block-based checkout. To continue using the  plugin , you must switch the checkout back to the classic shortcode.

> *<mark style="color:red;">**Leaving the default block-based checkout experience will result in a payment method not being detected it**</mark>*<mark style="color:red;">**&#x20;**</mark><mark style="color:red;">**will result in the checkout page displaying an error message stating,**</mark>**&#x20;**<mark style="color:orange;">**“There are no payment methods available.”**</mark>&#x20;

We will provide three methods to ensure that you are utilizing the Classic Cart and Checkout.

{% tabs %}
{% tab title="First Method" %}
From your wordpress admin page go to **Pages -> All Pages**, and then locate and edit the **Cart/Checkout** page.

1. Click to the **Document Overview**  <img src="/files/ZyxSzDbkNYDtM27oGG0k" alt="" data-size="line">&#x20;
2. Click on **Checkout** under the **List View** ![](/files/4I0VOhTa9cXCEfEJ4KEP)
3. Click on **Checkout Totals** ![](/files/3G3fEDDNCzQBKLV0Hwbt)
4. Click on Switch to classic Checkout

&#x20;<img src="/files/wq9GQtEqoJy2gj1TH7ul" alt="" data-size="original">

Please refer to the attached screenshot for a comprehensive overview of all the steps involved.

<figure><img src="/files/U0MYGvCA21q2034DIRyE" alt=""><figcaption></figcaption></figure>

{% endtab %}

{% tab title="Second Method" %}

> *Please refer to the WooCommerce documentation section titled* [*Reverting to the Classic Cart and Checkout*](https://woocommerce.com/document/woocommerce-store-editing/customizing-cart-and-checkout/#reverting-to-the-classic-cart-and-checkout)

1. **If using a block theme**: Go to **Appearance -> Editor -> Pages ->** Select Cart or Checkout -> click the *Edit icon*\
   **localIf using a non-block theme**: Go to ***Pages -> All Pages***, and then locate and edit the Cart/Checkout page.
2. Open the List View and select the Cart or Checkout block.
3. Click the “**Transform**” button, which is leftmost in the block toolbar
4. Choose “**Classic Shortcode**”.
5. The block will be transformed into a Classic Shortcode placeholder block.
6. Save your changes by clicking the Save button in the top bar.

<figure><img src="/files/2Y6YDD6IbwhZJijncHkA" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Third Method" %}

> The following youtube video shows how to manually switch the checkout  to the short-code version

{% embed url="<https://www.youtube.com/watch?v=3szAM1EJkHo>" %}

{% endtab %}
{% endtabs %}

## Installation

#### Automatic installation

Automatic installation is the easiest option as WordPress handles the file transfers itself and you don’t need to leave your web browser. To do an automatic install of the 8Pay Payment Gateway plugin, log in to your WordPress dashboard, navigate to the Plugins menu and click Add New.

In the search field type “8Pay Payment Gateway” and click Search Plugins. Once you’ve found our plugin you can view details about it such as the point release, rating, and description. Most importantly, of course, you can install it by simply clicking "Install Now", then "Activate".

#### Manual installation

The manual installation method involves downloading our plugin from [here](https://it.wordpress.org/plugins/8pay-payment-gateway/) and uploading it to your web server via your favorite FTP application. The WordPress codex contains instructions on how to do this [here](http://codex.wordpress.org/Managing_Plugins#Manual_Plugin_Installation).

## Setup

### One-Time Payment

Navigate to the "Plugin" menu and click on "Settings" in the 8Pay Payment Gateway row.

![](/files/-MedNXvskxTB29z8X2rJ)

Fill the following fields:

* Description: the payment method description visible on the checkout page
* API Key: the api key generated from the [API keys](https://app.8pay.network/keys) section of the web app
* Tokens: the tokens available at checkout
* Receiver: the blockchain address where payments will be received

![](/files/zFHiOsesA7JKeHO9BwEB)

![](/files/RSfCIcFgA0Mme3xB7mdt)

### Recurring Payments

The plugin also supports recurring payment on subscription products created with the [WooCommerce Subscriptions](https://woocommerce.com/products/woocommerce-subscriptions/) plugin.

To setup a recurring payment for a product follow these steps:

* Create one or more Automatic Payment on the [Payments](https://app.8pay.network/payments) section of the web-app&#x20;
* Go to the WooCommerce "Products" section
* Click on your subscription product
* Scroll down to the product data section and select "Attributes"
* Add a new attribute "8pay\_plan\_ids" containing a comma separated list of plan ids that you want to associate to the product (up to one per chain)

<figure><img src="/files/nceE80QjhIuN4aObWPHa" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/UZUbxRmEDTGsKGtnzwVj" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/LIyuk2VmxqhGVXyD6R9i" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/tpt2jUKiTfLhDcdVoOle" alt=""><figcaption></figcaption></figure>


# Streaming Donations

This tutorial is designed for streamers looking to expand their donation options by accepting cryptocurrencies on platforms like Twitch and YouTube. By following the step-by-step guide, streamers can easily integrate their channels with 8Pay, enabling viewers to make cryptocurrency donations. This opens up new avenues for streamers to engage with their audience and receive support in a decentralized and secure manner. Start accepting crypto donations and enhance your streaming experience today with the help of this tutorial.

{% embed url="<https://8pay.medium.com/how-to-accept-crypto-donations-on-twitch-and-youtube-with-8pay-72925acd920b>" %}


# JavaScript SDK

The SDK provides a way to programmatically interact with 8Pay's smart contracts.

It allows you to manage the subscriptions to your plans (e.g. trigger billings or terminate them).

## Installation

This is a [Node.js](https://nodejs.org/en/) module available through the [npm registry](https://www.npmjs.com/).

Before installing, [download and install Node.js](https://nodejs.org/en/download/).

Installation is done using the command:

```bash
$ npm install @8pay/sdk
```

To see all package details on the npm registry, click [here](https://www.npmjs.com/package/@8pay/sdk).

## Usage

This module uses [web3](https://www.npmjs.com/package/web3) under the hood, which is the most popular library used to interact with the `Web 3.0`.

To keep things familiar with `web3`, it follows the same strucure when sending transactions but adds additional functionalities.

To get started, import the module and provide it with an instance of `web3`:

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

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

### Sending transactions

There are two ways to sign a transaction before broadcasting it to the blockchain:

* Using an unlocked account (e.g. when using Metamask)

```javascript
eightPay.fixedRecurring.bill(planId, subscriptionIds)
    .send({ from: account })
```

* With privateKey

```javascript
eightPay.fixedRecurring.bill(planId, subscriptionIds)
    .send({ privateKey: '0x32df7......' })
```

### Estimate gas

The gas consumed by a transaction can be estimated using the `estimateGas` function which takes and `options`object and returns the amount of gas as number:

```javascript
eightPay.fixedRecurring.bill(planId, subscriptionIds)
    .estimateGas(options)
```

### Options

The `send` method accepts the same options available in `web3` like `gas`, `gasPrice`, `nonce` and so on.

### Events

The following events are emitted when sending a transaction: `transactionHash`, `receipt`, `confirmation` and `error`.

```javascript
const receipt = await eightPay.fixedRecurring.bill(planId, subscriptionIds)
    .send({ from: account })
    .on('transactionHash', hash => {})
    .on('receipt', receipt => {})
    .on('confirmation', confirmation => {})
    .on('error', error => {})
```

## Methods

Here is the list of all the available methods for each billing model.

### Fixed Recurring

#### Bill

Bills subscriptions of a plan.

Parameters:

* **planId** - id of the plan
* **subscriptionIds** - array of subscription ids

```javascript
const planId = '0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf4';
const subscriptionIds = ['0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba'];

const receipt = await eightPay.fixedRecurring.bill(planId, subscriptionIds)
    .send({ from: account })
```

#### Terminate

Forcefully cancels subscriptions of a plan.

The sender account must be the plan's admin or an operational account with terminate permission.

Parameters:

* **planId** - id of the plan
* **subscriptionIds** - array of subscription ids

```javascript
const planId = '0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf4';
const subscriptionIds = ['0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba'];

const receipt = await eightPay.fixedRecurring.terminate(planId, subscriptionIds)
    .send({ from: account })
```

### Variable Recurring

#### Bill

Bills subscriptions of a plan.

The sender account must be the plan's admin or an operational account with bill permission.

Parameters:

* **planId** - id of the plan
* **subscriptionIds** - array of subscription ids
* **amounts** - array of amounts to charge for each subscription

```javascript
const planId = '0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf4';
const subscriptionIds = ['0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba'];
const amounts = [eightPay.utils.parseAmount('10', '8PAY')];

const receipt = await eightPay.variableRecurring.bill(planId, subscriptionIds, amounts)
    .send({ from: account })
```

#### Terminate

Forcefully cancels subscriptions of a plan.

The sender account must be the plan's admin or an operational account with terminate permission.

Parameters:

* **planId** - id of the plan
* **subscriptionIds** - array of subscription on-chain ids

```javascript
const planId = '0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf4';
const subscriptionIds = ['0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba'];

const receipt = await eightPay.variableRecurring.terminate(planId, subscriptionIds)
    .send({ from: account })
```

### On Demand

#### Bill

Bills subscriptions of a plan.

The sender account must be the plan's admin or an operational account with bill permission.

Parameters:

* **planId** - id of the plan
* **subscriptionIds** - array of subscription ids
* **amounts** - array of amounts to charge for each subscription

```javascript
const planId = '0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf4';
const subscriptionIds = ['0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba'];
const amounts = [eightPay.utils.parseAmount('10', '8PAY')];

const receipt = await eightPay.onDemand.bill(planId, subscriptionIds, amounts)
    .send({ from: account })
```

#### Terminate

Forcefully cancels subscriptions of a plan.

The sender account must be the plan's admin or an operational account with terminate permission.

Parameters:

* **planId** - id of the plan
* subscriptionIds - array of subscription ids

```javascript
const planId = '0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf4';
const subscriptionIds = ['0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba'];

const receipt = await eightPay.onDemand.terminate(planId, subscriptionIds)
    .send({ from: account })
```

## Accounts

The accounts utility can be used to obtain an account object from a private key or a mnemonic. The account object has two properties: `address` and `privateKey`.

```javascript
const privateKey = '<private-key>';
const account = eightPay.accounts.fromPrivateKey(privateKey);

// OR

const mnemonic = '<mnemonic>';
const mnemonicIndex = 0;
const account = eightPay.accounts.fromMnemonic(mnemonic, mnemonicIndex);

console.log(account);

/*
{
    address: '0x2F2....',
    privateKey: '0x1Ee...'
}
*/
```

## Utils

To help in parsing amount from and to ethereum decimals, you can use `addDecimals` and `parseDecimals` methods.

```javascript
const parsedAmount = eightPay.utils.parseAmount('1', '8PAY') // 1000000000000000000
const amount = eightPay.utils.formatAmount(parsedAmount, '8PAY') // 1
```


# Overview

The 8Pay **REST API** provides developers with a straightforward and efficient way to retrieve information about operations performed on the blockchain. While the API allows for reading data, it does not support sending payments, creating recurring payments, or other blockchain interactions, which require direct interaction with the blockchain through a wallet or utilizing the 8Pay JavaScript SDK.

## Authentication

To access the 8Pay REST API, developers need to authenticate their requests using an API key that can be generated in the [API Keys](https://app.8pay.network/keys) section.&#x20;

The API key should be included in the `Headers` section of the HTTP request using the format:&#x20;

```bash
Authorization: Bearer [API KEY]
```

## Base URL

The base URL for making API requests is:

```
https://api.8pay.network/v1/:chain/
```

The `:chain` parameter in the base URL is a placeholder that should be replaced with the desired chain identifier when making API requests. Depending on the specific chain you want to interact with, you would replace `:chain` with one of the supported chain identifiers:

* **bsc** (BNB Chain)
* **ethereum** (Ethereum)
* **sandbox** (BNB Chain Testnet)

## Pagination

API endpoints returning lists of objects can have a lot of items and are thus paginated.

Pagination can be controlled passing the following query parameters in your HTTP request:

* **limit**: the number of items to fetch in the request (default 100, max 1000)
* **offset**: an arbitrary offset at which to start retrieving items (default 0)

The formatting of a paginated result is always:&#x20;

```javascript
{
    "data": [],
    "limit": 100,
    "offset": 0,
    "total": 10
}
```

For simplicity, only the data field will be shown from now on.

## Errors

8Pay uses conventional HTTP **response codes** to indicate the success or failure of an API request.

As a general rule:

* Codes in the `2xx` range indicate success
* Codes in the `4xx` range indicate incorrect or incomplete parameters (e.g., a required parameter was omitted, an operation failed with a 3rd party, etc.)
* Codes in the `5xx` range indicate an error with 8Pay's servers (these are rare)

8Pay also outputs an error message and an error code formatted in JSON:

```bash
{
    "error": {
        "code": 404,
        "message": "Page not found"
    }
}
```

## Transactions

Every operation on the blockchain is performed sending a transaction, uniquely identified by an hash. This identifier will be referred to as `transactionHash` in API responses.

Due to blockchain nature, the results produced by a transaction included in a block are not immediately final and can be reverted if a reorganization occurs. Finality is probabilistic and increases with the number of subsequent blocks mined after the block containing the transaction.

8Pay waits for a certain number of blocks depending on the chain before considering transactions confirmed:

* **BNB Chain**: 15 blocks
* **Ethereum**: 12 blocks

This status is referred to as `transactionStatus`.

At this time, the public APIs only support **confirmed** transactions.


# One Time

The One Time feature is designed for non-subscription transactions, making it ideal for e-commerce purchases. Additionally, it offers the convenient functionality of splitting payments across multiple recipients. This empowers merchants to effortlessly handle transactions involving multiple parties.

## Payments

A one-time payment is uniquely identified by its transaction hash.

The tag parameter can be used for an alternative way of identification or classification.

{% content-ref url="/pages/-MaSoqdF7VAs5Kvx3vGu" %}
[Payments](/api/one-time/payments)
{% endcontent-ref %}


# Payments

## Get a list of payments

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/one-time`

#### Path Parameters

| Name                                    | Type   | Description                              |
| --------------------------------------- | ------ | ---------------------------------------- |
| chain<mark style="color:red;">\*</mark> | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name            | Type   | Description                                                 |
| --------------- | ------ | ----------------------------------------------------------- |
| transactionHash | string | filter by transactionHash                                   |
| tag             | string | filter by tag                                               |
| sender          | string | filter by sender                                            |
| receiver        | string | filter by receiver                                          |
| token           | string | filter by token                                             |
| from            | string | filter by `timestamp` (default 0)                           |
| to              | string | filter by `timestamp` (default current timestamp)           |
| sort            | string | `asc` or `desc` (default `desc`), sort based on `timestamp` |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```http
{
    "data": [
        {
            "id": "0xc91551c7ed9a3c93081b7e5951dba12bafbdba0f3857449affe582a7b0381619",
            "description": "Ebook",
            "sender": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
            "token": "8PAY",
            "category": "Shop",
            "tag": "ebook_859294",
            "timestamp": 1574954504,
            "transactionHash": "0x7797672488458a27fe022981558636e25d92302bd80a19a4e84008aaa63ace21",
            "transactionStatus": "confirmed",
            "receivers": [
                {
                    "user": "0x38B70aC0BEf71A46Fc9E07f9c64913b9F533e54A",
                    "amount": "5",
                    "fee": "0.05"
                }
            ]
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get a payment

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/one-time/:id`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| id    | string | ID of the one-time                       |
| chain | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "id": "0xc91551c7ed9a3c93081b7e5951dba12bafbdba0f3857449affe582a7b0381619",
    "description": "Ebook",
    "sender": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
    "token": "8PAY",
    "category": "Shop",
    "tag": "ebook_859294",
    "timestamp": 1574954504,
    "transactionHash": "0x7797672488458a27fe022981558636e25d92302bd80a19a4e84008aaa63ace21",
    "transactionStatus": "confirmed",
    "receivers": [
        {
            "user": "0x38B70aC0BEf71A46Fc9E07f9c64913b9F533e54A",
            "amount": "5",
            "fee": "0.05"
        }
    ]
}
```

{% endtab %}
{% endtabs %}


# Transfers

## Get a list of transfers

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/one-time/transfers`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name     | Type   | Description                                                 |
| -------- | ------ | ----------------------------------------------------------- |
| tag      | string | filter by tag                                               |
| sender   | string | filter by sender                                            |
| receiver | string | filter by receiver                                          |
| token    | string | filter by token                                             |
| from     | string | filter by `timestamp` (default 0)                           |
| to       | string | filter by `timestamp` (default current timestamp)           |
| sort     | string | `asc` or `desc` (default `desc`), sort based on `timestamp` |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "description": "Ebook",
            "sender": "0x16F37b6c96C7038f3E4CDd7aAF9c9A8EC49c4EE7",
            "receiver": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
            "amount": "5.5",
            "fee": "0.05",
            "token": "8PAY",
            "oneTimeId": "0xc91551c7ed9a3c93081b7e5951dba12bafbdba0f3857449affe582a7b0381619",
            "category": "Streaming",
            "timestamp": 1582051910,
            "transactionHash": "0xfe335ee73fe51583a3549a71084f1e8e1d716b06052c0dd2bc864d15a5bb7555",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}


# Short Urls

Short urls allow you to share pre-formatted payment requests.

## Create a short url

<mark style="color:green;">`POST`</mark> `https://api.8pay.network/v1/:chain/one-time/short-urls`

#### Path Parameters

| Name  | Type  | Description                              |
| ----- | ----- | ---------------------------------------- |
| chain | sting | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

#### Request Body

| Name                                | Type    | Description                                                                                  |
| ----------------------------------- | ------- | -------------------------------------------------------------------------------------------- |
| name                                | string  | short url's name                                                                             |
| params                              | object  | object containing short url parameters                                                       |
| params.description                  | string  | payment's description                                                                        |
| params.receivers                    | array   | array of ethereum addresses                                                                  |
| params.amounts                      | array   | array of amounts to send to the respective receivers                                         |
| params.token                        | string  | erc20 token symbol, see Tokens                                                               |
| params.category                     | string  | category of the service/product, see Categories                                              |
| params.tag                          | string  | label used for identification or classification *(max 32 bytes)*                             |
| params.callbackSuccess              | string  | redirect url after success                                                                   |
| params.callbackError                | string  | redirect url after failure                                                                   |
| params.webhook                      | string  | url for server-side notification                                                             |
| params.extra                        | object  | extra parameters to be sent to webhook                                                       |
| params.chargeReceiversForServiceFee | boolean | when set to true receivers will be charged for service fee instead of sender (default false) |

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

```
{
    "path": "outwE",
    "name": "Ebook",
    "createdAt": 1574954504,
    "updatedAt": 1574954504,
    "params": {
        "description": "Ebook",
        "receivers": ["0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff"],
        "amounts": ["5"],
        "token": "8PAY",
        "category": "Shop",
        "tag": "ebook_859294",
        "chargeReceiversForServiceFee": false,
        "callbackSuccess": "https://yoursite.com/thankyou",
        "callbackError": "https://yoursite.com/error",
        "webhook": "https://yoursite.com/notifications",
        "extra": {
            "banner": "BR69",
            "traffic": "facebook"
        }
    },
    "link": "https://8pay.me/outwE"
}
```

{% endtab %}
{% endtabs %}

## Get a list of short urls

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/one-time/short-urls`

Retrive a list of short url created by the authenticated user.

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| chain | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "path": "outwE",
            "name": "Ebook",
            "createdAt": 1574954504,
            "updatedAt": 1574954504,
            "params": {
                "description": "Ebook",
                "receivers": ["0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff"],
                "amounts": ["5"],
                "token": "8PAY",
                "category": "Shop",
                "tag": "ebook_859294",
                "chargeReceiversForServiceFee": false,
                "callbackSuccess": "https://yoursite.com/thankyou",
                "callbackError": "https://yoursite.com/error",
                "webhook": "https://yoursite.com/notifications",
                "extra": {
                    "banner": "BR69",
                    "traffic": "facebook"
                }
            },
            "link": "https://8pay.me/outwE"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get a short-url

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/one-time/short-urls/:path`

Retrive a short url created by the authenticated user.

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| path  | string | path of the short url                    |
| chain | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "path": "outwE",
    "name": "Ebook",
    "createdAt": 1574954504,
    "updatedAt": 1574954504,
    "params": {
        "description": "Ebook",
        "receivers": ["0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff"],
        "amounts": ["5"],
        "token": "8PAY",
        "category": "Shop",
        "tag": "ebook_859294",
        "chargeReceiversForServiceFee": false,
        "callbackSuccess": "https://yoursite.com/thankyou",
        "callbackError": "https://yoursite.com/error",
        "webhook": "https://yoursite.com/notifications",
        "extra": {
            "banner": "BR69",
            "traffic": "facebook"
        }
    },
    "link": "https://8pay.me/outwE"
}
```

{% endtab %}
{% endtabs %}

## Update a short url

<mark style="color:orange;">`PUT`</mark> `https://api.8pay.network/v1/:chain/one-time/short-urls/:path`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| path  | string | path of the short url                    |
| chain | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

#### Request Body

| Name                                | Type    | Description                                                                                  |
| ----------------------------------- | ------- | -------------------------------------------------------------------------------------------- |
| name                                | string  | short url’s name                                                                             |
| params                              | string  | object containing short url parameters                                                       |
| params.description                  | string  | payment's description                                                                        |
| params.receivers                    | array   | array of ethereum addresses                                                                  |
| params.amounts                      | array   | array of amounts to send to the respective receivers                                         |
| params.token                        | string  | erc20 token symbol                                                                           |
| params.category                     | string  | category of the service/product, see categories                                              |
| params.tag                          | string  | label used for identification or classification *(max 32 bytes)*                             |
| params.callbackSuccess              | string  | redirect url after success                                                                   |
| params.callbackError                | string  | redirect url after failure                                                                   |
| params.webhook                      | string  | url for server-side notification                                                             |
| params.extra                        | string  | extra parameters to be sent to webhook                                                       |
| params.chargeReceiversForServiceFee | boolean | when set to true receivers will be charged for service fee instead of sender (default false) |

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

```
{
    "path": "outwE",
    "name": "Ebook",
    "createdAt": 1574954504,
    "updatedAt": 1574973485,
    "params": {
        "description": "Ebook",
        "receivers": ["0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff"],
        "amounts": ["5"],
        "token": "8PAY",
        "description": "Ebook",
        "category": "Shop",
        "tag": "ebook_859294",
        "chargeReceiversForServiceFee": false,
        "webhook": "https://yoursite.com/notifications",
        "extra": {
            "banner": "BR69",
            "traffic": "facebook"
        }
    },
    "link": "https://8pay.me/outwE"
}
```

{% endtab %}
{% endtabs %}

## Delete a short-url

<mark style="color:red;">`DELETE`</mark> `https://api.8pay.network/v1/:chain/one-time/short-urls/:path`

Delete a short url created by the authenticated user.

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| path  | string | path of the short url                    |
| chain | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
```

{% endtab %}
{% endtabs %}


# Wallet to wallet

The wallet-to-wallet payment option offered by 8Pay is specifically designed for single payments. It allows users to make payments without the need to connect their personal wallets directly. Instead, users can choose to send the payment amount to an intermediary wallet provided by 8Pay.&#x20;

It's important to note that for each payment session, a new wallet address is generated by 8Pay. This means that a unique wallet is assigned to each payment, ensuring a high level of security.

From there, the funds are transferred to the merchant's wallet, completing the transaction. This option offers users an added layer of convenience and privacy, as they can make payments without disclosing their personal wallet information.

## Payments

A wallet-to-wallet payment is uniquely identified by its id.

The tag parameter can be used for an alternative way of identification or classification.

{% content-ref url="/pages/-MaSoqdF7VAs5Kvx3vGu" %}
[Payments](/api/one-time/payments)
{% endcontent-ref %}


# Payments

## Get a list of payments

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/wallet-to-wallet/payments`

#### Path Parameters

| Name                                    | Type   | Description                              |
| --------------------------------------- | ------ | ---------------------------------------- |
| chain<mark style="color:red;">\*</mark> | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name     | Type   | Description                                                 |
| -------- | ------ | ----------------------------------------------------------- |
| tag      | string | filter by tag                                               |
| receiver | string | filter by receiver                                          |
| token    | string | filter by token                                             |
| from     | string | filter by `timestamp` (default 0)                           |
| to       | string | filter by `timestamp` (default current timestamp)           |
| sort     | string | `asc` or `desc` (default `desc`), sort based on `timestamp` |
| email    | string | filter by email                                             |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```http
{
    "data": [
        {
            "id": "23n9538b-1l6a-4kl6-b098-0f4gh38510k4",
            "description": "Ebook",
            "email": "**********",
            "token": "8PAY",
            "category": "Shop",
            "tag": "ebook_859294",
            "timestamp": 1574954504,
            "serviceFee": "0.25",
            "receivers": [
                {
                    "user": "0x38B70aC0BEf71A46Fc9E07f9c64913b9F533e54A",
                    "amount": "5",
                    "fee": "0.05",
                    "timestamp": 1574954504,
                    "transactionHash": "0x7797672488458a27fe022981558636e25d92302bd80a19a4e84008aaa63ace21",
                    "transactionStatus": "confirmed"
                }
            ]
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get a payment

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/wallet-to-wallet/payments/:id`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| id    | string | ID of the one-time                       |
| chain | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "id": "23n9538b-1l6a-4kl6-b098-0f4gh38510k4",
    "description": "Ebook",
    "email": "**********",
    "token": "8PAY",
    "category": "Shop",
    "tag": "ebook_859294",
    "timestamp": 1574954504,
    "serviceFee": "0.25",
    "receivers": [
        {
            "user": "0x38B70aC0BEf71A46Fc9E07f9c64913b9F533e54A",
            "amount": "5",
            "fee": "0.05",
            "timestamp": 1574954504,
            "transactionHash": "0x7797672488458a27fe022981558636e25d92302bd80a19a4e84008aaa63ace21",
            "transactionStatus": "confirmed"
        }
    ]
}
```

{% endtab %}
{% endtabs %}


# Transfers

## Get a list of transfers

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/wallet-to-wallet/transfers`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name  | Type   | Description                                                 |
| ----- | ------ | ----------------------------------------------------------- |
| email | string | filter by email                                             |
| token | string | filter by token                                             |
| from  | string | filter by `timestamp` (default 0)                           |
| to    | string | filter by `timestamp` (default current timestamp)           |
| sort  | string | `asc` or `desc` (default `desc`), sort based on `timestamp` |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "description": "Ebook",
            "email": "**********",
            "receiver": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
            "amount": "5.5",
            "fee": "0.05",
            "token": "8PAY",
            "payment_id": "23n9538b-1l6a-4kl6-b098-0f4gh38510k4",
            "category": "Streaming",
            "timestamp": 1582051910,
            "transactionHash": "0xfe335ee73fe51583a3549a71084f1e8e1d716b06052c0dd2bc864d15a5bb7555",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}


# Fixed Recurring

The Fixed Recurring feature enables merchants to set up recurring payments of a fixed amount at regular intervals. Users are charged the fixed amount at the subscription time and at the start of each billing period. This payment type is ideal for services like gym memberships or streaming services.

## Plans

Plans define the amount, token and billing period for subscriptions to recurring services and products. You can create plans using the web app.

{% content-ref url="/pages/-MaXcqzjEoXFx9yIyKdL" %}
[Plans](/api/fixed-recurring/plans)
{% endcontent-ref %}

## Subscriptions

Subscriptions allow you to charge customers on a recurring basis. Customers can subscribe through 8Pay’s hosted checkout pages that can be reached by embedded buttons, short urls and QR codes.

Subscriptions can be in four different statuses:

* **`ACTIVE`**: the current cycle was paid
* **`EXPIRED`**: the latest cycle is over, a payment is due for the next one
* **`CANCELLED`**: the subscription was cancelled by the user
* **`TERMINATED`**: the subscription was terminated by the vendor

{% content-ref url="/pages/-MaXe4Q3xL0rVJ3XP5ER" %}
[Subscriptions](/api/fixed-recurring/subscriptions)
{% endcontent-ref %}

## Billings

The first billing is executed when a customer subscribes to the plan. Billings can then be triggered at the start of each cycle from the webapp, the 8Pay Javascript SDK.

Billings can fail if the subscriber hasn’t got enough funds on his wallet, hasn’t enabled the token or his spending limit fo the token is too low. They can be retried at a later time.

{% content-ref url="/pages/-MaXgO-0QLMLEwONZtzc" %}
[Billings](/api/fixed-recurring/billings)
{% endcontent-ref %}

## Cancellations

Customers can cancel a subscription anytime from the web app and will not be charged again. A subscription can be terminated (forcefully cancelled) anytime by plan’s admin or operational accounts, using the web app or the 8Pay Javascript SDK.

{% content-ref url="/pages/-MaXhA6iBls3HT64iDVn" %}
[Cancellations](/api/fixed-recurring/cancellations)
{% endcontent-ref %}


# Plans

Plans define the amount, token and billing period for subscriptions to recurring services and products. You can create plans using the web app.

## Get a list of plans

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/fixed-recurring/plans`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name     | Type   | Description                                                 |
| -------- | ------ | ----------------------------------------------------------- |
| admin    | string | filter by admin                                             |
| receiver | string | filter by receiver                                          |
| from     | number | filter by `createdAt` (default 0)                           |
| to       | number | filter by `createdAt` (default current timestamp)           |
| sort     | string | `asc` or `desc` (default `desc`), sort based on `createdAt` |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "id": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "name": "FlixGo",
            "admin": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
            "amount": "5.5",
            "token": "8PAY",
            "period": 2592000,
            "receiver": "0x5A4278004294D3C8Ba351c2533951A79EE48D9b8",
            "category": "Streaming",
            "createdAt": 1575107256,
            "transactionHash": "0x54587230024701c54878c32ca0951c070666f2afccec09ddc1d6921d584cca3c",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get a plan

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/fixed-recurring/plans/:planId`

#### Path Parameters

| Name   | Type   | Description                              |
| ------ | ------ | ---------------------------------------- |
| planId | string | ID of the plan                           |
| chain  | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "id": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
    "name": "FlixGo",
    "admin": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
    "amount": "5.5",
    "token": "8PAY",
    "period": 2592000,
    "receiver": "0x5A4278004294D3C8Ba351c2533951A79EE48D9b8",
    "category": "Streaming",
    "createdAt": 1575107256,
    "transactionHash": "0x54587230024701c54878c32ca0951c070666f2afccec09ddc1d6921d584cca3c",
    "transactionStatus": "confirmed"
}
```

{% endtab %}
{% endtabs %}


# Subscriptions

Subscriptions allow you to charge customers on a recurring basis. Customers can subscribe through 8Pay’s hosted checkout pages that can be reached by embedded buttons, short urls and QR codes.

### Statuses

Subscriptions can be in four different statuses:

* **`ACTIVE`**: the current cycle was paid
* **`EXPIRED`**: the latest cycle is over, a payment is due for the next one
* **`CANCELLED`**: the subscription was cancelled by the user
* **`TERMINATED`**: the subscription was terminated by the vendor

## Get a list of subscriptions

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/fixed-recurring/subscriptions`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name   | Type   | Description                                                                  |
| ------ | ------ | ---------------------------------------------------------------------------- |
| user   | string | filter by user                                                               |
| status | string | filter by status (`ACTIVE`, `EXPIRED`, `CANCELLED` or `TERMINATED`)          |
| from   | number | filter by `subscribedAt` (default 0)                                         |
| to     | number | filter by `subscribedAt` (default current timestamp)                         |
| sortBy | string | order by `subscribedAt`, `cycleStart` or `cycleEnd` (default `subscribedAt`) |
| sort   | string | `asc` or `desc` (default `desc`), sort based on `sortBy` query parameter     |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "id": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "user": "0x16F37b6c96C7038f3E4CDd7aAF9c9A8EC49c4EE7",
            "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "status": "ACTIVE",
            "subscribedAt": 1571646052,
            "cycleStart": 1571646052,
            "cycleEnd": 1574238052,
            "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get subscriptions of a plan

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/fixed-recurring/plans/:planId/subscriptions`

#### Path Parameters

| Name   | Type   | Description                              |
| ------ | ------ | ---------------------------------------- |
| planId | string | ID of the plan                           |
| chain  | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name   | Type   | Description                                                                  |
| ------ | ------ | ---------------------------------------------------------------------------- |
| user   | string | filter by user                                                               |
| status | string | filter by status (`ACTIVE`, `EXPIRED`, `CANCELLED` or `TERMINATED`)          |
| from   | number | filter by `subscribedAt` (default 0)                                         |
| to     | number | filter by `subscribedAt` (default current timestamp)                         |
| sortBy | string | order by `subscribedAt`, `cycleStart` or `cycleEnd` (default `subscribedAt`) |
| sort   | string | `asc` or `desc` (default `desc`), sort based on `sortBy` query parameter     |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "id": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "user": "0x16F37b6c96C7038f3E4CDd7aAF9c9A8EC49c4EE7",
            "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "status": "ACTIVE",
            "subscribedAt": 1571646052,
            "cycleStart": 1571646052,
            "cycleEnd": 1574238052,
            "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get a subscription

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/fixed-recurring/subscriptions/:subscriptionId`

#### Path Parameters

| Name           | Type   | Description                              |
| -------------- | ------ | ---------------------------------------- |
| subscriptionId | string | ID of the subscription                   |
| chain          | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "id": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
    "user": "0x16F37b6c96C7038f3E4CDd7aAF9c9A8EC49c4EE7",
    "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
    "status": "ACTIVE",
    "subscribedAt": 1571646052,
    "cycleStart": 1571646052,
    "cycleEnd": 1574238052,
    "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
    "transactionStatus": "confirmed"
}
```

{% endtab %}
{% endtabs %}


# Billings

The first billing is executed when a customer subscribes to the plan. Billings can then be triggered at the start of each cycle from the webapp, the 8Pay Javascript library.

Billings can fail if the subscriber hasn’t got enough funds on his wallet, hasn’t enabled the token or his spending limit fo the token is too low. They can be retried at a later time.

## Get billings of a plan

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/fixed-recurring/plans/:planId/billings`

#### Path Parameters

| Name   | Type   | Description                              |
| ------ | ------ | ---------------------------------------- |
| planId | string | ID of the plan                           |
| chain  | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name        | Type   | Description                                           |
| ----------- | ------ | ----------------------------------------------------- |
| triggeredBy | string | filter by the user who triggered the billing          |
| from        | number | filter by `timestamp` (default 0)                     |
| to          | number | filter by `timestamp` (default current timestamp)     |
| sort        | string | `asc` or `desc` based on `timestamp` (default `desc`) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "subscriptionId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "success": 1,
            "amount": "10",
            "fee": "0.001",
            "token": "8PAY",
            "receiver": "0x5A4278004294D3C8Ba351c2533951A79EE48D9b8",
            "timestamp": 1571646052,
            "cycleStart": 1571646052,
            "cycleEnd": 1571732452,
            "triggeredBy": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
            "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get billings of a subscription

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/fixed-recurring/subscriptions/:subscriptionId/billings`

#### Path Parameters

| Name           | Type   | Description                              |
| -------------- | ------ | ---------------------------------------- |
| subscriptionId | string | ID of the subscription                   |
| chain          | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name | Type   | Description                                           |
| ---- | ------ | ----------------------------------------------------- |
| from | number | filter by `timestamp` (default 0)                     |
| to   | number | filter by `timestamp` (default current timestamp)     |
| sort | string | `asc` or `desc` based on `timestamp` (default `desc`) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "subscriptionId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "success": 1,
            "amount": "10",
            "fee": "0.001",
            "token": "8PAY",
            "receiver": "0x5A4278004294D3C8Ba351c2533951A79EE48D9b8",
            "timestamp": 1571646052,
            "cycleStart": 1571646052,
            "cycleEnd": 1571732452,
            "triggeredBy": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
            "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}


# Cancellations

Customers can cancel a subscription anytime from the web app and will not be charged again. A subscription can be terminated (forcefully cancelled) anytime by plan’s admin or operational accounts, using the web app or the 8Pay Javascript library.

## Get cancellations of a plan

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/fixed-recurring/plans/:planId/cancellations`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| id    | string | ID of the plan                           |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name        | Type   | Description                                           |
| ----------- | ------ | ----------------------------------------------------- |
| triggeredBy | string | filter by the user who triggered the billing          |
| from        | number | filter by `timestamp` (default 0)                     |
| to          | number | filter by `timestamp` (default current timestamp)     |
| sort        | string | `asc` or `desc` based on `timestamp` (default `desc`) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "subscriptionId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "timestamp": 1571686335,
            "forced": false,
            "triggeredBy": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
            "transactionHash": "0x9ed2fdc68aa1253d206b954ea065a38a6332bd1732d0992e9bcb7056e720e381",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get cancellation for a subscription

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/fixed-recurring/subscriptions/:subscriptionId/cancellation`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| id    | string | ID of the subscription                   |
| chain | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "subscriptionId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
    "timestamp": 1571646052,
    "forced": false,
    "triggeredBy": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
    "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
    "transactionStatus": "confirmed"
}
```

{% endtab %}
{% endtabs %}


# Short Urls

Short urls are easy ways to share subscription links to your plans.

## Create a short url

<mark style="color:green;">`POST`</mark> `https://api.8pay.network/v1/:chain/fixed-recurring/short-urls`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name                   | Type   | Description                            |
| ---------------------- | ------ | -------------------------------------- |
| name                   | string | name of the short url                  |
| planId                 | string | id of the                              |
| params                 | object | object containing short url param      |
| params.callbackSuccess | string | redirect url after success             |
| params.callbackError   | string | redirect url after failure             |
| params.extra           | string | extra parameters to be sent to webhook |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "path": "f9yth",
    "name": "Facebook banner",
    "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
    "createdAt": 1574954504,
    "updatedAt": 1574954504,
    "params": {
        "callbackSuccess": "https://www.google.com/",
        "callbackError": "https://www.google.com/",
        "extra": {
            "banner": "BR69",
            "traffic": "facebook"
        }
    },
    "link": "https://8pay.me/f9yth"
}
```

{% endtab %}
{% endtabs %}

## Get a list of short urls

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/fixed-recurring/short-urls`

Retrive a list of short url created by the authenticated user.

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| chain | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "path": "f9yth",
            "name": "Facebook banner",
            "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "createdAt": 1574954504,
            "updatedAt": 1574954504,
            "params": {
                "callbackSuccess": "https://www.google.com/",
                "callbackError": "https://www.google.com/",
                "extra": {
                    "banner": "BR69",
                    "traffic": "facebook"
                }
            },
            "link": "https://8pay.me/f9yth"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get short urls of a plan

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/fixed-recurring/plans/:planId/short-urls`

#### Path Parameters

| Name   | Type   | Description                              |
| ------ | ------ | ---------------------------------------- |
| planId | string | ID of the plan                           |
| chain  | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "path": "f9yth",
            "name": "Facebook banner",
            "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "createdAt": 1574954504,
            "updatedAt": 1574954504,
            "params": {
                "callbackSuccess": "https://www.google.com/",
                "callbackError": "https://www.google.com/",
                "extra": {
                    "banner": "BR69",
                    "traffic": "facebook"
                }
            },
            "link": "https://8pay.me/f9yth"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get a short url

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/bsc/fixed-recurring/short-urls/:path`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| path  | string | path of the short url                    |
| chain | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "path": "f9yth",
    "name": "Facebook banner",
    "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
    "createdAt": 1574954504,
    "updatedAt": 1574954504,
    "params": {
        "callbackSuccess": "https://www.google.com/",
        "callbackError": "https://www.google.com/",
        "extra": {
            "banner": "BR69",
            "traffic": "facebook"
        }
    },
    "link": "https://8pay.me/f9yth"
}
```

{% endtab %}
{% endtabs %}

## Update a short url

<mark style="color:orange;">`PUT`</mark> `https://api.8pay.network/v1/bsc/fixed-recurring/short-urls/:path`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| path  | string | path of the short url                    |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name                   | Type   | Description                            |
| ---------------------- | ------ | -------------------------------------- |
| name                   | string | name of the short url                  |
| planId                 | string | id of the                              |
| params                 | object | object containing short url param      |
| params.callbackSuccess | string | redirect url after success             |
| params.callbackError   | string | redirect url after failure             |
| params.extra           | string | extra parameters to be sent to webhook |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "path": "f9yth",
    "name": "Facebook banner",
    "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
    "createdAt": 1574954504,
    "updatedAt": 1574973485,
    "params": {
        "callbackSuccess": "https://www.google.com/",
        "callbackError": "https://www.google.com/",
        "extra": {
            "banner": "BR69",
            "traffic": "facebook"
        }
    },
    "link": "https://8pay.me/f9yth"
}
```

{% endtab %}
{% endtabs %}

## Delete a short url

<mark style="color:red;">`DELETE`</mark> `https://api.8pay.network/v1/bsc/fixed-recurring/short-urls/:path`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| path  | string | path of the short url                    |
| chain | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
```

{% endtab %}
{% endtabs %}


# Transfers

## Get a list of transfers

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/fixed-recurring/transfers`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name     | Type   | Description                                                 |
| -------- | ------ | ----------------------------------------------------------- |
| planId   | string | filter by plan                                              |
| sender   | string | filter by sender                                            |
| receiver | string | filter by receiver                                          |
| token    | string | filter by token                                             |
| from     | number | filter by `timestamp` (default 0)                           |
| to       | number | filter by `timestamp` (default current timestamp)           |
| sort     | string | `asc` or `desc` (default `desc`), sort based on `timestamp` |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "description": "FlixGo",
            "sender": "0x16F37b6c96C7038f3E4CDd7aAF9c9A8EC49c4EE7",
            "receiver": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
            "amount": "5.5",
            "fee": "0.05",
            "token": "8PAY",
            "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "subscriptionId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "category": "Streaming",
            "timestamp": 1582051910,
            "transactionHash": "0xfe335ee73fe51583a3549a71084f1e8e1d716b06052c0dd2bc864d15a5bb7555",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}


# Webhook

A webhook can be set up to receive notifications of events that occur on a plan.

## Set a webhook

<mark style="color:orange;">`PUT`</mark> `https://api.8pay.network/v1/:chain/fixed-recurring/plans/:planId/webhook`

#### Path Parameters

| Name   | Type   | Description                              |
| ------ | ------ | ---------------------------------------- |
| planId | string | ID of the plan                           |
| chain  | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

#### Request Body

| Name    | Type   | Description |
| ------- | ------ | ----------- |
| webhook | string | webhook url |

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

```
{
    "webhook": "http://mywebhook.com/path/file.php"
}
```

{% endtab %}
{% endtabs %}

## Get a webhook

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/fixed-recurring/plans/:planId/webhook`

#### Path Parameters

| Name   | Type   | Description                              |
| ------ | ------ | ---------------------------------------- |
| planId | string | ID of the plan                           |
| chain  | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "webhook": "http://mywebhook.com/path/file.php"
}
```

{% endtab %}
{% endtabs %}

## Delete a webhook

<mark style="color:red;">`DELETE`</mark> `https://api.8pay.network/v1/:chain/fixed-recurring/plans/:planId/webhook`

#### Path Parameters

| Name   | Type   | Description                              |
| ------ | ------ | ---------------------------------------- |
| planId | string | ID of the plan                           |
| chain  | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
```

{% endtab %}
{% endtabs %}


# Variable Recurring

The Variable Recurring feature allows for recurring payments of variable amounts at consistent intervals. This is particularly useful for businesses that offer curation-based services or content subscriptions. Merchants can set a maximum deduction amount, providing flexibility while ensuring customers are charged fairly. Users are charged the variable amount at the end of each billing period.

## Plans

Plans define the max billing amount, token and billing period for subscriptions to recurring services and products. You can create a plan using the web app.

{% content-ref url="/pages/-Mam2xX0y2LDzMfdvwGX" %}
[Plans](/api/variable-recurring/plans)
{% endcontent-ref %}

## Subscriptions

Subscriptions allow you to charge customers on a recurring basis. Customers can subscribe through 8Pay’s hosted checkout pages that can be reached by embedded buttons, short urls and QR codes.

Subscriptions can be in three different statuses:

* **`ACTIVE`**: a cycle is in progress, no payment is due
* **`EXPIRED`**: the latest cycle is over and billing can be triggered
* **`CANCELLATION_REQUESTED`**: user has requested cancellation and he’s waiting for vendor’s action
* **`CANCELLED`**: the subscription was cancelled by the user
* **`TERMINATED`**: the subscription was terminated by the vendor

{% content-ref url="/pages/-Mam2xCj0T24I-agkrEk" %}
[Subscriptions](/api/variable-recurring/subscriptions)
{% endcontent-ref %}

## Billings

Billings can then be triggered at the end of each cycle from the webapp or the 8Pay Javascript SDK.

Billings can fail if the subscriber hasn’t got enough funds on his wallet, hasn’t enabled the token or his spending limit fo the token is too low. They can be retried at a later time.

{% content-ref url="/pages/-Mam2wpCU0rFReUxFHgG" %}
[Billings](/api/variable-recurring/billings)
{% endcontent-ref %}

## Cancellation Requests

Customers can request to cancel a subscription anytime from the web app. When the cancellation request is received by the vendor, he will perform one last billing to account for the remaining unpaid period. After the billing, the subscription is automatically cancelled.

{% content-ref url="/pages/-Mam2wTgcz7k3z02RwBU" %}
[Cancellation Requests](/api/variable-recurring/cancellation-requests)
{% endcontent-ref %}

### Cancellations

Customers cannot directly cancel a subscription but they must request the cancellation to the vendor. When the cancellation request is received by the vendor, he will perform one last billing to account for the remaining unpaid period and the subscription will be immediately cancelled. A subscription can be terminated (forcefully cancelled) anytime by plan’s admin or operational accounts, using the web app or the 8Pay Javascript SDK.

{% content-ref url="/pages/-Mam2wAdc7kBTuU7eZ\_N" %}
[Cancellations](/api/variable-recurring/cancellations)
{% endcontent-ref %}


# Plans

Plans define the max billing amount, token and billing period for subscriptions to recurring services and products. You can create a plan using the web app.

## Get a list of plans

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/variable-recurring/plans`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name     | Type   | Description                                                 |
| -------- | ------ | ----------------------------------------------------------- |
| admin    | string | filter by admin                                             |
| receiver | string | filter by receiver                                          |
| from     | number | filter by `createdAt` (default 0)                           |
| to       | number | filter by `createdAt` (default current timestamp)           |
| sort     | string | `asc` or `desc` (default `desc`), sort based on `createdAt` |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "id": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "name": "VPS",
            "admin": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
            "maxAmount": 5.5,
            "token": "8PAY",
            "period": 2592000,
            "receiver": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
            "category": "Streaming services",
            "createdAt": 1575107256,
            "transactionHash": "0x54587230024701c54878c32ca0951c070666f2afccec09ddc1d6921d584cca3c",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get a plan

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/variable-recurring/plans/:planId`

#### Path Parameters

| Name   | Type   | Description                              |
| ------ | ------ | ---------------------------------------- |
| planId | string | ID of the plan                           |
| chain  | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "id": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
    "name": "VPS",
    "admin": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
    "maxAmount": 5.5,
    "token": "8PAY",
    "period": 2592000,
    "receiver": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
    "category": "Streaming services",
    "createdAt": 1575107256,
    "transactionHash": "0x54587230024701c54878c32ca0951c070666f2afccec09ddc1d6921d584cca3c",
    "transactionStatus": "confirmed"
}
```

{% endtab %}
{% endtabs %}


# Subscriptions

Subscriptions allow you to charge customers on a recurring basis. Customers can subscribe through 8Pay’s hosted checkout pages that can be reached by embedded buttons, short urls and QR codes.

Subscriptions can be in three different statuses:

* **`ACTIVE`**: a cycle is in progress, no payment is due
* **`EXPIRED`**: the latest cycle is over and billing can be triggered
* **`CANCELLATION_REQUESTED`**: user has requested cancellation and he’s waiting for vendor’s action
* **`CANCELLED`**: the subscription was cancelled by the user
* **`TERMINATED`**: the subscription was terminated by the vendor

## Get a list of subscriptions

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/variable-recurring/subscriptions`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name   | Type   | Description                                                                                   |
| ------ | ------ | --------------------------------------------------------------------------------------------- |
| user   | string | filter by user                                                                                |
| status | string | filter by status (`ACTIVE`, `EXPIRED`, `CANCELLATION_REQUESTED`, `CANCELLED` or `TERMINATED`) |
| from   | number | filter by `subscribedAt` (default 0)                                                          |
| to     | number | filter by `subscribedAt` (default current timestamp)                                          |
| sortBy | string | order by `subscribedAt`, `cycleStart` or `cycleEnd` (default `subscribedAt`)                  |
| sort   | string | `asc` or `desc` (default `desc`), sort based on `sortBy` query parameter                      |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "id": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "user": "0x16F37b6c96C7038f3E4CDd7aAF9c9A8EC49c4EE7",
            "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "status": "ACTIVE",
            "subscribedAt": 1571646052,
            "cycleStart": 1571646052,
            "cycleEnd": 1574238052,
            "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get subscriptions of a plan

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/variable-recurring/plans/:planId/subscriptions`

#### Path Parameters

| Name   | Type   | Description                              |
| ------ | ------ | ---------------------------------------- |
| planId | string | ID of the plan                           |
| chain  | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name   | Type   | Description                                                                                   |
| ------ | ------ | --------------------------------------------------------------------------------------------- |
| user   | string | filter by user                                                                                |
| status | string | filter by status (`ACTIVE`, `EXPIRED`, `CANCELLATION_REQUESTED`, `CANCELLED` or `TERMINATED`) |
| from   | number | filter by `subscribedAt` (default 0)                                                          |
| to     | number | filter by `subscribedAt` (default current timestamp)                                          |
| sortBy | string | order by `subscribedAt`, `cycleStart` or `cycleEnd` (default `subscribedAt`)                  |
| sort   | string | `asc` or `desc` (default `desc`), sort based on `sortBy` query parameter                      |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "id": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "user": "0x16F37b6c96C7038f3E4CDd7aAF9c9A8EC49c4EE7",
            "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "status": "ACTIVE",
            "subscribedAt": 1571646052,
            "cycleStart": 1571646052,
            "cycleEnd": 1574238052,
            "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get a subscription

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/variable-recurring/subscriptions/:subscriptionId`

#### Path Parameters

| Name           | Type   | Description                              |
| -------------- | ------ | ---------------------------------------- |
| subscriptionId | string | ID of the subscription                   |
| chain          | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "id": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
    "user": "0x16F37b6c96C7038f3E4CDd7aAF9c9A8EC49c4EE7",
    "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
    "status": "ACTIVE",
    "subscribedAt": 1571646052,
    "cycleStart": 1571646052,
    "cycleEnd": 1574238052,
    "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
    "transactionStatus": "confirmed"
}
```

{% endtab %}
{% endtabs %}


# Billings

Billings can then be triggered at the end of each cycle from the webapp or the 8Pay Javascript library.

Billings can fail if the subscriber hasn’t got enough funds on his wallet, hasn’t enabled the token or his spending limit fo the token is too low. They can be retried at a later time.

## Get billings of a plan

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/variable-recurring/plans/:planId/billings`

#### Path Parameters

| Name   | Type   | Description                              |
| ------ | ------ | ---------------------------------------- |
| planId | string | ID of the plan                           |
| chain  | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name        | Type   | Description                                           |
| ----------- | ------ | ----------------------------------------------------- |
| triggeredBy | string | filter by the user who triggered the billing          |
| from        | number | filter by `timestamp` (default 0)                     |
| to          | number | filter by `timestamp` (default current timestamp)     |
| sort        | string | `asc` or `desc` based on `timestamp` (default `desc`) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "subscriptionId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "success": 1,
            "amount": "10",
            "fee": "0.001",
            "token": "8PAY",
            "receiver": "0x5A4278004294D3C8Ba351c2533951A79EE48D9b8",
            "timestamp": 1571646052,
            "cycleStart": 1571646052,
            "cycleEnd": 1571732452,
            "triggeredBy": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
            "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get billings of a subscription

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/variable-recurring/subscriptions/:subscriptionId/billings`

#### Path Parameters

| Name           | Type   | Description                              |
| -------------- | ------ | ---------------------------------------- |
| subscriptionId | string | ID of the subscription                   |
| chain          | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name | Type   | Description                                           |
| ---- | ------ | ----------------------------------------------------- |
| from | number | filter by `timestamp` (default 0)                     |
| to   | number | filter by `timestamp` (default current timestamp)     |
| sort | string | `asc` or `desc` based on `timestamp` (default `desc`) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "subscriptionId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "success": 1,
            "amount": "10",
            "fee": "0.001",
            "token": "8PAY",
            "receiver": "0x5A4278004294D3C8Ba351c2533951A79EE48D9b8",
            "timestamp": 1571646052,
            "cycleStart": 1571646052,
            "cycleEnd": 1571732452,
            "triggeredBy": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
            "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}


# Cancellation Requests

Customers can request to cancel a subscription anytime from the web app. When the cancellation request is received by the vendor, he will perform one last billing to account for the remaining unpaid period. After the billing, the subscription is automatically cancelled.

## Get cancellation requests of a plan

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/variable-recurring/plans/:planId/cancellation-requests`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| id    | string | ID of the plan                           |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name | Type   | Description                                           |
| ---- | ------ | ----------------------------------------------------- |
| from | number | filter by `timestamp` (default 0)                     |
| to   | number | filter by `timestamp` (default current timestamp)     |
| sort | string | `asc` or `desc` based on `timestamp` (default `desc`) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "subscriptionId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "timestamp": 1571686335,
            "transactionHash": "0x9ed2fdc68aa1253d206b954ea065a38a6332bd1732d0992e9bcb7056e720e381",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get cancellation request of a subscription

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/variable-recurring/subscriptions/:subscriptionId/cancellation-request`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| id    | string | ID of the subscription                   |
| chain | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "subscriptionId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
    "timestamp": 1571646052,
    "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
    "transactionStatus": "confirmed"
}
```

{% endtab %}
{% endtabs %}


# Cancellations

Customers cannot directly cancel a subscription but they must request the cancellation to the vendor. When the cancellation request is received by the vendor, he will perform one last billing to account for the remaining unpaid period and the subscription will be immediately cancelled. A subscription can be terminated (forcefully cancelled) anytime by plan’s admin or operational accounts, using the web app or the 8Pay Javascript library.

## Get cancellations of a plan

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/variable-recurring/plans/:planId/cancellations`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| id    | string | ID of the plan                           |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name        | Type   | Description                                           |
| ----------- | ------ | ----------------------------------------------------- |
| triggeredBy | string | filter by the user who triggered the billing          |
| from        | number | filter by `timestamp` (default 0)                     |
| to          | number | filter by `timestamp` (default current timestamp)     |
| sort        | string | `asc` or `desc` based on `timestamp` (default `desc`) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "subscriptionId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "timestamp": 1571686335,
            "forced": false,
            "triggeredBy": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
            "transactionHash": "0x9ed2fdc68aa1253d206b954ea065a38a6332bd1732d0992e9bcb7056e720e381",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get cancellation for a subscription

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/variable-recurring/subscriptions/:subscriptionId/cancellation`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| id    | string | ID of the subscription                   |
| chain | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "subscriptionId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
    "timestamp": 1571646052,
    "forced": false,
    "triggeredBy": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
    "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
    "transactionStatus": "confirmed"
}
```

{% endtab %}
{% endtabs %}


# Webhook

A webhook can be set up to receive notifications of events that occur on a plan.

## Set a webhook

<mark style="color:orange;">`PUT`</mark> `https://api.8pay.network/v1/:chain/variable-recurring/plans/:planId/webhook`

#### Path Parameters

| Name   | Type   | Description                              |
| ------ | ------ | ---------------------------------------- |
| planId | string | ID of the plan                           |
| chain  | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

#### Request Body

| Name    | Type   | Description |
| ------- | ------ | ----------- |
| webhook | string | webhook url |

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

```
{
    "webhook": "http://mywebhook.com/path/file.php"
}
```

{% endtab %}
{% endtabs %}

## Get a webhook

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/variable-recurring/plans/:planId/webhook`

#### Path Parameters

| Name   | Type   | Description                              |
| ------ | ------ | ---------------------------------------- |
| planId | string | ID of the plan                           |
| chain  | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "webhook": "http://mywebhook.com/path/file.php"
}
```

{% endtab %}
{% endtabs %}

## Delete a webhook

<mark style="color:red;">`DELETE`</mark> `https://api.8pay.network/v1/:chain/variable-recurring/plans/:planId/webhook`

#### Path Parameters

| Name   | Type   | Description                              |
| ------ | ------ | ---------------------------------------- |
| planId | string | ID of the plan                           |
| chain  | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
```

{% endtab %}
{% endtabs %}


# Transfers

## Get a list of transfers

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/variable-recurring/transfers`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name     | Type   | Description                                                 |
| -------- | ------ | ----------------------------------------------------------- |
| planId   | string | filter by plan                                              |
| sender   | string | filter by sender                                            |
| receiver | string | filter by receiver                                          |
| token    | string | filter by token                                             |
| from     | number | filter by `timestamp` (default 0)                           |
| to       | number | filter by `timestamp` (default current timestamp)           |
| sort     | string | `asc` or `desc` (default `desc`), sort based on `timestamp` |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "description": "VPS",
            "sender": "0x16F37b6c96C7038f3E4CDd7aAF9c9A8EC49c4EE7",
            "receiver": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
            "amount": "5.5",
            "fee": "0.05",
            "token": "8PAY",
            "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "subscriptionId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "category": "Streaming services",
            "timestamp": 1582051910,
            "transactionHash": "0xfe335ee73fe51583a3549a71084f1e8e1d716b06052c0dd2bc864d15a5bb7555",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}


# Short Urls

Short urls are easy ways to share subscription links to your plans.

## Create a short url

<mark style="color:green;">`POST`</mark> `https://api.8pay.network/v1/:chain/variable-recurring/short-urls`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name                   | Type   | Description                            |
| ---------------------- | ------ | -------------------------------------- |
| name                   | string | name of the short url                  |
| planId                 | string | id of the                              |
| params                 | object | object containing short url param      |
| params.callbackSuccess | string | redirect url after success             |
| params.callbackError   | string | redirect url after failure             |
| params.extra           | string | extra parameters to be sent to webhook |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "path": "vr46y",
    "name": "Facebook banner",
    "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
    "createdAt": 1574954504,
    "updatedAt": 1574954504,
    "params": {
        "callbackSuccess": "https://www.google.com/",
        "callbackError": "https://www.google.com/",
        "extra": {
            "banner": "BR69",
            "traffic": "facebook"
        }
    },
    "link": "https://8pay.me/vr46y"
}
```

{% endtab %}
{% endtabs %}

## Get a list of short urls

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/variable-recurring/short-urls`

Retrive a list of short url created by the authenticated user.

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| chain | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "path": "vr46y",
            "name": "Facebook banner",
            "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "createdAt": 1574954504,
            "updatedAt": 1574954504,
            "params": {
                "callbackSuccess": "https://www.google.com/",
                "callbackError": "https://www.google.com/",
                "extra": {
                    "banner": "BR69",
                    "traffic": "facebook"
                }
            },
            "link": "https://8pay.me/vr46y"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get short urls of a plan

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/variable-recurring/plans/:planId/short-urls`

#### Path Parameters

| Name   | Type   | Description                              |
| ------ | ------ | ---------------------------------------- |
| planId | string | ID of the plan                           |
| chain  | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "path": "vr46y",
            "name": "Facebook banner",
            "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "createdAt": 1574954504,
            "updatedAt": 1574954504,
            "params": {
                "callbackSuccess": "https://www.google.com/",
                "callbackError": "https://www.google.com/",
                "extra": {
                    "banner": "BR69",
                    "traffic": "facebook"
                }
            },
            "link": "https://8pay.me/vr46y"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get a short url

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/bsc/variable-recurring/short-urls/:path`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| path  | string | path of the short url                    |
| chain | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "path": "vr46y",
    "name": "Facebook banner",
    "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
    "createdAt": 1574954504,
    "updatedAt": 1574954504,
    "params": {
        "callbackSuccess": "https://www.google.com/",
        "callbackError": "https://www.google.com/",
        "extra": {
            "banner": "BR69",
            "traffic": "facebook"
        }
    },
    "link": "https://8pay.me/vr46y"
}
```

{% endtab %}
{% endtabs %}

## Update a short url

<mark style="color:orange;">`PUT`</mark> `https://api.8pay.network/v1/bsc/variable-recurring/short-urls/:path`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| path  | string | path of the short url                    |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name                   | Type   | Description                            |
| ---------------------- | ------ | -------------------------------------- |
| name                   | string | name of the short url                  |
| planId                 | string | id of the                              |
| params                 | object | object containing short url param      |
| params.callbackSuccess | string | redirect url after success             |
| params.callbackError   | string | redirect url after failure             |
| params.extra           | string | extra parameters to be sent to webhook |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "path": "vr46y",
    "name": "Facebook banner",
    "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
    "createdAt": 1574954504,
    "updatedAt": 1574973485,
    "params": {
        "callbackSuccess": "https://www.google.com/",
        "callbackError": "https://www.google.com/",
        "extra": {
            "banner": "BR69",
            "traffic": "facebook"
        }
    },
    "link": "https://8pay.me/vr46y"
}
```

{% endtab %}
{% endtabs %}

## Delete a short url

<mark style="color:red;">`DELETE`</mark> `https://api.8pay.network/v1/bsc/variable-recurring/short-urls/:path`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| path  | string | path of the short url                    |
| chain | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name           | Type   | Description       |
| -------------- | ------ | ----------------- |
| Authentication | string | Bearer \<api-key> |

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

```
```

{% endtab %}
{% endtabs %}


# On Demand

The On Demand feature facilitates customizable recurring transactions. Buyers and sellers can establish a recurring payment agreement, with the option for users to exit the arrangement at any time. Similar to a bank direct debit, this feature grants the merchant the ability to withdraw funds from the user's wallet based on agreed-upon terms, offering convenience and flexibility.

## Plans

Plans define the minimum allowance, token and reset period for subscriptions to on-demand services and products. You can create a plan using the web app or directly interacting with our smart contracts.

{% content-ref url="/pages/-Mam72LGjrA2jhFSlinb" %}
[Plans](/api/on-demand/plans)
{% endcontent-ref %}

## Subscriptions

Subscriptions allow you to charge customers on a recurring basis. Customers can subscribe through 8Pay’s hosted checkout pages that can be reached by embedded buttons, short urls and QR codes.

Subscriptions can be in two different statuses:

* **`ACTIVE`**: user can be charged for its usage
* **`CANCELLED`**: the subscription was cancelled by the user
* **`TERMINATED`**: the subscription was terminated by the vendor

{% content-ref url="/pages/-Mam726E\_WLIelfSwcSM" %}
[Subscriptions](/api/on-demand/subscriptions)
{% endcontent-ref %}

## Allowances

The allowance represents the maximum amount that can be charged for the service during each cycle.

{% content-ref url="/pages/-Mam71qEyYM9BK65SWm1" %}
[Allowances](/api/on-demand/allowances)
{% endcontent-ref %}

## Billings

Throughout a subscription’s cycle, the vendor can perform an unlimited number of billings as long their total sum doesn’t exceed the maximum allowance set by the user. Billings can be triggered from the webapp or the 8Pay Javascript SDK.

Billings can fail if the subscriber hasn’t got enough funds on his wallet, hasn’t enabled the token or his spending limit fo the token is too low. They can be retried at a later time.

{% content-ref url="/pages/-Mam71aC1-r5UnRHeT6M" %}
[Billings](/api/on-demand/billings)
{% endcontent-ref %}

## Cancellations

Customers can cancel a subscription anytime from the web app and will not be charged again. A subscription can be terminated (forcefully cancelled) anytime by plan’s admin or operational accounts, using the web app or the 8Pay Javascript SDK.

{% content-ref url="/pages/-Mam71JfM3d4YfENyYYr" %}
[Cancellations](/api/on-demand/cancellations)
{% endcontent-ref %}


# Plans

Plans define the minimum allowance, token and reset period for subscriptions to on-demand services and products. You can create a plan using the web app or directly interacting with our smart contracts.

## Get a list of plans

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/on-demand/plans`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name     | Type   | Description                                                 |
| -------- | ------ | ----------------------------------------------------------- |
| admin    | string | filter by admin                                             |
| receiver | string | filter by receiver                                          |
| from     | number | filter by `createdAt` (default 0)                           |
| to       | number | filter by `createdAt` (default current timestamp)           |
| sort     | string | `asc` or `desc` (default `desc`), sort based on `createdAt` |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "id": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "name": "CarBook",
            "admin": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
            "minAllowance": 10,
            "token": "8PAY",
            "period": 2592000,
            "receiver": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
            "category": "Rents",
            "createdAt": 1575107256,
            "transactionHash": "0x54587230024701c54878c32ca0951c070666f2afccec09ddc1d6921d584cca3c",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get a plan

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/on-demand/plans/:planId`

#### Path Parameters

| Name   | Type   | Description                              |
| ------ | ------ | ---------------------------------------- |
| planId | string | ID of the plan                           |
| chain  | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "id": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
    "name": "CarBook",
    "admin": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
    "minAllowance": 10,
    "token": "8PAY",
    "period": 2592000,
    "receiver": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
    "category": "Rents",
    "createdAt": 1575107256,
    "transactionHash": "0x54587230024701c54878c32ca0951c070666f2afccec09ddc1d6921d584cca3c",
    "transactionStatus": "confirmed"
}
```

{% endtab %}
{% endtabs %}


# Subscriptions

Subscriptions allow you to charge customers on a recurring basis. Customers can subscribe through 8Pay’s hosted checkout pages that can be reached by embedded buttons, short urls and QR codes.

Subscriptions can be in two different statuses:

* **`ACTIVE`**: user can be charged for its usage
* **`CANCELLED`**: the subscription was cancelled by the user
* **`TERMINATED`**: the subscription was terminated by the vendor

## Get a list of subscriptions

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/on-demand/subscriptions`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name   | Type   | Description                                                                  |
| ------ | ------ | ---------------------------------------------------------------------------- |
| user   | string | filter by user                                                               |
| status | string | filter by status (`ACTIVE`, `CANCELLED` or `TERMINATED`)                     |
| from   | number | filter by `subscribedAt` (default 0)                                         |
| to     | number | filter by `subscribedAt` (default current timestamp)                         |
| sortBy | string | order by `subscribedAt`, `cycleStart` or `cycleEnd` (default `subscribedAt`) |
| sort   | string | `asc` or `desc` (default `desc`), sort based on `sortBy` query parameter     |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "id": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "user": "0x16F37b6c96C7038f3E4CDd7aAF9c9A8EC49c4EE7",
            "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "status": "ACTIVE",
            "subscribedAt": 1571646052,
            "allowance": "5",
            "cycleUsage": "1.2",
            "cycleStart": 1571646052,
            "cycleEnd": 1574238052,
            "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get subscriptions of a plan

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/on-demand/plans/:planId/subscriptions`

#### Path Parameters

| Name   | Type   | Description                              |
| ------ | ------ | ---------------------------------------- |
| planId | string | ID of the plan                           |
| chain  | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name   | Type   | Description                                                                  |
| ------ | ------ | ---------------------------------------------------------------------------- |
| user   | string | filter by user                                                               |
| status | string | filter by status (`ACTIVE`, `CANCELLED` or `TERMINATED`)                     |
| from   | number | filter by `subscribedAt` (default 0)                                         |
| to     | number | filter by `subscribedAt` (default current timestamp)                         |
| sortBy | string | order by `subscribedAt`, `cycleStart` or `cycleEnd` (default `subscribedAt`) |
| sort   | string | `asc` or `desc` (default `desc`), sort based on `sortBy` query parameter     |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "id": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "user": "0x16F37b6c96C7038f3E4CDd7aAF9c9A8EC49c4EE7",
            "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "status": "ACTIVE",
            "subscribedAt": 1571646052,
            "allowance": "5",
            "cycleUsage": "1.2",
            "cycleStart": 1571646052,
            "cycleEnd": 1574238052,
            "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get a subscription

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/bsc/on-demand/subscriptions/:subscriptionId`

#### Path Parameters

| Name           | Type   | Description                              |
| -------------- | ------ | ---------------------------------------- |
| subscriptionId | string | ID of the subscription                   |
| chain          | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "id": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
    "user": "0x16F37b6c96C7038f3E4CDd7aAF9c9A8EC49c4EE7",
    "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
    "status": "ACTIVE",
    "subscribedAt": 1571646052,
    "allowance": "5",
    "cycleUsage": "1.2",
    "cycleStart": 1571646052,
    "cycleEnd": 1574238052,
    "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
    "transactionStatus": "confirmed"
}
```

{% endtab %}
{% endtabs %}


# Allowances

The allowance represents the maximum amount that can be charged for the service during each cycle.

## Get allowance of a subscription

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/on-demand/subscriptions/:subscriptionId/allowance`

#### Path Parameters

| Name           | Type   | Description                              |
| -------------- | ------ | ---------------------------------------- |
| subscriptionId | string | ID of the subscription                   |
| chain          | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "amount": "10",
    "token": "8PAY",
    "timestamp": 1571646052,
    "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
    "transactionStatus": "confirmed"
}
```

{% endtab %}
{% endtabs %}


# Billings

Throughout a subscription’s cycle, the vendor can perform an unlimited number of billings as long their total sum doesn’t exceed the maximum allowance set by the user. Billings can be triggered from the webapp or the 8Pay Javascript SDK.

Billings can fail if the subscriber hasn’t got enough funds on his wallet, hasn’t enabled the token or his spending limit fo the token is too low. They can be retried at a later time.

## Get billings of a plan

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/on-demand/plans/:planId/billings`

#### Path Parameters

| Name   | Type   | Description                              |
| ------ | ------ | ---------------------------------------- |
| planId | string | ID of the plan                           |
| chain  | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name        | Type   | Description                                           |
| ----------- | ------ | ----------------------------------------------------- |
| triggeredBy | string | filter by the user who triggered the billing          |
| from        | number | filter by `timestamp` (default 0)                     |
| to          | number | filter by `timestamp` (default current timestamp)     |
| sort        | string | `asc` or `desc` based on `timestamp` (default `desc`) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "subscriptionId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "success": 1,
            "amount": "10",
            "fee": "0.001",
            "token": "8PAY",
            "receiver": "0x5A4278004294D3C8Ba351c2533951A79EE48D9b8",
            "timestamp": 1571646052,
            "triggeredBy": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
            "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get billings of a subscription

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/on-demand/subscriptions/:subscriptionId/billings`

#### Path Parameters

| Name           | Type   | Description                              |
| -------------- | ------ | ---------------------------------------- |
| subscriptionId | string | ID of the subscription                   |
| chain          | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name | Type   | Description                                           |
| ---- | ------ | ----------------------------------------------------- |
| from | number | filter by `timestamp` (default 0)                     |
| to   | number | filter by `timestamp` (default current timestamp)     |
| sort | string | `asc` or `desc` based on `timestamp` (default `desc`) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "subscriptionId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "success": 1,
            "amount": "10",
            "fee": "0.001",
            "token": "8PAY",
            "receiver": "0x5A4278004294D3C8Ba351c2533951A79EE48D9b8",
            "timestamp": 1571646052,
            "triggeredBy": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
            "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}


# Cancellations

Customers can cancel a subscription anytime from the web app and will not be charged again. A subscription can be terminated (forcefully cancelled) anytime by plan’s admin or operational accounts, using the web app or the 8Pay Javascript SDK.

## Get cancellations of a plan

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/on-demand/plans/:planId/cancellations`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| id    | string | ID of the plan                           |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name        | Type   | Description                                           |
| ----------- | ------ | ----------------------------------------------------- |
| triggeredBy | string | filter by the user who triggered the billing          |
| from        | number | filter by `timestamp` (default 0)                     |
| to          | number | filter by `timestamp` (default current timestamp)     |
| sort        | string | `asc` or `desc` based on `timestamp` (default `desc`) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "subscriptionId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "timestamp": 1571686335,
            "forced": false,
            "triggeredBy": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
            "transactionHash": "0x9ed2fdc68aa1253d206b954ea065a38a6332bd1732d0992e9bcb7056e720e381",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get cancellation for a subscription

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/on-demand/subscriptions/:subscriptionId/cancellation`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| id    | string | ID of the subscription                   |
| chain | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "subscriptionId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
    "timestamp": 1571646052,
    "forced": false,
    "triggeredBy": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
    "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
    "transactionStatus": "confirmed"
}
```

{% endtab %}
{% endtabs %}


# Webhook

A webhook can be set up to receive notifications of events that occur on a plan.

## Set a webhook

<mark style="color:orange;">`PUT`</mark> `https://api.8pay.network/v1/:chain/on-demand/plans/:planId/webhook`

#### Path Parameters

| Name   | Type   | Description                              |
| ------ | ------ | ---------------------------------------- |
| planId | string | ID of the plan                           |
| chain  | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

#### Request Body

| Name    | Type   | Description |
| ------- | ------ | ----------- |
| webhook | string | webhook url |

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

```
{
    "webhook": "http://mywebhook.com/path/file.php"
}
```

{% endtab %}
{% endtabs %}

## Get a webhook

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/on-demand/plans/:planId/webhook`

#### Path Parameters

| Name   | Type   | Description                              |
| ------ | ------ | ---------------------------------------- |
| planId | string | ID of the plan                           |
| chain  | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "webhook": "http://mywebhook.com/path/file.php"
}
```

{% endtab %}
{% endtabs %}

## Delete a webhook

<mark style="color:red;">`DELETE`</mark> `https://api.8pay.network/v1/:chain/on-demand/plans/:planId/webhook`

#### Path Parameters

| Name   | Type   | Description    |
| ------ | ------ | -------------- |
| planId | string | ID of the plan |
| chain  | string |                |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
```

{% endtab %}
{% endtabs %}


# Transfers

## Get a list of transfers

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/on-demand/transfers`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name     | Type   | Description                                                 |
| -------- | ------ | ----------------------------------------------------------- |
| planId   | string | filter by plan                                              |
| sender   | string | filter by sender                                            |
| receiver | string | filter by receiver                                          |
| token    | string | filter by token                                             |
| from     | number | filter by `timestamp` (default 0)                           |
| to       | number | filter by `timestamp` (default current timestamp)           |
| sort     | string | `asc` or `desc` (default `desc`), sort based on `timestamp` |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "description": "CarBook",
            "sender": "0x16F37b6c96C7038f3E4CDd7aAF9c9A8EC49c4EE7",
            "receiver": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
            "amount": "5.5",
            "fee": "0.05",
            "token": "8PAY",
            "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "subscriptionId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "category": "Rents",
            "timestamp": 1582051910,
            "transactionHash": "0xfe335ee73fe51583a3549a71084f1e8e1d716b06052c0dd2bc864d15a5bb7555",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}


# Short Urls

Short urls are easy ways to share subscription links to your plans.

## Create a short url

<mark style="color:green;">`POST`</mark> `https://api.8pay.network/v1/:chain/on-demand/short-urls`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name                   | Type   | Description                            |
| ---------------------- | ------ | -------------------------------------- |
| name                   | string | name of the short url                  |
| planId                 | string | id of the                              |
| params                 | object | object containing short url param      |
| params.callbackSuccess | string | redirect url after success             |
| params.callbackError   | string | redirect url after failure             |
| params.extra           | string | extra parameters to be sent to webhook |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "path": "dc4n3",
    "name": "Facebook banner",
    "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
    "createdAt": 1574954504,
    "updatedAt": 1574954504,
    "params": {
        "callbackSuccess": "https://www.google.com/",
        "callbackError": "https://www.google.com/",
        "extra": {
            "banner": "BR69",
            "traffic": "facebook"
        }
    },
    "link": "https://8pay.me/dc4n3"
}
```

{% endtab %}
{% endtabs %}

## Get a list of short urls

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/on-demand/short-urls`

Retrive a list of short url created by the authenticated user.

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| chain | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "path": "dc4n3",
            "name": "Facebook banner",
            "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "createdAt": 1574954504,
            "updatedAt": 1574954504,
            "params": {
                "callbackSuccess": "https://www.google.com/",
                "callbackError": "https://www.google.com/",
                "extra": {
                    "banner": "BR69",
                    "traffic": "facebook"
                }
            },
            "link": "https://8pay.me/dc4n3"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get short urls of a plan

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/on-demand/plans/:planId/short-urls`

#### Path Parameters

| Name   | Type   | Description                              |
| ------ | ------ | ---------------------------------------- |
| planId | string | ID of the plan                           |
| chain  | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "path": "dc4n3",
            "name": "Facebook banner",
            "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "createdAt": 1574954504,
            "updatedAt": 1574954504,
            "params": {
                "callbackSuccess": "https://www.google.com/",
                "callbackError": "https://www.google.com/",
                "extra": {
                    "banner": "BR69",
                    "traffic": "facebook"
                }
            },
            "link": "https://8pay.me/dc4n3"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get a short url

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/bsc/on-demand/short-urls/:path`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| path  | string | path of the short url                    |
| chain | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "path": "dc4n3",
    "name": "Facebook banner",
    "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
    "createdAt": 1574954504,
    "updatedAt": 1574954504,
    "params": {
        "callbackSuccess": "https://www.google.com/",
        "callbackError": "https://www.google.com/",
        "extra": {
            "banner": "BR69",
            "traffic": "facebook"
        }
    },
    "link": "https://8pay.me/dc4n3"
}
```

{% endtab %}
{% endtabs %}

## Update a short url

<mark style="color:orange;">`PUT`</mark> `https://api.8pay.network/v1/bsc/on-demand/short-urls/:path`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| path  | string | path of the short url                    |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name                   | Type   | Description                            |
| ---------------------- | ------ | -------------------------------------- |
| name                   | string | name of the short url                  |
| planId                 | string | id of the                              |
| params                 | object | object containing short url param      |
| params.callbackSuccess | string | redirect url after success             |
| params.callbackError   | string | redirect url after failure             |
| params.extra           | string | extra parameters to be sent to webhook |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "path": "dc4n3",
    "name": "Facebook banner",
    "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
    "createdAt": 1574954504,
    "updatedAt": 1574973485,
    "params": {
        "callbackSuccess": "https://www.google.com/",
        "callbackError": "https://www.google.com/",
        "extra": {
            "banner": "BR69",
            "traffic": "facebook"
        }
    },
    "link": "https://8pay.me/dc4n3"
}
```

{% endtab %}
{% endtabs %}

## Delete a short url

<mark style="color:red;">`DELETE`</mark> `https://api.8pay.network/v1/bsc/on-demand/short-urls/:path`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| path  | string | path of the short url                    |
| chain | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
```

{% endtab %}
{% endtabs %}


# Scheduled Payments

Scheduled Payments empower users to automate their payments, ensuring funds are sent at specific times without the need for manual intervention. Whether it's a one-time scheduled payment or at regular intervals, such as monthly payrolls, this feature streamlines the payment process, enhancing convenience, efficiency, and helping users stay on top of their financial obligations.

## Schedules

Schedules define the amount, token and frequency of the recurring payment. You can create a schedule using the web app.

{% content-ref url="/pages/7Q7bfEqdykUxnl10QjBA" %}
[Schedules](/api/scheduled-payments/schedules)
{% endcontent-ref %}

## Executions

A schedule can be executed once or multiple times depending on its frequency.

In order for executions to be performed, the user will need to have enough funds on its [Gas Wallet](/advanced-features/gas-wallet) to pay for blockchain fees.

An execution can fail if the sender hasn’t got enough funds on his wallet. In that case 8Pay will retry every 6 hours.

{% content-ref url="/pages/B7HYDFN8AyUPcoztaJwH" %}
[Executions](/api/scheduled-payments/executions)
{% endcontent-ref %}

## Cancellation

Customers can cancel a schedule anytime from the web app and it will not be executed again.

{% content-ref url="/pages/D222lbOFV3jvJgE0WrFP" %}
[Cancellation](/api/scheduled-payments/cancellation)
{% endcontent-ref %}


# Schedules

Schedules define the amount, token and frequency of the recurring payment. You can create a schedule using the web app.

## Get a list of schedules

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/scheduled-payments/schedules`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name            | Type   | Description                                                 |
| --------------- | ------ | ----------------------------------------------------------- |
| admin           | string | filter by admin                                             |
| receiver        | string | filter by receiver                                          |
| from            | number | filter by `createdAt` (default 0)                           |
| to              | number | filter by `createdAt` (default current timestamp)           |
| sort            | string | `asc` or `desc` (default `desc`), sort based on `createdAt` |
| transactionHash | string | filter by `transactionHash`                                 |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "id": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "name": "Salary",
            "admin": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
            "token": "8PAY",
            "status": "ACTIVE",
            "start": 1685285340,
            "repeat": 2592000,
            "nextExecution": 1685285340,
            "category": "Salary",
            "createdAt": 1684766721,
            "transactionHash": "0x54587230024701c54878c32ca0951c070666f2afccec09ddc1d6921d584cca3c",
            "transactionStatus": "confirmed",
            "receivers": [
                {
                    "user": "0x38B70aC0BEf71A46Fc9E07f9c64913b9F533e54A",
                    "amount": "1000"
                }
            ]
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get a schedule

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/scheduled-payments/schedules/:scheduleId`

#### Path Parameters

| Name       | Type   | Description                              |
| ---------- | ------ | ---------------------------------------- |
| scheduleId | string | ID of the schedule                       |
| chain      | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "id": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
    "name": "Salary",
    "admin": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
    "token": "8PAY",
    "status": "ACTIVE",
    "start": 1685285340,
    "repeat": 2592000,
    "nextExecution": 1685285340,
    "category": "Salary",
    "createdAt": 1684766721,
    "transactionHash": "0x54587230024701c54878c32ca0951c070666f2afccec09ddc1d6921d584cca3c",
    "transactionStatus": "confirmed",
    "receivers": [
        {
            "user": "0x38B70aC0BEf71A46Fc9E07f9c64913b9F533e54A",
            "amount": "1000"
        }
    ]
}
```

{% endtab %}
{% endtabs %}


# Executions

A schedule can be executed once or multiple times depending on its frequency.

In order for executions to be performed, the user will need to have enough funds on its gas-wallet to pay for blockchain fees.

An execution can fail if the sender hasn’t got enough funds on his wallet. In that case 8Pay will retry every 6 hours.

## Get a list of executions

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/scheduled-payments/executions`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name | Type   | Description                                           |
| ---- | ------ | ----------------------------------------------------- |
| from | number | filter by `timestamp` (default 0)                     |
| to   | number | filter by `timestamp` (default current timestamp)     |
| sort | string | `asc` or `desc` based on `timestamp` (default `desc`) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "scheduleId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "timestamp": 1684819496,
            "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
            "transactionStatus": "confirmed",
            "token": "8PAY",
            "receivers": [
                {
                    "user": "0x38B70aC0BEf71A46Fc9E07f9c64913b9F533e54A",
                    "amount": "1000",
                    "fee": "10"
                }
            ]
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get executions of a schedule

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/scheduled-payments/schedules/:scheduleId/executions`

#### Path Parameters

| Name       | Type   | Description                              |
| ---------- | ------ | ---------------------------------------- |
| scheduleId | string | ID of the schedule                       |
| chain      | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name | Type   | Description                                           |
| ---- | ------ | ----------------------------------------------------- |
| from | number | filter by `timestamp` (default 0)                     |
| to   | number | filter by `timestamp` (default current timestamp)     |
| sort | string | `asc` or `desc` based on `timestamp` (default `desc`) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "scheduleId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "timestamp": 1684819496,
            "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
            "transactionStatus": "confirmed",
            "token": "8PAY",
            "receivers": [
                {
                    "user": "0x38B70aC0BEf71A46Fc9E07f9c64913b9F533e54A",
                    "amount": "1000",
                    "fee": "10"
                }
            ]
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}


# Cancellation

Customers can cancel a schedule anytime from the web app and it will not be executed again.

## Get cancellation of a schedule

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/scheduled-payments/schedules/:scheduleId/cancellation`

#### Path Parameters

| Name       | Type   | Description                              |
| ---------- | ------ | ---------------------------------------- |
| scheduleId | string | ID of the schedule                       |
| chain      | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "scheduleId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
    "timestamp": 1571686335,
    "transactionHash": "0x9ed2fdc68aa1253d206b954ea065a38a6332bd1732d0992e9bcb7056e720e381",
    "transactionStatus": "confirmed"
}
```

{% endtab %}
{% endtabs %}


# Transfers

## Get a list of transfers

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/scheduled-payments/transfers`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name       | Type   | Description                                                 |
| ---------- | ------ | ----------------------------------------------------------- |
| scheduleId | string | filter by schedule                                          |
| sender     | string | filter by sender                                            |
| receiver   | string | filter by receiver                                          |
| token      | string | filter by token                                             |
| from       | number | filter by `timestamp` (default 0)                           |
| to         | number | filter by `timestamp` (default current timestamp)           |
| sort       | string | `asc` or `desc` (default `desc`), sort based on `timestamp` |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "description": "Salary",
            "sender": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
            "receiver": "0x38B70aC0BEf71A46Fc9E07f9c64913b9F533e54A",
            "amount": "1000",
            "fee": "10",
            "token": "8PAY",
            "scheduleId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "category": "Salary",
            "timestamp": 1582051910,
            "transactionHash": "0xfe335ee73fe51583a3549a71084f1e8e1d716b06052c0dd2bc864d15a5bb7555",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}


# Invest (DCA)

The Invest feature allows users to automate their crypto investments through regular purchases over time. By employing Dollar Cost Averaging (DCA), users can mitigate market volatility by spreading out their investment costs. This approach enables users to gradually build their crypto portfolio and potentially benefit from long-term growth.

## Strategies

Strategies define the input token, the amount, the output tokens and frequency of each recurring buy. You can create a strategy using the web app.

{% content-ref url="/pages/9wIHVvFA9Kfg6wYzbQQj" %}
[Strategies](/api/invest/strategies)
{% endcontent-ref %}

## Executions

A strategy is executed at regular intervals for an indefinite number of times, untile cancellation.

In order for executions to be performed, the user will need to have enough funds on its [Gas Wallet](/advanced-features/gas-wallet) to pay for blockchain fees.

An execution can fail if the user hasn’t got enough funds on his wallet. In that case 8Pay will retry every 6 hours.

{% content-ref url="/pages/FYKESer6YkTGPmU80qUf" %}
[Executions](/api/invest/executions)
{% endcontent-ref %}

## Cancellation

Customers can cancel a strategy anytime from the web app and it will not be executed again.

{% content-ref url="/pages/cjHwFQz4W0LiCIK0YDVn" %}
[Cancellation](/api/invest/cancellation)
{% endcontent-ref %}


# Strategies

Strategies define the input token, the amount, the output tokens and frequency of each recurring buy. You can create a strategy using the web app.

## Get a list of strategies

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/dollar-cost-average/strategies`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name  | Type   | Description                                                 |
| ----- | ------ | ----------------------------------------------------------- |
| admin | string | filter by admin                                             |
| from  | number | filter by `createdAt` (default 0)                           |
| to    | number | filter by `createdAt` (default current timestamp)           |
| sort  | string | `asc` or `desc` (default `desc`), sort based on `createdAt` |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "id": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "name": "My investment plan",
            "admin": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
            "status": "ACTIVE",
            "start": 1685285340,
            "frequency": 2592000,
            "nextExecution": 1685285340,
            "inputAmount": "100",
            "inputToken": "USDT",
            "createdAt": 1684766721,
            "transactionHash": "0x54587230024701c54878c32ca0951c070666f2afccec09ddc1d6921d584cca3c",
            "transactionStatus": "confirmed",
            "outputTokens": [
                {
                    "token": "8PAY",
                    "percentage": 100
                }
            ]
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get a strategy

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/dollar-cost-average/strategies/:strategyId`

#### Path Parameters

| Name       | Type   | Description                              |
| ---------- | ------ | ---------------------------------------- |
| strategyId | string | ID of the strategy                       |
| chain      | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "id": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
    "name": "My investment plan",
    "admin": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
    "status": "ACTIVE",
    "start": 1685285340,
    "frequency": 2592000,
    "nextExecution": 1685285340,
    "inputAmount": "100",
    "inputToken": "USDT",
    "createdAt": 1684766721,
    "transactionHash": "0x54587230024701c54878c32ca0951c070666f2afccec09ddc1d6921d584cca3c",
    "transactionStatus": "confirmed",
    "outputTokens": [
        {
            "token": "8PAY",
            "percentage": 100
        }
    ]
}
```

{% endtab %}
{% endtabs %}


# Executions

A strategy is executed at regular intervals for an indefinite number of times, untile cancellation.

In order for executions to be performed, the user will need to have enough funds on its gas-wallet to pay for blockchain fees.

An execution can fail if the user hasn’t got enough funds on his wallet. In that case 8Pay will retry every 6 hours.

## Get a list of executions

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/dollar-cost-average/executions`

#### Path Parameters

| Name  | Type   | Description                              |
| ----- | ------ | ---------------------------------------- |
| chain | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name | Type   | Description                                           |
| ---- | ------ | ----------------------------------------------------- |
| from | number | filter by `timestamp` (default 0)                     |
| to   | number | filter by `timestamp` (default current timestamp)     |
| sort | string | `asc` or `desc` based on `timestamp` (default `desc`) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "strategyId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "timestamp": 1684819496,
            "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
            "transactionStatus": "confirmed",
            "inputToken": "USDT",
            "fee": "1",
            "swaps": [
                {
                    "inputAmount": "100",
                    "outputAmount": "5000",
                    "outputToken": "8PAY"
                }
            ]
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get executions of a strategy

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/dollar-cost-average/strategies/:strategyId/executions`

#### Path Parameters

| Name       | Type   | Description                              |
| ---------- | ------ | ---------------------------------------- |
| strategyId | string | ID of the strategy                       |
| chain      | string | [chain identifier](/api/overview#chains) |

#### Query Parameters

| Name | Type   | Description                                           |
| ---- | ------ | ----------------------------------------------------- |
| from | number | filter by `timestamp` (default 0)                     |
| to   | number | filter by `timestamp` (default current timestamp)     |
| sort | string | `asc` or `desc` based on `timestamp` (default `desc`) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "data": [
        {
            "strategyId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "timestamp": 1684819496,
            "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
            "transactionStatus": "confirmed",
            "inputToken": "USDT",
            "fee": "1",
            "swaps": [
                {
                    "inputAmount": "100",
                    "outputAmount": "5000",
                    "outputToken": "8PAY"
                }
            ]
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}


# Cancellation

Customers can cancel a strategy anytime from the web app and it will not be executed again.

## Get cancellation of a strategy

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/dollar-cost-average/strategies/:strategyId/cancellation`

#### Path Parameters

| Name       | Type   | Description                              |
| ---------- | ------ | ---------------------------------------- |
| strategyId | string | ID of the strategy                       |
| chain      | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

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

```
{
    "strategyId": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
    "timestamp": 1571686335,
    "transactionHash": "0x9ed2fdc68aa1253d206b954ea065a38a6332bd1732d0992e9bcb7056e720e381",
    "transactionStatus": "confirmed"
}
```

{% endtab %}
{% endtabs %}


# Webhook Notifications

When an event occurs, 8Pay sends the corresponding data to your designated webhook endpoint. To ensure the authenticity of the notification, you can utilize the provided endpoint. For a detailed understanding of webhook notifications and the complete list of events, please refer to the [Webhook Notifications](/webhook-notifications/overview) section.

## Get a notification

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/webhook-notifications/:notificationId`

#### Path Parameters

| Name           | Type   | Description                              |
| -------------- | ------ | ---------------------------------------- |
| notificationId | string | id of the notification                   |
| chain          | string | [chain identifier](/api/overview#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | String | Bearer \<api-key> |

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

```http
{
    "id": "5ccf8bdc7707a8effa371d01452644d3a388b975290b968874d0a44ec0219226",
    "type": "one-time",
    "event": "Payment",
    "timestamp": 1585220116,
    "transactionHash": "0xb0f21bf5d722d981330d45d8625568cd0b356e8c7c464857131a6ebf99eadf80",
    "transactionStatus": "confirmed",
    "data": {
        "sender": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
        "description": "Ebook",
        "token": "8PAY",
        "category": "Shop",
        "tag": "ebook_859294",
        "receivers": [
            {
                "user": "0xB2e9F6F9414ea12A33302923A55b9B4Cf99CCD90",
                "amount": "5",
                "fee": "0.05"
            }
        ]
    },
    "extra": {
        "banner": "BR69",
        "traffic": "facebook"
    }
}
```

{% endtab %}
{% endtabs %}


# Overview

Webhooks are user-defined **HTTP callbacks** triggered by an **event**. 8Pay uses webhooks to asynchronously let your application know when events happen, like payments are completed, customers subscribe to plans, subscriptions are cancelled, billings are executed and so on.

When an event occurs, 8Pay makes an HTTP POST request to the URL you have configured for your webhook, sending a notification of the event. Your application can then perform whatever logic is necessary.

## Verify integrity

Each notification is identified by a unique id generated hashing the rest of the notification with the sha256 algorithm. To verify its integrity you can compare the id with the sha256 hash of the notification itself, stripped of its id.

## Retry logic

8Pay attempts to deliver the notifications for up to three days with an exponential back off. If your webhook has been removed when we attempt a retry, future retries of that event will be prevented. However, if you change a webhook endpoint before we’re able to retry, you should still expect to see future retry attempts.

## Verify events are sent from 8Pay

To confirm that received events are sent from 8Pay, you can use the **Webhook Notifications API** to retrieve the notifications by their id.


# Events


# One Time

## Payment

The Payment event is notified when a one-time payment is executed.

*Please Note:*\
*Since we have released **Wallet-to-Wallet**, every **short-url** (one-time) created via 8PAY Network will provide the user a default checkout flow that will allow him to pay via **Wallet-to-Wallet** or with a **Web3** wallet such as **Metamask**. For this reason, we highly recommend supporting the **Wallet-to-Wallet** event.* [Read more here](/webhook-notifications/events/wallet-to-wallet)

```
{
    "id": "7e398c290b8c73bc1557740b64b4ede616a2725c5527e49a76584d6dd0167967",
    "type": "one-time",
    "event": "Payment",
    "timestamp": 1585220116,
    "transactionHash": "0xb0f21bf5d722d981330d45d8625568cd0b356e8c7c464857131a6ebf99eadf80",
    "transactionStatus": "confirmed",
    "data": {
        "id": "0x563ac3fb11181935a6de874c69de5080bf90647bea11dc6e10e06356928a804c",
        "sender": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
        "description": "Ebook",
        "token": "8PAY",
        "category": "Shop",
        "tag": "ebook_859294",
        "receivers": [
            {
                "account": "0xB2e9F6F9414ea12A33302923A55b9B4Cf99CCD90",
                "amount": "5",
                "fee": "0.05"
            }
        ]
    },
    "extra": {
        "banner": "BR69",
        "traffic": "facebook"
    }
}
```


# Wallet-to-Wallet

## Payment

The Payment event is notified when a wallet-to-wallet payment is executed.

```
{
    "id": "33a50a73ec75230e44ec633e668e5de1f76a85a0b8336f36c48f1194c22aa546",
    "type": "wallet-to-wallet",
    "event": "Payment",
    "data": {
        "id": "62e1eb77-7204-4c06-a4b8-0096d3e8956b",
        "email": "john@doe.com",
        "description": "Ebook",
        "token": "8PAY",
        "category": "Shop",
        "tag": "ebook_859294",
        "receivers": [
            {
                "user": "0xe42fD8a58A82fDF624A8a94dA03a0e44F9934Dff",
                "amount": "5",
                "fee": "0.05",
                "timestamp": 1658999245,
                "transactionHash": "0x729ac710541d91828b9d4d106719c11cbaa4b3aa92f82caf87b2c67e48c351f3",
                "transactionStatus": "confirmed"
            }
        ]
    },
    "extra": {
        "banner": "BR69",
        "traffic": "facebook"
    }
}
```


# Fixed Recurring

## Subscription

The Subscription event is notified when a new user subscribes to a plan.

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

## Billing

The Billing event is notified when a subscriber is charged.

```
{
    "id": "5ccf8bdc7707a8effa371d01452644d3a388b975290b968874d0a44ec0219226",
    "type": "fixed-recurring",
    "event": "Billing",
    "timestamp": 1585220116,
    "transactionHash": "0xb0f21bf5d722d981330d45d8625568cd0b356e8c7c464857131a6ebf99eadf80",
    "transactionStatus": "confirmed",
    "data": {
        "planId":  "0xb7934ebf676eb81606da5dded26433ce994d9767924387d65378f263845f3af9",
        "subscriptionId": "0xf0e6a20e8069d403a538729549a17544a2bca3672312a4aed571d115e1fde7d4",
        "cycleStart": "1585218045",
        "cycleEnd": "1585219844"
    }
}
```

## BillingFailed

The BillingFailed event is notified when charging a subscriber fails due to unsufficient funds.

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

## SubscriptionCancelled

The SubscriptionCancelled event is notified when a user cancels a subscription.

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

## SubscriptionTerminated

The SubscriptionTerminated event is notified when a subscription is terminated by the vendor.

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


# Variable Recurring

## Subscription

The Subscription event is notified when a new user subscribes to a plan.

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

## Billing

The Billing event is notified when a subscriber is charged.

```
{
    "id": "5ccf8bdc7707a8effa371d01452644d3a388b975290b968874d0a44ec0219226",
    "type": "variable-recurring",
    "event": "Billing",
    "timestamp": 1585220116,
    "transactionHash": "0xb0f21bf5d722d981330d45d8625568cd0b356e8c7c464857131a6ebf99eadf80",
    "transactionStatus": "confirmed",
    "data": {
        "planId":  "0xb7934ebf676eb81606da5dded26433ce994d9767924387d65378f263845f3af9",
        "subscriptionId": "0xf0e6a20e8069d403a538729549a17544a2bca3672312a4aed571d115e1fde7d4",
        "amount": "5.4",
        "cycleStart": "1585218045",
        "cycleEnd": "1585219844"
    }
}
```

## BillingFailed

The BillingFailed event is notified when charging a subscriber fails due to unsufficient funds.

```
{
    "id": "5ccf8bdc7707a8effa371d01452644d3a388b975290b968874d0a44ec0219226",
    "type": "variable-recurring",
    "event": "Billing",
    "timestamp": 1585220116,
    "transactionHash": "0xb0f21bf5d722d981330d45d8625568cd0b356e8c7c464857131a6ebf99eadf80",
    "transactionStatus": "confirmed",
    "data": {
        "planId":  "0xb7934ebf676eb81606da5dded26433ce994d9767924387d65378f263845f3af9",
        "subscriptionId": "0xf0e6a20e8069d403a538729549a17544a2bca3672312a4aed571d115e1fde7d4",
        "amount": "5.4",
    }
}
```

## SubscriptionCancellationRequested

The SubscriptionCancellationRequested event is notified when a user requests to cancel a subscription.

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

## SubscriptionCancelled

The SubscriptionCancelled event is notified when a cancellation was requested and, after the final billing, the subscription is cancelled.

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

## SubscriptionTerminated

The SubscriptionTerminated event is notified when a subscription is terminated by the vendor.

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


# On Demand

## Subscription

The Subscription event is notified when a new user subscribes to a plan.

```
{
    "id": "5ccf8bdc7707a8effa371d01452644d3a388b975290b968874d0a44ec0219226",
    "type": "on-demand",
    "event": "Subscription",
    "timestamp": 1585220116,
    "transactionHash": "0xb0f21bf5d722d981330d45d8625568cd0b356e8c7c464857131a6ebf99eadf80",
    "transactionStatus": "confirmed",
    "data": {
        "planId":  "0xb7934ebf676eb81606da5dded26433ce994d9767924387d65378f263845f3af9",
        "subscriptionId": "0xf0e6a20e8069d403a538729549a17544a2bca3672312a4aed571d115e1fde7d4",
        "user": "0xB2e9F6F9414ea12A33302923A55b9B4Cf99CCD90",
        "allowance": 50
    },
    "extra": {
        "banner": "BR69",
        "traffic": "facebook"
    }
}
```

## Billing

The Billing event is notified when a subscriber is charged.

```
{
    "id": "5ccf8bdc7707a8effa371d01452644d3a388b975290b968874d0a44ec0219226",
    "type": "on-demand",
    "event": "Billing",
    "timestamp": 1585220116,
    "transactionHash": "0xb0f21bf5d722d981330d45d8625568cd0b356e8c7c464857131a6ebf99eadf80",
    "transactionStatus": "confirmed",
    "data": {
        "planId":  "0xb7934ebf676eb81606da5dded26433ce994d9767924387d65378f263845f3af9",
        "subscriptionId": "0xf0e6a20e8069d403a538729549a17544a2bca3672312a4aed571d115e1fde7d4",
        "amount": "7.8"
    }
}
```

## BillingFailed

The BillingFailed event is notified when charging a subscriber fails due to unsufficient funds.

```
{
    "id": "5ccf8bdc7707a8effa371d01452644d3a388b975290b968874d0a44ec0219226",
    "type": "on-demand",
    "event": "BillingFailed",
    "timestamp": 1585220116,
    "transactionHash": "0xb0f21bf5d722d981330d45d8625568cd0b356e8c7c464857131a6ebf99eadf80",
    "transactionStatus": "confirmed",
    "data": {
        "planId":  "0xb7934ebf676eb81606da5dded26433ce994d9767924387d65378f263845f3af9",
        "subscriptionId": "0xf0e6a20e8069d403a538729549a17544a2bca3672312a4aed571d115e1fde7d4",
        "amount": "5.4",
    }
}
```

## AllowanceChanged

The AllowanceChanged event is notified when a user changed the allowance for a subscription.

```
{
    "id": "5ccf8bdc7707a8effa371d01452644d3a388b975290b968874d0a44ec0219226",
    "type": "on-demand",
    "event": "AllowanceChanged",
    "timestamp": 1585220116,
    "transactionHash": "0xb0f21bf5d722d981330d45d8625568cd0b356e8c7c464857131a6ebf99eadf80",
    "transactionStatus": "confirmed",
    "data": {
        "planId":  "0xb7934ebf676eb81606da5dded26433ce994d9767924387d65378f263845f3af9",
        "subscriptionId": "0xf0e6a20e8069d403a538729549a17544a2bca3672312a4aed571d115e1fde7d4",
        "allowance": 40
    }
}
```

## SubscriptionCancelled

The SubscriptionCancelled event is notified when a user cancels a subscription.

```
{
    "id": "5ccf8bdc7707a8effa371d01452644d3a388b975290b968874d0a44ec0219226",
    "type": "on-demand",
    "event": "SubscriptionCancelled",
    "timestamp": 1585220116,
    "transactionHash": "0xb0f21bf5d722d981330d45d8625568cd0b356e8c7c464857131a6ebf99eadf80",
    "transactionStatus": "confirmed",
    "data": {
        "planId":  "0xb7934ebf676eb81606da5dded26433ce994d9767924387d65378f263845f3af9",
        "subscriptionId": "0xf0e6a20e8069d403a538729549a17544a2bca3672312a4aed571d115e1fde7d4"
    }
}
```

## SubscriptionTerminated

The SubscriptionTerminated event is notified when a subscription is terminated by the vendor.

```
{
    "id": "5ccf8bdc7707a8effa371d01452644d3a388b975290b968874d0a44ec0219226",
    "type": "on-demand",
    "event": "SubscriptionTerminated",
    "timestamp": 1585220116,
    "transactionHash": "0xb0f21bf5d722d981330d45d8625568cd0b356e8c7c464857131a6ebf99eadf80",
    "transactionStatus": "confirmed",
    "data": {
        "planId":  "0xb7934ebf676eb81606da5dded26433ce994d9767924387d65378f263845f3af9",
        "subscriptionId": "0xf0e6a20e8069d403a538729549a17544a2bca3672312a4aed571d115e1fde7d4"
    }
}
```


# Gas Wallet

The Gas Wallet is a dedicated wallet within the 8Pay ecosystem specifically designed to cover network fees required for utilizing 8Pay's advanced features such as `Scheduled Payments` and `Autobiller`. To ensure seamless transaction processing, the Gas Wallet needs to be funded with 8PAY Tokens, which will be used to pay the necessary fees (8Pay fee + blockchain fee).

Users have the flexibility to withdraw their deposited tokens from the Gas Wallet or deposit additional tokens as needed. However, it's important to note that there is a 24-hour timelock period after a withdrawal request, ensuring the security and integrity of the system.

By providing a separate wallet for gas fees, 8Pay streamlines the payment process and simplifies the management of network costs. Users can conveniently allocate and maintain their 8PAY Tokens within the Gas Wallet, enabling smooth and efficient utilization of the platform's advanced features.

### How to deposit

1. Access the Gas Wallet under the [Wallet](https://app.8pay.network/wallet) section.

<figure><img src="/files/iKTZAVQVhe9yDWzPmNrv" alt=""><figcaption></figcaption></figure>

2. Fill the desired amount and click **Confirm.**

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


# Autobiller

Introducing Autobiller, an innovative feature designed to streamline the billing process within 8PAY. Autobiller is specifically tailored for fixed recurring payments and can be easily enabled in the plan section.

Our dedicated team has worked diligently to create one of the most essential functions on our network, catering to both technical and non-technical users. With Autobiller, you can experience the full benefits of blockchain payments without the complexities.

Autobiller automates the billing operations for you by leveraging our smart contract technology. When it's time to charge subscribed users, the smart contract performs a balance check to ensure they have sufficient funds. This not only reduces gas fees but also minimizes the chances of failed payment attempts.

In addition to the standard gas fee, a fee based on your account tier will be charged for each billing attempt. These fees contribute to covering the costs incurred by 8PAY and are deducted from your gas wallet balance. To utilize Autobiller, your gas wallet must be enabled and filled with 8PAY Tokens.

To stay informed about the specific fee structure, we encourage you to refer to the updated table provided in the [Tiers](https://app.8pay.network/tiers) section of our platform. With Autobiller's automation capabilities and efficient fee management, you can enjoy a seamless billing experience while maximizing the benefits of our robust payment infrastructure.

### How to enable

1. Access the [Automatic Payments](https://app.8pay.network/payments/automatic-payments) section and select the desired plan.
2. Toggle the `Autobiller` switch.

<figure><img src="/files/t5K7jbTwFMdk30JRYgWI" alt=""><figcaption></figcaption></figure>


# Categories

Payments sent with 8Pay can be classified by assigning them a category.

Here is a comprehensive list of available categories:&#x20;

* Donations
* Rents
* Beauty and fitness
* Business
* Health
* Fashion
* Streaming services
* Education
* Salary
* Utilities
* Food
* Sport
* Shop
* Travel
* Other


# Tokens

8Pay supports a wide variety of tokens that can be used to make payments.

Here's a comprehensive list of supported tokens for each chain:

#### BNB Chain

* 8PAY
* BNB
* WBNB
* BUSD
* USDT
* USDC
* ETH
* BTCB
* MATIC
* CAKE
* BSCPAD
* DAI
* CUMMIES
* NAFTY
* HAPPY
* DOGE

#### Ethereum

* 8PAY
* ETH
* WETH
* BNB
* BUSD
* USDT
* USDC
* WBTC
* DAI
* MATIC

#### Sandbox (BNB Chain Testnet)

* 8PAY
* BNB
* WBNB
* BUSD
* USDT
* ETH
* BTCB


