> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fype.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Cashfree guide

# Cashfree Integration Guide

Cashfree is a robust payment gateway in India that offers advanced features like instant settlements and a wide variety of payment modes. Fype's Cashfree integration allows you to leverage these features through a unified interface.

## 1. Obtain Cashfree API Credentials

To connect Cashfree to Fype, you need your **App ID** (Client ID) and **Secret Key** (Client Secret).

1. Log in to your [Cashfree Merchant Dashboard](https://merchant.cashfree.com).
2. Switch to the desired environment (**Test** or **Production**) using the toggle at the top right.
3. Navigate to **Payment Gateway** > **Developers** > **API Keys**.
4. Copy your **App ID** and **Secret Key**.

## 2. Connect to Fype

1. Log in to the [Fype Dashboard](https://dashboard.fype.dev).
2. Navigate to **Connections**.
3. Click **Connect Cashfree**.
4. Select the environment:

* **Sandbox**: Use this for Cashfree **Test** credentials (App ID starts with `TEST`).
* **Live**: Use this for Cashfree **Production** credentials (App ID starts with `PROD`).

5. Enter your `App ID` and `Secret Key`.
6. (Optional but Recommended) Enter a **Webhook Secret**. You will set this in the Cashfree Dashboard in the next step.
7. Click **Save Connection**.

## 3. Configure Cashfree Webhooks

Fype needs webhooks to receive real-time updates from Cashfree.

1. In the Cashfree Dashboard, navigate to **Payment Gateway** > **Developers** > **Webhooks**.
2. Click **+ Add New Webhook**.
3. **Webhook URL**: Set this to `https://api.fype.dev/v1/webhooks/cashfree`.
4. **Webhook Secret**: Enter a strong, unique string. **This must match the Webhook Secret you provided in the Fype Dashboard.**
5. **Events**: Subscribe to the following events:

* `PAYMENT_SUCCESS_WEBHOOK`
* `PAYMENT_FAILED_WEBHOOK`
* `PAYMENT_USER_DROPPED_WEBHOOK`
* `REFUND_STATUS_WEBHOOK`

6. Click **Save**.

## 4. Verification

1. **Test Transaction**: Create a payment using your Fype Test API Key.
2. **Checkout**: Follow the `checkout_url`. Fype will load the Cashfree Web Checkout SDK.
3. **Status Sync**: Verify in the Fype Dashboard that the payment status transitions to `succeeded`.
4. **Webhook Delivery**: Confirm that your backend received the `payment.succeeded` event from Fype.

## Troubleshooting

### Signature Verification Failed

Cashfree signatures are sensitive to the raw request body. Ensure that the Webhook Secret in Fype matches the one in Cashfree exactly. If you are using a proxy or middleware that modifies the request body, signature verification will fail.

### Order Expired

Cashfree orders have a default expiry. If a customer stays on the checkout page too long without completing the payment, the order will expire. Fype handles this by marking the payment as `failed`.

### Refund Status Pending

Cashfree refunds may sometimes remain in `PENDING` state if the upstream bank is slow. Fype will update the refund status once it receives the `REFUND_STATUS_WEBHOOK` with a final state.
