Skip to content

DDPay Cancel Order

Description

取消 DDPay 訂單。行為依訂單狀態而異:

  • 未結帳/未付款:使訂單失效,無法再被結帳或付款。
  • 已付款完成:取消並退還所有相關交易;若有線上支付金流,連動退款至原支付方式;若有點數/票券,一併執行逆向流程(各平台支援程度不同)。

Resource

POST /v1/payment/ddpay/orders/{merchant_order_id}/cancel

Authorization

採用 OAuth 2.0 Bearer Token,詳細使用流程請參考 Auth Login

Path Parameters

Name Type Description
merchant_order_id string 我方訂單編號

Request Body

無(空 body)

Response Body Parameters

Name Type Description
status string 固定為 done
orderId string|undefined DDPay 訂單編號;有退款時帶入
amount integer|undefined 退款金額(元);訂單未付款時不帶
apiResponse object|undefined DDPay 退款明細(含付款服務、退款金額等);訂單未付款時不帶

Response Example — 未付款訂單,直接失效

{ "status": "done" }

Response Example — 已付款訂單,連動退款(LINE Pay)

{
    "status": "done",
    "orderId": "2406181725451zepbW",
    "amount": 480,
    "apiResponse": {
        "success": true,
        "paymentService": "linepay",
        "refundAmount": 480
    }
}

Error Response

DDPay 取消失敗時(如退款失敗),回應 HTTP 4xx,並包裝為統一錯誤格式回傳前端。

HTTP Status Description
400 請求參數錯誤或格式不符、訂單不存在
401 Authorization token 無效或過期
500 伺服器內部錯誤
{ "message": "錯誤說明文字" }