past_due and enters dunning. The customer keeps service during this grace window while Commet retries the charge. Customers can reactivate sooner from the Customer Portal by retrying payment or updating their card.
What happens when a payment fails
- The subscription status changes to
past_due - The failed invoice is marked as
outstanding - The customer keeps service: usage events and seat events still work (usage accrues as debt)
- The customer receives an email notification
- Commet retries the charge on a fixed schedule (dunning)
active. If all retries fail, the subscription is canceled and the invoice is marked as uncollectible.
Provider error mapping
Commet translates provider responses into a common payment outcome and keeps the provider detail alongside it. For recurring failures, thepayment.failed webhook exposes failureCode, failureMessage, and a recoveryUrl when a recovery path is available. The exact failureCode depends on the provider, so use the normalized outcome and the recovery URL for customer handling instead of matching only one provider’s raw codes.
Initial checkout card declines do not emit
payment.failed; the checkout response carries the failure state directly. Recurring failures use the dunning flow below.
Automatic retries
Retries run on day 1, day 3, day 5, and day 7 after the original failure (4 retries). The calendar is anchored to the failure and never moves. After the last failed retry the subscription is canceled. Manual retries from the Customer Portal orreactivate use the default payment method and have separate daily limits. They do not consume automatic retry slots or start another charge while an automatic retry is in progress.
Saved payment methods
Commet first tries the default saved method on the subscription’s payment connection. After a confirmed decline, it tries the other available methods on that connection, newest first. OXXO is excluded from these retries. Changing country routing does not change the connection used for these retries. Trying several methods counts as one scheduled retry. Commet stops when a payment succeeds. If a result is pending or unknown, it waits for that result before trying another method. A successful charge with another method does not change the customer’s default payment method.Dunning communications
Commet sends a payment-failure notification when a recurring charge enters dunning. For product-specific messaging, subscribe to these webhooks:payment.failed— a recurring charge failed; usefailureCode,failureMessage, andrecoveryUrlto explain the next step.payment.recovered— the outstanding invoice was paid and the subscription returned toactive.payment.retry_failed— all retries were exhausted and the subscription was canceled.
Check subscription status
- TypeScript
- Python
- Go
- Java
- PHP
- cURL
Gate access based on status
Commet keeps servingpast_due customers during the dunning window — usage and seat events still work. You decide whether to gate your own product on past_due. To grant access only while billing is healthy, treat active and trialing as the access states:
- TypeScript
- Python
- Go
- Java
- PHP
- cURL
Recover a subscription programmatically
The SDK exposes three server-side recovery primitives. Forpast_due subscriptions they all operate on the same outstanding renewal invoice — none of them void it. reactivate also reactivates canceled subscriptions.
Retry the charge server-to-server
reactivate charges the subscription’s saved payment method. It works on both past_due and canceled subscriptions, with different effects:
past_due: retries the same outstanding renewal invoice. The billing anchor stays fixed. On success the subscription returns toactiveandpayment.recoveredfires.canceled: generates a fresh invoice, resets the billing period anchor to now, and charges the saved card. On success the subscription returns toactiveandsubscription.reactivatedfires. Requires the plan to still be available in the subscription’s currency, otherwise it returnsPLAN_UNAVAILABLE(422).
recoveryUrl in the error details — a hosted page where the customer adds a new card and pays. This matters for subscriptions canceled by dunning: they reached canceled precisely because the saved card kept failing.
Send the customer a recovery link
createRecoveryLink returns a hosted, signed link so the customer pays the outstanding renewal themselves. Deliver it through your own email, SMS, or dashboard. The link stays valid until the charge is paid or the subscription is no longer past_due.
The payment.failed webhook already carries a recoveryUrl: the checkout URL for a first failed charge, a signed recovery link for a failed renewal. If you consume webhooks, no separate createRecoveryLink call is needed.
Update the payment method
updatePaymentMethod returns a hosted checkout where the customer updates the subscription’s default payment method. It works for active, trialing, and past_due subscriptions.
pending_payment subscription it returns 409 with subscription_not_active, as for any other status. After a first failed charge, the customer pays through the subscription’s payment checkout instead: the recoveryUrl on the payment.failed webhook.
Self-serve recovery
Customers inpast_due see their subscription in the Customer Portal with a Reactivate Subscription button. They can choose:
- Retry with their current card — useful when the failure was temporary (insufficient funds that are now available, a bank hold that cleared).
- Update their payment method — enter a new card through the subscription’s payment provider and retry in the same step.
active, and emits a payment.recovered event. A declined manual retry preserves the automatic dunning calendar. Retry attempts are rate-limited to 3 per day per customer.
Prompt payment update
Redirect customers to the Customer Portal to reactivate:- TypeScript
- Python
- Go
- Java
- PHP
- cURL