Overview
Credit expiration ensures that promotional or time-limited credits are used within their validity period. FlexPrice tracks expiration dates at the transaction level and automatically processes expired credits.How Credit Expiration Works
When credits are added to a wallet, each transaction can have an optional expiration date:- Before expiry: Credits with
credits_available > 0can be consumed - After expiry: Credits are marked as expired and removed from available balance
- No expiry date: Credits never expire (common for purchased credits)
Setting Expiration Dates
On Wallet Top-Up
Set expiration when manually adding credits:Expiry date must be in the future. Use ISO 8601 format in UTC timezone.
On Wallet Creation
Set expiration for initial credits:Via Credit Grants
Credit grants define expiration policy that applies to all granted credits: Never expire:Credit Consumption Order
When a wallet has multiple credit transactions, FlexPrice consumes them in this order:This ordering ensures expiring credits are consumed before they expire, maximizing value for customers.
Expired Credit Processing
FlexPrice automatically processes expired credits via a cron job:What Happens During Processing
Identify expired credits
Finds all wallet transactions where:
expiry_date < current timecredits_available > 0transaction_status = COMPLETED
Check for active subscriptions
If the customer has active subscriptions, expiration may be skipped to prevent service disruption.
Check for active invoices
If the customer has open invoices that might use these credits, expiration may be deferred.
Expiration Results
The cron endpoint returns details about expired credits:Skip Reasons
Credit expiration may be skipped for business reasons:Active Subscription Skip
Reason:active_subscription
If a customer has an active subscription, expiring credits might disrupt their service:
- SaaS products: May want to skip to avoid service disruption
- Pay-as-you-go: May want to expire regardless of subscription status
Active Invoice Skip
Reason:active_invoice
If a customer has open invoices, they might need credits to pay them:
- Skip expiration for invoices due within 7 days
- Allow expiration for overdue invoices (customer had opportunity to use credits)
Monitoring Expiring Credits
List Expiring Credits
Find credits expiring soon:Check Wallet for Expiring Credits
Get wallet balance with expiring credit breakdown:While the API doesn’t directly provide “expiring soon” breakdown, you can calculate this client-side by fetching transactions and filtering by expiry date.
Customer Notifications
Notify customers before credits expire:- Query wallets for credits expiring in next 7 days
- Calculate total expiring amount per customer
- Send email or in-app notification:
- Amount expiring
- Expiry date
- Suggestions for using credits
- Link to account or services
Best Practices
Expiration Date Selection
Promotional credits:- Short term: 30-60 days (encourages quick adoption)
- Medium term: 90-180 days (allows evaluation)
- Long term: 365+ days (customer flexibility)
- 7-14 days for quick trials
- 30 days for full product evaluation
- Align with subscription trial period
- 12-24 months minimum
- Consider no expiration for full purchases
- Clearly communicate expiration in sales terms
- Use
BILLING_CYCLEexpiration - Creates “use it or lose it” urgency
- Simplifies accounting and forecasting
Expiration Communication
At credit grant
Inform customers immediately when credits are granted:“You’ve received 500 credits! These expire on December 31, 2024.”
30 days before expiry
First reminder:“Reminder: You have 500 credits expiring in 30 days. Use them for [service benefits].”
7 days before expiry
Urgent reminder:“Last chance! 500 credits expire in 7 days. Don’t miss out on [benefits].”
Credit Priority Strategy
Assign priorities to ensure promotional credits are used first:Monitoring and Alerting
- Track expiration rates (what % of credits expire unused)
- Alert on high expiration rates (may indicate poor communication or product fit)
- Monitor skipped expirations (active subscriptions/invoices)
- Dashboard showing credits expiring in next 30/60/90 days
Testing Expiration
- Create test wallet with credits expiring tomorrow
- Run expiration cron manually
- Verify debit transaction created
- Check wallet balance updated
- Confirm original transaction marked expired
- Test skip conditions (active subscription/invoice)
Common Patterns
Trial Period Credits
Seasonal Promotion
Purchased Credit Package
Non-Expiring Credits
Accounting Considerations
Revenue Recognition
Expired credits may have accounting implications:- Prepaid credits: Expired credits may become recognized revenue
- Promotional credits: Typically no revenue impact (marketing expense)
- Refundable credits: May require liability adjustment
Reporting
Track credit expiration metrics:- Total credits expired per period
- Expiration rate (expired / granted)
- Revenue impact of expired prepaid credits
- Customer segments with high expiration rates
Audit Trail
Each expiration creates a clear audit trail:- Original credit transaction with expiry date
- Debit transaction with
transaction_reason: CREDIT_EXPIRED - Reference linking debit to expired credit
- Updated
credits_availableon original transaction
Troubleshooting
Credits Not Expiring
Check expiry date format:expiry_date is set and in ISO 8601 format with UTC timezone.
Check transaction status:
Only COMPLETED transactions are eligible for expiration. PENDING transactions (e.g., unpaid invoiced credits) won’t expire.
Run expiration manually:
Credits Expired Prematurely
Verify timezone: Expiry dates are in UTC. Customer’s local timezone may differ:Skipped Expirations Accumulating
Query skipped credits:Next Steps
Wallets
Learn about wallet management
Credit Grants
Configure automatic credit allocation
Auto Top-Up
Set up automatic credit replenishment
Webhooks
React to credit events in real-time