Getting Started

Get started easily with Cashfree API by downloading the following collection and importing it in Postman.


  Download Postman Collection

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

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 (check API reference section).

Endpoints

URL Environment
https://test.cashfree.com/ TEST
https://api.cashfree.com/ PRODUCTION

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. You can use the drop-down to construct example code for other apps.

Response Format

The response format for all requests is a JSON object.

Whether a request succeeded 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, to create the order from sample code below:


  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&notifyUrl=https%3A%2F%2Fexample.com%2Fnotify&paymentModes=&pc='

..
   $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 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 below for a list of available currencies. Please 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

Currencies

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

Currency Code Description
INR Indian Rupee
USD US Dollar
CNY Chinese Yuan Renminbi
GBP Pound Sterling
AED UAE Dirham
AUD Australian Dollar
AZN Azerbaijanian Manat
BHD Bahraini Dinar
CAD Canadian Dollar
CHF Swiss Franc
DKK Danish Krone
EGP Egyptian Pound
EUR Euro
HKD Hong Kong Dollar
ILS New Israeli Sheqel
INR Indian Rupee
JOD Jordanian Dinar
JPY Japanese Yen
KRW Korean Won
KWD Kuwaiti Dinar
MYR Malaysian Ringgit
NOK Norwegian Krone
NZD New Zealand Dollar
OMR Rial Omani
QAR Qatari Rial
RUB Russian Ruble
SAR Saudi Riyal
SEK Swedish Krona
SGD Singapore Dollar
THB Thai Baht
ZAR South African Rand


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

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


  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'

..
    $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 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 --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'

..
    $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 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 creation of order

Get Status

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


  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'

..
    $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 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
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 (eg: 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.


paymentDetails 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 of time. For example, to get the order link sample code below:


  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'

..
    $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 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 of failure when status is ERROR

Transactions

Fetch Transactions

To fetch transactions processed on your CashFree Account. For example, to create the order from sample code below:


  curl --request POST \
  --url https://test.cashfree.com/api/v1/transactions \
  --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-11&txStatus=SUCCESS&lastId=&count='

..
    $curl = curl_init();

    curl_setopt_array($curl, array(
    CURLOPT_URL => "https://test.cashfree.com/api/v1/transactions",
    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-11&txStatus=SUCCESS&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;
    }   
..


Transactions 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)
txStatus No Filter the transactions as per the status. Valid status values are SUCCESS, FAILED, PENDING, FLAGGED and CANCELLED
lastId Yes Use it for paginated response. Transactions having id greater than this value will be returned
count Yes Number of transactions you want to receive. Default is 20 and max is 50.

Transactions 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
transactions An array of transactions (see table below)

Transactions Array

Parameter Description
id id of the entry
orderId merchant order id that is passed during payment request
orderAmount Order Amount
orderNote Order Note
customerName Customer Name
customerPhone Customer Phone
customerEmail Customer Email
referenceId Transaction Reference Id
txAmount Transaction Amount
txStatus Transaction Status
txTime Transaction Time
settlementStatus Settlement Status
refundStatus Refund Status

Refunds

Initiate Refund

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


  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'

..
    $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 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
merchantRefundId No A merchant generated unique key to identify this refund. Will be auto generated if left blank
refundType No INSTANT for instant refunds
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

Parameter Description
status Status of API call. Values are - OK and ERROR
message Message saying if the transaction was refunded or not.
reason reason of failure when status is ERROR

Fetch All Refunds

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


  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='

..
    $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 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.

Refund 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 --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'

..
    $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 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 needs to 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 precedence

Refund 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)

Settlements

Fetch All Settlements

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


  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='

..
$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;
}   
..


All Settlements 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. 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.

All Settlements 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 --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='

..
    $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 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.

Single Settlement 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 Total transactions amount
referenceId Amount after deducting the TDR
txAmount Any adjustments (because of refunds OR disputes)
paymentMode Amount settled after including the adjustments
bankName transaction included from this day
serviceCharge transactions included till this day
serviceTax Bank Reference number
settlementAmount Amount after deducting service charge and service tax from transaction amount
txTime Transaction Time