Skip to main content
Available in🇮🇳 India🇸🇬 Singapore
Follow the steps given below to integrate Razorpay Payment Gateway with your Drupal Commerce website.

1. Build Integration

Install and configure the Drupal Commerce plugin.

2. Test Integration

Test the integration by making a test payment.

3. Go-Live Checklist

Check the go-live checklist.

1. Build Integration

Follow the steps given below:
To upload the plugin:
  1. Download the drupal_commerce_razorpay.zip.
  2. Log in to your Drupal Commerce account and navigate to Extend. Navigate to Extend on Drupal
  3. Click + Add new module.
  4. Add the module from URL or click Choose file and select the .zip file downloaded previously.
  5. Click Continue.
Add/upload drupal .zip file/URLYou have successfully uploaded the plugin.
Handy TipsAlternatively, you can skip this step and simply run composer require 'drupal/drupal_commerce_razorpay:^1.0' in your drupal directory to download the plugin. You can view the downloaded file in the contrib folder.
To install the plugin:
  1. On your Drupal Commerce Dashboard, navigate to Extend.
  2. Search for Razorpay in the Filter section.
  3. Select Commerce Razorpay and click Install.
Install drupal plugin
To configure the plugin:
  1. On your Drupal Commerce Dashboard, navigate to Commerce.
  2. Click Configuration. Navigate to commerce to configure the plugin
  3. In the Payment section, select Payment gateways. Configure the payment gateway
  4. Click + Add payment gateway. Add the payment gateway
  5. In the Name section, enter Razorpay and select Razorpay as the Plugin.
  6. Select Test Mode to test the integration and enter the test Key ID and Secret generated from the Razorpay Dashboard.
Handy TipsTo go live with the integration and start accepting real payments:
  • Select Live Mode.
  • Generate Live Mode API Keys and replace the test keys with the live keys in the integration. Click Save.
Switch to live mode
  1. Select the Payment Action based on your requirement. Set the Payment Action to Authorize and Capture to auto-capture payments. If you want to capture payments manually, set the Payment Method to Authorize.
  2. Select Enabled in the Status section.
  3. Click Save. Configure the Razorpay payment gateway
Handy TipsIf you want to edit any fields, navigate to CommerceConfiguration. Select Payment Gateway and click Edit.
You have successfully integrated the Razorpay Payment Gateway with your Drupal Commerce website.
Handy Tips
  • Webhooks are auto-configured when you enter and submit the API key ID during the installation. You can verify if webhooks are enabled on your Razorpay Dashboard.
  • The payment.authorized, payment.failed and refund.created events are auto-configured. You do not have to configure it on the Razorpay Dashboard.

2. Test Integration

After the integration is complete, a payment button will appear on your web page/app. You need to click the button and make a test transaction to ensure the integration works as expected. You can start accepting actual payments from your customers once the test is successful.
Watch Out!This is a mock payment page that uses your test API keys, test card and payment details.
  • Ensure you have entered only your Test Mode API keys in the Configuration section of the Drupal Commerce Dashboard.
  • Test mode features a mock bank page with Success and Failure buttons to replicate the live payment experience.
  • No real money is deducted due to the usage of test API keys. This is a simulated transaction.
Test the integration on your webpage/app
After the integration is complete, a Pay button appears on your webpage/app.Test integration on your webpage/appClick the button and make a test transaction to ensure the integration is working as expected. You can start accepting actual payments from your customers once the test transaction is successful.
Watch Out!This is a mock payment page that uses your test API keys, test card and payment details.
  • Ensure you have entered only your Test Mode API keys in the Checkout code.
  • Test mode features a mock bank page with Success and Failure buttons to replicate the live payment experience.
  • No real money is deducted due to the usage of test API keys. This is a simulated transaction.
Following are all the payment modes that the customer can use to complete the payment on the Checkout. Some of them are available by default, while others may require approval from us. Raise a request from the Dashboard to enable such payment methods.You can make test payments using one of the payment methods configured at the Checkout.
You can select any of the listed banks. After choosing a bank, Razorpay will redirect to a mock page where you can make the payment success or a failure. Since this is Test Mode, we will not redirect you to the bank login portals.Check the list of supported banks.
You can enter one of the following UPI IDs:
  • success@razorpay: To make the payment successful.
  • failure@razorpay: To fail the payment.
Check the list of supported UPI flows.
Handy TipsYou can use Test Mode to test UPI payments, and Live Mode for UPI Intent and QR payments.
You can use the following test cards to test transactions for your integration in Test Mode.

Domestic Cards

Use the following test cards for Indian payments:

Error Scenarios

Use these test cards to simulate payment errors. See the complete list of error test cards with detailed scenarios. Check the following lists:

International Cards

Use the following test cards to test international payments. Use any valid expiration date in the future in the MM/YY format and any random CVV to create a successful payment.Check the list of supported card networks.
You can select any of the listed wallets. After choosing a wallet, Razorpay will redirect to a mock page where you can make the payment success or a failure. Since this is Test Mode, we will not redirect you to the wallet login portals.Check the list of supported wallets.
You can track the payment status from the Dashboard or by polling APIs.
  1. Log in to the Razorpay Dashboard and navigate to TransactionsPayments.
  2. Check if a payment_ID has been generated and note the status. In case of a successful payment, the status is marked as captured. Payment details on Dashboard

3. Go-live Checklist

Follow these steps before taking the integration live:
You can perform an end-to-end simulation of funds flow in the Test Mode. Once confident that the integration is working as expected, switch to the Live Mode and start accepting payments from customers.
Watch Out!Ensure you are switching your test API keys with API keys generated in Live Mode.
To generate API Keys in Live Mode on your Razorpay Dashboard:
  1. Log in to the Razorpay Dashboard and switch to Live Mode on the menu.
  2. Navigate to Account & SettingsAPI KeysGenerate Key to generate the API Key for Live Mode.
  3. Download the keys and save them securely.
  4. On your Drupal Commerce Dashboard, navigate to Commerce.
  5. Click Configuration. Navigate to commerce to configure the plugin
  6. In the Payment section, select Payment gateways. Configure the payment gateway
  7. Click Edit. Edit the payment gateway configurations
  8. In the Mode section, select Live.
  9. Replace the Test Key ID and Secret with the Live Keys and accept actual payments.
Replace test keys with live ones
After a payment is authorized, you must capture it to settle the amount to your bank account as per the settlement schedule.Follow the steps given below to set a payment action:
  1. On the Drupal Commerce Dashboard, navigate to Commerce.
  2. Click Configuration. Navigate to commerce to configure the plugin
  3. In the Payment section, select Payment gateways. Configure the payment gateway
  4. Click Edit. Edit the payment gateway configurations
  5. In the Payment Action section, you can choose to: Edit the payment capture settings
    1. Authorize and Capture: This setting captures all authorized payments automatically. This eliminates the time and effort spent manually capturing payments.
    2. Authorize: Each authorized payment can also be captured individually.
      1. Once a payment is completed, navigate to CommerceOrders.
      2. Identify the order you want to capture the payment and click View. Identify the order
      3. Navigate to Payments.
      4. In the Operations section, click Capture. Manually capture the payment

Refunds

To initiate refunds using the Drupal Commerce Dashboard:
  1. Log in to the Drupal Commerce Dashboard.
  2. After a payment is completed, navigate to CommerceOrders.
  3. Identify the order you want to initiate a refund and click View. Identify the order
  4. Navigate to Payments.
  5. In the Operations section, click Refund. Issue a Refund
  6. You can either issue a full refund or a partial refund.
    • For a full refund, enter the entire payment amount.
    • For a partial refund, enter a value lesser than the payment amount.
  7. Click Refund.