Skip to main content
Loop allows you to charge a customer’s payment method automatically using the payIn endpoint, without requiring any action from the user or gas fees (Loop pays the fee). To do this, you’ll need either the customerId or paymentMethodId.

Setting up recurring payments

When the customer makes their first payment, configure the pay component’s paymentMode to authorize and set a minimumAuthorizationUsdAmount high enough to cover future charges (describe in more detail below). This initial transaction will create a customerId and paymentMethodId in Loop, which you can then use for subsequent recurring payments.

How authorizations work

When a customer is created in Loop, the pay widget will have the payer set a minimumAuthorizationUsdAmount. This amount represents the maximum cumulative total the payer authorizes you to charge their wallet. With each successful payment, the amount decreases. Thus, we suggest that at the first payment you set a high minAuthorizationAmount. Please note, the wallet owner can increase or decrease their authorization amount at any time. Thus, we suggest you check the balance and authorization, described here.

Create a payin

Call the create payin endpoint to create a payment. Payins can be created at any point prior to or when a payment is due. A payin that is create with a billDate that has passed will be processed immediately. Payins process on their billDate only if the paymentMethod has a preAuthorization balance and authorization that is equal to or above the amount. If this is not the case, the payin will sit in scheduled while Loop retries every 3 minutes for 7 days. The payin will charge the default paymentMethod associated with the customerId. You can optionally pass in another paymentMethodId to not charge the default. The payin will respond with the status ( preAuthorization balanceandauthorizationon) of the customer's paymentMethod. SDK Sample
 const result = await loop.payins.create({
        merchantId,
        amount: invoice.amountDue, 
        amountType: "fiat",
        billDate: invoice.dueDate,
        customerId: "cus_8a214", // Loop Customer ID
        subscriptionRefId: "8asukSOXdulGOV", // External Subscription ID
        invoiceRefId: "inv__10" // External Invoice ID
    });

Listen to webhooks

When a payment confirms onchain, the payment.processed webhook will fire. If there is a pending payin that is 10 minutes past due, the payment.missed webhook will fire.