# Cashfree Payment Gateway Integration

### Overview

The Cashfree Payment Link Integration allows businesses using Rapidbott to collect customer payments securely through chatbot-based workflows. Payment links are generated via Cashfree’s Payment Link API and shared directly with customers on WhatsApp or web chat.

***

### Installing the Cashfree Payment Link Integration

The Cashfree Payment Link Integration is available as a **Mini App** inside the Rapidbott App Store and can be installed per workspace.

#### Prerequisites

Before installing, ensure the following:

* You have an active **Rapidbott workspace**
* You have a **Cashfree merchant account**
* Your Cashfree account has **Payment Link API access enabled**
* API credentials (Client ID and Client Secret) are available

***

#### Step-by-Step Installation

1. Log in to your **Rapidbott Dashboard**
2. Select the **workspace** where you want to enable payments
3. Navigate to **Mini Apps → App Store**
4. Search for **Cashfree Payment Link**
5. Click **Install**
6. You will be prompted to enter your **Cashfree API credentials**
   * Client ID
   * Client Secret
7. Save the configuration

Once installed, the integration becomes available across chatbot flows within the selected workspace.

***

#### Configuration After Installation

After successful installation:

* Set **default currency** (INR by default)
* Configure **webhook endpoint** for payment status updates
* Verify API connectivity using a test payment

These settings can be updated anytime from the **Mini Apps → Installed Apps** section.

***

#### Using the Integration in a Chatbot Flow

1. Open the **Flow Builder** for your workspace
2. Add a **Payment / Action node**
3. Select **Cashfree Payment Link** as the action
4. Map required fields:
   * Amount
   * Currency
   * Customer Name
   * Customer Email
   * Customer Phone
   * Description
5. Publish the flow

When the flow runs, a payment link is generated and shared automatically with the customer.

***

#### Workspace-Level Behavior

* Integration is **workspace-specific**
* Each workspace can use its own Cashfree account
* Multiple chatbots in the same workspace can reuse the integration
* Removing the Mini App disables payment creation for that workspace

***

### How It Works

1. Customer interacts with a Rapidbott chatbot.
2. Chatbot requests payment based on flow logic.
3. Rapidbott creates a payment link using Cashfree Payment Link API.
4. Payment link is sent to the customer.
5. Customer completes the payment on Cashfree’s hosted checkout page.
6. Cashfree sends payment status via webhook.
7. Rapidbott processes the status and triggers the next action.

***

### Supported Features

* One-time payment link generation
* Secure server-side Cashfree API integration
* Custom payment amount and description
* Customer details capture
* Payment expiry handling
* Webhook-based payment confirmation
* Payment success trigger inside chatbot flow

***

### Required Inputs

#### 1. Payment Amount

* Amount must be entered in the **smallest currency unit**.
* Examples (INR):
  * INR 10 → `1000`
  * INR 250 → `25000`

***

#### 2. Currency

* **Default currency is INR**
* If your Cashfree account has **international payments enabled**, you may select other currencies.

Supported example currencies:

* INR – Indian Rupee (default)
* USD – US Dollar
* EUR – Euro

Note: Currency availability depends on your **Cashfree account configuration**. If international payments are not enabled, only INR can be used.

***

#### 3. Customer Details

Providing accurate customer details improves payment success and traceability.

* Customer Name
* Customer Email
* Customer Phone Number

**Phone Number Format**

Enter a valid phone number.

* For India, enter a **10-digit mobile number**
* For international numbers, **include the country code with `+`**

Examples:

* India: `9876543210`
* International: `+14155552671`

***

#### 4. Payment Description

A short description explaining the payment purpose.

Example:\
`Payment for services via Rapidbott chatbot`

***

#### 5. Payment Expiry

* Payment links support expiry time.
* Expiry is dynamically calculated during link creation.
* Recommended expiry range: **5 to 59 minutes** for chatbot flows.

***

### Payment Success Trigger (Important)

Payment success is detected using **Cashfree webhooks**.

#### Trigger Condition

The payment is considered **successful** when Cashfree sends a webhook with status:

`SUCCESS`

#### What Happens After Success

Once payment success is confirmed:

* Rapidbott marks the payment as completed
* Chatbot flow automatically continues
* Success confirmation message is sent to the customer
* Admin or system actions can be triggered (order confirmation, service activation, etc.)

No manual verification is required.

***

### Payment Statuses Supported

* SUCCESS
* FAILED
* PENDING
* EXPIRED

Each status can be handled inside the chatbot flow based on business logic.

***

### Important Note – Production Error

#### Error Message

`link_creation is not enabled or approved. Please reach out to care@cashfree.com.`

#### Meaning

Payment Link API is **not enabled** for your Cashfree production account.

#### Action Required

* Contact Cashfree Support at `care@cashfree.com`
* Request **Payment Link API (PL API)** enablement
* Mention usage: *API-based payment link creation via Cashfree Payment Gateway*

Once enabled, no changes are needed on Rapidbott.

***

### Security & Compliance

* All Cashfree API calls are server-side
* API keys are securely stored
* Rapidbott does not store card or payment credentials
* Payments are processed entirely by Cashfree

***

### Intended Use Case (Cashfree Context)

This integration is used to collect genuine customer payments for services, bookings, and orders initiated via chatbot conversations. Rapidbott functions as a technology layer; Cashfree handles payment processing.

***

### Limitations

* One-time payments only
* Currency support depends on Cashfree account permissions
* Subscription payments are not supported yet

***

### Coming Soon

* Subscription and recurring payments
* Payment reminders
* Payment analytics
* Multi-currency enhancements
