跳到內容

建立預約定期定額

在 ChatGPT 開啟在 Claude 開啟

POST /checkout-schedule

  • 正式環境:https://payment-api.oen.tw/checkout-schedule
  • 測試環境:https://payment-api.testing.oen.tw/checkout-schedule

建立可以指定首期扣款日與扣款間隔的定期定額,回傳 id 與定期定額編號 subscriptionHid。把消費者導到 https://{merchantId}.oen.tw/checkout/schedule/{id}。首期日是今天時,消費者付款當下扣第一期;是未來日期時,消費者只綁卡,到期由應援扣款。結帳頁 5 分鐘內有效。

Header 帶 Authorization: Bearer <token> 與 Content-Type: application/json 。token 的取得方式見驗證與 token。

欄位型別必填說明
merchantIdstring必填你的網域名稱。例如應援頁是 https://ming.oen.tw,就填 ming。必須與 token 所屬的網域相同,不同會回 400 V0001。
範例:ming
amountinteger必填每期金額(新台幣元)。必須等於 productDetails 的合計。
限制:1 以上的整數
範例:1200
currencystring選填幣別。目前只支援新台幣。
可用值:TWD
預設:TWD
numberOfPeriodsinteger選填總期數。不帶就是不限期,直到取消。
限制:2 以上
paymentIntervalinteger選填每幾個月扣款一次。
限制:1 到 12
預設:1
startDatestring | null選填首期扣款日(台北日期)。不帶就是今天。
限制:yyyy/MM/dd;今天到 12 個月內
範例:2026/10/15
orderIdstring必填你的訂單編號。之後可以用用訂單編號查詢找到這筆訂單的所有交易。
限制:不檢查重複。同一個 orderId 可以建立多筆交易
範例:A20260928001
successUrlstring (uri) | null必填付款成功後把消費者導回的網址。導回時不帶任何參數,請在網址裡放自己的訂單編號,例如 https://shop.example.com/thanks?order=A001。導回不代表付款成功,請以付款通知或查詢結果為準。
限制:要寫完整網址(含 https://);可以是 null,但欄位一定要有
failureUrlstring (uri) | null必填付款失敗或逾時後導回的網址,會加上 payment_error 參數,可能的值見錯誤碼一覽。
限制:同 successUrl。建議不要自帶 ? 參數與 # 片段
productDetailsarray必填商品明細,用來開立電子發票與顯示在 CRM。所有品項「數量 × 單價」的合計必須等於 amount,否則回 400 V0001(PRODUCT_AMOUNT_NOT_MATCH)。
productionCode
productDetails[].productionCode
string必填商品代碼
description
productDetails[].description
string必填商品名稱。第一個品項的名稱也會當成交易的商品描述
quantity
productDetails[].quantity
integer必填數量
限制:1 以上的整數
unit
productDetails[].unit
string必填單位,例如「個」「份」
unitPrice
productDetails[].unitPrice
integer必填單價(新台幣元)
userIdstring選填你系統裡的會員編號。
userNamestring條件必填消費者姓名。網域有開通電子發票時必填。
userEmailstring (email)條件必填消費者 Email。網域有開通電子發票時必填,發票通知會寄到這裡。
invoiceInfoobject選填電子發票資訊。網域有開通電子發票時才有作用;沒帶時開立雲端發票。
invoiceType
invoiceInfo.invoiceType
string必填cloud:雲端發票;company:公司戶(打統編)
可用值:cloud、company
carrierType
invoiceInfo.carrierType
string雲端發票必填載具類型:3J0002 手機條碼、CQ0001 自然人憑證、空字串為會員載具
可用值:3J0002、CQ0001、
carrierId
invoiceInfo.carrierId
string選填載具號碼。手機條碼格式為 / 加 7 碼,會即時向財政部驗證;自然人憑證為 2 個英文字母加 14 碼數字
buyerIdentifier
invoiceInfo.buyerIdentifier
string公司戶必填買受人統一編號,8 碼,會檢查檢查碼
buyerName
invoiceInfo.buyerName
string選填買受人名稱
email
invoiceInfo.email
string (email)選填發票通知 Email
customIdstring選填你自訂的資料,會原樣出現在付款通知與查詢結果中。
notestring選填備註。
use3dboolean選填是否走 3D 驗證。網域被設定為一律 3D 時會強制開啟。
預設:false

範例一律打測試環境。把 OEN_API_TOKEN 設成測試環境 CRM 產生的 token。

終端機視窗
curl -X POST "https://payment-api.testing.oen.tw/checkout-schedule" \
-H "Authorization: Bearer $OEN_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"merchantId": "ming",
"amount": 1500,
"numberOfPeriods": 4,
"paymentInterval": 3,
"startDate": "2026/10/15",
"orderId": "SUB20260928002",
"successUrl": "https://shop.example.com/subscribe/success?order=SUB20260928002",
"failureUrl": "https://shop.example.com/subscribe/failure/SUB20260928002",
"userName": "王小明",
"userEmail": "ming@example.com",
"productDetails": [
{
"productionCode": "BOX-Q",
"description": "季訂閱禮盒",
"quantity": 1,
"unit": "盒",
"unitPrice": 1500
}
]
}'
HTTP說明
200建立成功
400參數錯誤
401token 錯誤
欄位型別出現說明
idstring一定有定期定額的內部 id,組結帳頁網址用
subscriptionHidstring一定有定期定額編號,S 開頭共 17 字元。查詢與取消定期定額都用這個
{
"code": "S0000",
"data": {
"id": "2HhnfZ1kqRmA7cX0TQwq8vBn3Ls",
"subscriptionHid": "S20260928EF56GH78"
},
"message": ""
}
錯誤碼HTTP什麼時候會發生
V0001400欄位不符規則;首期日早於今天(START_DATE_MUST_GREATER_THAN_TODAY)或超過 12 個月(START_DATE_MUST_LESS_THAN_12_MONTHS);品項合計不等於金額
K0001400個人身分商家的交易金額超過風控門檻
A0001401token 錯誤

完整清單與處理方式見錯誤碼一覽。

跟「建立定期定額」的差別見定期定額。