Metrivo
Docs/Razorpay

Razorpay Setup

Connect Razorpay through guided webhook setup for confidence-based revenue attribution. The Manual Payment API remains the recommended self-serve fallback for private launch.

How the integration works

When a customer completes a payment on Razorpay, Razorpay sends a webhook event to Metrivo. Our server verifies the request using HMAC-SHA256 signature validation, extracts the customer email and payment details, and matches them to the visitor's session. The revenue is then attributed to the traffic source, landing page, and campaign of that session.

For the best attribution accuracy, pass the Metrivo visitor and session IDs in the Razorpay payment's notes field. This gives Metrivo high-confidence attribution even for anonymous visitors.

Setup steps

1

Ask Metrivo to create the integration

For private launch, Metrivo support creates the Razorpay payment integration row for your website and gives you a webhook URL like: https://metrivo.co/api/integrations/razorpay/webhook/YOUR_INTEGRATION_ID

2

Add the webhook in your Razorpay Dashboard

Log in to your Razorpay Dashboard and go to Settings → Webhooks → Add New Webhook. Paste the Metrivo webhook URL. Set a strong secret key and share it through the concierge setup path.

3

Select the webhook events to enable

In the Razorpay webhook configuration, enable the following events: payment.captured, order.paid, subscription.charged, and subscription.activated. Save the webhook.

4

Metrivo stores the webhook secret

Metrivo support stores the webhook secret in the integration config. Metrivo will verify every incoming webhook using HMAC-SHA256.

5

Test with a real transaction

Make a test purchase on your site (you can refund it immediately). Metrivo support confirms the payment appears with an attribution confidence label.

Supported webhook events

payment.captured

The primary event. Fired when a payment is successfully captured. Metrivo records the payment amount, customer email, and attributes it to the visitor session.

order.paid

Fired when all payments for a Razorpay Order are completed and the order is marked as paid. Use this if you create orders before capturing payment.

subscription.charged

Fired each time a recurring subscription payment is successfully charged. Subsequent billing cycles are tracked automatically.

subscription.activated

Fired when a new subscription becomes active after the first successful charge.

payment.authorized

Fired when a payment is authorized but not yet captured. Tracked for merchants who use manual capture flows.

Passing tracking IDs for high-confidence attribution

To get precise, session-level attribution, add the Metrivo visitor and session IDs to the Razorpay payment's notes field when creating the order or payment link on your server:

// server-side order creation razorpay.orders.create({ amount: 4900, // in paise (₹49) currency: "INR", notes: { metrivo_visitor_id: "rp_vis_xxxx", metrivo_session_id: "rp_ses_xxxx", }, });

Retrieve the IDs from the browser using the Metrivo tracking script: window.Metrivo.getVisitorId(). Pass them to your server when the customer initiates checkout.

Need more help?

Check our other integration guides or contact support for a guided setup.