Class: OffsitePayments::Integrations::Dotpay::Notification
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, #iso_currency, #valid_sender?
Instance Method Details
#acknowledge(authcode = nil) ⇒ Object
157
158
159
|
# File 'lib/offsite_payments/integrations/dotpay.rb', line 157
def acknowledge(authcode = nil)
generate_signature.to_s == md5.to_s
end
|
#complete? ⇒ Boolean
86
87
88
|
# File 'lib/offsite_payments/integrations/dotpay.rb', line 86
def complete?
status == 'OK' && %w(2 4 5).include?(t_status)
end
|
#currency ⇒ Object
90
91
92
|
# File 'lib/offsite_payments/integrations/dotpay.rb', line 90
def currency
orginal_amount.split(' ')[1]
end
|
#generate_signature ⇒ Object
153
154
155
|
# File 'lib/offsite_payments/integrations/dotpay.rb', line 153
def generate_signature
Digest::MD5.hexdigest(generate_signature_string)
end
|
#generate_signature_string ⇒ Object
149
150
151
|
# File 'lib/offsite_payments/integrations/dotpay.rb', line 149
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.
95
96
97
|
# File 'lib/offsite_payments/integrations/dotpay.rb', line 95
def gross
params['amount']
end
|
#pin=(value) ⇒ Object
99
100
101
|
# File 'lib/offsite_payments/integrations/dotpay.rb', line 99
def pin=(value)
@options[:pin] = value
end
|
#status ⇒ Object
103
104
105
|
# File 'lib/offsite_payments/integrations/dotpay.rb', line 103
def status
params['status']
end
|
#test? ⇒ Boolean
107
108
109
|
# File 'lib/offsite_payments/integrations/dotpay.rb', line 107
def test?
params['t_id'].match('.*-TST\d+') ? true : false
end
|