跳到內容

付款通知內容

在 ChatGPT 開啟在 Claude 開啟

付款通知的處理方式、重送規則與回查做法,請先看付款通知(webhook)。這一頁列出每一種通知的欄位。

  • POST 到你在 CRM 設定的「交易資料回傳網址位置」。
  • Header 只有 Content-Type: application/json。沒有簽章,也沒有事件編號。
  • 用 body 的 purpose 分辨是哪一種通知。
purpose 什麼時候送 預設會送嗎
charge 單次付款與定期定額每一期的結果;超商代碼、ATM 取號;LINE Pay 等待確認 會
token 綁卡頁完成或失敗 會
schedule_subscription 預約定期定額在結帳頁完成或失敗 會
refund 退款建立、完成或取消 要請應援開啟
subscription_cancelled 定期定額被取消(API 或 CRM) 要請應援開啟
subscription_retry 定期定額扣款失敗後,已排定重扣或重扣次數用完 要請應援開啟

refund、subscription_cancelled、subscription_retry 三種要請應援在後台開啟「Webhook 新版事件」才會送出。

單次付款、定期定額每一期的結果。同一筆交易可能收到多則,例如超商代碼先送取號(charging),繳費後再送 charged。

欄位型別出現說明
purposestring一定有charge
idstring一定有交易的內部 id。用它呼叫 GET /transactions/{id} 回查
transactionIdstring一定有同 id
transactionHidstring一定有交易編號(P 開頭)
merchantIdstring一定有你的網域名稱
orderIdstring可能沒有你的訂單編號
actionstring可能沒有onetime 或 subscription
statusstring一定有交易狀態:charging、charged、claimed、authorized、failed 等
successboolean可能沒有只在最終結果才有:status 不是 failed 時為 true。取號、等待確認(charging)時沒有這個欄位
paymentMethodstring可能沒有card、applePay、linePay、cvs、atm
amountnumber可能沒有金額
currencystring可能沒有幣別,小寫,例如 twd
paymentInfostring | object可能沒有信用卡:卡號末四碼字串(Apple Pay 的付款通知可能不帶 paymentInfo);超商:{ cvsName, code, expiredAt };ATM:{ bankName, bankCode, account, expiredAt };LINE Pay:LINE Pay 交易編號
authCodestring可能沒有授權碼
customIdstring可能沒有你帶入的自訂資料
productDetailsarray可能沒有建立交易時的商品明細
userPhonestring可能沒有消費者在結帳頁填的手機
createdAtstring可能沒有交易建立時間,不是通知送出的時間
paidAtstring可能沒有付款完成時間
messagestring可能沒有失敗原因。超商代碼、ATM、LINE Pay 逾期時是 PAYMENT_EXPIRED;3D 驗證開始後 10 分鐘沒完成是 3DS_ABANDONED
subscriptionIdstring可能沒有定期定額編號(S 開頭),定期定額才有
periodinteger可能沒有定期定額的第幾期
numberOfPeriodsinteger可能沒有定期定額總期數
isRetryboolean可能沒有定期定額:這次是否為失敗後的重新扣款
failureCodestring可能沒有定期定額扣款失敗的原因:invalid_card_number、invalid_cvv、expired_card、exceeds_credit_limit、payment_refused、duplicate_payment、charge_failed
scheduleStatusstring可能沒有定期定額狀態:pending、trialing、active、retrying、error、cancelled、completed
nextChargeAtstring可能沒有定期定額下次扣款時間。請以查詢定期定額明細為準

範例

{
"purpose": "charge",
"action": "onetime",
"merchantId": "ming",
"orderId": "A20260928001",
"id": "2HhndgEquCbDzC5OyVxWSGZmd2l",
"transactionId": "2HhndgEquCbDzC5OyVxWSGZmd2l",
"transactionHid": "P20260928AB12CD34",
"status": "charged",
"success": true,
"paymentMethod": "card",
"amount": 1200,
"currency": "twd",
"paymentInfo": "4242",
"authCode": "831000",
"customId": "cart-8812",
"createdAt": "2026-09-28T02:40:25.502Z",
"paidAt": "2026-09-28T02:41:03.118Z",
"productDetails": [
{
"productionCode": "SKU-001",
"description": "手沖咖啡豆 200g",
"quantity": 2,
"unit": "包",
"unitPrice": 600
}
],
"message": ""
}

超商代碼取號時(還沒繳費,沒有 success 欄位):

{
"purpose": "charge",
"action": "onetime",
"merchantId": "ming",
"orderId": "A20260928002",
"id": "2HhnkQ3vXy8LpA1cB0dE9fG2hIj",
"transactionId": "2HhnkQ3vXy8LpA1cB0dE9fG2hIj",
"transactionHid": "P20260928UV12WX34",
"status": "charging",
"paymentMethod": "cvs",
"amount": 500,
"currency": "twd",
"paymentInfo": {
"cvsName": "超商代碼繳費",
"code": "XXXXXXXXXXXX",
"expiredAt": "2026-09-30T02:00:00.000Z"
},
"message": ""
}

消費者繳費後,同一個 id 會再收到一則 status: charged、success: true 的通知。逾期未繳則是 status: failed、message: PAYMENT_EXPIRED。

建立綁卡頁後,消費者完成或放棄綁卡時送出。這是拿到 token 的唯一管道。

欄位型別出現說明
purposestring一定有token
idstring一定有建立綁卡頁時回傳的 id
transactionIdstring一定有同 id
merchantIdstring一定有你的網域名稱
successboolean一定有是否綁卡成功
tokenstring可能沒有成功時才有。用來呼叫用 token 扣款,請當成密碼一樣保存
paymentInfostring可能沒有卡號末四碼
customIdstring可能沒有建立綁卡頁時帶的自訂資料
messagestring可能沒有失敗原因。3D 驗證開始後 10 分鐘沒完成是 3DS_ABANDONED

範例

{
"purpose": "token",
"merchantId": "ming",
"id": "2HhngP9sVb3mK1xYdQe7Wc0RtUi",
"transactionId": "2HhngP9sVb3mK1xYdQe7Wc0RtUi",
"success": true,
"token": "2HhnhWm8Qe0sPz4LbXv9KdYt1Ra",
"paymentInfo": "4242",
"customId": "M001",
"message": ""
}

建立預約定期定額後,消費者在結帳頁完成或失敗時送出。之後每一期的扣款結果以 charge 通知送出。

欄位型別出現說明
purposestring一定有schedule_subscription
idstring一定有建立時回傳的 id
subscriptionIdstring一定有定期定額編號(S 開頭)
merchantIdstring一定有你的網域名稱
successboolean一定有是否成功
amountnumber可能沒有每期金額
currencystring可能沒有幣別(小寫)
periodinteger可能沒有已扣期數
numberOfPeriodsinteger可能沒有總期數
intervalinteger可能沒有每幾個月扣一次
startedAtstring可能沒有開始時間
nextChargeAtstring可能沒有下次扣款時間
paymentInfostring可能沒有成功時為卡號末四碼
customIdstring可能沒有你帶入的自訂資料
productDetailsarray可能沒有商品明細
messagestring可能沒有失敗原因

範例

{
"purpose": "schedule_subscription",
"merchantId": "ming",
"id": "2HhnfZ1kqRmA7cX0TQwq8vBn3Ls",
"subscriptionId": "S20260928EF56GH78",
"success": true,
"amount": 1500,
"currency": "twd",
"period": 0,
"numberOfPeriods": 4,
"interval": 3,
"startedAt": "2026-10-15T00:00:00.000Z",
"nextChargeAt": "2026-10-15T01:00:00.000Z",
"paymentInfo": "4242",
"message": ""
}
欄位 說明
purpose refund
id 這則退款事件的 id,每則都不同
refundId 退款單 id
chargeId、chargeHumanId 原交易的內部 id 與交易編號(P 開頭)
amount、origAmount 退款金額、原交易金額
currency 幣別(小寫)
refundStatus refunding(處理中)、refunded(完成)、cancelled(取消)
reason 退款原因
paymentMethod 原交易的付款方式
requestedAt、resolvedAt 申請時間、完成時間
customId 原交易的自訂資料
subscriptionId、period 定期定額交易才有
欄位 說明
purpose subscription_cancelled
subscriptionId 定期定額編號
source 誰取消的:merchant_api(API)或 crm(後台)
reason 取消原因
cancelledAt 取消時間
cancelledFromStatus 取消前的狀態
period、numberOfPeriods 已扣期數、總期數
customId 自訂資料
欄位 說明
purpose subscription_retry
outcome scheduled:已排定重新扣款;exhausted:重扣次數用完,定期定額停止
retryAttemptNumber 第幾次重扣
nextRetryAt 下次重扣時間(scheduled 才有)
failureCode 扣款失敗的原因
chargeId、chargeHumanId 失敗那一期的交易
subscriptionId、period 定期定額編號與期數