订阅
列出订阅支付
返回订阅的收费历史记录,适用时包含计划/阶段上下文。
GET
/
subscriptions
/
{subscription_id}
/
payments
列出订阅支付
curl --request GET \
--url https://api-sandbox.y.uno/v1/subscriptions/{subscription_id}/payments \
--header 'private-secret-key: <api-key>' \
--header 'public-api-key: <api-key>'import requests
url = "https://api-sandbox.y.uno/v1/subscriptions/{subscription_id}/payments"
headers = {
"public-api-key": "<api-key>",
"private-secret-key": "<api-key>"
}
response = requests.get(url, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'public-api-key': '<api-key>', 'private-secret-key': '<api-key>'}
};
fetch('https://api-sandbox.y.uno/v1/subscriptions/{subscription_id}/payments', 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.y.uno/v1/subscriptions/{subscription_id}/payments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"private-secret-key: <api-key>",
"public-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://api-sandbox.y.uno/v1/subscriptions/{subscription_id}/payments"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("public-api-key", "<api-key>")
req.Header.Add("private-secret-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://api-sandbox.y.uno/v1/subscriptions/{subscription_id}/payments")
.header("public-api-key", "<api-key>")
.header("private-secret-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.y.uno/v1/subscriptions/{subscription_id}/payments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["public-api-key"] = '<api-key>'
request["private-secret-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"data": [
{
"id": "00000000-0000-4000-8000-000000000010",
"payment_id": "00000000-0000-4000-8000-000000000011",
"idempotency_key": null,
"status": "SUCCEEDED",
"sub_status": null,
"provider": "PROVIDER_TEST",
"payment_method": {
"id": "00000000-0000-4000-8000-000000000012",
"type": "CARD"
},
"amount": {
"currency": "USD",
"value": 9.99
},
"currency": "USD",
"subtotal": 9.99,
"total": 9.99,
"plan_id": "00000000-0000-4000-8000-000000000001",
"line_items": [
{
"type": "PLAN",
"label": "Intro",
"service_period": {
"start": "2024-04-01T09:00:00Z",
"end": "2024-05-01T09:00:00Z"
},
"amount": {
"currency": "USD",
"value": 9.99
}
}
],
"phase": {
"index": 1,
"name": "Intro",
"type": "TRIAL"
},
"phase_payment": 1,
"billing_cycle": null,
"retry": {
"count": 0,
"forced": false
},
"trace_id": null,
"created_at": "2024-04-01T09:00:00.000000Z",
"updated_at": "2024-04-01T09:00:00.000000Z"
}
],
"pagination": {
"total": 1,
"limit": 20,
"offset": 0,
"has_more": false
}
}{
"code": "SUBSCRIPTION_NOT_FOUND",
"messages": [
"Subscription not found."
]
}这是一个全新的 endpoint在 Plans 推出之前,没有支付子资源,订阅对象 上的
payments 数组是一个旧版字段,始终为空。由于这里没有需要保留的既有商户集成,此 endpoint 以统一、简洁的 data[] 结构发布,并带有完整的计划/阶段上下文,不含任何旧版字段。收费上的折扣每一项都将
amount 保留为该次收费的全额价格。带有促销的收费还包含 discount_amount 和 net_amount。net_amount 等于 amount 减去 discount_amount:即客户为该次收费实际支付的金额。对于 100% 折扣的周期,该值为 0。没有促销的收费不包含这两个字段。请参阅 订阅计划促销。offset 必须是 limit 的倍数未对齐的 offset 会重复返回您已经看过的行并导致 has_more 出错,因此会被拒绝并返回 400 BAD_REQUEST,而不会被静默向下取整。免费周期表现为
total: 0,而非单独的状态$0 的计费周期(例如免费试用的支付)可以通过 total == 0 识别,没有单独的“免费”状态。授权
查询参数
此页面对您有帮助吗?
⌘I
列出订阅支付
curl --request GET \
--url https://api-sandbox.y.uno/v1/subscriptions/{subscription_id}/payments \
--header 'private-secret-key: <api-key>' \
--header 'public-api-key: <api-key>'import requests
url = "https://api-sandbox.y.uno/v1/subscriptions/{subscription_id}/payments"
headers = {
"public-api-key": "<api-key>",
"private-secret-key": "<api-key>"
}
response = requests.get(url, headers=headers)
print(response.text)const options = {
method: 'GET',
headers: {'public-api-key': '<api-key>', 'private-secret-key': '<api-key>'}
};
fetch('https://api-sandbox.y.uno/v1/subscriptions/{subscription_id}/payments', 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.y.uno/v1/subscriptions/{subscription_id}/payments",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"private-secret-key: <api-key>",
"public-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://api-sandbox.y.uno/v1/subscriptions/{subscription_id}/payments"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("public-api-key", "<api-key>")
req.Header.Add("private-secret-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://api-sandbox.y.uno/v1/subscriptions/{subscription_id}/payments")
.header("public-api-key", "<api-key>")
.header("private-secret-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.y.uno/v1/subscriptions/{subscription_id}/payments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["public-api-key"] = '<api-key>'
request["private-secret-key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"data": [
{
"id": "00000000-0000-4000-8000-000000000010",
"payment_id": "00000000-0000-4000-8000-000000000011",
"idempotency_key": null,
"status": "SUCCEEDED",
"sub_status": null,
"provider": "PROVIDER_TEST",
"payment_method": {
"id": "00000000-0000-4000-8000-000000000012",
"type": "CARD"
},
"amount": {
"currency": "USD",
"value": 9.99
},
"currency": "USD",
"subtotal": 9.99,
"total": 9.99,
"plan_id": "00000000-0000-4000-8000-000000000001",
"line_items": [
{
"type": "PLAN",
"label": "Intro",
"service_period": {
"start": "2024-04-01T09:00:00Z",
"end": "2024-05-01T09:00:00Z"
},
"amount": {
"currency": "USD",
"value": 9.99
}
}
],
"phase": {
"index": 1,
"name": "Intro",
"type": "TRIAL"
},
"phase_payment": 1,
"billing_cycle": null,
"retry": {
"count": 0,
"forced": false
},
"trace_id": null,
"created_at": "2024-04-01T09:00:00.000000Z",
"updated_at": "2024-04-01T09:00:00.000000Z"
}
],
"pagination": {
"total": 1,
"limit": 20,
"offset": 0,
"has_more": false
}
}{
"code": "SUBSCRIPTION_NOT_FOUND",
"messages": [
"Subscription not found."
]
}