class OffsitePayments::Integrations::Directebanking::Helper
Constants
- SIGNATURE_FIELDS
- SIGNATURE_IGNORE_AT_METHOD_CREATION_FIELDS
Public Class Methods
new(order, account, options = {})
click to toggle source
All credentials are mandatory and need to be set
credential1: User ID credential2: Project ID credential3: Project Password (Algorithm: SH1) credential4: Notification
Password (Algorithm: SH1)
Calls superclass method
# File lib/offsite_payments/integrations/directebanking.rb, line 47 def initialize(order, account, options = {}) super add_field('user_variable_0', order) add_field('project_id', options[:credential2]) @project_password = options[:credential3] end
Public Instance Methods
amount=(money)
click to toggle source
Need to format the amount to have 2 decimal places
# File lib/offsite_payments/integrations/directebanking.rb, line 91 def amount=(money) cents = to_cents(money) raise ArgumentError, "amount must be a Money object or an integer" if money.is_a?(String) raise ActionViewHelperError, "amount must be greater than $0.00" if cents.to_i <= 0 add_field mappings[:amount], sprintf("%.2f", cents.to_f/100) end
form_fields()
click to toggle source
# File lib/offsite_payments/integrations/directebanking.rb, line 108 def form_fields @fields.merge('hash' => generate_signature) end
generate_signature()
click to toggle source
# File lib/offsite_payments/integrations/directebanking.rb, line 104 def generate_signature Digest::SHA1.hexdigest(generate_signature_string) end
generate_signature_string()
click to toggle source
# File lib/offsite_payments/integrations/directebanking.rb, line 99 def generate_signature_string # format of signature: user_id|project_id|sender_holder|sender_account_number|sender_bank_code| sender_country_id|amount|currency_id|reason_1|reason_2|user_variable_0|user_variable_1|user_variable_2|user_variable_3|user_variable_4|user_variable_5|project_password SIGNATURE_FIELDS.map {|key| @fields[key.to_s]} * "|" + "|#{@project_password}" end