Skip to content

Commit 32d5252

Browse files
Aimen Sahnoungitbook-bot
authored andcommitted
GITBOOK-167: feat: detailed recurring payment flow
1 parent 6b1c427 commit 32d5252

1 file changed

Lines changed: 88 additions & 0 deletions

File tree

docs/request-network-api/recurring-payments.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,91 @@ sequenceDiagram
8282
API->>App: Webhook notification (payment.confirmed / payment.failed)
8383
end
8484
```
85+
86+
87+
88+
## Supported Networks
89+
90+
Recurring payments are supported on the following Blockchain networks:
91+
92+
* Ethereum
93+
* Polygon
94+
* Arbitrum
95+
* Gnosis
96+
* Base
97+
* Binance Smart Chain
98+
* Sepolia
99+
100+
## Supported currencies
101+
102+
The recurring payments support **all** **ERC20** currencies available in the supported networks
103+
104+
## How it works
105+
106+
### 1. Create a recurring payment
107+
108+
To enable recurring payments, a schedule must be created with the following endpoint:
109+
110+
{% openapi-operation spec="request-api" path="/v2/payouts" method="post" %}
111+
[OpenAPI request-api](https://api.request.network/open-api/openapi.json)
112+
{% endopenapi-operation %}
113+
114+
The response includes a payment permit payload (EIP-712 typed data) for signature, and, if required, transactions for token allowance approval.
115+
116+
### 2. Payer authorization
117+
118+
The payer must:
119+
120+
* Approve the recurring payment contract to spend the required amount of tokens (if not already approved)
121+
* Sign the payment permit using EIP-712 compatible wallet
122+
123+
**Example**
124+
125+
```javascript
126+
import { Wallet, providers } from "ethers";
127+
128+
const privateKey = 'WALLET_PRIVATE_KEY'
129+
const provider = const provider = new providers.JsonRpcProvider(
130+
"RPC_URL",
131+
);
132+
133+
const wallet = new Wallet(privateKey, provider);
134+
135+
const recurringPaymentPermit = ... // from API response
136+
const signature = await wallet._signTypedData(
137+
recurringPaymentPermit.domain,
138+
recurringPaymentPermit.types,
139+
recurringPaymentPermit.values
140+
);
141+
142+
```
143+
144+
### 3. Recurring payment activation
145+
146+
To activate the recurring payment, the resulting signature must be submitted to the following endpoint:
147+
148+
{% openapi-operation spec="request-api" path="/v2/payouts/recurring/{id}" method="post" %}
149+
[OpenAPI request-api](https://api.request.network/open-api/openapi.json)
150+
{% endopenapi-operation %}
151+
152+
A successful response confirms activation. The schedule is now active and payments will be executed automatically.
153+
154+
### 4. Status monitoring
155+
156+
The status, processed payments, next payment date, and other details can be retrieved at any time.
157+
158+
{% openapi-operation spec="request-api" path="/v2/payouts/recurring/{id}" method="get" %}
159+
[OpenAPI request-api](https://api.request.network/open-api/openapi.json)
160+
{% endopenapi-operation %}
161+
162+
### 5. Recurring payment management
163+
164+
Recurring payments can be `cancelled` or `unpaused`.
165+
166+
* **Cancel**: stops all future payments
167+
* **Unpause**: resume the recurring payment after it fails three times (due to insufficient balance or allowance)\
168+
169+
170+
{% openapi-operation spec="request-api" path="/v2/payouts/recurring/{id}" method="patch" %}
171+
[OpenAPI request-api](https://api.request.network/open-api/openapi.json)
172+
{% endopenapi-operation %}

0 commit comments

Comments
 (0)