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

# Embedded Payment Gateway Integration

Cashfree Payment Gateway accepts domestic and international payments, and supports a wide range of payment options. Integrate Embedded Payment Gateway to easily enable your businesses to collect payments from their customers. Use our pre-built checkout integration, or customise the payment flow as per your requirements. You can also use our SDKs to easily integrate your mobile applications with our gateway. You can easily collect payments using popular Payment Methods like Cards, UPI, Netbanking, Wallets, PayPal, EMI, and Pay Later options.

<Info>
  You can build and try out the integration in the [sandbox environment](/partners/embedded/integration/gateway-sandbox-environment).
</Info>

## Partner API keys

To get started with Partner API requests, you must first generate partner API keys from your [Partner Dashboard](https://partner.cashfree.com/partner-ui/authentication/login).

1. Go to **Partner Dashboard** > **Developers** section.
2. In the **Developers** Section, click **Generate API Key**.

<img src="https://mintcdn.com/cashfreepayments-d00050e9/bwBycJEKDh22PKJR/static/partners/embedded/integration/partners-api.png?fit=max&auto=format&n=bwBycJEKDh22PKJR&q=85&s=f99749866849a96e61ad77d445d1bc53" alt="" width="1600" height="555" data-path="static/partners/embedded/integration/partners-api.png" />

<Frame>
  <img src="https://mintcdn.com/cashfreepayments-d00050e9/bwBycJEKDh22PKJR/static/partners/embedded/integration/partner-api-2.png?fit=max&auto=format&n=bwBycJEKDh22PKJR&q=85&s=cdfd8ec48ef467ff827a728742ca361b" width="500px" data-path="static/partners/embedded/integration/partner-api-2.png" />
</Frame>

3. Copy and download the API keys for all API requests and future reference.

## Payment gateway APIs

All the Payment Gateway APIs that you find in [this](/api-reference/payments/latest/overview) document can be used using partner authentication for your merchants.

### Partner authentication

To use Payment Gateway APIs for Partner Auth integration, **x-client-id** and **x-client-secret** headers will not be used anymore, please use the following headers:

* **x-partner-apikey**: This is the common API Key generated and unique for each Partner.
* **x-partner-merchantid**: This is the unique merchant ID for each merchant associated with the Partner. To know the merchant ID, go to **Partner Dashboard** > **Merchants** section, and copy the **Merchant ID** of the merchant you want to transact with.

### Payment gateway SDKs

We support the following SDK integrations:

| Integration types                                                |
| :--------------------------------------------------------------- |
| [JS Integration](/payments/online/element/overview)              |
| [Web Integration](/payments/online/web/redirect)                 |
| [Android Integration](/payments/online/mobile/android)           |
| [iOS Integration](/payments/online/mobile/ios)                   |
| [React Native Integration](/payments/online/mobile/react-native) |
| [Cordova Integration](/payments/online/mobile/cordova)           |
| [Flutter Integration](/payments/online/mobile/flutter)           |

## Partner webhooks

To configure partner webhook,

1. Go to **Partner Dashboard** > **Developers** > **Webhooks**.

<img src="https://mintcdn.com/cashfreepayments-d00050e9/bwBycJEKDh22PKJR/static/partners/embedded/integration/Screenshot_2023-12-22_at_10.20.38_AM.png?fit=max&auto=format&n=bwBycJEKDh22PKJR&q=85&s=c6c7baafa6988eac66693ad671a03b31" alt="" width="3436" height="1926" data-path="static/partners/embedded/integration/Screenshot_2023-12-22_at_10.20.38_AM.png" />

2. Click **Add Webhook URL** and enter the URL where you want to receive the updates.
3. Select the events for which you want to configure the webhooks to receive updates, and click **Add Webhook**.

<img src="https://mintcdn.com/cashfreepayments-d00050e9/bwBycJEKDh22PKJR/static/partners/embedded/integration/Screenshot_2023-12-22_at_10.31.17_AM.png?fit=max&auto=format&n=bwBycJEKDh22PKJR&q=85&s=5f546e8dc178cf14b6ee85222cd4fee9" alt="" width="3436" height="1926" data-path="static/partners/embedded/integration/Screenshot_2023-12-22_at_10.31.17_AM.png" />

4. Your webhook is now added successfully. You can also edit the added webhook using the edit option from the Webhook homepage.

Cashfree Payments sends notifications to your configured endpoint as a POST request with the body containing the various parameters specifying the details of each event. Each request contains an event parameter that identifies its type.

We support webhooks in both encoded and JSON formats.

### How to use Cashfree Payments webhooks?

### 1. Create an endpoint URL

To receive event notifications, you need to create an endpoint in your server that can accept requests from Cashfree Payments. The endpoint URL can be HTTP in your local machine for testing purposes while developing. However, it should be HTTPS for the production environment.\
You receive webhook event notifications on the specified URLs. You can use one URL to handle different event types at once or specify individual URLs for specific events.

### 2. Select events to subscribe

You can configure webhooks to receive notifications for the following events:

* [Payment Success](/api-reference/payments/latest/payments/webhooks#payment-success-webhook)
* [User Dropped](/api-reference/payments/latest/payments/webhooks#payment-user-dropped-webhook)
* [Payment Failed](/api-reference/payments/latest/payments/webhooks#payment-failed-webhook)
* [Refunds](/api-reference/payments/latest/refunds/webhooks#refund-webhooks)
* [Settlement Webhooks](/payments/split/webhooks#settlement-webhook)

<Info>
  An additional object **merchant** is sent in partner webhook payload to
  identify the merchants.
</Info>

```json json theme={"dark"}
{
"merchant": {
"merchant_id": {{merchant identifier}}
},
"data": {
...
},
"event_time": ...,
"type": ...
}
```

### 3. Test webhooks

Test your webhooks in the sandbox environment before going live to check payloads and integration. Configuring your webhooks, from the dashboard, in the test environment and events triggered in test transactions will send webhooks to the configured endpoint.

You can create endpoint URLs and test webhooks using tools like [webhook.site](https://webhook.site) or create a tunnel to your localhost using tools like [ngrok](https://ngrok.com).

### 4. Verify webhooks

It's a best practice to verify webhooks so that your server isn't manipulated by other requests acting as Cashfree webhooks. Use webhook signatures to verify Cashfree Payments webhooks and perform further actions only after verifying the webhook.

#### Webhook signature

Use the signature to verify if the request hasn't been tampered with. To verify the signature at your end, you need your Cashfree Payment Gateway secret key along with the payload.

* The timestamp is present in the header `x-webhook-timestamp`.
* The actual signature is present in the header `x-webhook-signature`.

The signature creation logic is as below:

```text Signature theme={"dark"}
timestamp := 1617695238078;
signedPayload := $timestamp.$payload;
expectedSignature := Base64Encode(HMACSHA256($signedPayload, $partnerApiKey));
```

For sample codes, see [Manual Verification](/payments/online/webhooks/overview#manual-verification-custom-approach).

<Note>
  Use **\$partnerApiKey** instead of **\$merchantSecretKey** to verify the webhooks.
</Note>

<Info>
  Sometimes you may receive the same webhook more than once. It's recommended to ensure that your implementation of the webhook is idempotent. Also, your endpoint should return a 2xx response for a successful webhook delivery from our end. Please ensure the response is quick before performing other logic, which could cause a timeout.
</Info>

<div class="hidden" data-table-of-contents="bottom">
  <p class="mt-4 font-medium flex items-center gap-2 related-docs-heading">
    <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" class="w-4 h-4">
      <path d="M3 4h7a2 2 0 0 1 2 2v13a2 2 0 0 0-2-2H3z" />

      <path d="M21 4h-7a2 2 0 0 0-2 2v13a2 2 0 0 1 2-2h7z" />
    </svg>

    <span>Related Topics</span>
  </p>

  <ul>
    <li><a href="/docs/api-reference/payments/latest/overview">Payment Gateway API Overview</a></li>
    <li><a href="/docs/payments/online/element/overview">JS Integration</a></li>
    <li><a href="/docs/api-reference/payments/latest/payments/webhooks">Payment Webhooks</a></li>
    <li><a href="https://partner.cashfree.com/auth/login">Partner Dashboard </a></li>
  </ul>
</div>
