Refund a payment
curl --request POST \
--url https://api.yuvexpay.com/v1/payments/{paymentId}/refund \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Idempotency-Key: <x-idempotency-key>' \
--data '
{
"amount": 25,
"reason": "Customer requested refund"
}
'import requests
url = "https://api.yuvexpay.com/v1/payments/{paymentId}/refund"
payload = {
"amount": 25,
"reason": "Customer requested refund"
}
headers = {
"X-Idempotency-Key": "<x-idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Idempotency-Key': '<x-idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({amount: 25, reason: 'Customer requested refund'})
};
fetch('https://api.yuvexpay.com/v1/payments/{paymentId}/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.yuvexpay.com/v1/payments/{paymentId}/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([
'amount' => 25,
'reason' => 'Customer requested refund'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Idempotency-Key: <x-idempotency-key>"
],
]);
$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.yuvexpay.com/v1/payments/{paymentId}/refund"
payload := strings.NewReader("{\n \"amount\": 25,\n \"reason\": \"Customer requested refund\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Idempotency-Key", "<x-idempotency-key>")
req.Header.Add("Authorization", "Bearer <token>")
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.yuvexpay.com/v1/payments/{paymentId}/refund")
.header("X-Idempotency-Key", "<x-idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 25,\n \"reason\": \"Customer requested refund\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.yuvexpay.com/v1/payments/{paymentId}/refund")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Idempotency-Key"] = '<x-idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 25,\n \"reason\": \"Customer requested refund\"\n}"
response = http.request(request)
puts response.read_body{
"refund": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"txId": "<string>",
"amount": 123,
"reason": "<string>",
"processedAt": "2023-11-07T05:31:56Z",
"createdAt": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid request body",
"details": {
"amount": "Must be greater than 0.01"
}
}
}{
"error": {
"code": "INVALID_API_KEY",
"message": "Invalid or revoked API key"
}
}{
"error": {
"code": "NOT_FOUND",
"message": "Resource not found"
}
}{
"error": {
"code": "IDEMPOTENCY_PAYLOAD_MISMATCH",
"message": "Idempotency key already used with a different request body"
}
}Payments
Refund a payment
Issue a full or partial refund for a paid payment. Requires an idempotency key.
POST
/
v1
/
payments
/
{paymentId}
/
refund
Refund a payment
curl --request POST \
--url https://api.yuvexpay.com/v1/payments/{paymentId}/refund \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-Idempotency-Key: <x-idempotency-key>' \
--data '
{
"amount": 25,
"reason": "Customer requested refund"
}
'import requests
url = "https://api.yuvexpay.com/v1/payments/{paymentId}/refund"
payload = {
"amount": 25,
"reason": "Customer requested refund"
}
headers = {
"X-Idempotency-Key": "<x-idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Idempotency-Key': '<x-idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({amount: 25, reason: 'Customer requested refund'})
};
fetch('https://api.yuvexpay.com/v1/payments/{paymentId}/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.yuvexpay.com/v1/payments/{paymentId}/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([
'amount' => 25,
'reason' => 'Customer requested refund'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-Idempotency-Key: <x-idempotency-key>"
],
]);
$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.yuvexpay.com/v1/payments/{paymentId}/refund"
payload := strings.NewReader("{\n \"amount\": 25,\n \"reason\": \"Customer requested refund\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Idempotency-Key", "<x-idempotency-key>")
req.Header.Add("Authorization", "Bearer <token>")
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.yuvexpay.com/v1/payments/{paymentId}/refund")
.header("X-Idempotency-Key", "<x-idempotency-key>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"amount\": 25,\n \"reason\": \"Customer requested refund\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.yuvexpay.com/v1/payments/{paymentId}/refund")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Idempotency-Key"] = '<x-idempotency-key>'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount\": 25,\n \"reason\": \"Customer requested refund\"\n}"
response = http.request(request)
puts response.read_body{
"refund": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"txId": "<string>",
"amount": 123,
"reason": "<string>",
"processedAt": "2023-11-07T05:31:56Z",
"createdAt": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid request body",
"details": {
"amount": "Must be greater than 0.01"
}
}
}{
"error": {
"code": "INVALID_API_KEY",
"message": "Invalid or revoked API key"
}
}{
"error": {
"code": "NOT_FOUND",
"message": "Resource not found"
}
}{
"error": {
"code": "IDEMPOTENCY_PAYLOAD_MISMATCH",
"message": "Idempotency key already used with a different request body"
}
}Authorizations
YuvexPay API key. Include as Authorization: Bearer ypk_<env>_<kid>_<secret> where <env> is test (sandbox) or live (production). Create and manage keys in the dashboard under Settings > API Keys.
Headers
A unique string to ensure the request is processed only once. Must be unique per request. Valid for 24 hours.
Maximum string length:
100Path Parameters
The payment ID to refund.
Body
application/json
Response
Refund created.
Show child attributes
Show child attributes
⌘I

