This guide will help you integrate the Razorpay payment gateway into your web application to accept online payments.
Before you begin, make sure you have the following prerequisites in place:
-
Razorpay Account: You need to sign up for a Razorpay account at Razorpay Signup.
-
Web Application: You should have a web application where you want to integrate Razorpay for payment processing.
-
Server-Side Implementation: This guide assumes you have a server-side application to handle payment requests.
Clone or download this repository to get started with the Razorpay integration. Follow the steps below to integrate Razorpay into your application.
-
Sign in to your Razorpay account.
-
Navigate to the Razorpay Dashboard and obtain your
API Key
andAPI Secret
from theSettings
section. You will need these for the integration. -
Set up the necessary webhook URLs in your Razorpay dashboard to handle events like payment confirmation and refunds.
-
Include the Razorpay JavaScript library in your HTML:
<script src="https://checkout.razorpay.com/v1/razorpay.js"></script>
-
Create a Razorpay instance in your JavaScript code:
var rzp = new Razorpay({ key: 'YOUR_API_KEY', });
-
Create an order on the server-side, and pass the order ID to the client.
-
Trigger the payment when a user clicks on the payment button:
rzp.open({ amount: 1000, // The amount in paise (100 paise = 1 INR) currency: 'INR', name: 'Your Company Name', description: 'Payment for your product', order_id: 'YOUR_ORDER_ID', handler: function (response) { // Handle the payment success or failure here }, });
-
Handle the payment response on the server-side to confirm the payment.
-
Set up webhooks to handle various events and keep track of payments and refunds.
Provide clear and detailed instructions on how to use the Razorpay integration in your web application. Include code examples, configurations, and any relevant details to help users understand the integration process.
If you have any suggestions or improvements, please open an issue or submit a pull request to contribute to this project.