Skip to main content
A subscription is a revocable USDC spend permission. The customer approves a per-period maximum once; your backend checks the remaining allowance and charges only when payment is due.

Demo

Before rendering checkout, create the subscription-owner wallet with getOrCreateSubscriptionOwnerWallet() and expose only its public address to the browser.
1

Obtain customer approval

SubscriptionButton.ts
2

Check and charge from the backend

charge-subscription.ts
Keep CDP credentials and wallet secrets on the server. Persist subscription IDs, make scheduled charges idempotent, stop retrying cancelled permissions, and distinguish an exhausted current period from a failed transaction.
The backend charges at most the remaining period allowance and records the returned transaction hash before marking the invoice paid.
See the complete verified subscription fixture for client and backend project setup.

See also