> ## Documentation Index
> Fetch the complete documentation index at: https://razorpay-60c89f9a-mintlify-audit-missing-sections-1778528421.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Started With Optimizer

> 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:

<Steps>
  <Step title="Step 1">
    [Integrate with Razorpay Payment Gateway](#step-1-integrate-with-razorpay-payment-gateway).
  </Step>

  <Step title="Step 2">
    [Add Payment Providers](#step-2-add-payment-providers).
  </Step>

  <Step title="Step 3">
    [Configure Routing rules](#step-3-configure-routing-rules).
  </Step>
</Steps>

## 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](/payments/payment-gateway).

### 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](/api/payments#payments-entity) for the rest of the parameters.

````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
{
  "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
}
````

### 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](/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](/webhooks/payments) except for one additional parameter, `gateway_provider`.

```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
}
```

## Step 2: Add Payment Providers

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

The Razorpay Dashboard offers a self-serve flow to [add Payment Providers](/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](/security).

## Step 3: Configure Routing Rules

Create your rules on the Razorpay Dashboard to [dynamically route transactions](/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](/payments/optimizer/add-payment-providers)
* [Dynamic Routing](/payments/optimizer/dynamic-routing)
* [Capture and Refund Settings](/payments/optimizer/capture-refund-settings)
* [Supported Gateways and Aggregators](/payments/optimizer/supported-gateways-aggregators)
* [SR Analytics Dashboard](/payments/optimizer/success-rate)
* [Single Reconciliation View](/payments/optimizer/reconciliation)
* [Roles and Permissions](/payments/optimizer/roles-and-permissions)
* [Tokenisation for Optimizer](/payments/optimizer/tokenisation)
