Class: AbtainBilling::Billing::Integrations::Quickpay::Notification

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

Constant Summary collapse

MD5_CHECK_FIELDS =
[
  :msgtype, :ordernumber, :amount, :currency, :time, :state,
  :chstat, :chstatmsg, :qpstat, :qpstatmsg, :merchant, :merchantemail,
  :transaction, :cardtype, :cardnumber, :testmode
]

Instance Attribute Summary

Attributes inherited from Notification

#params, #raw

Instance Method Summary collapse

Methods inherited from Notification

#amount, #empty!, #initialize, #valid_sender?

Constructor Details

This class inherits a constructor from AbtainBilling::Billing::Integrations::Notification

Instance Method Details

#acknowledgeObject

Quickpay doesn’t do acknowledgements of callback notifications Instead it uses and MD5 hash of all parameters



67
68
69
# File 'lib/abtain_billing/billing/integrations/quickpay/notification.rb', line 67

def acknowledge      
  generate_md5check == params['md5check']
end

#complete?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/abtain_billing/billing/integrations/quickpay/notification.rb', line 8

def complete?
  status == '000'
end

#currencyObject



40
41
42
# File 'lib/abtain_billing/billing/integrations/quickpay/notification.rb', line 40

def currency
  params['currency']
end

#generate_md5checkObject



61
62
63
# File 'lib/abtain_billing/billing/integrations/quickpay/notification.rb', line 61

def generate_md5check
  Digest::MD5.hexdigest(generate_md5string)
end

#generate_md5stringObject



57
58
59
# File 'lib/abtain_billing/billing/integrations/quickpay/notification.rb', line 57

def generate_md5string
  MD5_CHECK_FIELDS.map { |key| params[key.to_s] } * "" + @options[:md5secret]
end

#grossObject



24
25
26
# File 'lib/abtain_billing/billing/integrations/quickpay/notification.rb', line 24

def gross
  "%.2f" % (gross_cents / 100.0)
end

#gross_centsObject



28
29
30
# File 'lib/abtain_billing/billing/integrations/quickpay/notification.rb', line 28

def gross_cents
  params['amount'].to_i
end

#item_idObject



12
13
14
# File 'lib/abtain_billing/billing/integrations/quickpay/notification.rb', line 12

def item_id
  params['ordernumber']
end

#received_atObject



20
21
22
# File 'lib/abtain_billing/billing/integrations/quickpay/notification.rb', line 20

def received_at
  Time.local(*params['time'].scan(/../))
end

#statusObject



36
37
38
# File 'lib/abtain_billing/billing/integrations/quickpay/notification.rb', line 36

def status
  params['qpstat']
end

#test?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/abtain_billing/billing/integrations/quickpay/notification.rb', line 32

def test?
  params['testmode'] == 'Yes'
end

#transaction_idObject



16
17
18
# File 'lib/abtain_billing/billing/integrations/quickpay/notification.rb', line 16

def transaction_id
  params['transaction']
end