invoice.payment_failed is the Stripe event that tells you a customer's payment just failed. Every failed renewal you do not act on is a paying customer on the way out, so this handler is where recovered revenue starts. This guide covers what the event means, what to do when it arrives, and how to test it with Stripe's decline cards before a real customer hits it. Facts are from Stripe's documentation, read 27 November 2026.
What does invoice.payment_failed mean?
Stripe sends it when a payment for an invoice fails. For subscriptions that is usually a renewal: the card on file was charged and declined. Stripe also sends invoice.updated on every attempt, with status still open after a failure. Source: Stripe docs, Using webhooks with subscriptions.
Two fields on the invoice matter most:
attempt_count: how many payment attempts were made so far.next_payment_attempt: when Stripe will try again. If you use Billing automations, it is set ininvoice.updated, not ininvoice.payment_failed.
What happens to the subscription?
- First invoice fails (with automatic charging): the subscription stays
incomplete. The customer has 23 hours to pay, after that it becomesincomplete_expiredand never bills. - Renewal fails: the subscription becomes
past_due. What happens next depends on your retry settings: it can end ascanceled,unpaid, staypast_due, or pause. - Unpaid: invoices keep being created but no payment is attempted. Stripe's advice is to revoke access at this point.
What should my handler do?
Stripe lists these actions for a failed payment: notify the customer, collect new payment details, update the default payment method on the subscription, and consider Smart Retries. In practice the handler is short:
- Verify the signature and return 2xx fast. Do the work after you respond.
- Look at the PaymentIntent status.
requires_payment_methodmeans you need a new card.requires_actionmeans the customer must complete authentication, andinvoice.payment_action_requiredis the event for that case. - Tell the customer once per failure, with a link to update the card. If Stripe's own failed payment emails are on, do not send a second email for the same attempt.
- Do not cut access on the first failure. Retries often recover the payment. Decide access on
customer.subscription.updatedwhen the status changes, not on the failure event. - Make it idempotent. Stripe does not promise event order, and the same event can arrive twice. Key on the event ID.
Which declines retries can never fix, and how the retry schedule works, is in how Stripe Smart Retries work.
Which Stripe test cards make a payment fail?
All of these work only in test mode or a sandbox. Source: Stripe docs, Testing.
| What you test | Card number | PaymentMethod | decline_code |
|---|---|---|---|
| Renewal fails after the card was saved | 4000000000000341 | pm_card_chargeCustomerFail | charge fails |
| Generic decline | 4000000000000002 | pm_card_visa_chargeDeclined | generic_decline |
| Insufficient funds | 4000000000009995 | pm_card_visa_chargeDeclinedInsufficientFunds | insufficient_funds |
| Lost card (hard decline) | 4000000000009987 | pm_card_visa_chargeDeclinedLostCard | lost_card |
| Stolen card (hard decline) | 4000000000009979 | pm_card_visa_chargeDeclinedStolenCard | stolen_card |
| Expired card | 4000000000000069 | pm_card_chargeDeclinedExpiredCard | error code expired_card |
| Too many attempts | 4000000000006975 | pm_card_visa_chargeDeclinedVelocityLimitExceeded | card_velocity_exceeded |
| 3D Secure on a subscription | 4000002760003184 | authentication |
The first card is the one for renewals. Most decline cards fail when you try to save them, so you never get a subscription to test. 4000000000000341 attaches to the customer fine and fails only when Stripe charges it.
How do I test a failed renewal end to end?
Stripe's own recipe (source: Stripe docs, Test Billing integrations):
- Set
4000000000000341as the customer's default payment method. - Create a subscription with a short trial, so the first charge happens when the trial ends.
- Let the trial end. The invoice finalizes, the charge fails and your endpoint receives
invoice.payment_failed. - Check the invoice and subscription statuses, and that your retry and customer emails behave as configured.
For a quarterly or annual renewal, use test clocks to move simulated time forward instead of waiting. To run the endpoint on your laptop, use the Stripe CLI, for example stripe listen --forward-to localhost:4242/webhook. Events from stripe trigger carry made-up data, so they test one handler, not the whole subscription flow.
How do I know my handler is working in production?
Count it. Compare failed invoices with those later paid: that is your failed payment recovery rate. If it does not move after you ship the handler, the emails are not reaching people or the link does not work. To see what each lost payment costs, use the failed payment calculator.
Retivo is our product. Its $490 Revenue Leak Report reads your invoice history from a restricted read-only Stripe key and shows in dollars how many failed payments were never recovered, without changing anything in your account.
Want your own numbers?
The Revenue Leak Report puts failed payments, unconverted trials, cancellations and downgrades in dollars per month, read from a restricted read-only Stripe key. $490, delivered within 48 hours of receiving the key. Nothing in your account is changed.
Get the Revenue Leak Report - $490 See a sample (synthetic data)