Spaces:
Running
Razorpay Integration Setup Guide
Overview
This document provides instructions on how to set up Razorpay payment gateway integration for the Bolt Spices e-commerce website. The integration allows customers to make payments using various methods including credit/debit cards, UPI, netbanking, and wallets.
Prerequisites
- A Razorpay account (create one at razorpay.com if you don't have one)
- Access to Razorpay Dashboard
- API keys from your Razorpay account
Setup Instructions
1. Install Dependencies
The Razorpay package has been added to the project dependencies. Run the following command to install it:
npm install
2. Get Your API Keys
- Log in to your Razorpay Dashboard
- Navigate to Settings > API Keys
- Generate a new API key pair if you don't have one already
- Note down your Key ID and Key Secret
3. Add Your API Key to the Code
Open the file src/pages/CheckoutPage.jsx and locate the following code section:
// Initialize Razorpay options
// You'll need to replace 'YOUR_RAZORPAY_KEY_ID' with your actual Razorpay key
const options = {
key: "YOUR_RAZORPAY_KEY_ID", // Enter your Razorpay Key ID here
amount: orderData.amount,
currency: orderData.currency,
// ... other options
};
Replace "YOUR_RAZORPAY_KEY_ID" with your actual Razorpay Key ID.
4. Backend Integration (Optional but Recommended)
For a production environment, it's recommended to create orders on your backend server for security reasons. This involves:
- Setting up a server endpoint to create Razorpay orders
- Modifying the frontend code to fetch the order ID from your backend
- Using the fetched order ID in the Razorpay options
5. Testing the Integration
Razorpay provides test cards and other payment methods for testing:
- Test Card Number: 4111 1111 1111 1111
- Expiry: Any future date
- CVV: Any 3-digit number
- Name: Any name
- 3D Secure Password: 1234
Security Considerations
- Never expose your Key Secret in the frontend code
- For production, always verify payments on your backend
- Implement proper error handling for failed payments
Additional Resources
Support
If you encounter any issues with the Razorpay integration, please contact:
- Razorpay Support: support@razorpay.com
- Your development team for application-specific issues