Class: ActiveMerchant::Billing::Integrations::Allpay::Notification
- Inherits:
-
Notification
- Object
- Notification
- ActiveMerchant::Billing::Integrations::Allpay::Notification
- Defined in:
- lib/active_merchant/billing/integrations/allpay/notification.rb
Instance Method Summary collapse
- #check_mac_value ⇒ Object
- #checksum_ok? ⇒ Boolean
-
#initialize(params) ⇒ Notification
constructor
A new instance of Notification.
- #merchant_id ⇒ Object
- #merchant_trade_no ⇒ Object
- #params=(params) ⇒ Object
- #payment_date ⇒ Object
- #payment_type ⇒ Object
- #payment_type_charge_fee ⇒ Object
- #rtn_code ⇒ Object
- #rtn_msg ⇒ Object
- #simulate_paid ⇒ Object
- #status ⇒ Object
- #trade_amt ⇒ Object
- #trade_date ⇒ Object
- #trade_no ⇒ Object
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_value ⇒ Object
88 89 90 |
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 88 def check_mac_value @params['CheckMacValue'] end |
#checksum_ok? ⇒ 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_id ⇒ Object
48 49 50 |
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 48 def merchant_id @params['MerchantID'] end |
#merchant_trade_no ⇒ Object
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_date ⇒ Object
68 69 70 |
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 68 def payment_date @params['PaymentDate'] end |
#payment_type ⇒ Object
72 73 74 |
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 72 def payment_type @params['PaymentType'] end |
#payment_type_charge_fee ⇒ Object
76 77 78 |
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 76 def payment_type_charge_fee @params['PaymentTypeChargeFee'] end |
#rtn_code ⇒ Object
44 45 46 |
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 44 def rtn_code @params['RtnCode'] end |
#rtn_msg ⇒ Object
56 57 58 |
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 56 def rtn_msg @params['RtnMsg'] end |
#simulate_paid ⇒ Object
84 85 86 |
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 84 def simulate_paid @params['SimulatePaid'] end |
#status ⇒ Object
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_amt ⇒ Object
64 65 66 |
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 64 def trade_amt @params['TradeAmt'] end |
#trade_date ⇒ Object
80 81 82 |
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 80 def trade_date @params['TradeDate'] end |
#trade_no ⇒ Object
60 61 62 |
# File 'lib/active_merchant/billing/integrations/allpay/notification.rb', line 60 def trade_no @params['TradeNo'] end |