curl --request POST \
--url https://api.xpaycheckout.com/payments/merchant/refund \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"xIntentId": "in_fooBOwYsaK50AEfK",
"amount": "200",
"refundReferenceId": "re123"
}
'import requests
url = "https://api.xpaycheckout.com/payments/merchant/refund"
payload = {
"xIntentId": "in_fooBOwYsaK50AEfK",
"amount": "200",
"refundReferenceId": "re123"
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({xIntentId: 'in_fooBOwYsaK50AEfK', amount: '200', refundReferenceId: 're123'})
};
fetch('https://api.xpaycheckout.com/payments/merchant/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://api.xpaycheckout.com/payments/merchant/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([
'xIntentId' => 'in_fooBOwYsaK50AEfK',
'amount' => '200',
'refundReferenceId' => 're123'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$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://api.xpaycheckout.com/payments/merchant/refund"
payload := strings.NewReader("{\n \"xIntentId\": \"in_fooBOwYsaK50AEfK\",\n \"amount\": \"200\",\n \"refundReferenceId\": \"re123\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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://api.xpaycheckout.com/payments/merchant/refund")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"xIntentId\": \"in_fooBOwYsaK50AEfK\",\n \"amount\": \"200\",\n \"refundReferenceId\": \"re123\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xpaycheckout.com/payments/merchant/refund")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"xIntentId\": \"in_fooBOwYsaK50AEfK\",\n \"amount\": \"200\",\n \"refundReferenceId\": \"re123\"\n}"
response = http.request(request)
puts response.read_body{
"refundId": "rf_fooBOwYsaK50AEaJ",
"intentId": "in_fooBOwYsaK50AEfK",
"amount": 2000,
"currency": "USD",
"refundedAt": 1727340330123,
"refundReferenceId": "re123"
}{
"errorCode": "bad_request",
"errorDescription": "Failed to read request"
}Refund
The Refund APIs allow merchants to process refunds for previously captured payments
curl --request POST \
--url https://api.xpaycheckout.com/payments/merchant/refund \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"xIntentId": "in_fooBOwYsaK50AEfK",
"amount": "200",
"refundReferenceId": "re123"
}
'import requests
url = "https://api.xpaycheckout.com/payments/merchant/refund"
payload = {
"xIntentId": "in_fooBOwYsaK50AEfK",
"amount": "200",
"refundReferenceId": "re123"
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({xIntentId: 'in_fooBOwYsaK50AEfK', amount: '200', refundReferenceId: 're123'})
};
fetch('https://api.xpaycheckout.com/payments/merchant/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://api.xpaycheckout.com/payments/merchant/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([
'xIntentId' => 'in_fooBOwYsaK50AEfK',
'amount' => '200',
'refundReferenceId' => 're123'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$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://api.xpaycheckout.com/payments/merchant/refund"
payload := strings.NewReader("{\n \"xIntentId\": \"in_fooBOwYsaK50AEfK\",\n \"amount\": \"200\",\n \"refundReferenceId\": \"re123\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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://api.xpaycheckout.com/payments/merchant/refund")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"xIntentId\": \"in_fooBOwYsaK50AEfK\",\n \"amount\": \"200\",\n \"refundReferenceId\": \"re123\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.xpaycheckout.com/payments/merchant/refund")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"xIntentId\": \"in_fooBOwYsaK50AEfK\",\n \"amount\": \"200\",\n \"refundReferenceId\": \"re123\"\n}"
response = http.request(request)
puts response.read_body{
"refundId": "rf_fooBOwYsaK50AEaJ",
"intentId": "in_fooBOwYsaK50AEfK",
"amount": 2000,
"currency": "USD",
"refundedAt": 1727340330123,
"refundReferenceId": "re123"
}{
"errorCode": "bad_request",
"errorDescription": "Failed to read request"
}Authorizations
Basic authentication header of the form Basic <encoded-value>, where <encoded-value> is the base64-encoded string username:password.
Headers
A unique key for making the request idempotent. Must match pattern: ^[a-zA-Z0-9\-_:\.]+$. See Idempotent Requests for more details.
255^[a-zA-Z0-9\-_:\.]+$Body
Refund API
Unique identifier of the intent
"in_fooBOwYsaK50AEfK"
The amount you want to refund, specified in the smallest unit of the currency (for example, cents for USD, paise for INR).
- If you want to issue a partial refund, provide the amount you wish to refund here. For example, if the original payment was $100 (i.e., 10000 cents), and you want to refund $20, you would enter 2000.
- If you leave this field blank, the full payment amount will be refunded automatically.
"200"
Your identifier for the refund
"re123"
Response
Refund API response
Unique identifier of the refund
"rf_fooBOwYsaK50AEaJ"
Unique identifier of the payment intent
"in_fooBOwYsaK50AEfK"
The amount in lowest count unit. e.g.: For USD 1, amount is 100 representing 100 cents (The minimum amount should be greater than 1 USD)
2000
Three letter abbreviation of the currency. Refer supported currencies
"USD"
Epoch timestamp in milliseconds of when the refund was processed
1727340330123
Your identifier for the refund
"re123"
Was this page helpful?