API ReferenceIntegrationsKnowledge Base

Magento 2.x Extension

You can integrate Razorpay Payment Gateway with your Magento Store to accept payments from customers.


  • Sign up for a Razorpay account.
  • Generate the API keys from the Razorpay Dashboard by navigating to SettingsAPI Keys. You can use the Test mode keys for testing and later switch to Live mode keys when going live with the integration.

Integration Steps🔗

  1. Download and Install Extension.
  2. Configure Magento Store.
  3. Set Up Webhooks.
  4. Accept Live Payments.

Step 1: Download and Install Extension🔗

Installation via Composer🔗

  1. Install the extension on your Magento store using the Composer Package Manager. Composer is an application-level package manager for the PHP programming language that provides a standard format for managing dependencies of PHP software and required libraries.

  2. Go to your installation root directory of Magento and execute the following command:

    Copycomposer require razorpay/magento bin/magento module:enable Razorpay_Magento
  3. You can check if the installation was successful by executing the following command in the Magento root directory.

    Copybin/magento module:status

    You should see Razorpay_Magento in the status. It might appear on the disabled modules list.

  4. Enable and deploy the Razorpay module using commands:

    Copybin/magento module:enable Razorpay_Magento bin/magento setup:upgrade bin/magento setup:static-content:deploy

Upgrade Magento Extension:
If you are existing user of this extension, you can upgrade to the the latest version using composer.

Installation Without Composer🔗

  1. Download the code.zip file from the latest release. Extract the zip.

  2. Place the code folder from Step 1 in your app folder. If you're performing an update, replace/overwrite the existing code folder.

  3. Enable and deploy the Razorpay module using commands:

    Copybin/magento module:enable Razorpay_Magento bin/magento setup:upgrade
  4. Import the SQL file (razorpay_sales_order.sql) into your project database.

Step 2: Configure Magento Store🔗

To configure your Magento store for Razorpay:

  1. Log into your Magento store.

  2. Choose Stores on the Admin sidebar to the left. Now go to Settings > Configuration.

  3. In the Configuration page, click on Sales on the left and choose Payment Methods.

  4. In the Payment Methods page, navigate to Razorpay.

  5. Enter your test mode [KEY_ID] and [KEY_SECRET]. These can be generated from your Dashboard.

  6. Select Yes for the option Enabled.

  7. Click Save Config. This activates your account in the Test Mode. You can use this account to make a few test payments to ensure a successful workflow. Note:
    In test mode, no real money is deducted from your account.

Step 3: Set Up Webhooks🔗

Webhooks are triggered when certain events occur. Subscribe to webhook events to receive notification (in the form of a webhook payload) when these events occur.

Setting up webhooks makes your integration more robust, and guards against issues arising from poor connectivity. The webhook URL is available on the plugin's settings page. You must copy it from there and use it to set up webhook on the Razorpay Dashboard.

Handy Tips
If you are using Magento plugin version 3.4.1, ensure the webhook delay is set to a minimum 300 seconds.

To set up webhooks in the Razorpay Dashboard:

  1. Log into the Razorpay Dashboard.
  2. Navigate to SettingsWebhooks.
  3. Click + Add New Webhook.
  4. In the Webhook Setup modal:
    • Paste the URL copied from the Magento site. Handy Tips
      Webhooks can only be delivered to public URLs. If you attempt to save a localhost endpoint as part of a webhook set-up, you will notice an error. Please refer to the test webhooks section for alternatives to localhost.
    • Enter the Secret you had provided on the Magento site. The secret is used to validate that the webhook is from Razorpay. Do not expose the secret publicly. Learn more about <a href="/docs/webhooks/#validation>.
    • In the Alert Email field, enter the email address to which notifications must be sent in case of webhook failure.
    • Select only the order.paid event from the list of Active Events.
  5. Click Create Webhook.

Learn more about webhooks.

Step 4: Accept Live Payments🔗

After testing your Magento store, when you are ready to accept live payments:

  1. Generate the [KEY_ID] and [KEY_SECRET] in the Live mode on your Razorpay Dashboard.
  2. Enter the Live mode [KEY_ID] and [KEY_SECRET] in your Magento store.

<callout warn>
As of now, Razorpay Order ID cannot be displayed on the Magento Admin Panel and the Magento Order ID cannot be displayed as the default Order ID on the Razorpay Dashboard.
However, to view Magento Order ID on Razorpay Dashboard, click **Individual Orders** and click **Notes** to view the Order IDs.
You can also search for Magento Order ID in the Razorpay Dashboard.
  1. Log into the Dashboard.
  2. Navigate to the **Transactions** page and then to the **Orders** tab.
  3. Enter the Magento ID in the field **Receipt** and click **Search**.

Upgrade Magento Extension🔗

If you are an existing user, you can upgrade the Magento extension using the composer. Enter the command given below:

Copycomposer update razorpay/magento bin/magento setup:upgrade


Below are some common error messages and the possible reasons and fixes:




Bad request error

The API Keys ([KEY_ID] and [KEY_SECRET]) are not configured correctly.

Make sure that the API Keys are active and entered correctly into the Magento Settings page.

Bad request error

You may be using a custom checkout theme like IWD and Firecheckout.

Make sure that you are using the GitHub/master branch.

cURL error

You do not have PHP-cURL installed on your server.

Ensure that you have PHP-cURL installed on your server.

cURL error

Port 443 is blocked.

Contact your hosting service to unblock the port.

Undefined index: razorpay in /app/code/Razorpay/Magento/Observer/AfterConfigSaveObserver.php

This issue is due to an error in module compilation.

Run run bin/magento setup:di:compile to recompile.

The following modules are outdated:
• Razorpay_Magento schema: Current Version - None, Required Version - 3.6.2
• Razorpay_Magento data: Current Version - None, Required Version - 3.6.2

The Razorpay Magento plugin version is outdated.

Download and install the latest Razorpay Magento Plugin from here.

Address Verification System🔗

If you are accepting international payments, you can use Razorpay's Address Verification System (AVS). AVS verifies if a customer's billing address (postal code and the billing street address) matches the billing address on file with the card issuer. Based on the response from the issuer, Razorpay will accept or cancel the transaction. This helps in the prevention of fraud in international payments.

Know more about Address Verification System.