Stripe Advanced: Usage-Based Billing & Prepaid Wallets Overview
This overview covers the advanced Usage-Based Billing (UBB) system integrated between ValStorm and Stripe. This architecture is designed specifically for organizations implementing consumption-based models, such as transactional credits, compute runtime, or API usage.
Core Concepts
1. Consumption Meters & Sum Aggregations
- Usage Meters: In Stripe, a meter is created to measure consumption in real-time (e.g., counting "Credits" used).
- Sum Aggregation: The meter tracks and aggregates the total volume of usage over a billing cycle. For example, if a customer consumes 1,000 credits, the meter sums them up. Based on a unit price (e.g., $0.01 per credit), the system calculates the corresponding dollar cost ($10).
2. Prepaid Billing Wallets
- Prepaid Cash Pool: Instead of billing in arrears, customers purchase a pool of credits in advance.
- Drawdowns: As usage events occur and are logged in ValStorm, the system automatically calculates the dollar cost and draws down from the customer's active wallet balance in real-time.
- Credit Ledger: Every purchase of credits is recorded as a Credit Grant, maintaining a complete ledger of credit history.
3. Automated Replenishment (Auto-Charge)
To prevent service interruptions when a customer's wallet balance runs low, the system uses auto-replenishment rules:
- Threshold (DIP): A minimum balance limit (e.g., $50).
- Replenishment Amount: The top-up value (e.g., $200).
- Auto-Charge Pipeline: When the wallet balance dips below the threshold, ValStorm automatically triggers an invoice in Stripe using the customer's payment method on file, processes the charge, and restores the wallet balance.
System Architecture Flow
The advanced billing loop operates as follows:
1. Usage Event Occurs (API/Manual) ──> 2. Mapped to Stripe Price ($0.01/unit)
│
4. Auto-Replenish Triggered <── 3. ValStorm Wallet Balance Deducted (Real-time)
│
5. Stripe Invoice Auto-Charged ──> 6. Wallet Balance Restored in ValStorm
- Usage Event ingestion: Payloads containing quantity and account ID are ingested by ValStorm.
- Price Resolution: ValStorm resolves the event to the mapped Stripe product and usage price.
- Wallet Deductions: The cash equivalent of the usage is drawn down from the customer's prepaid Billing Wallet.
- Threshold Check: If the remaining balance drops below the set Replenished Threshold, an automated trigger is fired.
- Auto-Charge Invoice: ValStorm creates and automatically processes a top-up invoice in Stripe using the pre-defined Credits for Usage price.
- Balance Sync: The successful Stripe payment triggers a credit sync, updating the customer's active wallet balance in ValStorm.