Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Is that skill safe to install?
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
Are you the author of Razorpay?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/ashish7802-razorpay)
# Razorpay API & SDK Skill
> **Verification Tier:** `code_example_tested` | **Last Verified:** 2026-11-18
> **Official Docs:** https://razorpay.com/docs/api/
## Overview
Razorpay provides Orders, UPI/Card/NetBanking Checkout, Subscriptions, Payment Links, Refunds, and Webhook notifications.
## Installation
```bash
npm install razorpay
pip install razorpay
```
## Authentication
Uses HTTP Basic Authentication with `RAZORPAY_KEY_ID` and `RAZORPAY_KEY_SECRET`. Only `key_id` may be passed to frontend Checkout; `RAZORPAY_KEY_SECRET` and `RAZORPAY_WEBHOOK_SECRET` MUST remain strictly server-side.
## Core Concepts
- **Smallest Currency Unit**: `amount` is always an integer in subunits (e.g., `50000` paise = ₹500.00 INR). Never pass floats.
- **Order-First Flow**: Create an Order server-side (`razorpay.orders.create`), pass `order_id` to Checkout, then cryptographically verify `HMAC-SHA256(order_id + "|" + payment_id, key_secret)` server-side before fulfilling the order.
- **Webhook Verification**: Verify the `x-razorpay-signature` header using `validateWebhookSignature(rawBody, signature, webhookSecret)` from `razorpay/dist/utils/razorpay-utils` (or `crypto.createHmac("sha256", secret)` + `crypto.timingSafeEqual`) over the exact raw request body string.
## Error Handling & Rate Limits
- Handle duplicate webhook deliveries idempotently using the `x-razorpay-event-id` header and unique database constraints on `payment_id` / `order_id`.
- Respect HTTP `429` rate limits with exponential backoff.
## Security Best Practices
- Never mark an order paid solely from client-side Checkout success callbacks without server-side signature verification or verified `payment.captured` webhook confirmation.
- Use `crypto.timingSafeEqual` when comparing hex HMAC digests manually.
- Return HTTP `2xx` quickly from webhook handlers (within 5 seconds) to avoid timeout retries.
## AI Pitfalls
- Passing rupees (e.g., `500`) instead of paise (`50000`), charging 100x too little.
- Passing `JSON.stringify(req.body)` instead of the raw request buffer to webhook signature validation.
- Using `RAZORPAY_KEY_SECRET` instead of the separate `RAZORPAY_WEBHOOK_SECRET` for webhook verification.
## Production Checklist
- [ ] Amounts calculated strictly as integer subunits (paise/cents)
- [ ] Payment signature verified server-side with `timingSafeEqual`
- [ ] Webhook endpoint reads raw body and validates `x-razorpay-signature` with `RAZORPAY_WEBHOOK_SECRET`
- [ ] Webhook processing is idempotent on `x-razorpay-event-id`
## References
- [Razorpay API Reference](https://razorpay.com/docs/api/)
- [Razorpay Webhook Validation](https://razorpay.com/docs/webhooks/validate-test/)
## Related skills
- [`stripe`](../stripe/SKILL.md) — alternative to
- [`paddle`](../paddle/SKILL.md) — alternative to
- [`resend`](../resend/SKILL.md) — works well with