Razorpay
Connect Razorpay with a Key ID and Key Secret and attribute payments and subscriptions.
Connecting Razorpay imports your payments, refunds and subscriptions into Trakily and keeps them in sync. Trakily only reads data; it never creates charges or changes anything in your Razorpay account. Read Revenue attribution first if you haven't.
1. Create a key id
- 1
Razorpay Dashboard → Account & Settings → API Keys → Generate key
- 2
Copy the Key ID and the Key Secret into the two fields below (the secret is only shown once; regenerate the key if you lost it)
- 3
Test keys (rzp_test_…) only see test-mode payments
Direct link: dashboard.razorpay.com/app/website-app-settings/api-keys
Razorpay needs both values. The Key Secret is only shown once when you generate the key; if you lost it, regenerate the key (this invalidates the old one).
2. Connect it in Trakily
- 1
Open your site's Settings → Revenue (owners only) and click Connect next to Razorpay.
- 2
Paste the key id and the key secret, then click Connect Razorpay. Trakily checks the key.
- 3
The first sync imports your full history in the background. After that, Trakily pulls changes every 15 minutes, and webhooks deliver new payments within seconds.
Keys are encrypted at rest and only used to read payments. Test-mode and live keys both work; a test key only sees test data.
3. Webhook for real-time updates
Razorpay webhooks are added by hand. They are optional: without one, new payments still arrive with the next sync (every 15 minutes).
In the Razorpay Dashboard, open Account & Settings → Webhooks and add a new webhook with the URL below. Choose a secret, select the events listed, and save. Use the same secret in Trakily.
https://trakily.com/api/webhooks/razorpay/pls_…
Events to send:
payment.capturedrefund.processedsubscription.activatedsubscription.chargedsubscription.updatedsubscription.pendingsubscription.haltedsubscription.pausedsubscription.resumedsubscription.cancelledsubscription.completedPaste the endpoint's signing secret into the Webhook card in Settings and click Save (you can also add it while connecting). Every webhook is verified with that secret; requests that don't match are rejected.
4. Pass the visitor id at checkout
Razorpay stores notes on the payment. Add the ids as notes when you open Razorpay Checkout. Trakily reads notes.trakily_visitor_id and notes.trakily_session_id.
// Client side: Razorpay Checkout stores `notes` on the payment
const vid = decodeURIComponent(document.cookie.match(/_trakily_vid=([^;]+)/)?.[1] ?? "").split("|")[0];
const sid = document.cookie.match(/_trakily_sid=([^;]+)/)?.[1] ?? "";
new Razorpay({
key: "rzp_live_…",
order_id: order.id, // or subscription_id: sub.id
notes: { trakily_visitor_id: vid, trakily_session_id: sid },
handler: (r) => location.assign("/thanks?razorpay_payment_id=" + r.razorpay_payment_id),
}).open();The keys are always trakily_visitor_id and trakily_session_id. The visitor id is the first part of the _trakily_vid cookie (before the first |); the session id is the _trakily_sid cookie. If the session id is missing, Trakily uses the visitor's latest session before the payment.
Success page detection
Payment Links and Payment Pages can redirect back to your site with razorpay_payment_id in the URL, and the script reports it. With Razorpay Checkout, redirect in the handler as in the example.
Troubleshooting
- “That doesn't look like a Razorpay Key ID.” The Key ID starts with
rzp_live_orrzp_test_. - “Razorpay rejected this Key ID / Key Secret pair.” The secret is wrong, or the key was regenerated. Copy both values again.
- Payments arrive but show as unattributed. Pass the visitor id at checkout (step 4). Payments that can't be matched yet are retried every hour for 90 days, so a later identify call can still link them.
- Nothing new since connecting. Click Sync now on the provider card. If the card says Needs attention, the error message tells you what the provider returned (for example a revoked key).