Class: ActiveMerchant::Billing::Integrations::Allpay::Notification

Inherits:
Notification
  • Object
show all
Defined in:
lib/active_merchant/billing/integrations/allpay/notification.rb

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Notification

Returns a new instance of Notification.



34
35
36
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 34

def initialize(params)
  self.params = params
end

Instance Method Details

#check_mac_valueObject



88
89
90
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 88

def check_mac_value
  @params['CheckMacValue']
end

#checksum_ok?Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 17

def checksum_ok?
  checksum = @params.delete('CheckMacValue')

  @params.delete('controller')
  @params.delete('action')

  raw_data = @params.map do |x, y|
    "#{x}=#{y}"
  end.join('&')

  hash_raw_data = "HashKey=#{ActiveMerchant::Billing::Integrations::Allpay.hash_key}&#{raw_data}&HashIV=#{ActiveMerchant::Billing::Integrations::Allpay.hash_iv}"

  url_endcode_data = (CGI::escape(hash_raw_data)).downcase

  (Digest::MD5.hexdigest(url_endcode_data) == checksum.to_s.downcase)
end

#merchant_idObject



48
49
50
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 48

def merchant_id
  @params['MerchantID']
end

#merchant_trade_noObject



52
53
54
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 52

def merchant_trade_no
  @params['MerchantTradeNo']
end

#params=(params) ⇒ Object



38
39
40
41
42
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 38

def params=(params)
  @params = params.inject({}) do |buffer, (name, value)|
    buffer.merge(name.to_s => value)
  end
end

#payment_dateObject



68
69
70
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 68

def payment_date
  @params['PaymentDate']
end

#payment_typeObject



72
73
74
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 72

def payment_type
  @params['PaymentType']
end

#payment_type_charge_feeObject



76
77
78
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 76

def payment_type_charge_fee
  @params['PaymentTypeChargeFee']
end

#rtn_codeObject



44
45
46
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 44

def rtn_code
  @params['RtnCode']
end

#rtn_msgObject



56
57
58
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 56

def rtn_msg
  @params['RtnMsg']
end

#simulate_paidObject



84
85
86
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 84

def simulate_paid
  @params['SimulatePaid']
end

#statusObject



9
10
11
12
13
14
15
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 9

def status
  if rtn_code == '1'
    true
  else
    false
  end
end

#trade_amtObject



64
65
66
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 64

def trade_amt
  @params['TradeAmt']
end

#trade_dateObject



80
81
82
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 80

def trade_date
  @params['TradeDate']
end

#trade_noObject



60
61
62
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 60

def trade_no
  @params['TradeNo']
end