跳到內容

建立綁卡頁

在 ChatGPT 開啟在 Claude 開啟

POST /checkout-token

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

建立綁卡頁,回傳 id。把消費者導到 https://{merchantId}.oen.tw/checkout/subscription/create/{id} 完成 3D 驗證並綁卡。綁卡頁 10 分鐘內有效。token 只會透過付款通知(purpose 為 token)送給你,導回網址不帶 token,也沒有查詢 API。

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

欄位型別必填說明
merchantIdstring必填你的網域名稱。例如應援頁是 https://ming.oen.tw,就填 ming。必須與 token 所屬的網域相同,不同會回 400 V0001。
範例:ming
successUrlstring (uri) | null必填綁卡成功後導回的網址。不帶 token。
限制:要寫完整網址(含 https://);可以是 null,但欄位一定要有
failureUrlstring (uri) | null必填綁卡失敗或逾時後導回的網址,會加上 payment_error。
限制:同 successUrl。建議不要自帶 ? 參數與 # 片段
customIdstring選填你自訂的資料,會出現在 token 通知裡,方便你對應是哪一位會員。
notestring選填備註。
payerEmailstring (email)選填持卡人 Email。沒帶時消費者要在綁卡頁自行填寫。

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

終端機視窗
curl -X POST "https://payment-api.testing.oen.tw/checkout-token" \
-H "Authorization: Bearer $OEN_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"merchantId": "ming",
"successUrl": "https://shop.example.com/cards/added?member=M001",
"failureUrl": "https://shop.example.com/cards/failed/M001",
"customId": "M001",
"payerEmail": "ming@example.com"
}'
HTTP說明
200建立成功
400參數錯誤或金流未開通
401token 錯誤
欄位型別出現說明
idstring一定有綁卡請求的 id。組綁卡頁網址用,也會出現在 token 通知的 id
{
"code": "S0000",
"data": {
"id": "2HhngP9sVb3mK1xYdQe7Wc0RtUi"
},
"message": ""
}
錯誤碼HTTP什麼時候會發生
V0001400欄位不符規則
V0002400網域的金流服務尚未開通
A0001401token 錯誤

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

完整流程見存卡與後續扣款。