class OffsitePayments::Integrations::Allpay::Notification
Public Instance Methods
acknowledge()
click to toggle source
TODO 使用查詢功能實作 acknowledge Allpay
沒有遠端驗證功能, 而以 checksum_ok? 代替
# File lib/offsite_payments/integrations/allpay.rb, line 187 def acknowledge checksum_ok? end
bank_code()
click to toggle source
for ATM
# File lib/offsite_payments/integrations/allpay.rb, line 281 def bank_code @params['BankCode'] end
barcode1()
click to toggle source
for BARCODE
# File lib/offsite_payments/integrations/allpay.rb, line 303 def barcode1 @params['Barcode1'] end
barcode2()
click to toggle source
# File lib/offsite_payments/integrations/allpay.rb, line 307 def barcode2 @params['Barcode2'] end
barcode3()
click to toggle source
# File lib/offsite_payments/integrations/allpay.rb, line 311 def barcode3 @params['Barcode3'] end
check_mac_value()
click to toggle source
# File lib/offsite_payments/integrations/allpay.rb, line 276 def check_mac_value @params['CheckMacValue'] end
checksum_ok?()
click to toggle source
# File lib/offsite_payments/integrations/allpay.rb, line 206 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=#{OffsitePayments::Integrations::Allpay.hash_key}&#{raw_data}&HashIV=#{OffsitePayments::Integrations::Allpay.hash_iv}" url_endcode_data = OffsitePayments::Integrations::Allpay::Helper.url_encode(hash_raw_data) url_endcode_data.downcase! (Digest::MD5.hexdigest(url_endcode_data) == checksum.to_s.downcase) end
complete?()
click to toggle source
# File lib/offsite_payments/integrations/allpay.rb, line 191 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/allpay.rb, line 298 def currency 'TWD' end
expire_date()
click to toggle source
# File lib/offsite_payments/integrations/allpay.rb, line 289 def expire_date @params['ExpireDate'] end
gross()
click to toggle source
# File lib/offsite_payments/integrations/allpay.rb, line 252 def gross ::Money.new(@params['TradeAmt'].to_i * 100, currency) end
merchant_id()
click to toggle source
# File lib/offsite_payments/integrations/allpay.rb, line 229 def merchant_id @params['MerchantID'] end
merchant_trade_no()
click to toggle source
廠商交易編號
# File lib/offsite_payments/integrations/allpay.rb, line 234 def merchant_trade_no @params['MerchantTradeNo'] end
Also aliased as: item_id
payment_date()
click to toggle source
# File lib/offsite_payments/integrations/allpay.rb, line 256 def payment_date @params['PaymentDate'] end
payment_no()
click to toggle source
for CVS
# File lib/offsite_payments/integrations/allpay.rb, line 294 def payment_no @params['PaymentNo'] end
payment_type()
click to toggle source
# File lib/offsite_payments/integrations/allpay.rb, line 260 def payment_type @params['PaymentType'] end
payment_type_charge_fee()
click to toggle source
# File lib/offsite_payments/integrations/allpay.rb, line 264 def payment_type_charge_fee @params['PaymentTypeChargeFee'] end
rtn_code()
click to toggle source
# File lib/offsite_payments/integrations/allpay.rb, line 225 def rtn_code @params['RtnCode'] end
rtn_msg()
click to toggle source
# File lib/offsite_payments/integrations/allpay.rb, line 239 def rtn_msg @params['RtnMsg'] end
simulate_paid()
click to toggle source
# File lib/offsite_payments/integrations/allpay.rb, line 272 def simulate_paid @params['SimulatePaid'] end
status()
click to toggle source
# File lib/offsite_payments/integrations/allpay.rb, line 176 def status if rtn_code == '1' true else false end end
trade_amt()
click to toggle source
# File lib/offsite_payments/integrations/allpay.rb, line 249 def trade_amt @params['TradeAmt'] end
trade_date()
click to toggle source
# File lib/offsite_payments/integrations/allpay.rb, line 268 def trade_date @params['TradeDate'] end
trade_no()
click to toggle source
AllPay 的交易編號
# File lib/offsite_payments/integrations/allpay.rb, line 244 def trade_no @params['TradeNo'] end
Also aliased as: transaction_id
v_account()
click to toggle source
# File lib/offsite_payments/integrations/allpay.rb, line 285 def v_account @params['vAccount'] end