Why Billing Testing Is Critical
Billing bugs have direct financial impact. An incorrect proration calculation that overcharges users by $5 multiplied by 10,000 subscribers equals $50,000 in potential refunds — plus damage to trust, churn risk, and possible legal issues. Undercharging is equally problematic: it creates revenue loss that may go undetected for months.
Subscription billing is one of the most complex areas in web application testing because it involves time-dependent logic, third-party payment provider integration, tax calculations, and multiple state transitions.
The Subscription Lifecycle
Each transition is a test scenario.
Key Testing Areas
Plan Creation and Selection
- All available plans display correct pricing (monthly, annual)
- Annual discount is calculated correctly
- Currency is correct based on user location
- Free trial clearly states its duration and what happens after
- Comparison table accurately reflects feature differences
Proration
When a user changes plans mid-cycle:
| Scenario | Expected Behavior |
|---|---|
| Upgrade mid-cycle | Charge the prorated difference immediately |
| Downgrade mid-cycle | Apply credit toward next billing period |
| Upgrade on last day of cycle | Charge nearly full price of new plan |
| Downgrade on first day of cycle | Credit nearly full amount of old plan |
Example calculation:
- Current plan: $20/month, Day 15 of 30-day cycle
- New plan: $50/month
- Remaining days: 15
- Prorated charge: ($50 - $20) × (15/30) = $15
Renewals
- Subscription renews on the correct date
- Correct amount is charged
- Invoice is generated and sent
- Access continues uninterrupted after renewal
- Annual subscriptions renew after exactly 12 months (handling leap years)
Cancellation
- Cancellation takes effect at end of billing period (not immediately)
- Access continues until the paid period ends
- User can re-subscribe before period ends (cancel the cancellation)
- User receives cancellation confirmation email
- Data is retained for a specified period after cancellation
Payment Failures and Dunning
| Day | Action | User Communication |
|---|---|---|
| 0 | Payment fails | Email: “Payment failed, please update your card” |
| 3 | First retry | Email: “Second attempt failed” |
| 7 | Second retry | Email: “Action required — update payment method” |
| 14 | Third retry | Email: “Final notice — subscription will be cancelled” |
| 21 | Cancel subscription | Email: “Subscription cancelled due to payment failure” |
Tax Calculations
- VAT/GST applied correctly based on customer location
- Tax-exempt customers are not charged tax
- Tax amount appears on invoices
- Different tax rates for different regions/countries
Exercise: Subscription Billing Test Suite
You are testing a SaaS application with three plans using Stripe as the payment provider.
Test Environment Setup
Use Stripe test mode with these test cards:
| Card Number | Scenario |
|---|---|
| 4242 4242 4242 4242 | Successful payment |
| 4000 0000 0000 0002 | Card declined |
| 4000 0000 0000 3220 | 3D Secure required |
| 4000 0025 0000 3155 | Insufficient funds |
| 4000 0000 0000 0341 | Attaching fails |
Scenario 1: Complete Lifecycle
| Step | Action | Expected Result |
|---|---|---|
| 1 | Sign up for 14-day free trial | Trial starts, no charge, full features |
| 2 | Check on day 13 | Reminder email: “Trial ends tomorrow” |
| 3 | Convert to Pro Monthly ($29/month) | First charge of $29, subscription active |
| 4 | On day 15, upgrade to Enterprise ($99/month) | Prorated charge: ($99-$29) × (15/30) = $35 |
| 5 | Wait for renewal | $99 charged on next billing date |
| 6 | Cancel subscription | Access continues until end of period |
| 7 | Period ends | Features downgraded, data retained 90 days |
Scenario 2: Payment Failure Recovery
| Step | Action | Expected Result |
|---|---|---|
| 1 | Subscribe with successful card | Subscription active |
| 2 | Update to card 4000 0000 0000 0002 (decline) | Card updated |
| 3 | Wait for renewal attempt | Payment fails, “Past Due” status |
| 4 | Check dunning email | “Please update your payment method” |
| 5 | Update to successful card | Payment retried and succeeds |
| 6 | Verify subscription status | Back to “Active” |
Scenario 3: Proration Calculations
| Step | Action | Expected Result |
|---|---|---|
| 1 | Subscribe to Basic ($10/month) on Jan 1 | Charged $10 |
| 2 | Upgrade to Pro ($29/month) on Jan 16 | Prorated: ($29-$10) × (15/31) = $9.19 |
| 3 | Check next invoice preview | $29 on Feb 1 |
| 4 | Downgrade to Basic on Jan 25 | Credit: ($29-$10) × (6/31) = $3.68 |
| 5 | Check next invoice | $10 - $3.68 credit = $6.32 |
Solution: Common Billing Bugs
Bug 1: Proration off by one day Proration calculated using calendar days including the change day, resulting in overcharge. The change day should count toward the new plan, not the old.
Bug 2: Cancellation takes effect immediately User cancels on day 5 of a paid month but loses access immediately instead of at the end of the billing period. Users have paid for the full month and should retain access.
Bug 3: Annual renewal charges monthly price Annual subscriptions ($290/year) renewed at the monthly rate ($29/month) due to a plan lookup error.
Bug 4: Dunning emails sent after manual cancellation User manually cancelled but still received “payment failed” dunning emails because the dunning workflow was not cancelled when the subscription was.
Bug 5: Tax applied twice on upgrade When upgrading mid-cycle, tax was calculated on both the full new price and the prorated amount. Tax should only apply to the prorated charge.
Bug 6: Free trial converts without consent Trial automatically converted to paid plan without explicit user action. Some jurisdictions require explicit opt-in for conversion.
Bug 7: Discount code applied to wrong plan A 20% discount code for annual plans was also working on monthly plans.
Billing Testing Best Practices
- Use time manipulation — Test date-dependent logic by adjusting the system clock or using Stripe’s test clock feature to simulate time progression
- Test with real payment flows — Always go through the full UI payment flow, not just API calls
- Verify invoices — Check that every transaction generates a correct invoice with proper line items
- Test currency handling — If your app supports multiple currencies, verify conversion and display
- Document every calculation — For proration and tax tests, show the math so anyone can verify
Key Takeaways
- Billing testing requires testing every state transition in the subscription lifecycle
- Proration is the most calculation-intensive area — verify the math for every mid-cycle change
- Always test with payment provider test cards to simulate success, failure, and edge cases
- Dunning flows are critical for revenue recovery — test the full retry and notification sequence
- Tax calculations vary by jurisdiction and must appear correctly on invoices
- Cancellation should not take effect until the end of the paid period