ActiveMerchant::Billing::Integrations::Helper
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)
# File lib/active_merchant/billing/integrations/directebanking/helper.rb, line 13 def initialize(order, account, options = {}) super add_field('user_variable_0', order) add_field('project_id', options[:credential2]) @project_password = options[:credential3] end
Need to format the amount to have 2 decimal places
# File lib/active_merchant/billing/integrations/directebanking/helper.rb, line 57 def amount=(money) cents = money.respond_to?(:cents) ? money.cents : money if money.is_a?(String) or cents.to_i <= 0 raise ArgumentError, 'money amount must be either a Money object or a positive integer in cents.' end add_field mappings[:amount], sprintf("%.2f", cents.to_f/100) end
# File lib/active_merchant/billing/integrations/directebanking/helper.rb, line 74 def form_fields @fields.merge('hash' => generate_signature) end
# File lib/active_merchant/billing/integrations/directebanking/helper.rb, line 70 def generate_signature Digest::SHA1.hexdigest(generate_signature_string) end
# File lib/active_merchant/billing/integrations/directebanking/helper.rb, line 65 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
Generated with the Darkfish Rdoc Generator 2.