Class: ActiveMerchant::Billing::Integrations::Quickpay::Notification
- Inherits:
-
Notification
- Object
- Notification
- ActiveMerchant::Billing::Integrations::Quickpay::Notification
show all
- Defined in:
- lib/active_merchant/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
#amount, #empty!, #initialize, #valid_sender?
Instance Method Details
#acknowledge ⇒ Object
Quickpay doesn’t do acknowledgements of callback notifications Instead it uses and MD5 hash of all parameters
67
68
69
|
# File 'lib/active_merchant/billing/integrations/quickpay/notification.rb', line 67
def acknowledge
generate_md5check == params['md5check']
end
|
#complete? ⇒ Boolean
8
9
10
|
# File 'lib/active_merchant/billing/integrations/quickpay/notification.rb', line 8
def complete?
status == '000'
end
|
#currency ⇒ Object
40
41
42
|
# File 'lib/active_merchant/billing/integrations/quickpay/notification.rb', line 40
def currency
params['currency']
end
|
#generate_md5check ⇒ Object
61
62
63
|
# File 'lib/active_merchant/billing/integrations/quickpay/notification.rb', line 61
def generate_md5check
Digest::MD5.hexdigest(generate_md5string)
end
|
#generate_md5string ⇒ Object
57
58
59
|
# File 'lib/active_merchant/billing/integrations/quickpay/notification.rb', line 57
def generate_md5string
MD5_CHECK_FIELDS.map { |key| params[key.to_s] } * "" + @options[:md5secret]
end
|
#gross ⇒ Object
24
25
26
|
# File 'lib/active_merchant/billing/integrations/quickpay/notification.rb', line 24
def gross
"%.2f" % (gross_cents / 100.0)
end
|
#gross_cents ⇒ Object
28
29
30
|
# File 'lib/active_merchant/billing/integrations/quickpay/notification.rb', line 28
def gross_cents
params['amount'].to_i
end
|
#item_id ⇒ Object
12
13
14
|
# File 'lib/active_merchant/billing/integrations/quickpay/notification.rb', line 12
def item_id
params['ordernumber']
end
|
#received_at ⇒ Object
20
21
22
|
# File 'lib/active_merchant/billing/integrations/quickpay/notification.rb', line 20
def received_at
Time.local(*params['time'].scan(/../))
end
|
#status ⇒ Object
36
37
38
|
# File 'lib/active_merchant/billing/integrations/quickpay/notification.rb', line 36
def status
params['qpstat']
end
|
#test? ⇒ Boolean
32
33
34
|
# File 'lib/active_merchant/billing/integrations/quickpay/notification.rb', line 32
def test?
params['testmode'] == 'Yes'
end
|
#transaction_id ⇒ Object
16
17
18
|
# File 'lib/active_merchant/billing/integrations/quickpay/notification.rb', line 16
def transaction_id
params['transaction']
end
|