Skip to content

信用卡取消授權

Cellvin Chung edited this page Feb 26, 2020 · 1 revision

版本:1.0

執行條件

  • 交易須為授權成功交易
  • 必須在發動請款之前執行(預設自交易授權日起算 21 個日曆日晚上九點前)
  • 完成取消授權的交易,將會於取消授權後,返還藍新金流商店及持卡人信用卡授權額度
Newebpay::CancelAuth::Request.new(price: "訂單金額", order_number: "訂單編號/交易序號")
參數 說明 必填 預設
number_type 單號類別

1 使用訂單編號
2 使用金流交易序號
1
order_number 訂單編號/交易序號

number_type1,請輸入商店訂單編號
number_type2,請輸入藍新金流交易序號。
V
price 取消授權金額 V
merchant_id 商店代號 config/initializers/newebpay.rb 中的 merchant_id
  • 詳細說明參見原文件,部分參數名稱與預設值與原文件不同。
  • 原文件其他的必填欄位會自動產生,不需處理。
  • 原文件的 NotifyURL 已整合至config/initializers/newebpay.rb中的cancel_auth_notify_callback,不需再指定路徑。

背景回傳

# config/initializers/newebpay.rb
config.cancel_auth_notify_callback do |newebpay_response|
  if newebpay_response.success?
    Order.find_by(order_number: newebpay_response.merchant_order_no)
  else
    Rails.logger.info "Newebpay Cancel Auth Not Succeed: #{newebpay_response.status}: #{newebpay_response.message} (#{newebpay_response.to_json})"
  end
end
  • 查詢是否成功:newebpay_response.success?
  • 來源是否為藍新:newebpay_response.valid?
  • 參見原文件第五、六點,可直接使用Result參數,原參數名稱underscore後為method
    • 例:newebpay_response.merchant_id, newebpay_response.trade_no
  • [即時處理]與[批次處理]兩種模式皆回傳至 cancel_auth_notify_callback,參數皆相同。