Create Subscription Refund
curl --request POST \
--url https://sandbox.cashfree.com/api/v2/subscriptions/create-refund \
--header 'Content-Type: application/json' \
--header 'X-Client-Id: <x-client-id>' \
--header 'X-Client-Secret: <x-client-secret>' \
--data '
{
"paymentId": "1223",
"refundAmount": 100,
"refundNote": "Charge refund",
"merchantRefundId": "test-refund",
"requestedSpeed": "STANDARD"
}
'import requests
url = "https://sandbox.cashfree.com/api/v2/subscriptions/create-refund"
payload = {
"paymentId": "1223",
"refundAmount": 100,
"refundNote": "Charge refund",
"merchantRefundId": "test-refund",
"requestedSpeed": "STANDARD"
}
headers = {
"X-Client-Id": "<x-client-id>",
"X-Client-Secret": "<x-client-secret>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Client-Id': '<x-client-id>',
'X-Client-Secret': '<x-client-secret>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
paymentId: '1223',
refundAmount: 100,
refundNote: 'Charge refund',
merchantRefundId: 'test-refund',
requestedSpeed: 'STANDARD'
})
};
fetch('https://sandbox.cashfree.com/api/v2/subscriptions/create-refund', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox.cashfree.com/api/v2/subscriptions/create-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 => json_encode([
'paymentId' => '1223',
'refundAmount' => 100,
'refundNote' => 'Charge refund',
'merchantRefundId' => 'test-refund',
'requestedSpeed' => 'STANDARD'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Client-Id: <x-client-id>",
"X-Client-Secret: <x-client-secret>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox.cashfree.com/api/v2/subscriptions/create-refund"
payload := strings.NewReader("{\n \"paymentId\": \"1223\",\n \"refundAmount\": 100,\n \"refundNote\": \"Charge refund\",\n \"merchantRefundId\": \"test-refund\",\n \"requestedSpeed\": \"STANDARD\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Client-Id", "<x-client-id>")
req.Header.Add("X-Client-Secret", "<x-client-secret>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://sandbox.cashfree.com/api/v2/subscriptions/create-refund")
.header("X-Client-Id", "<x-client-id>")
.header("X-Client-Secret", "<x-client-secret>")
.header("Content-Type", "application/json")
.body("{\n \"paymentId\": \"1223\",\n \"refundAmount\": 100,\n \"refundNote\": \"Charge refund\",\n \"merchantRefundId\": \"test-refund\",\n \"requestedSpeed\": \"STANDARD\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.cashfree.com/api/v2/subscriptions/create-refund")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Client-Id"] = '<x-client-id>'
request["X-Client-Secret"] = '<x-client-secret>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"paymentId\": \"1223\",\n \"refundAmount\": 100,\n \"refundNote\": \"Charge refund\",\n \"merchantRefundId\": \"test-refund\",\n \"requestedSpeed\": \"STANDARD\"\n}"
response = http.request(request)
puts response.read_body{
"subRefundId": "SUB_76d688d5-cbcc-49ea-960b-21b11433b641",
"merchantRefundId": "test-refund",
"paymentId": 1223,
"subReferenceId": 191645,
"refundAmount": 100,
"refundStatus": "INITIALIZED"
}{
"subRefundId": "SUB_76d688d5-cbcc-49ea-960b-21b11433b641",
"merchantRefundId": "test-refund",
"paymentId": 1223,
"subReferenceId": 191645,
"refundAmount": 100,
"refundStatus": "INITIALIZED"
}{
"status": "ERROR",
"message": "Server encountered an unexpected condition."
}Subscription Refund
Create Subscription Refund
Use this API to create a refund for the payment of a Subscription. Only one of paymentId or merchantTxnId should be passed. If both are passed then the request will be rejected.
POST
/
api
/
v2
/
subscriptions
/
create-refund
Create Subscription Refund
curl --request POST \
--url https://sandbox.cashfree.com/api/v2/subscriptions/create-refund \
--header 'Content-Type: application/json' \
--header 'X-Client-Id: <x-client-id>' \
--header 'X-Client-Secret: <x-client-secret>' \
--data '
{
"paymentId": "1223",
"refundAmount": 100,
"refundNote": "Charge refund",
"merchantRefundId": "test-refund",
"requestedSpeed": "STANDARD"
}
'import requests
url = "https://sandbox.cashfree.com/api/v2/subscriptions/create-refund"
payload = {
"paymentId": "1223",
"refundAmount": 100,
"refundNote": "Charge refund",
"merchantRefundId": "test-refund",
"requestedSpeed": "STANDARD"
}
headers = {
"X-Client-Id": "<x-client-id>",
"X-Client-Secret": "<x-client-secret>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Client-Id': '<x-client-id>',
'X-Client-Secret': '<x-client-secret>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
paymentId: '1223',
refundAmount: 100,
refundNote: 'Charge refund',
merchantRefundId: 'test-refund',
requestedSpeed: 'STANDARD'
})
};
fetch('https://sandbox.cashfree.com/api/v2/subscriptions/create-refund', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox.cashfree.com/api/v2/subscriptions/create-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 => json_encode([
'paymentId' => '1223',
'refundAmount' => 100,
'refundNote' => 'Charge refund',
'merchantRefundId' => 'test-refund',
'requestedSpeed' => 'STANDARD'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Client-Id: <x-client-id>",
"X-Client-Secret: <x-client-secret>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox.cashfree.com/api/v2/subscriptions/create-refund"
payload := strings.NewReader("{\n \"paymentId\": \"1223\",\n \"refundAmount\": 100,\n \"refundNote\": \"Charge refund\",\n \"merchantRefundId\": \"test-refund\",\n \"requestedSpeed\": \"STANDARD\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Client-Id", "<x-client-id>")
req.Header.Add("X-Client-Secret", "<x-client-secret>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://sandbox.cashfree.com/api/v2/subscriptions/create-refund")
.header("X-Client-Id", "<x-client-id>")
.header("X-Client-Secret", "<x-client-secret>")
.header("Content-Type", "application/json")
.body("{\n \"paymentId\": \"1223\",\n \"refundAmount\": 100,\n \"refundNote\": \"Charge refund\",\n \"merchantRefundId\": \"test-refund\",\n \"requestedSpeed\": \"STANDARD\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://sandbox.cashfree.com/api/v2/subscriptions/create-refund")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Client-Id"] = '<x-client-id>'
request["X-Client-Secret"] = '<x-client-secret>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"paymentId\": \"1223\",\n \"refundAmount\": 100,\n \"refundNote\": \"Charge refund\",\n \"merchantRefundId\": \"test-refund\",\n \"requestedSpeed\": \"STANDARD\"\n}"
response = http.request(request)
puts response.read_body{
"subRefundId": "SUB_76d688d5-cbcc-49ea-960b-21b11433b641",
"merchantRefundId": "test-refund",
"paymentId": 1223,
"subReferenceId": 191645,
"refundAmount": 100,
"refundStatus": "INITIALIZED"
}{
"subRefundId": "SUB_76d688d5-cbcc-49ea-960b-21b11433b641",
"merchantRefundId": "test-refund",
"paymentId": 1223,
"subReferenceId": 191645,
"refundAmount": 100,
"refundStatus": "INITIALIZED"
}{
"status": "ERROR",
"message": "Server encountered an unexpected condition."
}Headers
Client ID provided by Cashfree.
Example:
"asdf1234"
Client Secret provided by Cashfree.
Example:
"qwer9876"
Body
application/json
Payment ID for which the refund is to be created.
Example:
"1223"
Amount to be refunded.
Example:
100
Note associated with the refund.
Example:
"Charge refund"
Unique ID for the merchant's refund request.
Example:
"test-refund"
The requested speed for processing the refund (e.g., STANDARD).
Example:
"STANDARD"
Response
Successful creation of the refund.
Was this page helpful?
āI