更新訂閱
curl --request PUT \
--url https://api.zangsho.com/v1/subscriptions/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"plan_name": "<string>",
"mrr": "<string>",
"current_period_start": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://api.zangsho.com/v1/subscriptions/{id}"
payload = {
"plan_name": "<string>",
"mrr": "<string>",
"current_period_start": "2023-11-07T05:31:56Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
plan_name: '<string>',
mrr: '<string>',
current_period_start: '2023-11-07T05:31:56Z'
})
};
fetch('https://api.zangsho.com/v1/subscriptions/{id}', 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.zangsho.com/v1/subscriptions/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'plan_name' => '<string>',
'mrr' => '<string>',
'current_period_start' => '2023-11-07T05:31:56Z'
]),
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.zangsho.com/v1/subscriptions/{id}"
payload := strings.NewReader("{\n \"plan_name\": \"<string>\",\n \"mrr\": \"<string>\",\n \"current_period_start\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.zangsho.com/v1/subscriptions/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"plan_name\": \"<string>\",\n \"mrr\": \"<string>\",\n \"current_period_start\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zangsho.com/v1/subscriptions/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"plan_name\": \"<string>\",\n \"mrr\": \"<string>\",\n \"current_period_start\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 123,
"customer_id": 123,
"plan_name": "<string>",
"mrr": "<string>",
"billing_cycle": "<string>",
"started_at": "2023-11-07T05:31:56Z",
"current_period_start": "2023-11-07T05:31:56Z",
"cancelled_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
}{
"message": "Unauthenticated."
}{
"message": "Resource not found"
}訂閱 Subscriptions
更新訂閱
更新訂閱資料。
自動事件觸發
根據 MRR 變化自動產生事件:
- MRR 增加 → 升級事件 (
upgrade) - MRR 減少 → 降級事件 (
downgrade)
PUT
/
subscriptions
/
{id}
更新訂閱
curl --request PUT \
--url https://api.zangsho.com/v1/subscriptions/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"plan_name": "<string>",
"mrr": "<string>",
"current_period_start": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://api.zangsho.com/v1/subscriptions/{id}"
payload = {
"plan_name": "<string>",
"mrr": "<string>",
"current_period_start": "2023-11-07T05:31:56Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
plan_name: '<string>',
mrr: '<string>',
current_period_start: '2023-11-07T05:31:56Z'
})
};
fetch('https://api.zangsho.com/v1/subscriptions/{id}', 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.zangsho.com/v1/subscriptions/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'plan_name' => '<string>',
'mrr' => '<string>',
'current_period_start' => '2023-11-07T05:31:56Z'
]),
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.zangsho.com/v1/subscriptions/{id}"
payload := strings.NewReader("{\n \"plan_name\": \"<string>\",\n \"mrr\": \"<string>\",\n \"current_period_start\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("PUT", 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.put("https://api.zangsho.com/v1/subscriptions/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"plan_name\": \"<string>\",\n \"mrr\": \"<string>\",\n \"current_period_start\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zangsho.com/v1/subscriptions/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"plan_name\": \"<string>\",\n \"mrr\": \"<string>\",\n \"current_period_start\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": 123,
"customer_id": 123,
"plan_name": "<string>",
"mrr": "<string>",
"billing_cycle": "<string>",
"started_at": "2023-11-07T05:31:56Z",
"current_period_start": "2023-11-07T05:31:56Z",
"cancelled_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
}{
"message": "Unauthenticated."
}{
"message": "Resource not found"
}Authorizations
使用 Laravel Sanctum Token 進行認證。
Token 可在商家後台的「API 設定」頁面取得。
Path Parameters
Body
application/json
Response
訂閱更新成功
Show child attributes
Show child attributes
⌘I