Supercharge your Node.js server with the power of Razorpay payment gateway!
Before you dive into the magic of Razorpay Payment Gateway Integration API, make sure you have the following enchantments ready:
- 🧙♂️ Node.js installed on your machine.
- 🧪 A mystical Razorpay account with API key and secret.
To embark on this mystical journey, follow these steps:
-
✨ Clone the repository and enter the magical realm:
git clone <repository-url> cd node-razorpay
-
🧙♂️ Cast the spell to install the dependencies:
npm install
-
📜 Create a
.env
scroll in the root directory and inscribe your Razorpay API key and secret within:RAZORPAY_KEY_ID=<your-key-id> RAZORPAY_SECRET=<your-secret>
-
🎩 Wave your wand to start the server:
npm run dev
The portal to the server will open at http://localhost:4000. Enter at your own risk!
The API is home to the following magical portals:
- This 🔮 portal allows you to create a Razorpay order with just a flick of your wand. Simply provide the desired
price
and behold the order details that will be revealed to you!
price
(query parameter): The price of the order you wish to create.
- Success: 200 OK! The order details will be unveiled in the response body, ready for you to explore.
- Error: 500 Internal Server Error! An error message will be revealed, guiding you through the troubles.
- This 🌟 portal allows you to fetch the payments associated with a specific order. Provide the
orderId
and witness the magical details of the payments unfold before your eyes!
orderId
(query parameter): The ID of the order for which you want to fetch the payments.
- Success: 200 OK! The payment details will be revealed in the response body, showcasing the captivating information.
- Error: 500 Internal Server Error! An error message will be unveiled, guiding you through the troubles.
To create a Razorpay order, whisper the sacred incantation in the form of a GET request to the /orders
portal, with the price
query parameter set to the desired amount. The API will wield its powers to create the order and reveal its magnificent details.
🪄 Example Incantation:
GET /orders?price=1000
⚡️ Example Response:
{
"id": "order_1234567890",
"entity": "order",
"amount": 1000,
"currency": "INR",
"receipt": "receipt#1",
"createdAt": 1671234567
// ... other captivating order details
}
To fetch the payments associated with a specific order, conjure a GET request to the /orders/:orderId/payments
portal, replacing :orderId
with the actual ID of the order
. The API will unleash its powers and reveal the mesmerizing payment details.
🪄 Example Incantation:
GET /orders/order_1234567890/payments
⚡️ Example Response:
{
"count": 2,
"entity": "collection",
"items": [
{
"id": "pay_1234567890",
"entity": "payment",
"order_id": "order_1234567890",
"amount": 1000,
"status": "captured"
// ... other captivating payment details
},
{
"id": "pay_0987654321",
"entity": "payment",
"order_id": "order_1234567890",
"amount": 2000,
"status": "captured"
// ... other captivating payment details
}
]
// ... other captivating collection details
}
Join the league of magical developers! Contributions are welcomed and celebrated in this mystical realm. If you encounter any issues or have ideas for enchantments, feel free to open an issue or cast a pull request.
This project is licensed under the MIT License. Cast your spells responsibly!
Feel free to further customize the README according to your project's requirements and add any additional information or sections as needed.
Happy coding!