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.
Environment | URL |
Test | https://test.cashfree.com/ |
Production | https://api.cashfree.com/ |
Get started quickly with Cashfree Payment Gateway APIs by downloading the following collection and importing it in Postman.
URL | HTTP Verb | Functionality |
POST | To create payment link | |
POST | Returns payment link for an existing order | |
POST | Returns payment status of an existing order | |
POST | Sends Email with payment link to the customer’s mailbox | |
POST | Can do partial/full refund of the payment made for the order |
URL | HTTP Verb | Functionality |
POST | List all the refunds | |
POST | List specific refund |
URL | HTTP Verb | Functionality |
POST | Fetch settlements processed on your Cashfree Account | |
POST | Fetch transactions that are part of a settlement |
URL | HTTP Verb | Functionality |
/api/v1/credentials/verify | POST | Verifying Credentials |
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.
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."}
To create a new order (payment link) 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 --location -g --request POST '{{Base URL}}/api/v1/order/create' \--form 'appId="{{appId}}"' \--form 'secretKey="{{secretKey}}"' \--form 'orderId="order_00112"' \--form 'orderAmount="1"' \--form 'orderCurrency="INR"' \--form 'orderNote="Test order"' \--form 'customerEmail="[email protected]"' \--form 'customerName="Cashfree User"' \--form 'customerPhone="9999999999"' \--form 'returnUrl="http://localhost/handleResponse.php"' \--form 'notifyUrl="http://localhost/handlePaymentStatus.php"'
<?php$curl = curl_init();curl_setopt_array($curl, array(CURLOPT_URL => '%7B%7BBase%20URL%7D%7D/api/v1/order/create',CURLOPT_RETURNTRANSFER => true,CURLOPT_ENCODING => '',CURLOPT_MAXREDIRS => 10,CURLOPT_TIMEOUT => 0,CURLOPT_FOLLOWLOCATION => true,CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,CURLOPT_CUSTOMREQUEST => 'POST',CURLOPT_POSTFIELDS => array('appId' => '{{appId}}','secretKey' => '{{secretKey}}','orderId' => 'order_00112','orderAmount' => '1','orderCurrency' => 'INR','orderNote' => 'Test order','customerEmail' => '[email protected]','customerName' => 'Cashfree User','customerPhone' => '9999999999','returnUrl' => 'http://localhost/handleResponse.php','notifyUrl' => 'http://localhost/handlePaymentStatus.php'),));$response = curl_exec($curl);curl_close($curl);echo $response;
import java.io.*;import okhttp3.*;public class main {public static void main(String []args) throws IOException{OkHttpClient client = new OkHttpClient().newBuilder().build();MediaType mediaType = MediaType.parse("text/plain");RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("appId", "{{appId}}").addFormDataPart("secretKey", "{{secretKey}}").addFormDataPart("orderId", "order_00112").addFormDataPart("orderAmount", "1").addFormDataPart("orderCurrency", "INR").addFormDataPart("orderNote", "Test order").addFormDataPart("customerEmail", "[email protected]").addFormDataPart("customerName", "Cashfree User").addFormDataPart("customerPhone", "9999999999").addFormDataPart("returnUrl", "http://localhost/handleResponse.php").addFormDataPart("notifyUrl", "http://localhost/handlePaymentStatus.php").build();Request request = new Request.Builder().url("{{Base URL}}/api/v1/order/create").method("POST", body).build();Response response = client.newCall(request).execute();System.out.println(response.body().string());}}
package mainimport ("fmt""bytes""mime/multipart""net/http""io/ioutil")func main() {url := "{{Base URL}}/api/v1/order/create"method := "POST"payload := &bytes.Buffer{}writer := multipart.NewWriter(payload)_ = writer.WriteField("appId", "{{appId}}")_ = writer.WriteField("secretKey", "{{secretKey}}")_ = writer.WriteField("orderId", "order_00112")_ = writer.WriteField("orderAmount", "1")_ = writer.WriteField("orderCurrency", "INR")_ = writer.WriteField("orderNote", "Test order")_ = writer.WriteField("customerEmail", "[email protected]")_ = writer.WriteField("customerName", "Cashfree User")_ = writer.WriteField("customerPhone", "9999999999")_ = writer.WriteField("returnUrl", "http://localhost/handleResponse.php")_ = writer.WriteField("notifyUrl", "http://localhost/handlePaymentStatus.php")err := writer.Close()if err != nil {fmt.Println(err)return}client := &http.Client {}req, err := http.NewRequest(method, url, payload)if err != nil {fmt.Println(err)return}req.Header.Set("Content-Type", writer.FormDataContentType())res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := ioutil.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
import requestsurl = "{{Base URL}}/api/v1/order/create"payload={'appId': '{{appId}}','secretKey': '{{secretKey}}','orderId': 'order_00112','orderAmount': '1','orderCurrency': 'INR','orderNote': 'Test order','customerEmail': '[email protected]','customerName': 'Cashfree User','customerPhone': '9999999999','returnUrl': 'http://localhost/handleResponse.php','notifyUrl': 'http://localhost/handlePaymentStatus.php'}files=[]headers = {}response = requests.request("POST", url, headers=headers, data=payload, files=files)print(response.text)
using System;using RestSharp;namespace HelloWorldApplication {class HelloWorld {static void Main(string[] args) {var client = new RestClient("{{Base URL}}/api/v1/order/create");client.Timeout = -1;var request = new RestRequest(Method.POST);request.AlwaysMultipartFormData = true;request.AddParameter("appId", "{{appId}}");request.AddParameter("secretKey", "{{secretKey}}");request.AddParameter("orderId", "order_00112");request.AddParameter("orderAmount", "1");request.AddParameter("orderCurrency", "INR");request.AddParameter("orderNote", "Test order");request.AddParameter("customerEmail", "[email protected]");request.AddParameter("customerName", "Cashfree User");request.AddParameter("customerPhone", "9999999999");request.AddParameter("returnUrl", "http://localhost/handleResponse.php");request.AddParameter("notifyUrl", "http://localhost/handlePaymentStatus.php");IRestResponse response = client.Execute(request);Console.WriteLine(response.Content);}}}
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 [email protected] 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 |
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 |
Use the currency code values available here for the orderCurrency variable in the parameters for order creation. Only INR is available by default. Contact [email protected] 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 --location -g --request POST '{{Base URL}}/api/v1/order/info/link' \--form 'appId="{{appId}}"' \--form 'secretKey="{{secretKey}}"' \--form 'orderId="order_00112"'
<?php$curl = curl_init();curl_setopt_array($curl, array(CURLOPT_URL => '{{Base URL}}/api/v1/order/info/link',CURLOPT_RETURNTRANSFER => true,CURLOPT_ENCODING => '',CURLOPT_MAXREDIRS => 10,CURLOPT_TIMEOUT => 0,CURLOPT_FOLLOWLOCATION => true,CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,CURLOPT_CUSTOMREQUEST => 'POST',CURLOPT_POSTFIELDS => array('appId' => '{{appId}}','secretKey' => '{{secretKey}}','orderId' => 'order_00112'),));$response = curl_exec($curl);curl_close($curl);echo $response;
import java.io.*;import okhttp3.*;public class main {public static void main(String []args) throws IOException{OkHttpClient client = new OkHttpClient().newBuilder().build();MediaType mediaType = MediaType.parse("text/plain");RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("appId", "{{appId}}").addFormDataPart("secretKey", "{{secretKey}}").addFormDataPart("orderId", "order_00112").build();Request request = new Request.Builder().url("{{Base URL}}/api/v1/order/info/link").method("POST", body).build();Response response = client.newCall(request).execute();System.out.println(response.body().string());}}
package mainimport ("fmt""bytes""mime/multipart""net/http""io/ioutil")func main() {url := "{{Base URL}}/api/v1/order/info/link"method := "POST"payload := &bytes.Buffer{}writer := multipart.NewWriter(payload)_ = writer.WriteField("appId", "{{appId}}")_ = writer.WriteField("secretKey", "{{secretKey}}")_ = writer.WriteField("orderId", "order_00112")err := writer.Close()if err != nil {fmt.Println(err)return}client := &http.Client {}req, err := http.NewRequest(method, url, payload)if err != nil {fmt.Println(err)return}req.Header.Set("Content-Type", writer.FormDataContentType())res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := ioutil.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
import requestsurl = "{{Base URL}}/api/v1/order/info/link"payload={'appId': '{{appId}}','secretKey': '{{secretKey}}','orderId': 'order_00112'}files=[]headers = {}response = requests.request("POST", url, headers=headers, data=payload, files=files)print(response.text)
using System;using RestSharp;namespace HelloWorldApplication {class HelloWorld {static void Main(string[] args) {var client = new RestClient("{{Base URL}}/api/v1/order/info/link");client.Timeout = -1;var request = new RestRequest(Method.POST);request.AlwaysMultipartFormData = true;request.AddParameter("appId", "{{appId}}");request.AddParameter("secretKey", "{{secretKey}}");request.AddParameter("orderId", "order_00112");IRestResponse response = client.Execute(request);Console.WriteLine(response.Content);}}}
Parameter | Required | Description |
appId | Yes | Your app Id |
secretKey | Yes | Your Secret Key |
orderId | Yes | Order/Invoice Id |
Parameter | Description |
| Status of API call. Values are OK and ERROR |
| Link of payment page for that order. Returned when status is OK |
| Reason of failure when status is ERROR |
Returns all the details for an order.
curl --location -g --request POST '{{Base URL}}/api/v1/order/info' \--form 'appId="{{appId}}"' \--form 'secretKey="{{secretKey}}"' \--form 'orderId="order_00112"'
<?php$curl = curl_init();curl_setopt_array($curl, array(CURLOPT_URL => '{{Base URL}}/api/v1/order/info',CURLOPT_RETURNTRANSFER => true,CURLOPT_ENCODING => '',CURLOPT_MAXREDIRS => 10,CURLOPT_TIMEOUT => 0,CURLOPT_FOLLOWLOCATION => true,CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,CURLOPT_CUSTOMREQUEST => 'POST',CURLOPT_POSTFIELDS => array('appId' => '{{appId}}','secretKey' => '{{secretKey}}','orderId' => 'order_00112'),));$response = curl_exec($curl);curl_close($curl);echo $response;
import java.io.*;import okhttp3.*;public class main {public static void main(String []args) throws IOException{OkHttpClient client = new OkHttpClient().newBuilder().build();MediaType mediaType = MediaType.parse("text/plain");RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("appId", "{{appId}}").addFormDataPart("secretKey", "{{secretKey}}").addFormDataPart("orderId", "order_00112").build();Request request = new Request.Builder().url("{{Base URL}}/api/v1/order/info").method("POST", body).build();Response response = client.newCall(request).execute();System.out.println(response.body().string());}}
package mainimport ("fmt""bytes""mime/multipart""net/http""io/ioutil")func main() {url := "{{Base URL}}/api/v1/order/info"method := "POST"payload := &bytes.Buffer{}writer := multipart.NewWriter(payload)_ = writer.WriteField("appId", "{{appId}}")_ = writer.WriteField("secretKey", "{{secretKey}}")_ = writer.WriteField("orderId", "order_00112")err := writer.Close()if err != nil {fmt.Println(err)return}client := &http.Client {}req, err := http.NewRequest(method, url, payload)if err != nil {fmt.Println(err)return}req.Header.Set("Content-Type", writer.FormDataContentType())res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := ioutil.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
import requestsurl = "{{Base URL}}/api/v1/order/info"payload={'appId': '{{appId}}','secretKey': '{{secretKey}}','orderId': 'order_00112'}files=[]headers = {}response = requests.request("POST", url, headers=headers, data=payload, files=files)print(response.text)
using System;using RestSharp;namespace HelloWorldApplication {class HelloWorld {static void Main(string[] args) {var client = new RestClient("{{Base URL}}/api/v1/order/info");client.Timeout = -1;var request = new RestRequest(Method.POST);request.AlwaysMultipartFormData = true;request.AddParameter("appId", "{{appId}}");request.AddParameter("secretKey", "{{secretKey}}");request.AddParameter("orderId", "order_00112");IRestResponse response = client.Execute(request);Console.WriteLine(response.Content);}}}
Parameter | Required | Description |
appId | Yes | Your app id |
secretKey | Yes | Your Secret Key |
orderId | Yes | Order/Invoice Id |
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 |
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 --location -g --request POST '{{Base URL}}/api/v1/order/info/status' \--form 'appId="{{appId}}"' \--form 'secretKey="{{secretKey}}"' \--form 'orderId="order_00112"'
<?php$curl = curl_init();curl_setopt_array($curl, array(CURLOPT_URL => '%7B%7BBase%20URL%7D%7D/api/v1/order/info/status',CURLOPT_RETURNTRANSFER => true,CURLOPT_ENCODING => '',CURLOPT_MAXREDIRS => 10,CURLOPT_TIMEOUT => 0,CURLOPT_FOLLOWLOCATION => true,CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,CURLOPT_CUSTOMREQUEST => 'POST',CURLOPT_POSTFIELDS => array('appId' => '{{appId}}','secretKey' => '{{secretKey}}','orderId' => 'order_00112'),));$response = curl_exec($curl);curl_close($curl);echo $response;
import java.io.*;import okhttp3.*;public class main {public static void main(String []args) throws IOException{OkHttpClient client = new OkHttpClient().newBuilder().build();MediaType mediaType = MediaType.parse("text/plain");RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("appId", "{{appId}}").addFormDataPart("secretKey", "{{secretKey}}").addFormDataPart("orderId", "order_00112").build();Request request = new Request.Builder().url("{{Base URL}}/api/v1/order/info/status").method("POST", body).build();Response response = client.newCall(request).execute();System.out.println(response.body().string());}}
package mainimport ("fmt""bytes""mime/multipart""net/http""io/ioutil")func main() {url := "{{Base URL}}/api/v1/order/info/status"method := "POST"payload := &bytes.Buffer{}writer := multipart.NewWriter(payload)_ = writer.WriteField("appId", "{{appId}}")_ = writer.WriteField("secretKey", "{{secretKey}}")_ = writer.WriteField("orderId", "order_00112")err := writer.Close()if err != nil {fmt.Println(err)return}client := &http.Client {}req, err := http.NewRequest(method, url, payload)if err != nil {fmt.Println(err)return}req.Header.Set("Content-Type", writer.FormDataContentType())res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := ioutil.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
import requestsurl = "{{Base URL}}/api/v1/order/info/status"payload={'appId': '{{appId}}','secretKey': '{{secretKey}}','orderId': 'order_00112'}files=[]headers = {}response = requests.request("POST", url, headers=headers, data=payload, files=files)print(response.text)
using System;using RestSharp;namespace HelloWorldApplication {class HelloWorld {static void Main(string[] args) {var client = new RestClient("{{Base URL}}/api/v1/order/info/status");client.Timeout = -1;var request = new RestRequest(Method.POST);request.AlwaysMultipartFormData = true;request.AddParameter("appId", "{{appId}}");request.AddParameter("secretKey", "{{secretKey}}");request.AddParameter("orderId", "order_00112");IRestResponse response = client.Execute(request);Console.WriteLine(response.Content);}}}
Parameter | Required | Description |
appId | Yes | Your app id |
secretKey | Yes | Your Secret Key |
orderId | Yes | Order/Invoice Id |
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) |
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"}
Triggers a payment email for the payment received.
curl --location -g --request POST '{{Base URL}}/api/v1/order/email' \--form 'appId="{{appId}}"' \--form 'secretKey="{{secretKey}}"' \--form 'orderId="order_00112"'
<?php$curl = curl_init();curl_setopt_array($curl, array(CURLOPT_URL => '{{Base URL}}/api/v1/order/email',CURLOPT_RETURNTRANSFER => true,CURLOPT_ENCODING => '',CURLOPT_MAXREDIRS => 10,CURLOPT_TIMEOUT => 0,CURLOPT_FOLLOWLOCATION => true,CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,CURLOPT_CUSTOMREQUEST => 'POST',CURLOPT_POSTFIELDS => array('appId' => '{{appId}}','secretKey' => '{{secretKey}}','orderId' => 'order_00112'),));$response = curl_exec($curl);curl_close($curl);echo $response;
import java.io.*;import okhttp3.*;public class main {public static void main(String []args) throws IOException{OkHttpClient client = new OkHttpClient().newBuilder().build();MediaType mediaType = MediaType.parse("text/plain");RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("appId", "{{appId}}").addFormDataPart("secretKey", "{{secretKey}}").addFormDataPart("orderId", "order_00112").build();Request request = new Request.Builder().url("{{Base URL}}/api/v1/order/email").method("POST", body).build();Response response = client.newCall(request).execute();System.out.println(response.body().string());}}
package mainimport ("fmt""bytes""mime/multipart""net/http""io/ioutil")func main() {url := "{{Base URL}}/api/v1/order/email"method := "POST"payload := &bytes.Buffer{}writer := multipart.NewWriter(payload)_ = writer.WriteField("appId", "{{appId}}")_ = writer.WriteField("secretKey", "{{secretKey}}")_ = writer.WriteField("orderId", "order_00112")err := writer.Close()if err != nil {fmt.Println(err)return}client := &http.Client {}req, err := http.NewRequest(method, url, payload)if err != nil {fmt.Println(err)return}req.Header.Set("Content-Type", writer.FormDataContentType())res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := ioutil.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
import requestsurl = "{{Base URL}}/api/v1/order/email"payload={'appId': '{{appId}}','secretKey': '{{secretKey}}','orderId': 'order_00112'}files=[]headers = {}response = requests.request("POST", url, headers=headers, data=payload, files=files)print(response.text)
using System;using RestSharp;namespace HelloWorldApplication {class HelloWorld {static void Main(string[] args) {var client = new RestClient("{{Base URL}}/api/v1/order/email");client.Timeout = -1;var request = new RestRequest(Method.POST);request.AlwaysMultipartFormData = true;request.AddParameter("appId", "{{appId}}");request.AddParameter("secretKey", "{{secretKey}}");request.AddParameter("orderId", "order_00112");IRestResponse response = client.Execute(request);Console.WriteLine(response.Content);}}}
Parameter | Required | Description |
appId | Yes | Your app id |
secretKey | Yes | Your Secret Key |
orderId | Yes | Order/Invoice Id |
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. |
To initiate a refund on Cashfree, send a POST request to the class URL containing the contents of the order. For example, initiate refund sample code is available below:
curl --location -g --request POST '{{Base URL}}/api/v1/order/refund' \--form 'appId="{{appId}}"' \--form 'secretKey="{{secretKey}}"' \--form 'referenceId="28759"' \--form 'refundAmount="1"' \--form 'refundNote="partial refund"'
<?php$curl = curl_init();curl_setopt_array($curl, array(CURLOPT_URL => '%7B%7BBase%20URL%7D%7D/api/v1/order/refund',CURLOPT_RETURNTRANSFER => true,CURLOPT_ENCODING => '',CURLOPT_MAXREDIRS => 10,CURLOPT_TIMEOUT => 0,CURLOPT_FOLLOWLOCATION => true,CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,CURLOPT_CUSTOMREQUEST => 'POST',CURLOPT_POSTFIELDS => array('appId' => '{{appId}}','secretKey' => '{{secretKey}}','referenceId' => '28759','refundAmount' => '1','refundNote' => 'partial refund'),));$response = curl_exec($curl);curl_close($curl);echo $response;
import java.io.*;import okhttp3.*;public class main {public static void main(String []args) throws IOException{OkHttpClient client = new OkHttpClient().newBuilder().build();MediaType mediaType = MediaType.parse("text/plain");RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("appId", "{{appId}}").addFormDataPart("secretKey", "{{secretKey}}").addFormDataPart("referenceId", "28759").addFormDataPart("refundAmount", "1").addFormDataPart("refundNote", "partial refund").build();Request request = new Request.Builder().url("{{Base URL}}/api/v1/order/refund").method("POST", body).build();Response response = client.newCall(request).execute();System.out.println(response.body().string());}}
package mainimport ("fmt""bytes""mime/multipart""net/http""io/ioutil")func main() {url := "{{Base URL}}/api/v1/order/refund"method := "POST"payload := &bytes.Buffer{}writer := multipart.NewWriter(payload)_ = writer.WriteField("appId", "{{appId}}")_ = writer.WriteField("secretKey", "{{secretKey}}")_ = writer.WriteField("referenceId", "28759")_ = writer.WriteField("refundAmount", "1")_ = writer.WriteField("refundNote", "partial refund")err := writer.Close()if err != nil {fmt.Println(err)return}client := &http.Client {}req, err := http.NewRequest(method, url, payload)if err != nil {fmt.Println(err)return}req.Header.Set("Content-Type", writer.FormDataContentType())res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := ioutil.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
import requestsurl = "{{Base URL}}/api/v1/order/refund"payload={'appId' : '{{appId}}','secretKey' : '{{secretKey}}','referenceId' : '28759','refundAmount': '1','refundNote': 'partial refund'}files=[]headers = {}response = requests.request("POST", url, headers=headers, data=payload, files=files)print(response.text)
using System;using RestSharp;namespace HelloWorldApplication {class HelloWorld {static void Main(string[] args) {var client = new RestClient("{{Base URL}}/api/v1/order/refund");client.Timeout = -1;var request = new RestRequest(Method.POST);request.AlwaysMultipartFormData = true;request.AddParameter("appId", "{{appId}}");request.AddParameter("secretKey", "{{secretKey}}");request.AddParameter("referenceId", "28759");request.AddParameter("refundAmount", "1");request.AddParameter("refundNote", "partial refund");IRestResponse response = client.Execute(request);Console.WriteLine(response.Content);}}}
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 |
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 |
Status | Sub Code | Message |
ERROR | 400 | Refunds cannot be initiated after 180 days of the transaction. |
ERROR | 400 | Duplicate Merchant Refund Id. |
ERROR | 400 | Can't process this refund. Please check transaction status for this transaction. |
ERROR | 400 | Total refund cannot be greater than the refundable amount. |
ERROR | 400 | Refunds for this payment mode are not supported. |
To fetch refunds processed on your Cashfree Account. For example, see sample code below:
curl --location -g --request POST '{{Base URL}}/api/v1/refunds' \--form 'appId="{{appId}}"' \--form 'secretKey="{{secretKey}}"' \--form 'startDate="2018-04-02"' \--form 'endDate="2018-06-10"'
<?php$curl = curl_init();curl_setopt_array($curl, array(CURLOPT_URL => '{{Base URL}}/api/v1/refunds',CURLOPT_RETURNTRANSFER => true,CURLOPT_ENCODING => '',CURLOPT_MAXREDIRS => 10,CURLOPT_TIMEOUT => 0,CURLOPT_FOLLOWLOCATION => true,CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,CURLOPT_CUSTOMREQUEST => 'POST',CURLOPT_POSTFIELDS => array('appId' => '{{appId}}','secretKey' => '{{secretKey}}','startDate' => '2018-04-02','endDate' => '2018-06-10'),));$response = curl_exec($curl);curl_close($curl);echo $response;
import java.io.*;import okhttp3.*;public class main {public static void main(String []args) throws IOException{OkHttpClient client = new OkHttpClient().newBuilder().build();MediaType mediaType = MediaType.parse("text/plain");RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("appId", "{{appId}}").addFormDataPart("secretKey", "{{secretKey}}").addFormDataPart("startDate", "2018-04-02").addFormDataPart("endDate", "2018-06-10").build();Request request = new Request.Builder().url("{{Base URL}}/api/v1/refunds").method("POST", body).build();Response response = client.newCall(request).execute();System.out.println(response.body().string());}}
package mainimport ("fmt""bytes""mime/multipart""net/http""io/ioutil")func main() {url := "{{Base URL}}/api/v1/refunds"method := "POST"payload := &bytes.Buffer{}writer := multipart.NewWriter(payload)_ = writer.WriteField("appId", "{{appId}}")_ = writer.WriteField("secretKey", "{{secretKey}}")_ = writer.WriteField("startDate", "2018-04-02")_ = writer.WriteField("endDate", "2018-06-10")err := writer.Close()if err != nil {fmt.Println(err)return}client := &http.Client {}req, err := http.NewRequest(method, url, payload)if err != nil {fmt.Println(err)return}req.Header.Set("Content-Type", writer.FormDataContentType())res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := ioutil.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
import requestsurl = "{{Base URL}}/api/v1/refunds"payload={'appId' : '{{appId}}','secretKey' : '{{secretKey}}','startDate' : '2018-04-02','endDate' : '2018-06-10'}files=[]headers = {}response = requests.request("POST", url, headers=headers, data=payload, files=files)print(response.text)
using System;using RestSharp;namespace HelloWorldApplication {class HelloWorld {static void Main(string[] args) {var client = new RestClient("{{Base URL}}/api/v1/refunds");client.Timeout = -1;var request = new RestRequest(Method.POST);request.AlwaysMultipartFormData = true;request.AddParameter("appId", "{{appId}}");request.AddParameter("secretKey", "{{secretKey}}");request.AddParameter("startDate", "2018-04-02");request.AddParameter("endDate", "2018-06-10");IRestResponse response = client.Execute(request);Console.WriteLine(response.Content);}}}
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. |
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). |
Parameter | Description |
| Id of the refund |
| merchant order id that is passed during payment request |
| Acquirer Reference number that was generated for this refund |
| Cashfree reference id of the transaction |
| Transaction Amount |
| Amount supposed to be refunded |
| Note provided during refund initiation |
| Refund processing status (Values will be YES or NO) |
| DateTime of refund initiation |
| DateTime of refund processing (Will be blank for unprocessed ones) |
To fetch refunds processed on your Cashfree Account. For example, see sample code below:
curl --location -g --request POST '{{Base URL}}/api/v1/refundStatus/' \--form 'appId="{{appId}}"' \--form 'secretKey="{{secretKey}}"' \--form 'refundId="587"'
<?php$curl = curl_init();curl_setopt_array($curl, array(CURLOPT_URL => '{{Base URL}}/api/v1/refundStatus/',CURLOPT_RETURNTRANSFER => true,CURLOPT_ENCODING => '',CURLOPT_MAXREDIRS => 10,CURLOPT_TIMEOUT => 0,CURLOPT_FOLLOWLOCATION => true,CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,CURLOPT_CUSTOMREQUEST => 'POST',CURLOPT_POSTFIELDS => array('appId' => '{{appId}}','secretKey' => '{{secretKey}}','refundId' => '587'),));$response = curl_exec($curl);curl_close($curl);echo $response;
import java.io.*;import okhttp3.*;public class main {public static void main(String []args) throws IOException{OkHttpClient client = new OkHttpClient().newBuilder().build();MediaType mediaType = MediaType.parse("text/plain");RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("appId", "{{appId}}").addFormDataPart("secretKey", "{{secretKey}}").addFormDataPart("refundId", "587").build();Request request = new Request.Builder().url("{{Base URL}}/api/v1/refundStatus/").method("POST", body).build();Response response = client.newCall(request).execute();System.out.println(response.body().string());}}
package mainimport ("fmt""bytes""mime/multipart""net/http""io/ioutil")func main() {url := "{{Base URL}}/api/v1/refundStatus/"method := "POST"payload := &bytes.Buffer{}writer := multipart.NewWriter(payload)_ = writer.WriteField("appId", "{{appId}}")_ = writer.WriteField("secretKey", "{{secretKey}}")_ = writer.WriteField("refundId", "587")err := writer.Close()if err != nil {fmt.Println(err)return}client := &http.Client {}req, err := http.NewRequest(method, url, payload)if err != nil {fmt.Println(err)return}req.Header.Set("Content-Type", writer.FormDataContentType())res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := ioutil.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
import requestsurl = "{{Base URL}}/api/v1/refundStatus/"payload={'appId' : '{{appId}}','secretKey' : '{{secretKey}}','refundId' : '587'}files=[]headers = {}response = requests.request("POST", url, headers=headers, data=payload, files=files)print(response.text)
using System;using RestSharp;namespace HelloWorldApplication {class HelloWorld {static void Main(string[] args) {var client = new RestClient("{{Base URL}}/api/v1/refundStatus/");client.Timeout = -1;var request = new RestRequest(Method.POST);request.AlwaysMultipartFormData = true;request.AddParameter("appId", "{{appId}}");request.AddParameter("secretKey", "{{secretKey}}");request.AddParameter("refundId", "587");IRestResponse response = client.Execute(request);Console.WriteLine(response.Content);}}}
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 |
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) |
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) |
To fetch all settlements processed on your Cashfree Account. For example, see sample code below:
curl --location -g --request POST '{{Base URL}}/api/v1/settlements' \--form 'appId="{{appId}}"' \--form 'secretKey="{{secretKey}}"' \--form 'startDate="2017-04-02"' \--form 'endDate="2018-06-10"'
<?php$curl = curl_init();curl_setopt_array($curl, array(CURLOPT_URL => '{{Base URL}}/api/v1/settlements',CURLOPT_RETURNTRANSFER => true,CURLOPT_ENCODING => '',CURLOPT_MAXREDIRS => 10,CURLOPT_TIMEOUT => 0,CURLOPT_FOLLOWLOCATION => true,CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,CURLOPT_CUSTOMREQUEST => 'POST',CURLOPT_POSTFIELDS => array('appId' => '{{appId}}','secretKey' => '{{secretKey}}','startDate' => '2017-04-02','endDate' => '2018-06-10'),));$response = curl_exec($curl);curl_close($curl);echo $response;
import java.io.*;import okhttp3.*;public class main {public static void main(String []args) throws IOException{OkHttpClient client = new OkHttpClient().newBuilder().build();MediaType mediaType = MediaType.parse("text/plain");RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("appId", "{{appId}}").addFormDataPart("secretKey", "{{secretKey}}").addFormDataPart("startDate", "2017-04-02").addFormDataPart("endDate", "2018-06-10").build();Request request = new Request.Builder().url("{{Base URL}}/api/v1/settlements").method("POST", body).build();Response response = client.newCall(request).execute();System.out.println(response.body().string());}}
package mainimport ("fmt""bytes""mime/multipart""net/http""io/ioutil")func main() {url := "{{Base URL}}/api/v1/settlements"method := "POST"payload := &bytes.Buffer{}writer := multipart.NewWriter(payload)_ = writer.WriteField("appId", "{{appId}}")_ = writer.WriteField("secretKey", "{{secretKey}}")_ = writer.WriteField("startDate", "2017-04-02")_ = writer.WriteField("endDate", "2018-06-10")err := writer.Close()if err != nil {fmt.Println(err)return}client := &http.Client {}req, err := http.NewRequest(method, url, payload)if err != nil {fmt.Println(err)return}req.Header.Set("Content-Type", writer.FormDataContentType())res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := ioutil.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
import requestsurl = "{{Base URL}}/api/v1/settlements"payload={'appId' : '{{appId}}','secretKey' : '{{secretKey}}','startDate' : '2017-04-02','endDate' : '2018-06-10'}files=[]headers = {}response = requests.request("POST", url, headers=headers, data=payload, files=files)print(response.text)
using System;using RestSharp;namespace HelloWorldApplication {class HelloWorld {static void Main(string[] args) {var client = new RestClient("{{Base URL}}/api/v1/settlements");client.Timeout = -1;var request = new RestRequest(Method.POST);request.AlwaysMultipartFormData = true;request.AddParameter("appId", "{{appId}}");request.AddParameter("secretKey", "{{secretKey}}");request.AddParameter("startDate", "2017-04-02");request.AddParameter("endDate", "2018-06-10");IRestResponse response = client.Execute(request);Console.WriteLine(response.Content);}}}
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. |
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 |
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) |
To fetch transactions that are part of a settlement. For example, see sample code below:
curl --location -g --request POST '{{Base URL}}/api/v1/settlement' \--form 'appId="{{appId}}"' \--form 'secretKey="{{secretKey}}"' \--form 'settlementId="46"'
<?php$curl = curl_init();curl_setopt_array($curl, array(CURLOPT_URL => '{{Base URL}}/api/v1/settlement',CURLOPT_RETURNTRANSFER => true,CURLOPT_ENCODING => '',CURLOPT_MAXREDIRS => 10,CURLOPT_TIMEOUT => 0,CURLOPT_FOLLOWLOCATION => true,CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,CURLOPT_CUSTOMREQUEST => 'POST',CURLOPT_POSTFIELDS => array('appId' => '{{appId}}','secretKey' => '{{secretKey}}','settlementId' => '46'),));$response = curl_exec($curl);curl_close($curl);echo $response;
import java.io.*;import okhttp3.*;public class main {public static void main(String []args) throws IOException{OkHttpClient client = new OkHttpClient().newBuilder().build();MediaType mediaType = MediaType.parse("text/plain");RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM).addFormDataPart("appId", "{{appId}}").addFormDataPart("secretKey", "{{secretKey}}").addFormDataPart("settlementId", "46").build();Request request = new Request.Builder().url("{{Base URL}}/api/v1/settlement").method("POST", body).build();Response response = client.newCall(request).execute();System.out.println(response.body().string());}}
package mainimport ("fmt""bytes""mime/multipart""net/http""io/ioutil")func main() {url := "{{Base URL}}/api/v1/settlement"method := "POST"payload := &bytes.Buffer{}writer := multipart.NewWriter(payload)_ = writer.WriteField("appId", "{{appId}}")_ = writer.WriteField("secretKey", "{{secretKey}}")_ = writer.WriteField("settlementId", "46")err := writer.Close()if err != nil {fmt.Println(err)return}client := &http.Client {}req, err := http.NewRequest(method, url, payload)if err != nil {fmt.Println(err)return}req.Header.Set("Content-Type", writer.FormDataContentType())res, err := client.Do(req)if err != nil {fmt.Println(err)return}defer res.Body.Close()body, err := ioutil.ReadAll(res.Body)if err != nil {fmt.Println(err)return}fmt.Println(string(body))}
import requestsurl = "{{Base URL}}/api/v1/settlement"payload={'appId' : '{{appId}}','secretKey' : '{{secretKey}}','settlementId' : '46'}files=[]headers = {}response = requests.request("POST", url, headers=headers, data=payload, files=files)print(response.text)
using System;using RestSharp;namespace HelloWorldApplication {class HelloWorld {static void Main(string[] args) {var client = new RestClient("{{Base URL}}/api/v1/settlement");client.Timeout = -1;var request = new RestRequest(Method.POST);request.AlwaysMultipartFormData = true;request.AddParameter("appId", "{{appId}}");request.AddParameter("secretKey", "{{secretKey}}");request.AddParameter("settlementId", "46");IRestResponse response = client.Execute(request);Console.WriteLine(response.Content);}}}
Parameter | Required | Description |
appId | Yes | Your app id |
secretKey | Yes | Your Secret Key |
settlementId | Yes | ID of the settlement |
lastId | No | Use it for a 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. |
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 |
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 |