Parent

Class/Module Index [+]

Quicksearch

ActiveMerchant::Billing::Integrations::Directebanking::Helper

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)

# 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

Public Instance Methods

amount=(money) click to toggle source

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
form_fields() click to toggle source
# File lib/active_merchant/billing/integrations/directebanking/helper.rb, line 74
def form_fields
  @fields.merge('hash' => generate_signature)
end
generate_signature() click to toggle source
# File lib/active_merchant/billing/integrations/directebanking/helper.rb, line 70
def generate_signature
  Digest::SHA1.hexdigest(generate_signature_string)
end
generate_signature_string() click to toggle source
# 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

[Validate]

Generated with the Darkfish Rdoc Generator 2.