class OffsitePayments::Integrations::Ecpay::Notification
Public Instance Methods
acknowledge()
click to toggle source
TODO 使用查詢功能實作 acknowledge Ecpay
沒有遠端驗證功能, 而以 checksum_ok? 代替
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 19 def acknowledge checksum_ok? end
bank_code()
click to toggle source
for ATM
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 129 def bank_code @params['BankCode'] end
barcode1()
click to toggle source
for BARCODE
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 156 def barcode1 @params['Barcode1'] end
barcode2()
click to toggle source
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 160 def barcode2 @params['Barcode2'] end
barcode3()
click to toggle source
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 164 def barcode3 @params['Barcode3'] end
card4no()
click to toggle source
for CreditCard
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 142 def card4no @params['card4no'] end
check_mac_value()
click to toggle source
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 124 def check_mac_value @params['CheckMacValue'] end
checksum_ok?()
click to toggle source
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 54 def checksum_ok? params_copy = @params.clone checksum = params_copy.delete('CheckMacValue') # 把 params 轉成 query string 前必須先依照 hash key 做 sort # 依照英文字母排序,由 A 到 Z 且大小寫不敏感 raw_data = params_copy.sort_by{ |k,v| k.downcase }.map do |x, y| "#{x}=#{y}" end.join('&') hash_raw_data = "HashKey=#{hash_key}&#{raw_data}&HashIV=#{hash_iv}" url_encode_data = OffsitePayments::Integrations::Ecpay::Helper.url_encode(hash_raw_data) url_encode_data.downcase! (Digest::MD5.hexdigest(url_encode_data) == checksum.to_s.downcase) end
complete?()
click to toggle source
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 23 def complete? case @params['RtnCode'] when '1' #付款成功 true when '2' # ATM 取號成功 true when '10100073' # CVS 或 BARCODE 取號成功 true when '800' #貨到付款訂單建立成功 true else false end end
currency()
click to toggle source
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 151 def currency 'TWD' end
expire_date()
click to toggle source
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 137 def expire_date @params['ExpireDate'] end
gross()
click to toggle source
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 100 def gross ::Money.new(@params['TradeAmt'].to_i * 100, currency) end
hash_iv()
click to toggle source
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 50 def hash_iv @hash_iv || OffsitePayments::Integrations::Ecpay.hash_iv end
hash_iv=(iv)
click to toggle source
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 42 def hash_iv=(iv) @hash_iv = iv end
hash_key()
click to toggle source
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 46 def hash_key @hash_key || OffsitePayments::Integrations::Ecpay.hash_key end
hash_key=(key)
click to toggle source
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 38 def hash_key=(key) @hash_key = key end
merchant_id()
click to toggle source
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 77 def merchant_id @params['MerchantID'] end
merchant_trade_no()
click to toggle source
廠商交易編號
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 82 def merchant_trade_no @params['MerchantTradeNo'] end
Also aliased as: item_id
payment_date()
click to toggle source
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 104 def payment_date @params['PaymentDate'] end
payment_no()
click to toggle source
for CVS
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 147 def payment_no @params['PaymentNo'] end
payment_type()
click to toggle source
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 108 def payment_type @params['PaymentType'] end
payment_type_charge_fee()
click to toggle source
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 112 def payment_type_charge_fee @params['PaymentTypeChargeFee'] end
rtn_code()
click to toggle source
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 73 def rtn_code @params['RtnCode'] end
rtn_msg()
click to toggle source
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 87 def rtn_msg @params['RtnMsg'] end
simulate_paid()
click to toggle source
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 120 def simulate_paid @params['SimulatePaid'] end
status()
click to toggle source
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 8 def status if rtn_code == '1' true else false end end
trade_amt()
click to toggle source
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 97 def trade_amt @params['TradeAmt'] end
trade_date()
click to toggle source
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 116 def trade_date @params['TradeDate'] end
trade_no()
click to toggle source
EcPay 的交易編號
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 92 def trade_no @params['TradeNo'] end
Also aliased as: transaction_id
v_account()
click to toggle source
# File lib/offsite_payments/integrations/ecpay/notification.rb, line 133 def v_account @params['vAccount'] end