何時使用
以下情境適合使用本頁 API:- 建立顧客資料(Customer)與訂閱產品(Product)
- 以已綁定的支付令牌(Token)建立訂閱(Subscription)
- 更新 / 取消訂閱
- 查詢訂閱狀態、下次扣款時間、扣款訂單列表
- 對失敗扣款執行手動重試(Charge)
1. 建立 Customer
Endpoint and Method
Create Customer
此
customer_id 會在後續建立 Subscription 時被引用,用於將訂閱關聯到指定顧客。
Request Parameters
Response
回傳customer_id。
2. 更新 Customer
Endpoint and Method
Update Customer
customer_id 為主鍵)。
Request Parameters
Response
回傳更新筆數。3. 查詢 Customer
Endpoint and Method
Query Customer
Request Parameters
Response
回傳符合條件的 Customer 列表。4. 刪除 Customer
Endpoint and Method
Delete Customer
Request Parameters
Response
回傳被刪除的 ID 與結果。5. 建立 Product
Endpoint and Method
Create Product
Request Parameters
在 Sandbox 環境中,
interval 支援 minutes、hours 以方便測試。Response
回傳新建立的product_id。
6. 更新 Product
Endpoint and Method
Update Product
Request Parameters
Response
回傳更新筆數。7. 查詢 Product
Endpoint and Method
Query Product
Request Parameters
Response
回傳符合條件的 Product 列表。8. 刪除 Product
Endpoint and Method
Delete Product
Request Parameters
Response
回傳被刪除的 ID 與結果。9. 建立 Subscription
建立 Subscription 前,請先確保已完成以下資源:
customer_idproduct_idtoken_id
Endpoint and Method
Create Subscription
start_time(若提供)及產品週期自動排程扣款。
Request Parameters
products 內部參數
Example Request
Create Subscription Request
Response Parameters(data)
10. 更新 Subscription
Endpoint and Method
Update Subscription
Request Parameters
Response Parameters(data)
11. 查詢 Subscription
Endpoint and Method
Query Subscription
Request Parameters
Response Parameters(data)
12. 取消 Subscription
Endpoint and Method
Cancel Subscription
Request Parameters
13. 查詢訂閱扣款訂單列表
Endpoint and Method
List Billing Orders
Request Parameters
Response Parameters(data)
14. 手動重試扣款(Charge)
Endpoint and Method
Retry Charge
Request Parameters
本 API 只適用於狀態為
UNPAID、INCOMPLETE、PAST_DUE 的訂閱扣款事件。- 若重試日期在下一次扣款日前,訂閱會繼續按計劃進行
- 若重試日期在下一次扣款日之後,訂閱可能被取消(依平台規則為準)
- 若重試失敗,狀態保持不變
整合注意事項與最佳實務
- 建議商戶在後台儲存並關聯:
customer_id、product_id、subscription_id、subscription_order_id - 請以 Webhook(定期付款通知)作為扣款成功/失敗的主要事件來源,並搭配查詢 API 做補單
- Sandbox 可使用更短週期(minutes / hours)驗證重試與狀態流轉,再切換至正式週期(monthly / yearly)

