How do I process a refund with Razorpay?
Use razorpay.payments.refund(paymentId, { amount: payment.amount, notes: { reason } }). For a partial refund, specify a smaller amount. Update the payment status to 'refunded' in the database, store the refund ID, and revoke premium access if applicable.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Handling Razorpay Refunds and Failed Payments in Node.js
Handle the payment.failed webhook: update the payment status to 'failed', store the failure reason and code, notify the user via email, and provide a retry endpoint that creates a new order. Users can retry the payment with the new order ID.
Handle refund.processed (refund completed successfully update status and notify user) and refund.failed (refund could not be processed investigate and retry). Always verify the webhook signature before processing.
Create a new Razorpay order with the same amount: razorpay.orders.create({ amount, currency, receipt: 'retry_' + Date.now() }). Update the payment record with the new order ID and status 'created'. Return the new order ID to the frontend for a new checkout attempt.
Still have questions?
Browse all our FAQs or reach out to our support team
