Sha256: c2d59af6e337cad73bfe43cb929abb073e9826b26804c17a7857f6143bdf9444

Contents?: true

Size: 1.63 KB

Versions: 58

Compression:

Stored size: 1.63 KB

Contents

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    module Integrations #:nodoc:
      module Epay
        class Helper < ActiveMerchant::Billing::Integrations::Helper

          def initialize(order, merchantnumber, options = {})
            super
						add_field('windowstate', 3)
            add_field('language', '0')
            add_field('orderid', format_order_number(order))
						@fields = Hash[@fields.sort]
          end
              
          def md5secret(value)
            @md5secret = value
          end
          
          def form_fields
            @fields.merge('hash' => generate_md5hash)
          end
            
          def generate_md5string
						@fields.sort.each.map { |key, value| key != 'hash' ? value.to_s : ''} * "" + @md5secret
          end
          
          def generate_md5hash
            Digest::MD5.hexdigest(generate_md5string)
          end

          # Limited to 20 digits max
          def format_order_number(number)
            number.to_s.gsub(/[^\w_]/, '').rjust(4, "0")[0...20]
          end

          mapping :account, 'merchantnumber'
          mapping :language, 'language'
          mapping :amount, 'amount'
          mapping :currency, 'currency'
          mapping :return_url, 'accepturl'
          mapping :cancel_return_url, 'cancelurl'
          mapping :notify_url, 'callbackurl'
					mapping :autocapture, 'instantcapture'
          mapping :description, 'description'
					mapping :credential3, 'md5secret'
          mapping :customer, ''
          mapping :billing_address, {}
          mapping :tax, ''
          mapping :shipping, ''
        
				end
      end
    end
  end
end

Version data entries

58 entries across 58 versions & 5 rubygems

Version Path
activemerchant-1.41.0 lib/active_merchant/billing/integrations/epay/helper.rb
activemerchant-1.40.0 lib/active_merchant/billing/integrations/epay/helper.rb
activemerchant-1.39.2 lib/active_merchant/billing/integrations/epay/helper.rb
activemerchant-1.39.1 lib/active_merchant/billing/integrations/epay/helper.rb
activemerchant-1.39.0 lib/active_merchant/billing/integrations/epay/helper.rb
activemerchant-1.38.1 lib/active_merchant/billing/integrations/epay/helper.rb
activemerchant-1.38.0 lib/active_merchant/billing/integrations/epay/helper.rb
activemerchant-1.37.0 lib/active_merchant/billing/integrations/epay/helper.rb
activemerchant-1.36.0 lib/active_merchant/billing/integrations/epay/helper.rb
activemerchant-1.35.0 lib/active_merchant/billing/integrations/epay/helper.rb
activemerchant-1.35.1 lib/active_merchant/billing/integrations/epay/helper.rb
activemerchant-1.34.1 lib/active_merchant/billing/integrations/epay/helper.rb
activemerchant-1.34.0 lib/active_merchant/billing/integrations/epay/helper.rb
activemerchant-1.33.0 lib/active_merchant/billing/integrations/epay/helper.rb
activemerchant-1.32.1 lib/active_merchant/billing/integrations/epay/helper.rb
activemerchant-1.32.0 lib/active_merchant/billing/integrations/epay/helper.rb
activemerchant-1.31.1 lib/active_merchant/billing/integrations/epay/helper.rb
activemerchant-1.31.0 lib/active_merchant/billing/integrations/epay/helper.rb
activemerchant-1.30.0 lib/active_merchant/billing/integrations/epay/helper.rb
jelaniharris-activemerchant-1.29.2 lib/active_merchant/billing/integrations/epay/helper.rb