- When a subscription cycle is paid, grant the user credits by calling the Deposit API (Default mode only).
- As the user consumes the product, the Proxy charges usage against that credit balance.
- If the balance reaches zero mid‑cycle, users can top up via the automated Stripe Checkout flow to continue using the service immediately.
- At the next cycle, grant a new bundle of credits according to the plan. (Decide whether unused credits roll over.)
This guide targets Default mode (app‑scoped wallet). In Shared mode, the wallet is user‑controlled and external deposit grants aren’t supported yet. You can still run subscriptions for access/entitlements while usage is billed from the shared wallet.
Event to listen for (Stripe)
Listen for the subscription invoice being paid and only then grant credits:invoice.payment_succeeded
withbilling_reason=subscription_create
→ first cycleinvoice.payment_succeeded
withbilling_reason=subscription_cycle
→ renewals
Pseudocode (webhook → Deposit API)
- Always make the handler idempotent using a stable key (e.g.,
invoice.id
). - If you support upgrades/downgrades mid‑cycle, decide whether to grant a pro‑rated deposit or wait until the next cycle.
- Record your mapping and resulting deposits in your own DB for support/audit.
Mid‑cycle top‑ups (optional)
If a user burns through their plan credits before renewal:- The Proxy will return a normal assistant message with a Stripe Checkout link.
- After payment succeeds, Paywalls auto‑deposits the purchased credits.
- The user can continue immediately; the next cycle still grants the plan’s credits.
Other payment systems (PSPs)
If you’re not on Stripe (or you also sell through other channels like app stores or crypto):- Handle the payment confirmation in your system.
- Call the Deposit API with the correct amount and metadata (transaction id, plan, etc.).
- Keep the same idempotency and audit practices.
Testing
- Use Stripe test keys and test cards to run through the full flow in Default mode (no real funds).
- Verify deposits appear in the ledger and usage charges decrement the balance.
- Switch to live by replacing the Dashboard key with your restricted live key.
- Do credits roll over? Your choice. If not, reset at each cycle; if yes, deposit only the delta.
- What if the subscription payment fails? Don’t deposit; the next successful payment triggers the grant.
- Can I combine Subscription + pay‑as‑you‑go? Yes—grant a monthly bundle, then let users top up mid‑cycle as needed.