创建订阅
curl --request POST \
--url https://api.qbank.cl/platform/v1/subscriptions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"stored_card_id": "5f0f2c9e-6a4b-4c7e-9a1d-2b3c4d5e6f70",
"amount": "45.00",
"interval": "monthly",
"description": "Monthly plan",
"idempotency_key": "plan-cust1042-monthly"
}
'import requests
url = "https://api.qbank.cl/platform/v1/subscriptions"
payload = {
"stored_card_id": "5f0f2c9e-6a4b-4c7e-9a1d-2b3c4d5e6f70",
"amount": "45.00",
"interval": "monthly",
"description": "Monthly plan",
"idempotency_key": "plan-cust1042-monthly"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
stored_card_id: '5f0f2c9e-6a4b-4c7e-9a1d-2b3c4d5e6f70',
amount: '45.00',
interval: 'monthly',
description: 'Monthly plan',
idempotency_key: 'plan-cust1042-monthly'
})
};
fetch('https://api.qbank.cl/platform/v1/subscriptions', 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.qbank.cl/platform/v1/subscriptions",
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([
'stored_card_id' => '5f0f2c9e-6a4b-4c7e-9a1d-2b3c4d5e6f70',
'amount' => '45.00',
'interval' => 'monthly',
'description' => 'Monthly plan',
'idempotency_key' => 'plan-cust1042-monthly'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.qbank.cl/platform/v1/subscriptions"
payload := strings.NewReader("{\n \"stored_card_id\": \"5f0f2c9e-6a4b-4c7e-9a1d-2b3c4d5e6f70\",\n \"amount\": \"45.00\",\n \"interval\": \"monthly\",\n \"description\": \"Monthly plan\",\n \"idempotency_key\": \"plan-cust1042-monthly\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.qbank.cl/platform/v1/subscriptions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"stored_card_id\": \"5f0f2c9e-6a4b-4c7e-9a1d-2b3c4d5e6f70\",\n \"amount\": \"45.00\",\n \"interval\": \"monthly\",\n \"description\": \"Monthly plan\",\n \"idempotency_key\": \"plan-cust1042-monthly\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.qbank.cl/platform/v1/subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"stored_card_id\": \"5f0f2c9e-6a4b-4c7e-9a1d-2b3c4d5e6f70\",\n \"amount\": \"45.00\",\n \"interval\": \"monthly\",\n \"description\": \"Monthly plan\",\n \"idempotency_key\": \"plan-cust1042-monthly\"\n}"
response = http.request(request)
puts response.read_body{
"subscription_id": "7a1c9e2d-3b4f-5061-8273-9a4b5c6d7e8f",
"account_id": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"stored_card_id": "5f0f2c9e-6a4b-4c7e-9a1d-2b3c4d5e6f70",
"payer_reference": "customer-1042",
"amount": "45.00",
"currency": "BOB",
"description": "Monthly plan",
"interval": "monthly",
"status": "active",
"period": 1,
"next_charge_at": "2026-08-20T18:00:00Z",
"created_at": "2026-07-20T18:00:00Z"
}{
"subscription_id": "7a1c9e2d-3b4f-5061-8273-9a4b5c6d7e8f",
"account_id": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"stored_card_id": "5f0f2c9e-6a4b-4c7e-9a1d-2b3c4d5e6f70",
"payer_reference": "customer-1042",
"amount": "45.00",
"currency": "BOB",
"description": "Monthly plan",
"interval": "monthly",
"status": "active",
"period": 1,
"next_charge_at": "2026-08-20T18:00:00Z",
"created_at": "2026-07-20T18:00:00Z"
}{
"error": "invalid_json",
"message": "request body is not valid JSON: unknown field"
}{
"error": "unauthorized",
"message": "invalid or missing credentials"
}{
"error": "not_found",
"message": "resource not found"
}对已保存卡片的循环扣款(平台为你执行排期)。除非 start_at 为将来时间(试用),首个周期在创建时同步扣款。每笔扣款都是普通卡 payin(通过 payin_credited 入账);被拒后每天重试最多 3 次,随后订阅变为 past_due。必须提供 idempotency_key(重试返回原订阅)。需要付款人的一张有效已存卡。
POST
/
v1
/
subscriptions
创建订阅
curl --request POST \
--url https://api.qbank.cl/platform/v1/subscriptions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"stored_card_id": "5f0f2c9e-6a4b-4c7e-9a1d-2b3c4d5e6f70",
"amount": "45.00",
"interval": "monthly",
"description": "Monthly plan",
"idempotency_key": "plan-cust1042-monthly"
}
'import requests
url = "https://api.qbank.cl/platform/v1/subscriptions"
payload = {
"stored_card_id": "5f0f2c9e-6a4b-4c7e-9a1d-2b3c4d5e6f70",
"amount": "45.00",
"interval": "monthly",
"description": "Monthly plan",
"idempotency_key": "plan-cust1042-monthly"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
stored_card_id: '5f0f2c9e-6a4b-4c7e-9a1d-2b3c4d5e6f70',
amount: '45.00',
interval: 'monthly',
description: 'Monthly plan',
idempotency_key: 'plan-cust1042-monthly'
})
};
fetch('https://api.qbank.cl/platform/v1/subscriptions', 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.qbank.cl/platform/v1/subscriptions",
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([
'stored_card_id' => '5f0f2c9e-6a4b-4c7e-9a1d-2b3c4d5e6f70',
'amount' => '45.00',
'interval' => 'monthly',
'description' => 'Monthly plan',
'idempotency_key' => 'plan-cust1042-monthly'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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.qbank.cl/platform/v1/subscriptions"
payload := strings.NewReader("{\n \"stored_card_id\": \"5f0f2c9e-6a4b-4c7e-9a1d-2b3c4d5e6f70\",\n \"amount\": \"45.00\",\n \"interval\": \"monthly\",\n \"description\": \"Monthly plan\",\n \"idempotency_key\": \"plan-cust1042-monthly\"\n}")
req, _ := http.NewRequest("POST", url, payload)
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.qbank.cl/platform/v1/subscriptions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"stored_card_id\": \"5f0f2c9e-6a4b-4c7e-9a1d-2b3c4d5e6f70\",\n \"amount\": \"45.00\",\n \"interval\": \"monthly\",\n \"description\": \"Monthly plan\",\n \"idempotency_key\": \"plan-cust1042-monthly\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.qbank.cl/platform/v1/subscriptions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"stored_card_id\": \"5f0f2c9e-6a4b-4c7e-9a1d-2b3c4d5e6f70\",\n \"amount\": \"45.00\",\n \"interval\": \"monthly\",\n \"description\": \"Monthly plan\",\n \"idempotency_key\": \"plan-cust1042-monthly\"\n}"
response = http.request(request)
puts response.read_body{
"subscription_id": "7a1c9e2d-3b4f-5061-8273-9a4b5c6d7e8f",
"account_id": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"stored_card_id": "5f0f2c9e-6a4b-4c7e-9a1d-2b3c4d5e6f70",
"payer_reference": "customer-1042",
"amount": "45.00",
"currency": "BOB",
"description": "Monthly plan",
"interval": "monthly",
"status": "active",
"period": 1,
"next_charge_at": "2026-08-20T18:00:00Z",
"created_at": "2026-07-20T18:00:00Z"
}{
"subscription_id": "7a1c9e2d-3b4f-5061-8273-9a4b5c6d7e8f",
"account_id": "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d",
"stored_card_id": "5f0f2c9e-6a4b-4c7e-9a1d-2b3c4d5e6f70",
"payer_reference": "customer-1042",
"amount": "45.00",
"currency": "BOB",
"description": "Monthly plan",
"interval": "monthly",
"status": "active",
"period": 1,
"next_charge_at": "2026-08-20T18:00:00Z",
"created_at": "2026-07-20T18:00:00Z"
}{
"error": "invalid_json",
"message": "request body is not valid JSON: unknown field"
}{
"error": "unauthorized",
"message": "invalid or missing credentials"
}{
"error": "not_found",
"message": "resource not found"
}授权
会话 JWT(来自注册/登录)或 API key(pk_...)。
也接受 X-API-Key: <token> 作为替代请求头。
请求体
application/json
响应
幂等重放 — 原订阅。
可用选项:
daily, weekly, monthly, yearly 可用选项:
active, paused, past_due, canceled 最后修改于 2026年8月22日
⌘I