Skip to content
usage billingwebhookrecurring payments
Joshua C.

Recurring USDC Usage Billing with Cap and Webhook Events

Learn how to implement recurring, capped USDC payments for API usage billing and set up webhook notifications for both success and failure, using non-custodial flows.

Recurring USDC Usage Billing with Cap and Webhook Events

Recurring billing for API usage is a standard SaaS practice, but doing it with USDC requires a different approach than card rails. Onchain payments are final and non-custodial. You want a customer to approve a recurring payment, but give them a clear cap each period. You also need your backend to receive webhook events on both successful and failed collections. This guide walks through the mechanics: creating a recurring, capped USDC authorization, using it for API usage billing, and wiring up webhook notifications.

What Does a Capped Recurring USDC Approval Look Like?

When you set up recurring USDC billing, the customer signs a transaction that allows a merchant address to pull up to a fixed amount of USDC from their wallet, per billing period. This cap is visible and signed onchain. There is no way to pull more than this per period. If the customer’s usage is below the cap, you only collect what they owe. If their usage exceeds the cap, you collect up to the approved limit and notify them that they’ve hit the cap.

Core Flow: Recurring Usage Billing with Onchain USDC

The typical sequence is:

  1. Customer signs a capped USDC approval for your contract or settlement address.
  2. Each billing period, your backend calculates API usage and the USDC owed.
  3. You trigger a collection for the owed amount, up to the cap.
  4. Settlement happens onchain, directly to your address.
  5. You receive a webhook with the payment result. Success and failure are both notified.
  6. If collection fails (due to insufficient balance, revoked approval, or onchain error), your webhook handler marks the payment as failed and you can notify the customer or suspend service.

Worked Example: $250 Monthly Cap, Usage-Based Billing

Suppose you run an AI inference API and charge $0.10 per 1000 tokens, billed monthly. You want to let users opt in to recurring USDC payments, with a $250/month cap.

Step 1: Create a Recurring Payment Link or Widget

You use Reclack’s API or dashboard to create a recurring payment request:

  • Asset: USDC
  • Chain: Base
  • Recurrence: Monthly
  • Cap: $250
  • Description: “AI API usage, $0.10 per 1K tokens, up to $250/mo”

You send the customer a hosted checkout link or embed the widget in your dashboard. The customer connects their wallet and signs the recurring capped approval. No seed phrase, no private key. The approval is a standard ERC-20 allowance, scoped to your contract or settlement address, and bounded to $250 per period.

Step 2: Meter Usage and Calculate Charges

Each billing period (e.g., 1st of the month), your backend tallies usage. Suppose this month the customer used 1,400,000 tokens. That’s 1,400 * $0.10 = $140 due.

Step 3: Trigger Collection

You call Reclack’s API to initiate collection for $140. Reclack submits an onchain transaction to transfer $140 USDC from the customer’s wallet to your settlement address. If the user has sufficient balance and hasn’t revoked the approval, the transfer settles onchain.

import requests

# Example: trigger collection (pseudo-code, replace endpoints/tokens as needed)
collection_payload = {
  "customer_id": "cus_abc123",
  "amount": 140.00,
  "currency": "USDC",
  "chain": "base"
}
response = requests.post("https://api.reclack.com/v1/collections", json=collection_payload)

Step 4: Receive Webhook Notification

You configure a webhook endpoint in your backend. Reclack sends a POST request when the payment settles onchain (or fails). Your handler updates the user’s billing status accordingly.

Example webhook payload on success:

{
  "event": "payment.succeeded",
  "customer_id": "cus_abc123",
  "amount": 140.00,
  "currency": "USDC",
  "chain": "base",
  "tx_hash": "0xabc...def",
  "timestamp": "2024-06-01T01:23:45Z"
}

On failure (e.g., insufficient balance):

{
  "event": "payment.failed",
  "customer_id": "cus_abc123",
  "reason": "insufficient_balance",
  "amount": 140.00,
  "currency": "USDC",
  "chain": "base",
  "timestamp": "2024-06-01T01:24:45Z"
}

Step 5: Handle Success and Failure in Your Application

On success, you mark the invoice or usage period as paid. On failure, you can notify the user, retry later, or suspend the API key. Because all payment attempts are final and onchain, there is no chargeback risk. If the user revokes or reduces their approval mid-period, you only collect what is permitted and receive a webhook if the attempt fails.

Handling Overages and Cap Hits

If the user’s usage exceeds the cap, you can:

  • Collect up to the cap ($250 in this example).
  • Notify the user they hit their monthly limit.
  • Allow them to raise their cap (by re-signing a new approval), or pause service until the next period.

This pattern is predictable for both sides. The customer never pays more than the cap, and you know the onchain limit up front.

Webhook Integration: Key Considerations

Webhooks arrive on every payment attempt, not just on success. You should verify the payload signature to ensure authenticity. Store payment status and transaction hashes for reconciliation. If your webhook endpoint is unavailable, Reclack retries delivery. You can always poll the API for status if needed, but webhooks are the primary real-time trigger for updating your billing state.

What Happens If Collection Fails?

  • If the customer has insufficient USDC, no funds move. You get a failed payment webhook.
  • If the customer revoked the approval, collection fails onchain. You get a failed payment webhook.
  • If there’s an onchain error (e.g., gas issues), you get a failed payment webhook.
  • In all cases, there is no partial collection: either the full requested amount settles, or nothing moves.

You decide how to handle failures: retry, notify, or restrict service. You never risk collecting more than the signed cap, and the customer cannot be debited above their approval.

Multi-Chain and Non-Custodial Constraints

You can offer recurring, capped billing across Arc, Base, Ethereum, and Polygon. The mechanics are the same: capped approval, onchain collection, webhook on result. Reclack never takes custody of funds: every payment moves from the customer’s wallet to your settlement address. No one is asked for a private key or seed phrase. Only the customer can raise or revoke their cap, by signing a new approval.

Summary

Recurring, capped USDC billing with webhook events gives you flexible usage-based pricing, predictable limits, and clean integration to your backend. Webhooks keep your billing system in sync with onchain settlement, and the cap ensures both predictability and customer trust. We built Reclack to let you implement this with hosted checkout, embeddable flows, an API, and real-time webhooks for every payment event. You can learn more at reclack.com.

usage billingwebhookrecurring payments