Razorpay Integration

Connect your Razorpay account to Paygent to collect invoice payments through Razorpay Payment Links. Paygent generates hosted payment links, can embed them in invoice emails, and marks invoices as paid when Razorpay confirms the payment via webhook.

What Paygent handles for you:

  • Creates Razorpay Payment Links for unpaid invoices
  • Maps Paygent customers to Razorpay Customers on first payment link
  • Verifies webhook signatures (HMAC-SHA256) and records payments automatically
  • Stores API credentials encrypted — only masked values are shown in the dashboard

Prerequisites

  • A Razorpay account with API access (test or live mode)
  • At least one customer with an email address (required for automated invoice emails)
  • An unpaid invoice with a total amount greater than zero

Setup overview

StepActionDescription
1Connect Razorpay in PaygentAdd your Key ID, Key Secret, and webhook secret under Settings → Integrations.
2Configure Razorpay webhookRegister Paygent’s webhook URL and enable payment.captured + payment_link.paid.
3Collect paymentsGenerate a Razorpay link from an invoice, or enable automatic links in order emails.
4Payment confirmedRazorpay notifies Paygent via webhook; the invoice is marked paid automatically.

Step 1 — Connect Razorpay in Paygent

  1. Open Settings → Integrations in the Paygent dashboard.
  2. Toggle Razorpay on (or click Edit if already connected).
  3. Enter a connection name (for example, Production Razorpay).
  4. Paste your Key ID — starts with rzp_test_ or rzp_live_.
  5. Paste your Key Secret (shown once when you generate the key pair).
  6. Paste your Webhook Secret (you set this in Step 2 when creating the webhook — you can save the connection after the webhook is ready, or edit later).
  7. Click Save Connection. Copy the webhook URL shown on the card — you need it in the next step.

Where to find your Razorpay API keys: In the Razorpay Dashboard → Account & Settings → API Keys, generate a Test or Live key. Copy both the Key ID and Key Secret. Use test keys while setting up; switch to live keys for production.


Step 2 — Configure the Razorpay webhook

Paygent needs Razorpay to send events when a customer completes payment. The webhook URL is unique to your organization and shown in the Razorpay connection card / modal under Settings → Integrations.

Webhook URL format
https://api.withpaygent.com/api/webhooks/razorpay/{your-organization-id}

In the Razorpay Dashboard

  1. Make sure you are in the correct mode (Test or Live) — webhooks are mode-specific.
  2. Go to Account & Settings → Webhooks and click Add New Webhook (or + Create New Webhook).
  3. Paste your Paygent webhook URL (copy it from Settings → Integrations → Razorpay).
  4. Set a Secret (any strong string you choose). You will paste the same value into Paygent as the Webhook Secret.
  5. Under Active Events, enable exactly these two events (see table below).
  6. Save the webhook.
  7. Return to Paygent → Settings → Integrations → Edit Razorpay and paste the webhook secret if you did not save it during initial connect.

Test mode webhook OTP: When creating, editing, or deleting a webhook in Test mode, Razorpay may ask for an OTP. Use the default test OTP: 754081.

Webhook events to enable

Paygent listens only to these events. Enable both so payment confirmation works whether the capture arrives as a payment event or as a payment-link event.

EventRequired?Why
payment.capturedYes — primaryFires when payment is successfully captured. Paygent marks the invoice paid and stores the Razorpay payment id.
payment_link.paidYes — recommendedFires when a Payment Link is fully paid. Acts as a backup / complementary signal for the same invoice flow.

Do not enable other events for Paygent: Events such as payment.authorized, payment.failed, order.paid, or refund.* are not handled by Paygent today. Enabling them is harmless (they are acknowledged and ignored) but not required.

Test vs live mode: API keys and webhooks are separate for Razorpay Test and Live modes. When you go live, create a new webhook in Live mode, use Live Key ID / Key Secret, and update all three values in Paygent.


Step 3 — Collect payments on invoices

Once Razorpay is connected, you can collect payment in two ways.

  1. Open an unpaid invoice from the Invoices list.
  2. Open the actions menu (⋯) and click Generate Razorpay Link.
  3. Copy the short URL (or open it) and send it to your customer.
  4. After payment, the customer is redirected to a Paygent confirmation page; the invoice status updates automatically via webhook.
  1. Configure email delivery under Settings → Email.
  2. When creating or editing an order, set Invoice email to Send invoice with Razorpay payment link.
  3. When an invoice is generated and emailed, Paygent creates a Payment Link and embeds the short URL in the email body.

Email requirements: Automated emails need an active email provider under Settings → Email, and the customer (or order contact) must have a valid email address.


Step 4 — How payment confirmation works

  1. Customer pays on the Razorpay hosted payment page.
  2. Razorpay sends payment.captured and/or payment_link.paid to your Paygent webhook URL with header X-Razorpay-Signature.
  3. Paygent verifies the HMAC-SHA256 signature using your stored webhook secret.
  4. The payment link record is marked completed, and the invoice is recorded as paid (paymentMethod: razorpay).

Manual fallback: If a webhook is delayed or misconfigured, you can still mark the invoice paid from the invoice page using Record Payment with method Razorpay (manual).


Key differences from Stripe

  • Razorpay needs Key ID + Key Secret (Stripe uses a single secret key).
  • You choose the webhook secret yourself in the Razorpay Dashboard (Stripe generates a whsec_... signing secret).
  • Required events: payment.captured + payment_link.paid (Stripe: checkout.session.completed).
  • Signature header is X-Razorpay-Signature (HMAC-SHA256 over the raw body).