> ## Documentation Index
> Fetch the complete documentation index at: https://doc-test-my.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Integration Steps

> Steps to integrate your Magento Extensions with Razorpay Payment Gateway.

Follow the steps given below to integrate Razorpay Payment Gateway with your Magento website.<br />

<CardGroup cols={3}>
  <Card title="1. Build Integration" href="/docs/payments/payment-gateway/ecommerce-plugins/magento/integration-steps#1-build-integration">
    Install the Magento plugin.
  </Card>

  <Card title="2. Test Integration" href="/docs/payments/payment-gateway/ecommerce-plugins/magento/integration-steps#2-test-integration">
    Test the integration by making a test payment.
  </Card>

  <Card title="3. Go-Live Checklist" href="/docs/payments/payment-gateway/ecommerce-plugins/magento/integration-steps#3-go-live-checklist">
    Check the go-live checklist.
  </Card>
</CardGroup>

## 1. Build Integration

Follow the steps given below to integrate Razorpay Payment Gateway with your Magento 1.x and 2.x Extensions.

<AccordionGroup>
  <Accordion title="Integration Steps for Magento 1.x Extension">
    <AccordionGroup>
      <Accordion title="Step 1: Download and Install via Repository">
        Follow the steps given below to download and install Magento 1.x Extension.

        #### Download Repository

        1. [Download](https://github.com/razorpay/razorpay-magento-v1/releases/latest) the `Razorpay-1.2.1.tgz` file from the latest release.
        2. If you have **Onepage Checkout (IWD or Fire Checkout)**, [download](https://github.com/razorpay/razorpay-magento-v1/releases/latest) the Source Code zip from the latest release. With Onepage Checkout you can gather the required information from the shopper and complete the checkout process quickly. When Onepage Checkout is enabled, the entire checkout process takes place on a single page.

        ### Install Repository

        You can install the repository in two ways:

        <Tabs>
          <Tab title="Install via Magento Connect">
            1. Go to Magento Connect Manager.
            2. Go to `Direct package file upload`.
            3. Click `Choose File` and select the TGZ file from Step 1.
            4. Click `upload`.
          </Tab>

          <Tab title="Install Without Magento Connect">
            1. Unzip and open the downloaded folder.
            2. Copy the **app** folder.
            3. Paste and merge it into the Magento root folder.
            4. Copy the **js** folder.
            5. Paste and merge it into the Magento root folder.
          </Tab>
        </Tabs>

        Once installed, navigate to **Configuration** and then to **Payment Gateways** and [configure the extension](#step-2-configure-magento-store-1-x) to suit your needs.
      </Accordion>

      <Accordion title="Step 2: Configure Magento Store 1.x">
        To configure your Magento store for Razorpay:

        1. Log in to your [Magento store](https://business.adobe.com/products/magento/magento-commerce.html/).
        2. Click on the **System** tab and then select **Configuration** option from the drop-down list.
                   <img src="https://curlec.com/docs/build/browser/assets/images/ecommerce-plugins-magento1.x-3.jpg" width="650" />
        3. Click **Payment Methods** in the menu panel.
        4. Scroll down. Click **Razorpay** and enter your test mode `[KEY_ID]` and `[KEY_SECRET]`.
                   <img src="https://curlec.com/docs/build/browser/assets/images/ecommerce-plugins-magento1.x-4.jpg" width="600" />
        5. Select **Yes** for the **Enabled** option.
        6. Click **Save Config** button. This activates your account in the Test Mode. You can use this account to make a few test payments to ensure a successful workflow.

        <Info>
          **Handy Tips**

          In test mode, no real money is deducted from your account.
        </Info>
      </Accordion>
    </AccordionGroup>
  </Accordion>

  <Accordion title="Integration Steps for Magento 2.x Extension">
    <AccordionGroup>
      <Accordion title="Step 1: Download and Install Extension">
        You can install the extension through two ways:

        <Tabs>
          <Tab title="Install Using 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:

            ```bash Command theme={null}
            composer 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.

            ```bash Command theme={null}
            bin/magento module:status
            ```

            <Info>
              **Handy Tips**

              You should see `Razorpay_Magento` in the status. It might appear on the disabled modules list.
            </Info>

            4. Enable and deploy the Razorpay module using commands:

            ```bash Command theme={null}
            bin/magento module:enable Razorpay_Magento
            bin/magento setup:di:compile
            bin/magento setup:upgrade
            bin/magento cache:flush
            bin/magento setup:static-content:deploy
            ```

            <Note>
              **Upgrade Magento Extension**

              If you are an existing extension user, you can [upgrade](/docs/payments/payment-gateway/ecommerce-plugins/magento#upgrade-magento-extension) to the latest version using the composer.
            </Note>
          </Tab>

          <Tab title="Install Without Composer">
            1. Download the `code.zip` file from the [latest release](https://github.com/razorpay/razorpay-magento/releases/latest). 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:

            ```bash Command theme={null}
            bin/magento module:enable Razorpay_Magento
            bin/magento setup:upgrade
            ```

            4. Install Magento cron jobs using the command:

            ```bash Command theme={null}
            bin/magento cron:install
            ```

            5. Enter the following command to compile the dependency code:

            ```bash Command theme={null}
            bin/magento setup:di:compile
            ```

            6. Enter the following command to upgrade the Razorpay Magento module from the Magento installation folder:

            ```bash Command theme={null}
            bin/magento setup:di:upgrade
            ```

            7. On the Magento Admin Dashboard, open Razorpay payment method settings and click **Save Config**.

            <Warning>
              **Watch Out!**

              If you see the message `One or more of the Cache Types are invalidated: Page Cache.` highlighted in yellow on the Admin page, go to **Cache Management** and refresh cache types.
            </Warning>

            8. Run the following command:

            ```bash Command theme={null}
            bin/magento cache:flush
            ```
          </Tab>
        </Tabs>
      </Accordion>

      <Accordion title="Step 2: Configure Magento Store 2.x">
        To configure your Magento store for Razorpay:

        1. Log in to your [Magento store](https://business.adobe.com/products/magento/magento-commerce.html/).
        2. Choose **Stores** on the Admin sidebar to the left. Now go to **Settings** → **Configuration**.
                   <img src="https://curlec.com/docs/build/browser/assets/images/plugins-magento-magento-2.x-1.jpg" width="800" />
        3. In the **Configuration** page, click on **Sales** on the left and choose **Payment Methods**.
                   <img src="https://curlec.com/docs/build/browser/assets/images/plugins-magento-magento-2.x-2.jpg" width="800" />
        4. In the **Payment Methods** page, navigate to Razorpay.
                   <img src="https://curlec.com/docs/build/browser/assets/images/plugins-magento-magento-2.x-1.jpg" width="800" />
        5. Enter your test mode \[KEY\_ID] and \[KEY\_SECRET]. These can be <a href="/docs/api/authentication#generate-api-keys" target="_blank">generated from the Razorpay Dashboard</a>.
        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 and ensure a successful workflow.

        <Info>
          **Handy Tips**

          In test mode, no real money is deducted from your account.
        </Info>
      </Accordion>

      <Accordion title="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.

        <Info>
          **Handy Tips**

          * If you are using Magento plugin version 3.4.1, ensure the webhook delay is set to a minimum of 300 seconds.
          * Webhook is auto-configured on Magento plugin version 3.8.1-beta and above. For versions lower than 3.8.1-beta, you should [configure webhooks manually](/docs/payments/payment-gateway/ecommerce-plugins/magento/integration-steps#step-3-set-up-webhooks).
        </Info>

        To set up webhooks in the Razorpay Dashboard:

        1. Log in to the Razorpay Dashboard.
        2. Navigate to **Accounts & Settings** → **Webhooks**.
        3. Click + Add New Webhook.
        4. In the Webhook Setup modal:
           * Paste the URL copied from the Magento site.

        <Info>
          **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](/docs/webhooks/validate-test) section for alternatives to localhost.
        </Info>

        * 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. Know more about [webhooks validation](/docs/webhooks/validate-test#validate-webhooks).
        * 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**.

        Know more about [webhooks](/docs/webhooks).

        <Info>
          **Handy Tips**

          If the notification says Razorpay table is not set up correctly, please contact our [Support team](https://curlec.com/support/).
        </Info>
      </Accordion>

      <Accordion title="Step 4: Set Up Cron With Magento">
        Setup cron with Magento to execute Razorpay cronjobs for the following actions:

        **Cancel Pending Orders** <br />

        It will cancel the order created by Razorpay according to the timeout saved in the configuration if Cancel Pending Order is enabled.

        **Update Order to Processing** <br />

        Accepts response from Razorpay Webhook for events `payment.authorized` and `order.paid` and updates pending order to processing.

        Install Magento cron jobs using the command:

        ```bash Command theme={null}
        bin/magento cron:install
        ```
      </Accordion>
    </AccordionGroup>
  </Accordion>
</AccordionGroup>

## 2. Test Integration

After the integration, a **Pay** 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.

<img src="https://curlec.com/docs/build/browser/assets/images/magento-pay.jpg" width="700" />

You can make test payments using one of the payment methods configured at the Checkout.

* No money is deducted from the customer's account as this is a simulated transaction.
* Ensure you have entered the API keys generated in the test mode in the Checkout code.

<AccordionGroup>
  <Accordion title="Supported Payment Methods">
    After the integration is complete, a **Pay** button appears on your webpage/app.

    Click 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.

    <Warning>
      **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](/docs/payments/dashboard/account-settings/api-keys#generate-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.
    </Warning>

    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.

    | Payment Method                                                 | Code     | Availability |
    | -------------------------------------------------------------- | -------- | ------------ |
    | [Debit and Credit Cards](/docs/payments/payment-methods/cards) | `card`   | ✓            |
    | [FPX](/docs/payments/payment-methods/fpx)                      | `fpx`    | ✓            |
    | [Wallets](/docs/payments/payment-methods/wallets)              | `wallet` | ✓            |

    You can make test payments using one of the payment methods configured at the Checkout.

    <AccordionGroup>
      <Accordion title="FPX">
        You can select any of the listed banks. After choosing a bank, Razorpay Curlec will redirect to a mock page where you can make the payment a `success` or a `failure`. Since this is Test Mode, we will not redirect you to the bank login portals.
      </Accordion>

      <Accordion title="Wallet">
        You can select any of the listed wallets. After choosing a wallet, you will be redirected 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.

        <Warning>
          **Watch Out!**

          iOS integration for Touch'n Go wallet is currently unavailable. We will be adding support for it soon.
        </Warning>
      </Accordion>

      <Accordion title="Cards">
        You can use one of the following test cards to test transactions for your integration in Test Mode.

        | Card Network | Card Number         | CVV & Expiry Date                       |
        | ------------ | ------------------- | --------------------------------------- |
        | Mastercard   | 5272 0088 0623 5704 | Use a random CVV and any future date ^^ |
        | Visa         | 4842 7930 0208 6571 |                                         |

        Check the following lists:

        * [Supported Card Networks](/docs/payments/payment-methods/cards).
        * [Cards Error Codes](/docs/errors/payments/cards).
      </Accordion>
    </AccordionGroup>
  </Accordion>

  <Accordion title="Verify Payment Status">
    You can track the payment status from the Dashboard or by polling APIs.

    <Tabs>
      <Tab title="Verify Payment Status From Dashboard">
        1. Log in to the Razorpay Dashboard and navigate to **Transactions** → **Payments**.
        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`.

                   <img class="click-zoom" src="https://curlec.com/docs/build/browser/assets/images/my-testpayment.jpg" width="800" alt="Payment details on Dashboard" />
      </Tab>

      <Tab title="Poll APIs">
        [Poll Payment APIs](/docs/api/payments#fetch-multiple-payments) to check the payment status.
      </Tab>
    </Tabs>
  </Accordion>
</AccordionGroup>

## 3. Go-live Checklist

Follow these steps before taking the integration live:

<AccordionGroup>
  <Accordion title="1 Accept Live Payments">
    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.

    <Warning>
      **Watch Out!**

      Ensure you are switching your test API keys with API keys generated in Live Mode.
    </Warning>

    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 & Settings** → **API Keys** → **Generate Key** to generate the API Key for Live Mode.
    3. Download the keys and save them securely.
    4. Replace the Test API Key with the Live Key in the Checkout code and start accepting actual payments.

    <br />
  </Accordion>

  <Accordion title="2 Payment Capture">
    After payment is `authorized`, you need to capture it to settle the amount to your bank account as per the settlement schedule. Payments that are not captured are auto-refunded after a fixed time.

    <Warning>
      **Watch Out**

      * You should deliver the products or services to your customers only after the payment is captured. Razorpay automatically refunds all the uncaptured payments.
      * You can track the payment status using our [Fetch a Payment API](/docs/api/payments#fetch-a-payment) or webhooks.
    </Warning>

    <Tabs>
      <Tab title="Auto-capture Payments (Recommended)">
        Authorized payments can be automatically captured. You can auto-capture all payments [using global settings](/docs/payments/payments/capture-settings#auto-capture-all-payments) on the Razorpay Dashboard. Know more about [capture settings for payments](/docs/payments/payments/capture-settings).

        <Warning>
          **Watch Out!**

          Payment capture settings work only if you have integrated with Orders API on your server side. Know more about the [Orders API](/docs/api/orders/create).
        </Warning>
      </Tab>

      <Tab title="Manually Capture Payments">
        Each authorized payment can also be captured individually. You can manually capture payments using [Payment Capture API](/docs/api/payments/capture) or [Dashboard](/docs/payments/payments/dashboard#manually-capture-payments). Know more about [capture settings for payments](/docs/payments/payments/capture-settings).
      </Tab>
    </Tabs>
  </Accordion>
</AccordionGroup>
