Collect and Reconcile Payment

This section provides details on how to integrate with Auto Collect. It explains how to create a virtual account and receive payments from your customers.

4800

Auto Collect Integration Flow

Steps to Integrate

  1. Setup
  2. Initialization and Authorization
  3. Create Virtual Account
  4. Share Details with Customer for Payments
  5. Customer Makes Payment
  6. Get Notified Instantly for Successful Payments
  7. Receive Amount and Reconcile

Step 1: Setup

Get the Client Id and Client Secret key from your Auto Collect dashboard and ensure that your IP is whitelisted.

Host URL: Use the following URL for PROD and TEST, respectively:

Production Environment: https://cac-api.cashfree.com
Test Environment: https://cac-gamma.cashfree.com

Step 2: Initialization and Authorization

Call the authenticate API to Cashfree system/server to obtain an Authorization Bearer token. All other API calls must have this token as Authorization header in the format 'Bearer ' (without quotes) to get processed. Know more about the authorize API.

curl --location --request POST 'https://{Host URL}/cac/v1/authorize' \
--header 'X-Client-ID: client_id' \
--header 'X-Client-Secret: client_secret'
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://{Host URL}/cac/v1/authorize',
  'headers': {
    'X-Client-ID': 'client_id',
    'X-Client-Secret': 'client_secret'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
import requests

url = "https://{Host URL}/cac/v1/authorize"

payload = {}
headers = {
  'X-Client-ID': 'client_id',
  'X-Client-Secret': 'client_secret'
}

response = requests.request("POST", url, headers=headers, data = payload)

print(response.text.encode('utf8'))
Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("{Host URL}/cac/v1/authorize")
  .header("X-Client-ID", "client_id")
  .header("X-Client-Secret", "client_response")
  .asString();

Sample Response

{
    "status": "SUCCESS",
    "message": "Token generated",
    "subCode": "200",
    "data": {"token":"eyJ0eXA...fWStg", "expiry":1564130052}
}

Step 3: Create Virtual Account

Create a unique virtual bank account number or UPI ID for each customer to make the payment. Create a virtual account using the Create Virtual Account /VPA API.

Sample Code to Create a virtual Bank Account

curl --location --request POST 
'https://{Host URL}/cac/v1/createVA' \
--header 'Authorization: Bearer {Token}' \
--header 'Content-Type: application/json' \
--data-raw '
 {
	 "vAccountId":"VATEST1", 
	 "name":"john doe", 
	 "phone":"9876543210", 
	 "email":"[email protected]", 
	 "remitterAccount":"007711300000000", 
	 "remitterIfsc":"Bank0000001"
 }

Sample Code to Create a Virtual UPI ID

curl --location --request POST 
'https://{Host URL}/cac/v1/createVA' \
--header 'Authorization: Bearer {Token}' \
--header 'Content-Type: application/json' \
--data-raw '
{
	"virtualVpaId":"VATEST1", 
	"name":"john doe", 
	"phone":"9876543210", 
	"email":"[email protected]", 
	"remitterAccount":"007711300000000", 
	"remitterIfsc":"Bank0000001"
} '

Step 4: Share Details with Customer for Payments

Share the virtual bank account details or virtual UPI ID with the customers. Customers can make payment through NEFT, RTGS, IMPS, UPI ID, or other UPI applications.

Step 5: Customer Makes Payment

Customers will make the payment to the virtual bank account that you have shared. Payment can be made through bank transfer or UPI payment method.

Step 6: Get Notified Instantly for Successful Payments

You get notified instantly on your phone and email when customers make the payment. Ensure you have enabled the notification preferences and added your phone number and email to receive the notifications.
The AMOUNT_COLLECTED webhook also notifies you when your customers make the payment. Ensure you have configured webhooks for your account.

Sample Response

Transfer to Virtual Bank Account

{
 "event": "AMOUNT_COLLECTED",
 "amount": 3021,
 "vAccountId": "1234",
 "vAccountNumber": "808080101234",
 "email": "[email protected]",
 "phone": "9876543210",
 "referenceId": 7606233,
 "utr": "0212345321344",
 "creditRefNo": "0976541123",
 "remitterAccount": "123455666778",
 "remitterIfsc": "UTIB0000870",
 "remarks": "UPI",
 "remitterName": "Cashfree payments",
 "paymentTime": "2020-09-10 12:06:16",
 "signature": "fOFgW9+4lpj+VNBuDxQ2TKk1syDXZmqeMZRbaJc87Bk="
}

Transfer to Virtual UPI ID

{
    "event":"AMOUNT_COLLECTED",
    "amount":"400",
    "vAccountId":"abcd123",
    "virtualVpaId":"cashmelgabcd123@yesbankltd",
    "isVpa":"1",
    "email":"[email protected]",
    "phone":"9876543210",
    "referenceId":87654,
    "utr":"N123456789",
    "creditRefNo":"0976541123",
    "remitterAccount":"123455666778",
    "remitterName":"CASHFREE PAYMENTS",
    "paymentTime":"2019-07-20 15:27:37",
    "signature":"8uV792gBZaasJHBFSsfaMHLuqnZKkoBFjw9gEJ8Sx85V+jgbpg4ME="
 }

Step 7: Receive Amount and Reconcile

Cashfree settles the amount to your account as per agreed settlement cycles.

  • For payments through virtual bank accounts, the settlements are made at 9 AM, 12 PM, 3 PM, and 6 PM on all bank working days.
  • For payments through Virtual UPI, the settlements are made at 6 PM on all bank working days.

AMOUNT_SETTLED webhook notifies you when the payment is settled to your bank account.

Sample Response

{
  "event":"AMOUNT_SETTLED",
  "amount":"25000",
  "count":"10",
  "utr":"N123456789"
  "settlementId":"256"
  "signature":"8uV792gBZaasJHBFSsfaMHLuqnZKkoBFjw9gEJ8Sx85V+jgbpg4ME="
}