An Indian SaaS founder discovers that a customer's recurring charge failed overnight. Should the app immediately block the account, keep access for a few days, or ask the customer to pay again? The answer depends on the product's published policy and the payment provider's actual event state. It should not be decided by a single browser callback.
Razorpay Subscriptions documents different events for an active subscription, a pending payment problem and a halted subscription after retries. These states matter because a failed attempt is not necessarily the end of the customer relationship.
Separate billing state from access state
Store the provider's subscription ID, current billing status, paid-through date and the product's access decision. A subscription may be pending while the customer still has a grace period. Another may be cancelled but paid through the end of a term. Define those rules before connecting webhooks to account permissions.
On the account page, show the next action in plain language: payment is being retried, update payment method, contact support, or access ends on a stated date. Do not show a vague red error while the business quietly continues to charge or block access.
Treat webhooks as evidence, not a shortcut
The gateway sends events to the server. Validate the signature on the raw request body before changing any record. Razorpay's webhook guidance explains that duplicate deliveries can occur and the x-razorpay-event-id header can identify an event already processed. It also warns that events may arrive out of order.
Keep an event log, make the handler idempotent and query the provider when an event conflicts with your local record. A browser success screen is useful feedback but not authoritative proof that the charge settled. Avoid running the same entitlement or notification action twice when a webhook is retried.
Design a humane recovery journey
Send a clear notice when payment needs attention, with the plan, amount and a safe link to the account's billing page. Keep the message free of full card details. Explain the retry and grace-period policy without inventing a universal schedule: the provider and payment method determine what retries are available. If the customer cannot update the payment method, offer a support path.
At the end of the grace period, reduce access according to the product's terms. Consider read-only access or data export for business records if appropriate. Never erase customer data merely because one invoice failed; retention needs a separate policy. Support should see the subscription history and event IDs without needing broad access to payment credentials.
Test the states before release
In test mode, simulate activation, a failed charge, duplicate webhook, late event, recovered payment, cancellation and a refund. Check both the billing record and what the customer can actually do in the app after each event. Reconcile the provider dashboard with your own database on a schedule, and flag unexplained differences for review.
This is a small part of a SaaS product with a large effect on trust. If your billing provider and app access disagree today, describe the affected flows. I can help design and implement a safer subscription-state workflow.





