Skip to main content
本頁記錄定期付款可使用的 API 端點。開始前請先閱讀「定期付款概覽」,了解整體流程與必要條件(例如:Customer、Product、Token、Subscription 的關係,以及扣款失敗後的處理策略)。

何時使用

以下情境適合使用本頁 API:
  • 建立顧客資料(Customer)與訂閱產品(Product)
  • 以已綁定的支付令牌(Token)建立訂閱(Subscription)
  • 更新 / 取消訂閱
  • 查詢訂閱狀態、下次扣款時間、扣款訂單列表
  • 對失敗扣款執行手動重試(Charge)

1. 建立 Customer

Endpoint and Method

Create Customer
建立一筆新的顧客資料(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
依條件查詢 Customer 列表(支援分頁)。

Request Parameters

Response

回傳符合條件的 Customer 列表。

4. 刪除 Customer

Endpoint and Method

Delete Customer
刪除指定 Customer。此操作無法還原。

Request Parameters

Response

回傳被刪除的 ID 與結果。

5. 建立 Product

Endpoint and Method

Create Product
建立可被訂閱引用的產品(Product)。通常代表一個固定計費方案(例如月費、年費)。

Request Parameters

在 Sandbox 環境中,interval 支援 minuteshours 以方便測試。

Response

回傳新建立的 product_id

6. 更新 Product

Endpoint and Method

Update Product
更新產品資料(不影響既有已建立的扣款紀錄,但可能影響後續新扣款計算方式,實際行為以系統設定為準)。

Request Parameters

Response

回傳更新筆數。

7. 查詢 Product

Endpoint and Method

Query Product
依條件查詢 Product 列表(支援分頁)。

Request Parameters

Response

回傳符合條件的 Product 列表。

8. 刪除 Product

Endpoint and Method

Delete Product
刪除指定 Product(需確保該產品未被任何 Subscription 使用中)。

Request Parameters

Response

回傳被刪除的 ID 與結果。

9. 建立 Subscription

建立 Subscription 前,請先確保已完成以下資源:
  • customer_id
  • product_id
  • token_id

Endpoint and Method

Create Subscription
建立新的訂閱計劃。Subscription 建立後,系統會依 start_time(若提供)及產品週期自動排程扣款。

Request Parameters

products 內部參數

Example Request

Create Subscription Request

Response Parameters(data)


10. 更新 Subscription

Endpoint and Method

Update Subscription
更新訂閱配置(例如:扣款次數、產品、token、開始時間)。

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 只適用於狀態為 UNPAIDINCOMPLETEPAST_DUE 的訂閱扣款事件。
  • 若重試日期在下一次扣款日前,訂閱會繼續按計劃進行
  • 若重試日期在下一次扣款日之後,訂閱可能被取消(依平台規則為準)
  • 若重試失敗,狀態保持不變

整合注意事項與最佳實務

  • 建議商戶在後台儲存並關聯:customer_idproduct_idsubscription_idsubscription_order_id
  • 請以 Webhook(定期付款通知)作為扣款成功/失敗的主要事件來源,並搭配查詢 API 做補單
  • Sandbox 可使用更短週期(minutes / hours)驗證重試與狀態流轉,再切換至正式週期(monthly / yearly)