Sha256: 8ac1bed5107022503dbfc2c71ce5f1bad7cd0892c2276c3bb6c1747d5637d696

Contents?: true

Size: 1.38 KB

Versions: 33

Compression:

Stored size: 1.38 KB

Contents

require "openssl"

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    module Integrations #:nodoc:
      module Dwolla
        class Helper < ActiveMerchant::Billing::Integrations::Helper
          def initialize(order, account, options = {})
            super
            add_field('name', 'Store Purchase')

            timestamp = Time.now.to_i.to_s

            if ActiveMerchant::Billing::Base.integration_mode == :test || options[:test]
              add_field('test', 'true')
              # timestamp used for test signature generation:
              timestamp = "1370726016"
            end

            add_field('timestamp', timestamp)
            add_field('allowFundingSources', 'true')

            key = options[:credential2].to_s
            secret = options[:credential3].to_s
            orderid = order.to_s
            signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA1.new, secret, "#{key}&#{timestamp}&#{orderid}")
            add_field('signature', signature)
          end

          mapping :account, 'destinationid'
          mapping :credential2, 'key'
          mapping :notify_url, 'callback'
          mapping :return_url, 'redirect'
          mapping :description, 'description'
          mapping :amount, 'amount'
          mapping :tax, 'tax'
          mapping :shipping, 'shipping'
          mapping :order, 'orderid'
        end
      end
    end
  end
end

Version data entries

33 entries across 33 versions & 2 rubygems

Version Path
tanga_activemerchant-1.38.0.5 lib/active_merchant/billing/integrations/dwolla/helper.rb
tanga_activemerchant-1.38.0.4 lib/active_merchant/billing/integrations/dwolla/helper.rb
tanga_activemerchant-1.38.0.3 lib/active_merchant/billing/integrations/dwolla/helper.rb
tanga_activemerchant-1.38.0.2 lib/active_merchant/billing/integrations/dwolla/helper.rb
tanga_activemerchant-1.38.0.1 lib/active_merchant/billing/integrations/dwolla/helper.rb
tanga_activemerchant-1.38.0 lib/active_merchant/billing/integrations/dwolla/helper.rb
tanga_activemerchant-1.37.0 lib/active_merchant/billing/integrations/dwolla/helper.rb
activemerchant-1.43.3 lib/active_merchant/billing/integrations/dwolla/helper.rb
activemerchant-1.43.1 lib/active_merchant/billing/integrations/dwolla/helper.rb
activemerchant-1.43.0 lib/active_merchant/billing/integrations/dwolla/helper.rb
activemerchant-1.42.9 lib/active_merchant/billing/integrations/dwolla/helper.rb
activemerchant-1.42.8 lib/active_merchant/billing/integrations/dwolla/helper.rb
activemerchant-1.42.7 lib/active_merchant/billing/integrations/dwolla/helper.rb
activemerchant-1.42.6 lib/active_merchant/billing/integrations/dwolla/helper.rb
activemerchant-1.42.5 lib/active_merchant/billing/integrations/dwolla/helper.rb
activemerchant-1.42.4 lib/active_merchant/billing/integrations/dwolla/helper.rb
activemerchant-1.42.3 lib/active_merchant/billing/integrations/dwolla/helper.rb
activemerchant-1.42.2 lib/active_merchant/billing/integrations/dwolla/helper.rb
activemerchant-1.42.1 lib/active_merchant/billing/integrations/dwolla/helper.rb
activemerchant-1.42.0 lib/active_merchant/billing/integrations/dwolla/helper.rb