Payment Gateway API

CashFree uses API keys to allow access to the API. Once you have signed up at our merchant site, you will be able to see your AppId and SecretKey.

CashFree expects API key to be included in all API requests to the server. Use the endpoint /api/v1/credentials/verify to verify your credentials.

End Points

Environment

URL

Test

https://test.cashfree.com/

Production

https://api.cashfree.com/

Postman Collection

Get started quickly with Cashfree Payment Gateway APIs by downloading the following collection and importing it in Postman.

Quick Reference

Order API

URL

HTTP Verb

Functionality

/api/v1/order/create

POST

To create orders

/api/v1/order/info/link

POST

Returns payment link for an existing order

/api/v1/order/info/status

POST

Returns payment status of an existing order

/api/v1/order/email

POST

Sends Email with payment link to the customer’s mailbox

/api/v1/order/refund

POST

Can do partial/full refund of the payment made for the order

Transactions API

URL

HTTP Verb

Functionality

/api/v1/transactions

POST

List the transactions

Refunds API

URL

HTTP Verb

Functionality

/api/v1/refunds

POST

List the refunds

Settlements API

URL

HTTP Verb

Functionality

/api/v1/settlements

POST

Fetch settlements processed on your CashFree Account

/api/v1/settlement

POST

Fetch transactions that are part of a settlement

Credentials Verify API

URL

HTTP Verb

Functionality

/api/v1/credentials/verify

POST

Verifying Credentials

Request Format

For POST requests, Content-Type header should be set to application/x-www-form-urlencoded.

Authentication is done via parameters. The appId parameter identifies which merchant account you are accessing, and the secretKey parameter authenticates the endpoint.

In the examples that follow, the keys for your app are included in the command.

Response Format

The response format for all requests is a JSON object.

The request being a success or not is indicated by the HTTP status code. A 2xx status code indicates success, whereas a 4xx status code indicates failure. When a request fails, the response body is still JSON, but always contains the fields status and reason (only if status is an error) which you can inspect to use for debugging. For example, trying to save an object with invalid keys will return the message:

{
"status": "ERROR",
"error": "An order with the same id exists."
}

Orders

Create Orders

To create a new order on Cashfree, send a POST request to the class URL containing the contents of the order. For example, order creation sample code is available below:

Curl
PHP
Curl
curl -X POST \
https://test.cashfree.com/api/v1/order/create \
-H 'cache-control: no-cache' \
-H 'content-type: application/x-www-form-urlencoded' \
-d 'appId=${APPLICATION_ID}&secretKey=${SECRET_KEY}&orderId=xBasilxTestx1&orderAmount=154&orderNote=Subscription&customerName=Test%20Name&customerPhone=9111122222&customerEmail=basil%40cashfree.com&sellerPhone=&returnUrl=https%3A%2F%2Fexample.com%2Freturn¬ifyUrl=https%3A%2F%2Fexample.com%2Fnotify&paymentModes=&pc='
PHP
..
$apiEndpoint = "https://test.cashfree.com";
$opUrl = $apiEndpoint."/api/v1/order/create";
$cf_request = array();
$cf_request["appId"] = "${APPLICATION_ID}";
$cf_request["secretKey"] = "${SECRET_KEY}";
$cf_request["orderId"] = "ORDER-104";
$cf_request["orderAmount"] = 100;
$cf_request["orderNote"] = "Subscription";
$cf_request["customerPhone"] = "9000012345";
$cf_request["customerName"] = "Test Name";
$cf_request["customerEmail"] = "test@cashfree.com";
$cf_request["returnUrl"] = "RETURNURL";
$cf_request["notifyUrl"] = "NOTIFYURL";
$timeout = 10;
$request_string = "";
foreach($cf_request as $key=>$value) {
$request_string .= $key.'='.rawurlencode($value).'&';
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"$opUrl?");
curl_setopt($ch,CURLOPT_POST, count($cf_request));
curl_setopt($ch,CURLOPT_POSTFIELDS, $request_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
$curl_result=curl_exec ($ch);
curl_close ($ch);
$jsonResponse = json_decode($curl_result);
if ($jsonResponse->{'status'} == "OK") {
$paymentLink = $jsonResponse->{"paymentLink"};
//Send this payment link to customer over email/SMS OR redirect to this link on browser
} else {
//Log request, $jsonResponse["reason"]
}
..

Request and Response Parameters

Request Parameters
Response Parameters
Request Parameters

Parameter

Required

Description

appId

Yes

Your app id

secretKey

Yes

Your Secret Key

orderId

Yes

Order/Invoice Id

orderAmount

Yes

Bill amount of the order

orderCurrency

No

Currency for the order. INR if left empty. See the Currency Codes here. Contact care@cashfree.com to enable new currencies.

orderNote

No

A help text to make customers know more about the order

customerName

Yes

Name of the customer

customerPhone

Yes

Phone number of customer

customerEmail

Yes

Email ID of the customer

sellerPhone

No

Notification phone number, which will get notified when payment for the order succeeds. Use it to accept COD payments

returnUrl

Yes

Return URL to which user will be redirected after the payment (max-len 500)

notifyUrl

No

Notification URL for server-server communication. Useful when user’s connection drops while re-directing (max-len 500) notifyUrl should be an https URL

paymentModes

No

Allowed payment modes for this order. Available values: cc, dc, nb, upi, paypal, wallet.

pc

No

Partner Code

Response Parameters

Parameter

Description

status

Status of API call. Values are OK and ERROR

paymentLink

Link of payment page for that order. Returned when status is OK

reason

Reason for failure when status is an ERROR

Currencies

Use the currency code values available here for the orderCurrency variable in the parameters for order creation. Only INR is available by default. Contact care@cashfree.com to enable new currencies.

Returns payment link for an existing order. Further, you can send it the customer via email or sms. For example, get order link sample code is available below:

CURL
PHP
CURL
curl -X POST \
https://test.cashfree.com/api/v1/order/info/link \
-H 'cache-control: no-cache' \
-H 'content-type: application/x-www-form-urlencoded' \
-d 'appId=${APPLICATION_ID}&secretKey=${SECRET_KEY}&orderId=Testx1'
PHP
..
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://test.cashfree.com/api/v1/order/info/link",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "appId=${APPLICATION_ID}&secretKey=${SECRET_KEY}&orderId=Testx1",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
..

Request and Response Parameters

Request Parameters
Response Parameters
Request Parameters

Parameter

Required

Description

appId

Yes

Your app Id

secretKey

Yes

Your Secret Key

orderId

Yes

Order/Invoice Id

Response Parameters

Parameter

Description

status

Status of API call. Values are OK and ERROR

paymentLink

Link of payment page for that order. Returned when status is OK

reason

Reason of failure when status is ERROR

Get Details

Returns all the details for an order. Check the “Get Status” section for payment status:

CURL
PHP
CURL
curl --request POST \
--url https://test.cashfree.com/api/v1/order/info/ \
--header 'cache-control: no-cache' \
--header 'content-type: application/x-www-form-urlencoded' \
--data 'appId=${APPLICATION_ID}&secretKey=${SECRET_KEY}&orderId=Testx1'
PHP
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://test.cashfree.com/api/v1/order/info/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "appId=${APPLICATION_ID}&secretKey=${SECRET_KEY}&orderId=Testx1",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
..

Request and Response Parameters

Request Parameters
Response Parameters
Request Parameters

Parameter

Required

Description

appId

Yes

Your app id

secretKey

Yes

Your Secret Key

orderId

Yes

Order/Invoice Id

Response Parameters

Parameter

Description

status

Status of API call. Values are - OK and ERROR

details.orderId

Merchant generated order Id for the order

details.orderAmount

Total Amount to be paid for this order

details.orderNote

A brief associated with order

details.customerName

Name of the payee

details.customerPhone

Phone number of the payee

details.orderStatus

The status of the order payment. Either “ACTIVE” or “PAID”

details.addedOn

The time of order creation

Get Status

Returns payment status of an existing order. This can also be used to query order status at any point in time. For example, to get the order link sample code is available below:

CURL
PHP
CURL
curl --request POST \
--url https://test.cashfree.com/api/v1/order/info/status \
--header 'cache-control: no-cache' \
--header 'content-type: application/x-www-form-urlencoded' \
--data 'appId=${APPLICATION_ID}&secretKey=${SECRET_KEY}&orderId=Testx1'
PHP
..
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://test.cashfree.com/api/v1/order/info/status",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "appId=${APPLICATION_ID}&secretKey=${SECRET_KEY}&orderId=Testx1",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
..

Request and Response Parameters

Request Parameters
Response Parameters
Request Parameters

Parameter

Required

Description

appId

Yes

Your app id

secretKey

Yes

Your Secret Key

orderId

Yes

Order/Invoice Id

Response Parameters

Parameter

Description

status

Status of API call. Values are - OK and ERROR

paymentLink

Link of payment page for that order. Returned when status is OK

reason

Reason for failure when status is ERROR

txStatus

Transaction status, if a payment has been attempted

txTime

Transaction time, if payment has been attempted

txMsg

Transaction message, if payment has been attempted

referenceId

Transaction reference ID, if payment has been attempted

paymentMode

Payment mode of transaction, if payment has been attempted

orderCurrency

Currency of the order

paymentDetails.paymentMode

Payment mode of transaction, if payment has been attempted

paymentDetails.bankName

Name of the bank if payment has been attempted (only in case of Netbanking)

paymentDetails.cardNumber

Masked card number if payment has been attempted (only in case of Debit & Credit Cards)

paymentDetails.cardCountry

Country code of the card if payment has been attempted (only in case of Debit & Credit Cards)

paymentDetails.cardScheme

Scheme of the card (Example: VISA) if payment has been attempted (only in case of Debit & Credit Cards)

Status Response

  • No payments attempted against an order :

{
"orderStatus": "ACTIVE",
"status": "OK"
}
  • Unsuccessful payment attempt against an order:

txStatus would be CANCELLED in the below response if a user lands on the payment page and clicks on 'back to merchant' instead of selecting a payment mode and proceeding with the transaction.

Payment details are only available for Netbanking and Credit/Debit Cards in the below response.

{
"orderStatus": "ACTIVE",
"txStatus": "PENDING",
"txTime": "2018-03-29 15:33:42",
"txMsg": null,
"referenceId": "2610",
"paymentMode": "NET_BANKING",
"orderCurrency": "INR",
"paymentDetails": {
"paymentMode": "NET_BANKING",
"bankName": "Yes Bank Ltd"
},
"status": "OK"
}
  • Succesful payment made against an order:

{
"orderStatus": "PAID",
"txStatus": "SUCCESS",
"txTime": "2017-05-08 20:35:11",
"txMsg": "transaction successful",
"referenceId": "2602",
"paymentMode": "AIRTEL_MONEY",
"orderCurrency": "INR",
"status": "OK"
}
  • Order status when a transaction gets FLAGGED and then goes to SUCCESS/CANCELLED.

{
"orderStatus": "PROCESSED",
"txStatus": "FLAGGED", // This will get updated based on whether transaction was approved (SUCCESS) or rejected (CANCELLED)
"txTime": "2017-05-08 20:35:11",
"txMsg": "Transaction successful",
"referenceId": "2603",
"paymentMode": "CREDIT_CARD",
"orderCurrency": "INR",
"paymentDetails": {
"paymentMode": "CREDIT_CARD",
"cardNumber": "3400XXXXX0009",
"cardCountry": "IN",
"cardScheme": "AMEX"
},
"status": "OK"
}

Trigger Payment Email

Returns payment status of an existing order. This can also be used to query order status at any point in time. For example, to get the order link sample code below:

CURL
PHP
CURL
curl --request POST \
--url https://test.cashfree.com/api/v1/order/email \
--header 'cache-control: no-cache' \
--header 'content-type: application/x-www-form-urlencoded' \
--data 'appId=${APPLICATION_ID}&secretKey=${SECRET_KEY}&orderId=Testx1'
PHP
..
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://test.cashfree.com/api/v1/order/email",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "appId=${APPLICATION_ID}&secretKey=${SECRET_KEY}&orderId=Testx1",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/x-www-form-urlencoded",
"postman-token: 5b4a0cff-1e77-115e-c7be-a46387687913"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
..

Request and Response Parameters

Request Parameters
Response Parameters
Request Parameters

Parameter

Required

Description

appId

Yes

Your app id

secretKey

Yes

Your Secret Key

orderId

Yes

Order/Invoice Id

Response Parameters

Parameter

Description

status

Status of API call. Values are - OK and ERROR.

message

Message saying if the email was delivered or not.

reason

Reason for failure when the status is ERROR.

Refunds

Initiate Refund

Returns payment status of an existing order. This can also be used to query order status at any point in time. For example, to get the order link sample code below:

CURL
PHP
CURL
curl --request POST \
--url https://test.cashfree.com/api/v1/order/refund \
--header 'cache-control: no-cache' \
--header 'content-type: application/x-www-form-urlencoded' \
--data 'appId=${APPLICATION_ID}&secretKey=${SECRET_KEY}&orderId=Testx1&referenceId=13307&refundAmount=102.00&refundNote=Sample%20Refund%20note'
PHP
..
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://test.cashfree.com/api/v1/order/refund",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "appId=${APPLICATION_ID}&secretKey=${SECRET_KEY}&orderId=Testx1&referenceId=13307&refundAmount=102.00&refundNote=Sample%20Refund%20note",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
..

Request and Response Parameters

Request Parameters
Response Parameters
Request Parameters

Parameter

Required

Description

appId

Yes

Your app id

secretKey

Yes

Your Secret Key

referenceId

Yes

CashFree reference ID

refundAmount

Yes

Amount to be refunded. Should be lesser than or equal to the transaction amount.

refundNote

Yes

A refund note for your reference

refundType

No

INSTANT for instant refunds

merchantRefundId

No

A merchant generated unique key to identify this refund. Required if refundType is INSTANT.

accountNo

No

Account number to transfer refund amount. Required if mode of transfer is BANK_TRANSFER

ifsc

No

IFSC code. Required if mode of transfer is BANK_TRANSFER

Response Parameters

Parameter

Description

status

Status of API call. Values are - OK and ERROR

message

Message saying if the transaction was refunded or not.

reason

Reason for failure when status is ERROR

Fetch All Refunds

To fetch refunds processed on your CashFree Account. For example, see sample code below:

CURL
PHP
CURL
curl --request POST \
--url https://test.cashfree.com/api/v1/refunds \
--header 'cache-control: no-cache' \
--header 'content-type: application/x-www-form-urlencoded' \
--data 'appId=${APPLICATION_ID}&secretKey=${SECRET_KEY}&startDate=2018-01-01&endDate=2018-01-15&lastId=&count='
PHP
..
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://test.cashfree.com/api/v1/refunds",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "appId=${APPLICATION_ID}&secretKey=${SECRET_KEY}&startDate=2018-01-01&endDate=2018-01-15&lastId=&count=",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
..

Refund Request and Response Parameters

Request Parameters
Response Parameters
Request Parameters

Parameter

Required

Description

appId

Yes

Your app id

secretKey

Yes

Your Secret Key

startDate

Yes

Date(in the format of YYYY-MM-DD), from which you want the data.

endDate

Yes

Date till you want the data (this date is included).

lastId

No

Use it for paginated response. Refunds having id greater than this value will be returned

count

No

Number of refunds you want to receive. Default is 20 and max is 50.

Response Parameters

Parameter

Description

status

Status of API call. Values are - OK and ERROR

settlements

List of transaction

message

Response message (will have the reason when status is sent as ERROR)

lastId

ID of the last transaction returned. Use it in your next request if current one didn’t return all the transactions.

refund

The details of the refund (see table below).

Refund Array

Parameter

Description

refundId

Id of the refund

orderId

merchant order id that is passed during payment request

arn

Acquirer Reference number that was generated for this refund

referenceId

Cashfree reference id of the transaction

txAmount

Transaction Amount

refundAmount

Amount supposed to be refunded

refundNote

Note provided during refund initiation

processed

Refund processing status (Values will be YES or NO)

initiatedOn

DateTime of refund initiation

processedOn

DateTime of refund processing (Will be blank for unprocessed ones)

Fetch Single Refund

To fetch refunds processed on your CashFree Account. For example, see sample code below:

CURL
PHP
CURL
curl --request POST \
--url https://test.cashfree.com/api/v1/refundStatus/ \
--header 'cache-control: no-cache' \
--header 'content-type: application/x-www-form-urlencoded' \
--data 'appId=${APPLICATION_ID}&secretKey=${SECRET_KEY}&refundId=123'
PHP
..
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://test.cashfree.com/api/v1/refundStatus/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "appId=${APPLICATION_ID}&secretKey=${SECRET_KEY}&refundId=123",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
..

Refund Request and Response Parameters

Request Parameters
Response Parameters
Request Parameters

Parameter

Required

Description

appId

Yes

Your app id

secretKey

Yes

Your Secret Key

refundId

No

Refund Id of the refund you want to fetch. This parameter or merchantRefundId must be provided in the request.

merchantRefundId

No

Merchant generated id, merchantRefundId corresponding to the refund the details of which you want to fetch. This parameter or refundId needs to be provided in the request. If both are provided then refundId will have precedenc

Response Parameters

Parameter

Description

status

Status of API call. Values are - OK and ERROR

message

response message (will have the reason when status is sent as ERROR)

refund

The details of the refund (see table below)

Refund Array

Parameter

Description

refundId

Id of the refund

orderId

merchant order id that is passed during payment request

arn

Acquirer Reference number that was generated for this refund

referenceId

Cashfree reference id of the transaction

txAmount

Transaction Amount

refundAmount

Amount supposed to be refunded

refundNote

Note provided during refund initiation

processed

Refund processing status (Values will be YES or NO)

initiatedOn

DateTime of refund initiation

processedOn

DateTime of refund processing (Will be blank for unprocessed ones)

Instant Refunds

You can process instant refunds to your customers account using our APIs.

Request and Response Parameters

Request Parameters
Response Parameters
Request Parameters

Parameter

Required

Description

appId

Yes

Your app id

secretKey

Yes

Your Secret Key

referenceId

Yes

CashFree reference Id

refundAmount

Yes

Amount to be refunded. Should be lesser than equal to transaction amount

refundNote

Yes

A refund note for your reference

refundType

Yes

INSTANT for instant refunds

merchantRefundId

No

A merchant generated unique key to identify this refund. Required if refundType is INSTANT.

mode

No

Required for INSTANT refund and only if payment mode was netbanking. Can be BANK_TRANSFER or CASHGRAM. In case of other payment modes, refund will be made to source.

accountNo

No

Account number to transfer refund amount. Required if mode is BANK_TRANSFER.

ifsc

No

IFSC code. Required if mode is BANK_TRANSFER.

Response Parameters

Response Parameters

Parameter

Description

status

Status of API call. Values are - OK and ERROR

message

Message saying if the transaction was refunded or not.

reason

Reason for failure when status is ERROR

Settlements

Fetch All Settlements

To fetch all settlements processed on your CashFree Account. For example, see sample code below:

CURL
PHP
CURL
curl --request POST \
--url https://test.cashfree.com/api/v1/settlements \
--header 'cache-control: no-cache' \
--header 'content-type: application/x-www-form-urlencoded' \
--data 'appId=${APPLICATION_ID}&secretKey=${SECRET_KEY}&startDate=2018-01-01&endDate=2018-01-15&lastId=&count='
PHP
..
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://test.cashfree.com/api/v1/settlements",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "appId=${APPLICATION_ID}&secretKey=${SECRET_KEY}&startDate=2018-01-01&endDate=2018-01-15&lastId=&count=",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/x-www-form-urlencoded",
"postman-token: 20dbc7f5-dbb9-58d3-bc0a-afdcba7a60be"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
..

Request and Response Parameters

Request Parameters
Response Parameters
Request Parameters

Parameter

Required

Description

appId

Yes

Your app id

secretKey

Yes

Your Secret Key

startDate

Yes

Date(in the format of YYYY-MM-DD), from which you want the data

endDate

Yes

Date till you want the data (this date is included)

lastId

No

Use it for a paginated response. Settlements having id greater than this value will be returned

count

No

Number of settlements you want to receive. Default is 20 and max is 50.

Response Parameters

Parameter

Description

status

Status of API call. Values are - OK and ERROR

settlements

List of settlements

message

Response message (will have the reason when status is sent as ERROR)

lastId

ID of the last transaction returned. Use it in your next request if current one didn’t return all the transactions

Settlement Array

Parameter

Description

id

Settlement Id (use it to fetch transactions that are part of this settlement)

totalTxAmount

Total transactions amount

settlementAmount

Amount after deducting the TDR

adjustment

Any adjustments (because of refunds OR disputes)

amountSettled

Amount settled after including the adjustments

transactionFrom

Transaction included from this day

transactionTill

Transactions included till this day

utr

Bank Reference number

settledOn

Time of settlement (this could be different than credit date shown on the account statement)

Fetch Single Settlement

To fetch transactions that are part of a settlement. For example, see sample code below:

CURL
PHP
CURL
curl --request POST \
--url https://test.cashfree.com/api/v1/settlement \
--header 'cache-control: no-cache' \
--header 'content-type: application/x-www-form-urlencoded' \
--data 'appId=${APPLICATION_ID}&secretKey=${SECRET_KEY}&settlementId=123456&lastId=&count='
PHP
..
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://test.cashfree.com/api/v1/</span>settlement",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "appId=${APPLICATION_ID}&secretKey=${SECRET_KEY}&settlementId=123456&lastId=&count=",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache",
"content-type: application/x-www-form-urlencoded"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
..

Single Settlement Request and Response Parameters

Request Parameters
Response Parameters
Request Parameters

Parameter

Required

Description

appId

Yes

Your app id

secretKey

Yes

Your Secret Key

settlementId

Yes

ID of the settlement

lastId

No

Use it for paginated response. Transactions having id greater than this value will be returned

count

No

Number of transactions you want to receive. Default is 20 and max is 50.

Response Parameters

Parameter

Description

status

Status of API call. Values are - OK and ERROR

transactions

List of transactions

message

response message (will have the reason when status is sent as ERROR)

lastId

ID of the last transaction returned. Use it in your next request if current one didn’t return all the transactions

Transaction Array

Parameter

Description

id

Settlement Id (use it to fetch transactions that are part of this settlement)

orderId

Merchant order id that is passed during payment request

referenceId

Cashfree reference id of the transaction

txAmount

Transaction Amount

paymentMode

Payment mode of transaction, if payment has been attempted

bankName

Name of the bank if payment has been attempted (only in case of Netbanking)

serviceCharge

Cashfree Service Charge

serviceTax

Payable Service Tax levied on Service Charge

settlementAmount

Amount after deducting service charge and service tax from transaction amount

txTime

Transaction Time