Skip to content

捐款平台

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

請先申請藍新金流捐款平台服務

版本:1.0

完成 config/initializers/newebpay.rb 中的 donation_notify_callback 設定

# view
<%= newebpay_donation_pay_button "顯示文字", "捐款連結", order_number: "捐款單號", description: "捐款說明", price: "金額",
class: 'btn btn-success', id: 'donation', data: {disable_with: 'paying'} %>
參數 說明 必填 type 預設
order_number 捐款單號

限英、數、_,上限 20 字。
同商店中不可重複。
V String
description 捐款說明

上限 50 字。
V String
price 金額 V Integer
payment_methods 付款方式

:credit 信用卡
:webatm WEB ATM
:vacc ATM 轉帳
:cvs 超商代碼
:barcode 超商條碼
V Array of Symbols
merchant_id 商店代號 String config/initializers/newebpay.rb 中的 merchant_id
return_url 完成捐款返回收款單位網址

若不設定,則不顯示返回收款單位頁面按鈕,使用者將停留在藍新金流捐款完成頁面
String
expire_date 捐款有效期限,非即時交易的捐款有效天數

純數字,上限 180。
Integer 7
template_type 使用類型,將依此參數設定顯示捐款支付頁面項目之文字。

donate:捐款
payment:繳款
donate
anonymous 匿名捐款

true 匿名捐款
false 非匿名捐款
template_typepayment時,則固定為非匿名捐款,此參數無作用。
Boolean false
name 姓名/公司名稱

上限 30 字
String
uni_no 身份字號/統編

上限 10 字
String
phone 電話

限數字、-,上限 10 字。
String
email 電子信箱

上限 50 字
String
id_address 戶籍地址

上限 100 字
String
address 通訊地址

上限 100 字
String
receipt_name 收據抬頭

上限 30 字
String
receipt_address 收據地址

上限 100 字
String
  • 詳細說明參見原文件,部分參數名稱與預設值與原文件不同。
  • 原文件其他的必填欄位會自動產生,不需處理。
  • 原文件的 NotifyURL 已整合至config/initializers/newebpay.rb中的donation_notify_callback,不需再指定路徑。

在測試環境中

  • 信用卡卡號請填 4000-2211-1111-1111,到期日及背面三碼任意填寫。
  • WebATM 將立刻完成交易並傳送交易完成資料。
  • ATM 轉帳、超商代碼、超商條碼可至測試後台點"模擬觸發"按鈕,會立刻傳送付款完成資料。

背景回傳

config.donation_notify_callback do |newebpay_response|
   if newebpay_response.success? && newebpay_response.valid?
     Donation.find_by(order_number: newebpay_response.result.merchant_order_no)
          .update_attributes!(paid: true)
   else
     Rails.logger.info "Newebpay Donation Payment Not Succeed: #{newebpay_response.status}: #{newebpay_response.message} (#{newebpay_response.result.to_json})"
   end
 end
  • 付款是否成功:newebpay_response.success?
  • 參見原文件第六點,可直接使用Result參數,原參數名稱underscore後為method
    • 例:newebpay_response.merchant_id, newebpay_response.trade_no