Class: OffsitePayments::Integrations::Directebanking::Notification
- Inherits:
-
Notification
- Object
- Notification
- OffsitePayments::Integrations::Directebanking::Notification
show all
- Defined in:
- lib/offsite_payments/integrations/directebanking.rb
Constant Summary
collapse
- PAYMENT_HOOK_SIGNATURE_FIELDS =
for verifying the signature of the URL parameters
[
:transaction,
:user_id,
:project_id,
:sender_holder,
:sender_account_number,
:sender_bank_code,
:sender_bank_name,
:sender_bank_bic,
:sender_iban,
:sender_country_id,
:recipient_holder,
:recipient_account_number,
:recipient_bank_code,
:recipient_bank_name,
:recipient_bank_bic,
:recipient_iban,
:recipient_country_id,
:international_transaction,
:amount,
:currency_id,
:reason_1,
:reason_2,
:security_criteria,
:user_variable_0,
:user_variable_1,
:user_variable_2,
:user_variable_3,
:user_variable_4,
:user_variable_5,
:created
]
- PAYMENT_HOOK_IGNORE_AT_METHOD_CREATION_FIELDS =
[
:transaction,
:amount,
:currency_id,
:user_variable_0,
:user_variable_1,
:user_variable_2,
:user_variable_3,
:created
]
Instance Attribute Summary
Attributes inherited from Notification
#params, #raw
Instance Method Summary
collapse
#amount, #empty!, #gross_cents, #iso_currency, #valid_sender?
Constructor Details
#initialize(data, options) ⇒ Notification
Returns a new instance of Notification.
123
124
125
126
127
128
|
# File 'lib/offsite_payments/integrations/directebanking.rb', line 123
def initialize(data, options)
if options[:credential4].nil?
raise ArgumentError, "You need to provide the notification password (SH1) as the option :credential4 to verify that the notification originated from Directebanking (Payment Networks AG)"
end
super
end
|
Instance Method Details
#acknowledge(authcode = nil) ⇒ Object
227
228
229
230
|
# File 'lib/offsite_payments/integrations/directebanking.rb', line 227
def acknowledge(authcode = nil)
generate_signature.to_s == params['hash'].to_s
end
|
#complete? ⇒ Boolean
130
131
132
|
# File 'lib/offsite_payments/integrations/directebanking.rb', line 130
def complete?
status == 'Completed'
end
|
#currency ⇒ Object
156
157
158
|
# File 'lib/offsite_payments/integrations/directebanking.rb', line 156
def currency
params['currency_id']
end
|
#generate_signature ⇒ Object
223
224
225
|
# File 'lib/offsite_payments/integrations/directebanking.rb', line 223
def generate_signature
Digest::SHA1.hexdigest(generate_signature_string)
end
|
#generate_signature_string ⇒ Object
218
219
220
221
|
# File 'lib/offsite_payments/integrations/directebanking.rb', line 218
def generate_signature_string
PAYMENT_HOOK_SIGNATURE_FIELDS.map {|key| params[key.to_s]} * "|" + "|#{@options[:credential4]}"
end
|
#gross ⇒ Object
the money amount we received in X.2 decimal.
148
149
150
|
# File 'lib/offsite_payments/integrations/directebanking.rb', line 148
def gross
"%.2f" % params['amount'].to_f
end
|
#item_id ⇒ Object
134
135
136
|
# File 'lib/offsite_payments/integrations/directebanking.rb', line 134
def item_id
params['user_variable_0']
end
|
#received_at ⇒ Object
When was this payment received by the client.
143
144
145
|
# File 'lib/offsite_payments/integrations/directebanking.rb', line 143
def received_at
Time.parse(params['created']) if params['created']
end
|
#status ⇒ Object
152
153
154
|
# File 'lib/offsite_payments/integrations/directebanking.rb', line 152
def status
'Completed'
end
|
#test? ⇒ Boolean
160
161
162
|
# File 'lib/offsite_payments/integrations/directebanking.rb', line 160
def test?
params['sender_bank_name'] == 'Testbank'
end
|
#transaction_id ⇒ Object
138
139
140
|
# File 'lib/offsite_payments/integrations/directebanking.rb', line 138
def transaction_id
params['transaction']
end
|