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

# Get Started With Optimizer

> Integrate Optimizer on your website to start accepting payments.

<div style={{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"0.35rem 0.9rem",border:"1px solid rgba(128,128,128,0.28)",borderRadius:"0.5rem",padding:"0.45rem 0.75rem",margin:"0 0 1.25rem",fontSize:"0.875rem"}}>
  <span style={{fontWeight:600}}>Available in</span>
  <span>🇮🇳 India</span>
</div>

Check the prerequisites and the integration steps for Optimizer.

## Prerequisites

* [Create a Razorpay account](https://dashboard.razorpay.com/).
* If you are an existing Razorpay user, please raise a request with our [support team](https://razorpay.com/support/#request) to get this feature activated on your Razorpay account.

## Integration Steps

To accept payments using Optimizer, follow the steps given below:

1. [Integrate with Razorpay Payment Gateway](#step-1-integrate-with-razorpay-payment-gateway).
2. [Add Payment Providers](#step-2-add-payment-providers).
3. [Configure Routing rules](#step-3-configure-routing-rules).

## Step 1: Integrate With Razorpay Payment Gateway

You can start accepting payments by integrating your website, app, or ecommerce store with the Razorpay Payment Gateway through any of the [integration methods available](/docs/payments/payment-gateway).

<AccordionGroup>
  <Accordion title="Payments API">
    Payments APIs are used to capture and fetch payments. The payment entity has one extra field with Optimizer to identify the payment provider through which the payment is processed.

    Given below is the additional response parameter apart from the Payment Entity:

    `gateway_provider`
    : `string` The payment provider used to process the payment. Possible values:

    * `payu`
    * `cashfree`
    * `paytm`
    * `pinelabs`
    * `ccavenue`
    * `ingenico`
    * `billdesk_optimizer`

    Refer to [Payments Entity](/docs/api/payments/entity) for the rest of the parameters.

    <CodeGroup>
      ```json Payment Success theme={null}
      {
        "id": "pay_JTiNyKvjH6p3GD",
        "entity": "payment",
        "amount": 100,
        "currency": "INR",
        "status": "captured",
        "order_id": null,
        "invoice_id": null,
        "international": false,
        "method": "card",
        "amount_refunded": 0,
        "refund_status": null,
        "captured": true,
        "description": null,
        "card_id": "card_JTiNyNf65C8Qkn",
        "bank": null,
        "wallet": null,
        "vpa": null,
        "email": "testing@razorpay.com",
        "contact": "+919876543210",
        "notes": [],
        "fee": 0,
        "tax": 0,
        "error_code": null,
        "error_description": null,
        "error_source": null,
        "error_step": null,
        "error_reason": null,
        "acquirer_data": {
          "auth_code": null
        },
        "gateway_provider": "payu",
        "created_at": 1652227221
      }
      ```

      ```json Payment Failure theme={null}
      {
        "id": "pay_Kb8P4crStfXJea",
        "entity": "payment",
        "amount": 10000,
        "currency": "INR",
        "status": "failed",
        "order_id": null,
        "invoice_id": null,
        "international": false,
        "method": "card",
        "amount_refunded": 0,
        "refund_status": null,
        "captured": false,
        "description": "Test Transaction",
        "card_id": "card_Kb8P4eO7zAsjQJ",
        "card": {
          "id": "card_Kb8P4eO7zAsjQJ",
          "entity": "card",
          "name": "",
          "last4": "0153",
          "network": "Visa",
          "type": "debit",
          "issuer": null,
          "international": false,
          "emi": false,
          "sub_type": "consumer",
          "token_iin": null
        },
        "bank": null,
        "wallet": null,
        "vpa": null,
        "email": "gaurav.kumar@example.com",
        "contact": "+9000090000",
        "notes": {
          "address": "Razorpay Corporate Office"
        },
        "fee": null,
        "tax": null,
        "error_code": "BAD_REQUEST_ERROR",
        "error_description": "Your payment has been cancelled. Try again or complete the payment later.",
        "error_source": "customer",
        "error_step": "payment_authentication",
        "error_reason": "payment_cancelled",
        "acquirer_data": {
          "auth_code": null
        },
        "gateway_provider": "payu",
        "created_at": 1667384312
      }
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Webhooks">
    You can use Webhooks to configure and receive notifications when a specific event occurs. When an event is triggered, we send an HTTP POST payload in JSON to the webhook's configured URL. You can [set up Webhooks](/docs/webhooks/setup-edit-payments) from the Dashboard.

    Given below is the sample payload for webhook events for Optimizer. All the parameters and events will remain the same as shown in the [sample payloads for payment webhooks](/docs/webhooks/payments) except for one additional parameter, `gateway_provider`.

    <CodeGroup>
      ```json Webhook Sample Payload theme={null}
      {
        "entity": "event",
        "account_id": "acc_BFQ7uQEaa7j2z7",
        "event": "payment.authorized",
        "contains": [
          "payment"
        ],
        "payload": {
          "payment": {
            "entity": {
              "id": "pay_DESlfW9H8K9uqM",
              "entity": "payment",
              "amount": 100,
              "currency": "INR",
              "status": "authorized",
              "order_id": "order_DESlLckIVRkHWj",
              "invoice_id": null,
              "international": false,
              "method": "netbanking",
              "amount_refunded": 0,
              "refund_status": null,
              "captured": false,
              "description": null,
              "card_id": null,
              "bank": "HDFC",
              "wallet": null,
              "vpa": null,
              "email": "gaurav.kumar@example.com",
              "contact": "+919876543210",
              "notes": [],
              "fee": null,
              "tax": null,
              "error_code": null,
              "error_description": null,
              "error_source": null,
              "error_step": null,
              "error_reason": null,
              "acquirer_data": {
                "bank_transaction_id": "0125836177"
              },
              "gateway_provider": "payu",
              "created_at": 1567674599
            }
          }
        },
        "created_at": 1567674606
      }
      ```
    </CodeGroup>
  </Accordion>
</AccordionGroup>

## Step 2: Add Payment Providers

Watch this video to know how to add payment providers and configure rules using Optimizer.

<iframe width="560" height="315" src="https://www.youtube.com/embed/xmjn0GD-7qM" title="YouTube video player" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen />

The Razorpay Dashboard offers a self-serve flow to [add Payment Providers](/docs/payments/optimizer/add-payment-providers) by submitting your details. This process is secure, and the details you add are fully encrypted which is only visible on your Dashboard. Know more about [Razorpay Security](/docs/security).

## Step 3: Configure Routing Rules

Create your rules on the Razorpay Dashboard to [dynamically route transactions](/docs/payments/optimizer/dynamic-routing) using different parameters like payment method, amount, issuer, and more. You can also add priorities in every rule to ensure transactions are routed to the best-performing gateway.

### Related Information

* [Add a Payment Provider](/docs/payments/optimizer/add-payment-providers)
* [Dynamic Routing](/docs/payments/optimizer/dynamic-routing)
* [Capture and Refund Settings](/docs/payments/optimizer/capture-refund-settings)
* [Supported Gateways and Aggregators](/docs/payments/optimizer/supported-gateways-aggregators)
* [SR Analytics Dashboard](/docs/payments/optimizer/success-rate)
* [Single Reconciliation View](/docs/payments/optimizer/reconciliation)
* [Roles and Permissions](/docs/payments/optimizer/roles-and-permissions)
* [Tokenisation for Optimizer](/docs/payments/optimizer/tokenisation)
