# Recover failed Razorpay payments with a fresh payment link

> When a Razorpay payment fails, we work out why, send the customer a fresh payment link with a friendly note, and flag risky or high value failures in Slack.

- Workflow type: agent
- Services: Razorpay, Gmail, Slack
- Categories: Finance, Sales
- Published: 2026-08-09

## What it does

- Picks up every failed Razorpay payment the moment it happens and pulls the full record, including the amount, the item, the customer's email and phone, and the exact reason the payment did not go through
- Decides whether the payment is worth retrying: a bank timeout or not enough money in the account gets a second chance, a stolen or blocked card does not
- For recoverable failures, creates a brand new payment link for the same amount and emails the customer a short, warm note that names what they were buying and gives them one clear way to pay
- Posts to Slack when a failure looks unrecoverable or when the amount is above the limit you set, so someone on your team can follow up personally
- Tags every new link with the payment it came from, and never chases the same customer twice in one day about the same order

## What you'll need

- A Razorpay account you can create payment links from, with the failed payment alert switched on in your Razorpay dashboard
- A Gmail account to send the recovery emails from
- A Slack workspace and a channel where failure alerts should land
- An amount you consider high value, so we know when to pull a human in
- Optional: a phone number on your customers if you want the link sent by SMS as well as email

## Prompt

Run this every time Razorpay tells us a payment has failed. Set it up on a Razorpay webhook subscribed to the payment.failed event, and read the failed payment id out of the webhook body (payload.payment.entity.id).

Start by calling Razorpay Fetch a Payment with that id, so I am working from the authoritative record rather than the webhook snapshot. From the payment I need the amount and currency, the order id, the description, the customer email and contact number, the notes, and the whole error block: error_code, error_description, error_source, error_step and error_reason. Razorpay amounts are integers in paise, so divide by 100 whenever money is shown to a person. If there is an order id and the payment description is thin, call Razorpay Fetch an Order to get a better name for what the customer was actually buying.

Then judge what kind of failure this was, reading the error fields rather than matching a fixed list of codes. Treat it as recoverable when the customer could plausibly pay again right now: not enough funds, a bank or gateway timeout or outage, an issuer that was temporarily unavailable, an OTP that expired or was never entered, an abandoned or cancelled attempt, or a one off decline with no fraud signal. Treat it as unrecoverable when retrying would be pointless or unwise: a card reported stolen or lost, a blocked or restricted card, a suspected fraud decline, or an account the issuer has closed. If the error text is genuinely ambiguous, take the recoverable path but say so plainly in the Slack message when one gets posted.

For a recoverable failure, create a fresh way to pay using Razorpay Create a Payment Link for exactly the same amount and currency as the failed payment. Prefill the customer name, email and contact from the payment record, write a description that names the item the customer was buying, turn reminders on, and set the link to expire in 72 hours (keep that expiry easy to change). Stamp the original payment id into the link notes, for example notes.original_payment_id, along with the original order id and the error code, so a recovered payment can always be traced back to the failure it came from.

Then send the customer a short recovery email with Gmail Send a Message. Keep it to three or four friendly sentences and never blame them or imply their card was rejected: say the payment did not go through, name the item, and make the new payment link the one obvious next step. Put a stable marker in the subject line so the email can be recognised later, ideally the order id, falling back to the failed payment id when there is no order. If the customer has a phone number and no usable email, or SMS is simply the better channel for this audience, use Razorpay Send or Resend Payment Link Notification with the SMS medium instead of, or alongside, the email.

Before anything goes to the customer, make sure I am not chasing the same person twice in one day about the same order. Use Gmail List Messages with a query along the lines of in:sent to:<customer email> newer_than:1d combined with the order id marker, and if a recovery email for that order already went out in the last 24 hours, skip the email entirely. Skipping the email never skips the Slack side of this workflow.

For an unrecoverable failure, do not email the customer at all and do not create a payment link. Post to Slack with Send a Message instead, so a human can decide what to do: customer name and email, the amount in rupees, the item, the payment id, the error code and reason, and a one line read on why this looks unrecoverable. Also post to Slack whenever the failed amount is above a configurable high value threshold (default it to 25,000 rupees, which is 2,500,000 paise) even when the failure was recoverable and a link has already gone out. In that case the message should say that a recovery link was created and sent, and carry the new link so the account owner can follow up personally.

Handle the edges sensibly. If the payment has neither an email nor a phone number, skip the customer outreach and post to Slack. If creating the payment link fails, never send an email promising a link that does not exist: post that failure to Slack instead. Post at most one Slack message per failed payment rather than one per branch, and keep it short enough to read in the channel without expanding it.

## How to customize

- Change the high value amount that always triggers a Slack alert, and pick which channel it posts to
- Rewrite the recovery email in your own voice, and change how long the new payment link stays valid
- Choose email, SMS, or both as the way the new link reaches the customer
- Adjust which failure reasons count as worth retrying versus worth escalating to a person

## FAQ

### Does this email every customer whose payment fails?

No. Customers only hear from us when the payment could genuinely be retried, like a bank timeout or not enough money in the account. If the card was reported stolen or blocked, we stay quiet and tell your team in Slack instead.

### Could a customer get chased several times in one day?

No. Before sending anything we check whether a recovery email for that same order already went out in the last 24 hours, and skip it if one did.

### Does this only work for card payments?

It works for any failed Razorpay payment, including UPI and netbanking. The reason for the failure is what decides the response, not the payment method.

### Can the new payment link be sent by text message instead of email?

Yes. Razorpay can text the link straight to the customer's phone, which often works better than email. You can use text, email, or both.

### How do we know a recovered sale came from this workflow?

Every new payment link carries a note pointing back to the original failed payment, so when it gets paid you can trace the recovered revenue to the failure it started from.

### Do I need a developer to set this up?

Only lightly. You connect Razorpay, Gmail and Slack, and switch on the failed payment alert in your Razorpay dashboard. Everything after that is settings you can edit in plain language.

Use this prompt in General Input: https://www.generalinput.com/prompts/recover-failed-razorpay-payments-with-a-fresh-payment-link