> ## 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 Drupal Commerce website with the Razorpay Payment Gateway.

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

<CardGroup cols={3}>
  <Card title="1. Build Integration" href="/docs/payments/payment-gateway/ecommerce-plugins/drupal-commerce/integration-steps#1-build-integration">
    Install and configure the Drupal Commerce plugin.
  </Card>

  <Card title="2. Test Integration" href="/docs/payments/payment-gateway/ecommerce-plugins/drupal-commerce/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/drupal-commerce/integration-steps#3-go-live-checklist">
    Check the go-live checklist.
  </Card>
</CardGroup>

## 1. Build Integration

Follow the steps given below:

<AccordionGroup>
  <Accordion title="1 Download and Upload Plugin">
    To upload the plugin:

    1. [Download](https://github.com/razorpay/drupal_commerce_razorpay/releases) the `drupal_commerce_razorpay.zip`.
    2. Log in to your [Drupal Commerce account](https://drupal.plugin.razorpay.in/) and navigate to **Extend**.
           <img src="https://curlec.com/docs/build/browser/assets/images/drupal-extend.jpg" alt="Navigate to Extend on Drupal" width="800" />
    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**.

    <img src="https://curlec.com/docs/build/browser/assets/images/add-drupal-plugin1.gif" alt="Add/upload drupal .zip file/URL" width="800" />

    You have successfully uploaded the plugin.

    <Info>
      **Handy Tips**

      Alternatively, 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.
    </Info>
  </Accordion>

  <Accordion title="2 Install Plugin">
    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**.

    <img src="https://curlec.com/docs/build/browser/assets/images/drupal-install-plugin.jpg" alt="Install drupal plugin" width="800" />
  </Accordion>

  <Accordion title="3 Configure Plugin">
    To configure the plugin:

    1. On your Drupal Commerce Dashboard, navigate to **Commerce**.
    2. Click **Configuration**.
           <img src="https://curlec.com/docs/build/browser/assets/images/drupal-commerce-config.jpg" alt="Navigate to commerce to configure the plugin" width="800" />
    3. In the **Payment** section, select **Payment gateways**.
           <img src="https://curlec.com/docs/build/browser/assets/images/drupal-config-pg.jpg" alt="Configure the payment gateway" width="800" />
    4. Click **+ Add payment gateway**.
           <img src="https://curlec.com/docs/build/browser/assets/images/drupal-config-add-pg.jpg" alt="Add the payment gateway" width="800" />
    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](/docs/api/authentication#generate-api-keys).

    <Info>
      **Handy Tips**

      To go live with the integration and start accepting real payments:

      * Select **Live** Mode.
      * Generate [Live Mode API Keys](/docs/api/authentication#live-mode-api-keys) and replace the test keys with the live keys in the integration. Click **Save**.

      <img src="https://curlec.com/docs/build/browser/assets/images/drupal-live-mode.jpg" alt="Switch to live mode" width="800" />
    </Info>

    7. 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**.
    8. Select **Enabled** in the **Status** section.
    9. Click **Save**.
           <img src="https://curlec.com/docs/build/browser/assets/images/drupal-config.gif" alt="Configure the Razorpay payment gateway" width="800" />

    <Info>
      **Handy Tips**

      If you want to edit any fields, navigate to **Commerce** → **Configuration**. Select **Payment Gateway** and click **Edit**.
    </Info>

    You have successfully integrated the Razorpay Payment Gateway with your Drupal Commerce website.

    <Info>
      **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.
    </Info>
  </Accordion>
</AccordionGroup>

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

<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/api/authentication#generate-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.
</Warning>

<img src="https://curlec.com/docs/build/browser/assets/drupal-test2.gif" alt="Test the integration on your webpage/app" width="800" />

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

    <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. On your [Drupal Commerce Dashboard](https://drupal.plugin.razorpay.in/), navigate to **Commerce**.
    5. Click **Configuration**.
           <img src="https://curlec.com/docs/build/browser/assets/images/drupal-commerce-config.jpg" alt="Navigate to commerce to configure the plugin" width="800" />
    6. In the **Payment** section, select **Payment gateways**.
           <img src="https://curlec.com/docs/build/browser/assets/images/drupal-config-pg.jpg" alt="Configure the payment gateway" width="800" />
    7. Click **Edit**.
           <img src="https://curlec.com/docs/build/browser/assets/images/drupal-edit-config.jpg" alt="Edit the payment gateway configurations" width="800" />
    8. In the **Mode** section, select **Live**.
    9. Replace the Test Key ID and Secret with the Live Keys and accept actual payments.

    <img src="https://curlec.com/docs/build/browser/assets/images/drupal-live-keys.jpg" alt="Replace test keys with live ones" width="800" />
  </Accordion>

  <Accordion title="2 Payment Capture">
    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](https://drupal.plugin.razorpay.in/), navigate to **Commerce**.
    2. Click **Configuration**.
           <img src="https://curlec.com/docs/build/browser/assets/images/drupal-commerce-config.jpg" alt="Navigate to commerce to configure the plugin" width="800" />
    3. In the **Payment** section, select **Payment gateways**.
           <img src="https://curlec.com/docs/build/browser/assets/images/drupal-config-pg.jpg" alt="Configure the payment gateway" width="800" />
    4. Click **Edit**.
           <img src="https://curlec.com/docs/build/browser/assets/images/drupal-edit-config.jpg" alt="Edit the payment gateway configurations" width="800" />
    5. In the **Payment Action** section, you can choose to:
           <img src="https://curlec.com/docs/build/browser/assets/images/drupal-payment-capture.jpg" alt="Edit the payment capture settings" width="800" />
       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 **Commerce** → **Orders**.
          2. Identify the order you want to capture the payment and click **View**.
                 <img src="https://curlec.com/docs/build/browser/assets/images/drupal-order.jpg" alt="Identify the order" width="800" />
          3. Navigate to **Payments**.
          4. In the **Operations** section, click **Capture**.
                 <img src="https://curlec.com/docs/build/browser/assets/images/drupal-manual-capture.jpg" alt="Manually capture the payment" width="800" />
  </Accordion>
</AccordionGroup>

#### Refunds

To initiate refunds using the Drupal Commerce Dashboard:

1. Log in to the [Drupal Commerce Dashboard](https://drupal.plugin.razorpay.in/).
2. After a payment is completed, navigate to **Commerce** → **Orders**.
3. Identify the order you want to initiate a refund and click **View**.
   <img src="https://curlec.com/docs/build/browser/assets/images/drupal-order.jpg" alt="Identify the order" width="800" />
4. Navigate to **Payments**.
5. In the **Operations** section, click **Refund**.
   <img src="https://curlec.com/docs/build/browser/assets/images/drupal-refund.jpg" alt="Issue a Refund" width="800" />
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**.
