
How to Test Dunning Emails Without Charging a Real Card
Need a disposable inbox right now?
Spin up a temporary email address in seconds — no signup, no spam, no trace.
Dunning emails — the retry sequence a billing system fires when a card declines — usually ship untested. Teams test the happy-path receipt and call it done, then find out in production that the day-7 "your payment failed again" email links to an expired checkout session, or that the suppression logic never fires after a customer cancels. Dunning bugs are expensive because they either annoy a paying customer or let a churned one keep getting billed.
The reason dunning sequences dodge test coverage is timing. A real dunning flow spans days: an initial decline, a retry at 72 hours, another at day 7, a final notice before cancellation. Nobody wants to wait a week to find out if the third email renders correctly. Here's a way to compress that into one test run using a disposable inbox per attempt.
Why one inbox isn't enough
Most teams test dunning the same way they test a welcome email: fire the event, check one inbox, move on. That misses the actual failure modes. Dunning bugs live in the differences between emails in the sequence — a retry link that still points at an old invoice ID, a "final notice" that doesn't actually warn about cancellation, copy that says "we'll try again in 3 days" when the schedule was changed to 5. You can't catch a sequencing bug by looking at one message in isolation.
The fix is to give every attempt in the sequence its own address, so you can pull up all four emails side by side afterward and diff them instead of trusting your memory of what the first one said.
The per-attempt inbox pattern
Name each throwaway address after the billing cycle and the retry number: [email protected], [email protected], and so on. Point your test customer's email at the attempt-1 address for the first charge, then update it to attempt-2 before triggering the next retry. Because each address is independent, nothing from attempt 1 can leak into attempt 2's inbox and mask a bug where your system reused stale content.
This also solves a review problem: a reviewer or support lead can open all four addresses in separate tabs on cybertemp.xyz and compare the actual rendered emails without needing database access or a staging email client.
Compressing the week into one test run
You don't need to wait for real decline retries if your payment processor supports a test clock — Stripe's test clocks and similar staging tools let you advance simulated time and fire the scheduled retry jobs immediately. Pair that with the per-attempt inbox pattern and a full dunning sequence — four emails spread over a week in production — runs in a few minutes locally or in CI.
The script is simple: advance the clock, trigger the retry job, poll the matching CyberTemp address, assert on what came back, then advance again.
import httpx, time
API_KEY = "tk_..."
HEADERS = {"X-API-Key": API_KEY}
BASE = "https://api.cybertemp.xyz"
def poll_mail(address, timeout=30, interval=2):
deadline = time.time() + timeout
while time.time() < deadline:
resp = httpx.get(f"{BASE}/getMail", params={"email": address}, headers=HEADERS)
messages = resp.json()
if messages:
return messages[0]
time.sleep(interval)
raise TimeoutError(f"no mail for {address}")
attempts = [
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
]
results = []
for i, address in enumerate(attempts, start=1):
advance_test_clock_and_retry_charge(attempt=i) # your billing system's hook
msg = poll_mail(address)
results.append(msg)
assert f"attempt {i}" in msg["subject"].lower() or str(i) in msg["body"]
Each call to /getMail both creates the inbox on first read and returns whatever has landed since — there's no separate inbox-creation step to wire up. If you're running this inside Playwright or Cypress rather than a plain script, the same polling loop drops into a custom command; the pattern from getting OTP codes into Playwright and Cypress tests carries over directly.
What to actually check in each email
Once you have all four messages pulled, the checks that catch real bugs are:
The amount and currency match the original invoice, not a stale cached value from attempt 1.
The "update payment method" link resolves to a live checkout session — expired session tokens in dunning emails are one of the most common silent failures, because the link worked fine when QA tested it the same day the email was generated.
The final-notice email actually states the cancellation date, and the tone escalates — a dunning sequence where every email reads identically is usually a sign the template logic ignores the attempt number entirely.
Mail stops arriving at every subsequent attempt address once you simulate a successful retry or a cancellation. A dunning system that keeps emailing after the card is fixed is the bug that generates support tickets.
That last check is the one teams skip most often, because it requires asserting on the absence of mail rather than its presence. Poll the next attempt address with a short timeout and confirm it stays empty — an empty array back from /getMail is the expected, correct result in that case, not a test failure.
Running this across billing plans, not just billing cycles
If your product has multiple pricing tiers with different dunning copy — a grace period for annual plans, an immediate suspension for monthly ones — multiply the attempt pattern by plan: [email protected], [email protected]. Running this matrix in CI on every billing-logic change means a dunning regression surfaces in a pull request instead of a week later in a support queue, which is exactly the coverage gap this whole pattern exists to close.
Running a matrix like that daily in CI adds up to real inbox volume fast — a handful of plans times four attempts times every merge to main. CyberTemp's FREE tier covers occasional manual checks, and ECO or CORE cover a CI job that runs this matrix on every billing-related pull request without you tracking a quota by hand; ELITE is there once the suite runs on every commit across a larger team.
Bottom line
Dunning emails get skipped in test suites because they feel like a once-a-month problem until the week they're not. The per-attempt inbox pattern turns a week-long sequence into a script that runs in minutes, and it gives you something concrete to diff instead of a vague sense that "the emails probably still work." If you're already testing other transactional flows this way, the setup from testing transactional emails without a real inbox and handling rate limits and retries in CyberTemp API scripts both plug straight into this one.
If you're scripting this into CI rather than running it by hand, check the plan tiers against how often your billing logic changes — a dunning matrix that runs on every merge needs a different quota than one you run once before a release. Sign up if that's the shape of your test suite.