Class: ActiveMerchant::Billing::Integrations::Dotpay::Notification
- Inherits:
-
Notification
- Object
- Notification
- ActiveMerchant::Billing::Integrations::Dotpay::Notification
show all
- Defined in:
- lib/active_merchant/billing/integrations/dotpay/notification.rb
Constant Summary
collapse
- PAYMENT_HOOK_FIELDS =
[
:id,
:control,
:t_id,
:orginal_amount,
:email,
:service,
:code,
:username,
:password,
:t_status,
:description,
:md5,
:p_info,
:p_email,
:t_date
]
- PAYMENT_HOOK_SIGNATURE_FIELDS =
[
:id,
:control,
:t_id,
:amount,
:email,
:service,
:code,
:username,
:password,
:t_status
]
Instance Attribute Summary
Attributes inherited from Notification
#params, #raw
Instance Method Summary
collapse
#amount, #empty!, #gross_cents, #initialize, #valid_sender?
Instance Method Details
#acknowledge(authcode = nil) ⇒ Object
79
80
81
|
# File 'lib/active_merchant/billing/integrations/dotpay/notification.rb', line 79
def acknowledge(authcode = nil)
generate_signature.to_s == md5.to_s
end
|
#complete? ⇒ Boolean
8
9
10
|
# File 'lib/active_merchant/billing/integrations/dotpay/notification.rb', line 8
def complete?
status == 'OK' && %w(2 4 5).include?(t_status)
end
|
#currency ⇒ Object
12
13
14
|
# File 'lib/active_merchant/billing/integrations/dotpay/notification.rb', line 12
def currency
orginal_amount.split(' ')[1]
end
|
#generate_signature ⇒ Object
75
76
77
|
# File 'lib/active_merchant/billing/integrations/dotpay/notification.rb', line 75
def generate_signature
Digest::MD5.hexdigest(generate_signature_string)
end
|
#generate_signature_string ⇒ Object
71
72
73
|
# File 'lib/active_merchant/billing/integrations/dotpay/notification.rb', line 71
def generate_signature_string
"#{@options[:pin]}:" + PAYMENT_HOOK_SIGNATURE_FIELDS.map {|key| params[key.to_s]} * ":"
end
|
#gross ⇒ Object
the money amount we received in X.2 decimal.
17
18
19
|
# File 'lib/active_merchant/billing/integrations/dotpay/notification.rb', line 17
def gross
params['amount']
end
|
#pin=(value) ⇒ Object
21
22
23
|
# File 'lib/active_merchant/billing/integrations/dotpay/notification.rb', line 21
def pin=(value)
@options[:pin] = value
end
|
#status ⇒ Object
25
26
27
|
# File 'lib/active_merchant/billing/integrations/dotpay/notification.rb', line 25
def status
params['status']
end
|
#test? ⇒ Boolean
29
30
31
|
# File 'lib/active_merchant/billing/integrations/dotpay/notification.rb', line 29
def test?
params['t_id'].match('.*-TST\d+') ? true : false
end
|