Razorpay
Connect Razorpay so captured payments, subscription charges and processed refunds appear in rupees against their source.
Razorpay is the usual choice for businesses billing in India. It reports captured payments, subscription charges and refunds to Statsy over a signed webhook.
Connect Razorpay
Copy the webhook URL
In Statsy, open Site settings › Integrations and press Connect on the Razorpay tile. The dialog shows the URL for your site, ending in
/api/hooks/razorpay/and yourws_site key, with a copy button.Add it as a webhook in Razorpay
Paste the URL into a new webhook endpoint in Razorpay and subscribe it to the events listed below.
Paste the signing secret back
Razorpay asks you to choose a secret when you create the webhook in the dashboard. Paste it into the second field in the dialog and press Save and connect. It is stored encrypted and never shown again, so keep your own copy.
Which events to subscribe to
| Event | What Statsy does with it |
|---|---|
payment.captured | Records the payment. Authorised-but-not-captured payments are deliberately not counted. |
subscription.charged | Records a renewal. |
refund.processed | Records a refund. |
subscription.cancelled | Marks the customer as churned. Note the British spelling, with two ls. |
Passing the visitor through
Razorpay carries a notes object on payments and subscriptions. The script adds notes[statsy_vid] to rzp.io payment links when a visitor clicks one.
If you open Razorpay Checkout with its JavaScript widget, put the id in the notes yourself:
const vid = statsy.visitorId();
new Razorpay({
key: 'rzp_live_xxx',
order_id: orderId,
notes: vid ? { statsy_vid: vid } : {},
}).open();Subscription charges look for the note on the payment first and then on the subscription, so setting it on the subscription keeps renewals credited to the original source.
Rupees and reporting
Razorpay reports in paise, and Statsy stores the amount in rupees with INR as the currency, alongside a converted USD figure. If your reporting currency is INR, the dashboard reads in rupees throughout; the attribution report always totals in USD so mixed currencies add up.
How the webhook is verified
Razorpay signs the body with your chosen secret and sends the result in the X-Razorpay-Signature header. There is no timestamp, so the secret is all that stands between your dashboard and a forged payment. Rotate it if it ever leaks, and update it in Statsy at the same time.
Last updated · Markdown version