Create a refund
curl --request POST \
--url https://api-sandbox.uqpaytech.com/api/v2/payment/refunds \
--header 'Content-Type: application/json' \
--header 'x-auth-token: <api-key>' \
--header 'x-client-id: <x-client-id>' \
--header 'x-idempotency-key: <x-idempotency-key>' \
--data '
{
"payment_intent_id": "PI1234567890123456789",
"amount": "10.01",
"reason": "Return good",
"payment_attempt_id": "PA1234567890123456789",
"metadata": {
"customer_id": "cust_12345",
"order_id": "order_6789"
}
}
'import requests
url = "https://api-sandbox.uqpaytech.com/api/v2/payment/refunds"
payload = {
"payment_intent_id": "PI1234567890123456789",
"amount": "10.01",
"reason": "Return good",
"payment_attempt_id": "PA1234567890123456789",
"metadata": {
"customer_id": "cust_12345",
"order_id": "order_6789"
}
}
headers = {
"x-client-id": "<x-client-id>",
"x-idempotency-key": "<x-idempotency-key>",
"x-auth-token": "<api-key>",
"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-idempotency-key': '<x-idempotency-key>',
'x-auth-token': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
payment_intent_id: 'PI1234567890123456789',
amount: '10.01',
reason: 'Return good',
payment_attempt_id: 'PA1234567890123456789',
metadata: {customer_id: 'cust_12345', order_id: 'order_6789'}
})
};
fetch('https://api-sandbox.uqpaytech.com/api/v2/payment/refunds', 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-sandbox.uqpaytech.com/api/v2/payment/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 => json_encode([
'payment_intent_id' => 'PI1234567890123456789',
'amount' => '10.01',
'reason' => 'Return good',
'payment_attempt_id' => 'PA1234567890123456789',
'metadata' => [
'customer_id' => 'cust_12345',
'order_id' => 'order_6789'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-auth-token: <api-key>",
"x-client-id: <x-client-id>",
"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-sandbox.uqpaytech.com/api/v2/payment/refunds"
payload := strings.NewReader("{\n \"payment_intent_id\": \"PI1234567890123456789\",\n \"amount\": \"10.01\",\n \"reason\": \"Return good\",\n \"payment_attempt_id\": \"PA1234567890123456789\",\n \"metadata\": {\n \"customer_id\": \"cust_12345\",\n \"order_id\": \"order_6789\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-client-id", "<x-client-id>")
req.Header.Add("x-idempotency-key", "<x-idempotency-key>")
req.Header.Add("x-auth-token", "<api-key>")
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-sandbox.uqpaytech.com/api/v2/payment/refunds")
.header("x-client-id", "<x-client-id>")
.header("x-idempotency-key", "<x-idempotency-key>")
.header("x-auth-token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"payment_intent_id\": \"PI1234567890123456789\",\n \"amount\": \"10.01\",\n \"reason\": \"Return good\",\n \"payment_attempt_id\": \"PA1234567890123456789\",\n \"metadata\": {\n \"customer_id\": \"cust_12345\",\n \"order_id\": \"order_6789\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.uqpaytech.com/api/v2/payment/refunds")
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-idempotency-key"] = '<x-idempotency-key>'
request["x-auth-token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"payment_intent_id\": \"PI1234567890123456789\",\n \"amount\": \"10.01\",\n \"reason\": \"Return good\",\n \"payment_attempt_id\": \"PA1234567890123456789\",\n \"metadata\": {\n \"customer_id\": \"cust_12345\",\n \"order_id\": \"order_6789\"\n }\n}"
response = http.request(request)
puts response.read_body{
"payment_refund_id": "RF123456789",
"payment_attempt_id": "PA123456789",
"amount": "10.01",
"currency": "USD",
"refund_status": "SUCCEEDED",
"create_time": "2024-03-01T00:00:00+08:00",
"update_time": "2024-03-01T00:00:00+08:00",
"reason": "Order 1234 has been returned",
"metadata": {
"customer_id": "cust_12345",
"order_id": "order_6789"
}
}Payment Refunds
Create a refund
为已完成的付款创建退款
POST
/
v2
/
payment
/
refunds
Create a refund
curl --request POST \
--url https://api-sandbox.uqpaytech.com/api/v2/payment/refunds \
--header 'Content-Type: application/json' \
--header 'x-auth-token: <api-key>' \
--header 'x-client-id: <x-client-id>' \
--header 'x-idempotency-key: <x-idempotency-key>' \
--data '
{
"payment_intent_id": "PI1234567890123456789",
"amount": "10.01",
"reason": "Return good",
"payment_attempt_id": "PA1234567890123456789",
"metadata": {
"customer_id": "cust_12345",
"order_id": "order_6789"
}
}
'import requests
url = "https://api-sandbox.uqpaytech.com/api/v2/payment/refunds"
payload = {
"payment_intent_id": "PI1234567890123456789",
"amount": "10.01",
"reason": "Return good",
"payment_attempt_id": "PA1234567890123456789",
"metadata": {
"customer_id": "cust_12345",
"order_id": "order_6789"
}
}
headers = {
"x-client-id": "<x-client-id>",
"x-idempotency-key": "<x-idempotency-key>",
"x-auth-token": "<api-key>",
"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-idempotency-key': '<x-idempotency-key>',
'x-auth-token': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
payment_intent_id: 'PI1234567890123456789',
amount: '10.01',
reason: 'Return good',
payment_attempt_id: 'PA1234567890123456789',
metadata: {customer_id: 'cust_12345', order_id: 'order_6789'}
})
};
fetch('https://api-sandbox.uqpaytech.com/api/v2/payment/refunds', 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-sandbox.uqpaytech.com/api/v2/payment/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 => json_encode([
'payment_intent_id' => 'PI1234567890123456789',
'amount' => '10.01',
'reason' => 'Return good',
'payment_attempt_id' => 'PA1234567890123456789',
'metadata' => [
'customer_id' => 'cust_12345',
'order_id' => 'order_6789'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-auth-token: <api-key>",
"x-client-id: <x-client-id>",
"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-sandbox.uqpaytech.com/api/v2/payment/refunds"
payload := strings.NewReader("{\n \"payment_intent_id\": \"PI1234567890123456789\",\n \"amount\": \"10.01\",\n \"reason\": \"Return good\",\n \"payment_attempt_id\": \"PA1234567890123456789\",\n \"metadata\": {\n \"customer_id\": \"cust_12345\",\n \"order_id\": \"order_6789\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-client-id", "<x-client-id>")
req.Header.Add("x-idempotency-key", "<x-idempotency-key>")
req.Header.Add("x-auth-token", "<api-key>")
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-sandbox.uqpaytech.com/api/v2/payment/refunds")
.header("x-client-id", "<x-client-id>")
.header("x-idempotency-key", "<x-idempotency-key>")
.header("x-auth-token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"payment_intent_id\": \"PI1234567890123456789\",\n \"amount\": \"10.01\",\n \"reason\": \"Return good\",\n \"payment_attempt_id\": \"PA1234567890123456789\",\n \"metadata\": {\n \"customer_id\": \"cust_12345\",\n \"order_id\": \"order_6789\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.uqpaytech.com/api/v2/payment/refunds")
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-idempotency-key"] = '<x-idempotency-key>'
request["x-auth-token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"payment_intent_id\": \"PI1234567890123456789\",\n \"amount\": \"10.01\",\n \"reason\": \"Return good\",\n \"payment_attempt_id\": \"PA1234567890123456789\",\n \"metadata\": {\n \"customer_id\": \"cust_12345\",\n \"order_id\": \"order_6789\"\n }\n}"
response = http.request(request)
puts response.read_body{
"payment_refund_id": "RF123456789",
"payment_attempt_id": "PA123456789",
"amount": "10.01",
"currency": "USD",
"refund_status": "SUCCEEDED",
"create_time": "2024-03-01T00:00:00+08:00",
"update_time": "2024-03-01T00:00:00+08:00",
"reason": "Order 1234 has been returned",
"metadata": {
"customer_id": "cust_12345",
"order_id": "order_6789"
}
}授权
UQPay 提供的登录 API Token。
请求头
UQPAY 生成的 API 客户端 ID
指定代表哪个子账户发起该请求。应设置为 account_id,可通过 List Connected Accounts 获取。若省略或为空,则使用主账户执行请求。
更多信息见 Connected Accounts。
用于保持操作幂等性的唯一标识符(UUID),确保同一操作重复执行不会产生意外影响或重复结果。它有助于在网络错误、重试或故障时保持数据一致性。
请求体
application/json
要退款的 PaymentIntent 的 ID
Maximum string length:
36示例:
"PI1234567890123456789"
要退款的金额
示例:
"10.01"
退款原因
Maximum string length:
100示例:
"Return good"
要退款的 PaymentAttempt 的 ID
示例:
"PA1234567890123456789"
退款的附加元数据
Show child attributes
Show child attributes
示例:
{
"customer_id": "cust_12345",
"order_id": "order_6789"
}
响应
200 - application/json
成功创建退款
退款的唯一标识
示例:
"RF123456789"
已退款的 PaymentAttempt 的 ID
示例:
"PA123456789"
已退款的金额
示例:
"10.01"
三字母币种代码(ISO 4217)
示例:
"USD"
退款的当前状态。
INITIATED:退款已发起。PROCESSING:退款正在处理中。SUCCEEDED:退款已成功完成。FAILED:退款尝试失败。REVERSAL_INITIATED:退款的冲正已发起。REVERSAL_PROCESSING:退款的冲正正在处理中。REVERSAL_SUCCEEDED:退款的冲正已成功完成。
可用选项:
INITIATED, PROCESSING, SUCCEEDED, FAILED, REVERSAL_INITIATED, REVERSAL_PROCESSING, REVERSAL_SUCCEEDED 示例:
"SUCCEEDED"
该退款的创建时间。
示例:
"2024-03-01T00:00:00+08:00"
该退款最近一次更新或操作的时间。
示例:
"2024-03-01T00:00:00+08:00"
退款原因
Maximum string length:
100示例:
"Order 1234 has been returned"
与退款关联的附加元数据。用户自定义的键值对。
Show child attributes
Show child attributes
示例:
{
"customer_id": "cust_12345",
"order_id": "order_6789"
}
⌘I

