Sample guide: Collect a subscription or one-time payment
Collecting crypto subscriptions on-chain can be done in 4 simple steps.
Create an item
Collect authorization via checkout page or widget
Invoice (i.e. schedule payment) by creating a transfer request
Configuring webhooks and granting access
Handling cancellations
Using our SDK
1. Create a subscription
You can use our create POST items
endpoint to configure subscriptions in Loop. A subscription is denoted with a type
= 2
and a one-time payment has a type=2
and a frequencyCount = 0.
These items will appear on the company dashboard and can also be managed there.
2. Collecting authorization
Companies have two ways to collect authorization: use Loop's checkout page or add Loop’s checkout widget to your website.
Checkout page
Loop provides a custom checkout page for each item with the type of "subscription, donation, and fee". This page can be sent directly to the end customer via email, telegram, or an externally generated invoice or it can be embedded directly on your site in a "pay with crypto" button.
Checkout widget
For those that prefer, Loop provides checkout widget that can be integrated in the context of your company's website or application, to enable your customers to pay with crypto. The modal allows end users to give Loop authorization to enable autopay.
3. Invoice
Once you have authorization to bill a customer, you can then schedule payments. You can choose to auto-invoice or bill manually.
Auto-invoicing
This is best for companies that have fixed payment amounts and dates (i.e. $30/mo every month).
Loop will automatically generate the next invoice for subscriptions and one-time payments with auto-invoicing enabled based on the item's payment frequency and amount specified.
Manually
This is best for companies who may have changing payment amounts and dates and thus require flexibility in scheduling payments or are using Loop to schedule outbound payments.
Companies can generate an invoice (called a transfer requests) manually using the POST Transfers
call.
4. Configuring webhooks and granting access
Loop uses webhooks to notify you of events. You can configure these webhooks by simply providing an endpoint.
The AgreementSignedUp
event lets you know that a wallet provided authorization to be billed - it does not mean you have been paid yet, but it does indicate the user has set an allowance for payments.
The TransferProcessed
event is the payment notification and indicates funds have been sent to the receiving wallet.
The AgreementCancelled
event is the notification that indicates a customer has cancelled their subscription. See below for more details on cancellations.
Granting access
You can use the wallet address,
email, or
a reference ID
provided in either of these events to provide access to your system.
Even with immediate invoicing, there will be a delay between the webhook events, as the transaction must be confirmed on-chain. Companies can decide to grant access based on the AgreementSignedUp
event and take action if you do not hear about the TransferProcessed
event within a certain amount of time, (e.g. show a warning, etc). We built Loop to be flexible, so companies can decide how "aggressive" they want to be about payment confirmation.
There are a few reasons why the TransferProcessed
event would not occur:
The wallet does not have enough balance to cover the payment
The wallet does not have enough token allowance to cover the payment
The transaction is stuck in the mempool
Loop's relay network is down
Wallet amount and balance information can be found on our company dashboard for all active subscribers if you are troubleshooting a late payment.
5. Cancellations
Customers can cancel a subscription either:
directly with the end company, who then can tell Loop about the cancellation via the
PATCH agreements
call, orthe customer can cancel directly on Loop's Portal.
Regardless of method, Loop will emit a AgreementCancelled
events that can be used to manage the end customer's access.
When a subscription is canceled, all future scheduled invoices will be cancelled but any currently due invoices will not be. Companies can cancel these scheduled payments using the PATCH Transfer
call.
Last updated