π Complete Guide to Razorpay Payment Gateway
Master Online Payments in India
β’ Introduction to Razorpay
β What is Razorpay?
Razorpay is India's leading payment gateway solution that enables businesses to accept, process, and disburse online payments. Founded in 2014 by Shashank Kumar and Harshil Mathur, Razorpay has become one of the most trusted payment platforms in India.
β Why Choose Razorpay?
- Easy Integration: Simple APIs and SDKs for quick setup
- Multiple Payment Options: Cards, UPI, Wallets, Net Banking
- Instant Settlements: Quick fund transfers to your bank
- Developer-Friendly: Comprehensive documentation
- 24/7 Support: Round-the-clock customer assistance
β Business Benefits
β Increase conversion rates by 20-30%
β Reduce cart abandonment
β Accept international payments
β Automated reconciliation
β Real-time analytics dashboard
β’ Key Features of Razorpay
β Payment Gateway
Accept payments through 100+ payment methods including Credit Cards, Debit Cards, Net Banking, UPI, and Wallets.
β Payment Links
Create and share payment links via SMS, email, or messaging apps without any coding.
β Payment Pages
Build customizable payment pages in minutes without technical knowledge.
β Subscriptions
Automate recurring payments for subscription-based businesses.
β Route
Split payments automatically between multiple parties (marketplace feature).
β Smart Collect
Virtual accounts for automated payment reconciliation.
| Feature | Description | Best For |
|---|---|---|
| Payment Gateway | Standard checkout integration | E-commerce websites |
| Payment Links | Share links to collect payments | Small businesses, freelancers |
| Payment Pages | No-code payment collection | Quick product sales |
| Subscriptions | Recurring payment automation | SaaS, memberships |
| Razorpay X | Business banking and payouts | All business types |
β’ How Razorpay Works
β The Payment Process
Step 1: Customer Initiates Payment
Customer selects products and clicks on 'Pay Now' button on your website.
Step 2: Razorpay Checkout Opens
Razorpay's secure payment interface appears with multiple payment options.
Step 3: Customer Enters Details
Customer chooses payment method and enters required information.
Step 4: Payment Processing
Razorpay securely processes the payment through the banking network.
Step 5: Confirmation
Both merchant and customer receive payment confirmation.
Step 6: Settlement
Funds are settled to your bank account within T+2 or T+3 days.
β’ Payment Flow Diagram
β’ Integration Steps
β Prerequisites
- Active Razorpay account
- API Key and Secret Key
- Website with HTTPS enabled
- Basic knowledge of HTML, CSS, JavaScript
β Step-by-Step Integration
1. Sign up on Razorpay Dashboard (https://dashboard.razorpay.com)
2. Complete KYC verification
3. Get your API Keys from Settings β API Keys
4. Integrate Razorpay Checkout on your website
5. Test in Test Mode before going live
6. Switch to Live Mode after testing
β Integration Methods
| Method | Difficulty | Time Required | Customization |
|---|---|---|---|
| Standard Checkout | Easy | 15-30 minutes | Limited |
| Payment Links | Very Easy | 5 minutes | Minimal |
| Payment Button | Easy | 10 minutes | Medium |
| Custom Integration | Advanced | 2-4 hours | Full |
β’ Pricing Structure
β Standard Pricing
| Payment Method | Pricing | Notes |
|---|---|---|
| Domestic Credit Cards | 2% per transaction | + βΉ2 GST |
| Domestic Debit Cards | 2% per transaction | + βΉ2 GST |
| Net Banking | 2% per transaction | + βΉ2 GST |
| UPI | 2% per transaction | + βΉ2 GST |
| Wallets | 2% per transaction | + βΉ2 GST |
| International Cards | 3% per transaction | + βΉ2 GST |
β Example Calculation
Transaction Amount: βΉ1,000
Payment Gateway Fee (2%): βΉ20
GST on Fee (18%): βΉ3.60
Total Deduction: βΉ23.60
Amount Settled: βΉ976.40
β’ Supported Payment Methods
β Available Options
| Category | Options | Processing Time |
|---|---|---|
| Credit Cards | Visa, Mastercard, American Express, RuPay | Instant |
| Debit Cards | Visa, Mastercard, Maestro, RuPay | Instant |
| Net Banking | 50+ banks including SBI, HDFC, ICICI | Instant |
| UPI | All UPI apps (Google Pay, PhonePe, Paytm) | Instant |
| Wallets | Paytm, PhonePe, Freecharge, Mobikwik | Instant |
| EMI | Cardless EMI, Credit Card EMI | Instant |
| Pay Later | LazyPay, Simpl, ZestMoney | Instant |
β’ Code Implementation
β Basic HTML Integration
<!DOCTYPE html>
<html>
<head>
<title>Razorpay Payment</title>
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
</head>
<body>
<button id="payButton">Pay βΉ500</button>
<script>
document.getElementById('payButton').onclick = function(e) {
var options = {
"key": "YOUR_KEY_ID",
"amount": "50000", // Amount in paise (βΉ500)
"currency": "INR",
"name": "Your Company Name",
"description": "Product Purchase",
"image": "https://your-logo-url.com/logo.png",
"handler": function (response) {
alert("Payment Successful!");
console.log(response.razorpay_payment_id);
},
"prefill": {
"name": "Customer Name",
"email": "customer@example.com",
"contact": "9999999999"
},
"theme": {
"color": "#F37254"
}
};
var rzp1 = new Razorpay(options);
rzp1.open();
}
</script>
</body>
</html>
β Server-Side Order Creation (Node.js)
const Razorpay = require('razorpay');
const razorpay = new Razorpay({
key_id: 'YOUR_KEY_ID',
key_secret: 'YOUR_KEY_SECRET'
});
// Create Order
const options = {
amount: 50000, // amount in paise
currency: "INR",
receipt: "order_rcptid_11"
};
razorpay.orders.create(options, function(err, order) {
console.log(order);
// Send order.id to frontend
});
β Payment Verification (Backend)
const crypto = require('crypto');
function verifyPayment(orderId, paymentId, signature) {
const text = orderId + "|" + paymentId;
const generated_signature = crypto
.createHmac('sha256', 'YOUR_KEY_SECRET')
.update(text)
.digest('hex');
if (generated_signature === signature) {
return true; // Payment verified
}
return false; // Payment not verified
}
β’ API Reference
β Common API Endpoints
| Endpoint | Method | Purpose |
|---|---|---|
| /orders | POST | Create a new order |
| /orders/{order_id} | GET | Fetch order details |
| /payments/{payment_id} | GET | Fetch payment details |
| /payments/{payment_id}/capture | POST | Capture authorized payment |
| /refunds | POST | Create a refund |
β Authentication
Base URL: https://api.razorpay.com/v1/
Authentication: Basic Auth (Key ID : Key Secret)
Content-Type: application/json
β’ Security Features
β PCI DSS Compliance
Razorpay is PCI DSS Level 1 certified, ensuring the highest level of payment security standards.
β Data Encryption
All sensitive data is encrypted using 256-bit SSL/TLS encryption during transmission and storage.
β Two-Factor Authentication
All card transactions require OTP or 3D Secure authentication for added security.
β Security Best Practices
- Never expose your API Key Secret on the frontend
- Always verify payment signatures on the server
- Use webhooks for reliable payment notifications
- Implement rate limiting on your payment endpoints
- Store API keys securely using environment variables
- Enable dashboard IP whitelisting
β’ Razorpay vs Competitors
| Feature | Razorpay | Paytm | Instamojo |
|---|---|---|---|
| Transaction Fee | 2% + GST | 2% + GST | 2% + GST |
| Setup Fee | βΉ0 | βΉ0 | βΉ0 |
| Settlement Time | T+2 days | T+3 days | T+7 days |
| Payment Methods | 100+ | 100+ | 50+ |
| International Payments | β Yes | β Yes | β No |
| Subscription Support | β Yes | β Yes | β Yes |
| API Quality | Excellent | Good | Average |
