List refunds
curl --request GET \
--url https://merchant-api-prod.anyway.sh/v1/refunds \
--header 'X-API-Key: <api-key>'import requests
url = "https://merchant-api-prod.anyway.sh/v1/refunds"
headers = {"X-API-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-API-Key': '<api-key>'}};
fetch('https://merchant-api-prod.anyway.sh/v1/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://merchant-api-prod.anyway.sh/v1/refunds",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-Key: <api-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"
"net/http"
"io"
)
func main() {
url := "https://merchant-api-prod.anyway.sh/v1/refunds"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://merchant-api-prod.anyway.sh/v1/refunds")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://merchant-api-prod.anyway.sh/v1/refunds")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"data": {
"current": 123,
"page": 123,
"pages": 123,
"records": [
{
"amountCents": 123,
"createdAt": "<string>",
"currency": "<string>",
"failedAt": "<string>",
"failureReason": "<string>",
"fullyRefunded": true,
"orderId": "<string>",
"orgId": "<string>",
"reason": "<string>",
"refundId": "<string>",
"refundedAt": "<string>",
"status": "<string>",
"totalRefundedCents": 123
}
],
"size": 123,
"total": 123
},
"error": {
"code": "<string>",
"message": "<string>"
},
"message": "<string>",
"success": true
}{
"data": "<unknown>",
"error": {
"code": "<string>",
"message": "<string>"
},
"message": "<string>",
"success": true
}{
"data": "<unknown>",
"error": {
"code": "<string>",
"message": "<string>"
},
"message": "<string>",
"success": true
}{
"data": "<unknown>",
"error": {
"code": "<string>",
"message": "<string>"
},
"message": "<string>",
"success": true
}Merchant API 端点
列出退款
分页列出当前组织的退款,并使用筛选条件进行对账。
GET
/
v1
/
refunds
List refunds
curl --request GET \
--url https://merchant-api-prod.anyway.sh/v1/refunds \
--header 'X-API-Key: <api-key>'import requests
url = "https://merchant-api-prod.anyway.sh/v1/refunds"
headers = {"X-API-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-API-Key': '<api-key>'}};
fetch('https://merchant-api-prod.anyway.sh/v1/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://merchant-api-prod.anyway.sh/v1/refunds",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-Key: <api-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"
"net/http"
"io"
)
func main() {
url := "https://merchant-api-prod.anyway.sh/v1/refunds"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://merchant-api-prod.anyway.sh/v1/refunds")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://merchant-api-prod.anyway.sh/v1/refunds")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"data": {
"current": 123,
"page": 123,
"pages": 123,
"records": [
{
"amountCents": 123,
"createdAt": "<string>",
"currency": "<string>",
"failedAt": "<string>",
"failureReason": "<string>",
"fullyRefunded": true,
"orderId": "<string>",
"orgId": "<string>",
"reason": "<string>",
"refundId": "<string>",
"refundedAt": "<string>",
"status": "<string>",
"totalRefundedCents": 123
}
],
"size": 123,
"total": 123
},
"error": {
"code": "<string>",
"message": "<string>"
},
"message": "<string>",
"success": true
}{
"data": "<unknown>",
"error": {
"code": "<string>",
"message": "<string>"
},
"message": "<string>",
"success": true
}{
"data": "<unknown>",
"error": {
"code": "<string>",
"message": "<string>"
},
"message": "<string>",
"success": true
}{
"data": "<unknown>",
"error": {
"code": "<string>",
"message": "<string>"
},
"message": "<string>",
"success": true
}请使用属于目标组织的 API 密钥进行认证。
每笔退款的字段与
refund.succeeded、refund.failed Webhook
相同,事件和 API 读取可以用同一套代码对账。status 为 succeeded、failed 或
pending(仍在审核或处理中)。pending 不会发送 Webhook;退款结束时会发送
refund.succeeded 或 refund.failed。
按时间段对账时,使用 date_from 和 date_to 筛选并逐页读取。查看某个订单的全部退款时,
使用 order_id 筛选。totalRefundedCents 和 fullyRefunded 反映请求时订单的状态。Webhook 中的这两个字段是事件发生时的值;同一订单之后又有退款成功时,API 返回的合计会高于之前那条 Webhook。授权
Merchant API key (format: ak_BASE64)
查询参数
Page number
Page size (max 100)
Filter by order ID (ORD_...)
succeeded, failed or pending
Refunds requested at or after this unix timestamp
Refunds requested at or before this unix timestamp