Payu Payment Gateway-Step-by-Step Guide: Integrating Instamojo Payment Gateway for Indian Transactions on Your Website
Integrating Instamojo as a payment gateway on your website to handle Indian transactions involves several steps. Instamojo provides a simple API that can be integrated with your website to accept payments. Below is a step-by-step guide to help you integrate Instamojo:
### Step 1: Sign Up for an Instamojo Account
1. Go to the Instamojo website (https://www.instamojo.com/).
2. Click on the “Sign Up” button.
3. Fill in the required details such as your name, email, phone number, and password.
4. Complete the sign-up process by verifying your email and phone number.
### Step 2: Set Up Your Account
1. Log in to your Instamojo dashboard.
2. Fill in your business details, including your business name, website, and address.
3. Link your bank account to receive payments. You will need to provide bank account details and upload KYC documents as required by Instamojo.
### Step 3: Get API Keys
1. Once your account is set up and verified, navigate to the “API & Webhooks” section in your Instamojo dashboard.
2. Click on “Generate API Keys.”
3. Note down your `Client ID`, `Client Secret`, and `Test Secret Key`. These will be used in your website’s backend to communicate with Instamojo.
### Step 4: Install Instamojo PHP Library (If Using PHP)
If your website is built on PHP, you can use the Instamojo PHP library to simplify the integration process.
1. Download the library from GitHub: https://github.com/Instamojo/api-php-client
2. Include the library in your project.
### Step 5: Integrate the Payment Gateway
1. **Create a Payment Request**: In your code, create a payment request object with the necessary details such as the amount, buyer’s name, email, and phone number.
“`php
include ‘vendor/autoload.php’;
$api = new \Instamojo\Instamojo(‘Client ID’, ‘Client Secret’);
$payment_data = [
‘purpose’ => ‘Funding’,
‘amount’ => 500,
‘buyer_name’ => ‘John Doe’,
‘buyer_email’ => ‘[email protected]’,
‘buyer_phone’ => ‘9999999999’,
‘redirect_url’ => ‘http://your-website.com/payment-success/’,
‘send_email’ => true,
‘webhook’ => ‘http://your-website.com/webhook/’,
];
try {
$response = $api->paymentRequestCreate($payment_data);
// Handle response here
} catch (Exception $e) {
// Handle exception
}
“`
2. **Redirect to Payment Page**: Once the payment request is created, redirect the user to the payment page URL provided in the response.
3. **Handle Payment Response**: After the payment is processed, Instamojo will redirect the user back to your specified `redirect_url`. You can use this URL to confirm the payment status.
### Step 6: Set Up Webhooks (Optional)
Webhooks allow you to receive real-time notifications about the status of a payment. You can set up a webhook endpoint on your server to handle these notifications.
1. In the Instamojo dashboard, navigate to the “API & Webhooks” section.
2. Enter the URL of your webhook endpoint and save it.
3. Implement a webhook handler on your server to process incoming webhook events.
### Step 7: Test Your Integration
Before going live, thoroughly test your payment integration in the test environment provided by Instamojo. Ensure that payments are processed correctly and that you receive notifications for all transactions.
### Step 8: Go Live
Once you are confident that everything is working as expected, switch to the live environment by using your live API keys and webhook URL.
Remember to handle all sensitive data securely and follow best practices for payment processing to ensure the safety of your customers’ information.