Skip to main content

Overview

A Razorpay connection in Flexprice stores encrypted credentials that allow the system to interact with your Razorpay account for:
  • Creating customers in Razorpay
  • Processing payment links via Razorpay Checkout
  • Receiving webhook notifications from Razorpay
  • Synchronizing customer data between systems
  • Syncing invoices to Razorpay for payment collection

Prerequisites

Before setting up your Razorpay connection, ensure you have:
  1. Active Razorpay Account - Sign up at razorpay.com
  2. API Keys - Available in your Razorpay Dashboard
  3. Webhook Endpoint - Configured in Razorpay Dashboard
  4. Flexprice Environment - Valid tenant and environment IDs

Step 1: Gather Razorpay Credentials

Required Credentials

Finding Your Credentials

  1. API Keys:
    • Go to Razorpay Dashboard → Settings → API Keys
    • Copy your Key ID
    • Copy your Secret Key
    • Use test keys for development
  2. Webhook Secret:
    • Go to Razorpay Dashboard → Settings → Webhooks
    • Create or select your webhook endpoint
    • Copy the webhook secret (used for signature verification)

Step 2: Configure Webhook Endpoint in Razorpay

Webhook URL Format

Required Webhook Events

Configure these events in your Razorpay webhook endpoint:
The payment_link.* events are required if you use Flexprice Checkout Sessions. Without them, subscriptions created via Checkout will remain in draft status after payment. If you only use manual invoice payment links (not Checkout Sessions), these three events are optional.

Setting Up the Webhook

  1. Go to Razorpay Dashboard → Settings → Webhooks
  2. Click + Add New Webhook
  3. Enter your webhook URL
  4. Select the required events listed above
  5. Click Create Webhook
  6. Copy the Webhook Secret for your connection

Step 3: Create Razorpay Connection

Using Flexprice Dashboard

1

Open Razorpay in Integrations

In the left sidebar, click Integrations, then click Connect on the Razorpay card.
2

Enter your credentials

Enter a Connection name, your Key ID, and your Key secret, then click Continue. Keys are encrypted and never shown again.
Connect Razorpay sheet on the Credentials step with the connection name, key ID, and key secret
3

Choose what syncs

Switch on Push invoices to send Flexprice invoices to Razorpay when they are finalised. Nothing syncs until you switch it on, and you can change it later. Click Continue.
Sync step with the Push invoices switch
4

Add the webhook

The Webhook step shows your Webhook URL and the Events to send. Add them to a Razorpay webhook as in Step 2, enter its secret in Webhook signing secret (optional), and click Connect Razorpay.
Webhook step with the webhook URL, the events to send, and the webhook signing secret
To change the connection later, click Configure on the Razorpay card. You can rename it and change what syncs. Keys can’t be shown or edited: to change them, disconnect and connect again.
Razorpay connection settings with the name, Push invoices, webhook, and Disconnect

API Request

API Request

Endpoint: POST /api/v1/connections Headers:
Request Body:

Response

Security Best Practices

Credential Management

  1. Environment Separation: Use different keys for test/production
  2. Key Rotation: Regularly rotate your Razorpay API keys
  3. Access Control: Limit API key permissions in Razorpay
  4. Encryption: All credentials are encrypted at rest in Flexprice

Webhook Security

  1. HTTPS Only: Always use HTTPS for webhook endpoints
  2. Signature Verification: Flexprice verifies all webhook signatures
  3. Secret Management: Keep webhook secrets secure and rotate regularly
  4. Rate Limiting: Implement rate limiting on webhook endpoints

Troubleshooting

Common Issues

Debug Steps

  1. Check Razorpay Dashboard: Verify API keys and webhook configuration
  2. Test API Keys: Use Razorpay API to test key validity
  3. Monitor Webhooks: Check webhook delivery logs in Razorpay
  4. Review Logs: Check Flexprice application logs for errors

Next Steps

After setting up your Razorpay connection:
  1. Test Customer Sync: Create a test customer and sync to Razorpay
  2. Create Payment Links: Test payment link creation and flow
  3. Monitor Webhooks: Ensure webhook events are being received
  4. Go Live: Switch to production keys when ready