Skip to Content
IntegrationsRazorpay

Razorpay

Route Razorpay payment events to WhatsApp — order confirmations on success, retry prompts on failure. Signed with HMAC-SHA256 so forged events are rejected.

What you get

EventTypical template
payment.captured”Payment received ✅” — amount, id, order link
payment.failed”Payment didn’t go through” — amount, retry link

You can wire one or both events. Each event gets its own template + variable mapping.

Prerequisites

  • Razorpay Live or Test account (dashboard.razorpay.com )
  • At least one approved WhatsApp template in Msgai — usually with 2-3 variables (amount, customer name, order id)
  • Your Msgai WABA active (Dashboard shows WABA connected)

Setup

1. Copy your Msgai webhook URL

In Msgai, open Integrations → Razorpay. Copy the webhook URL — it looks like:

https://api.msgai.in/api/v1/webhooks/integrations/<your-user-id>/razorpay

2. Add the webhook in Razorpay

Razorpay dashboard → Settings → Webhooks → + Add New Webhook.

FieldValue
Webhook URLThe URL from step 1
SecretGenerate a random string (32+ chars). Save this — you’ll paste it into Msgai next.
Alert EmailYour email
Active Eventspayment.captured and/or payment.failed

Click Create Webhook.

3. Paste the secret + pick your template in Msgai

Back on the Razorpay integration page in Msgai → Configuration tab:

  1. Paste the secret from step 2 into Webhook Secret. This is what locks down forged requests — once set, any unsigned or wrongly-signed POST gets rejected with 401.
  2. Pick your approved template for payment.captured.
  3. Set Phone Field → contact (Razorpay puts the customer phone on the payment entity’s contact field).
  4. Variable Mappings — for each template variable, choose the payload field:
Template varField path (payment.captured payload)Sample value
{{1}}amount50000 (in paise)
{{2}}currencyINR
{{3}}idpay_29QQoUBi66xm2f
{{4}}emailcustomer@example.com
{{5}}notes.order_idYour passed-through note
  1. Repeat for payment.failed — typically amount + error_description.
  2. Toggle Enabled on and Save.

4. Test

In Razorpay dashboard → the webhook you just created → Send Test Event. Msgai receives it, fires the template, and logs the outcome.

Check Integrations → Razorpay → Logs — you should see a sent row within 5 seconds.

Payload reference

Razorpay wraps the payment in payload.payment.entity — Msgai normalizes this so you just use the inner field name (id, amount, contact, etc.) in your field paths.

Key fields on a payment:

  • id — pay_..., unique per payment
  • amount — in paise (divide by 100 for rupees; Razorpay doesn’t do this for you)
  • currency — INR, USD, etc.
  • status — captured / failed
  • method — card / netbanking / upi / wallet
  • email, contact — customer details
  • notes — any custom key/value you passed at order creation
  • error_code, error_description — only on failed payments

For the full shape, see Razorpay’s payment webhook docs .

Common gotchas

  • Amount is in paise. {{1}} = amount renders as “50000” for a ₹500 charge. Template it as ₹{{1}} and educate users, or pre-divide by 100 in your template variable copy.
  • Secret mismatch — every attempt logs signature_failed with status 401. Double-check you pasted the same secret in both dashboards (no trailing newline).
  • notes fields need to be sent at order creation. If you didn’t pass them, they won’t show up on the webhook.
  • Test events have dummy data. Real phone/email fields are blank on test events — the message will target an empty phone. Test with a real small-amount payment when you can.