Sha256: 8bd30d13fa5188a941dbd383695ed280f656c2c3ab00b5e268d8d5638f5234b0

Contents?: true

Size: 772 Bytes

Versions: 33

Compression:

Stored size: 772 Bytes

Contents

require "openssl"

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    module Integrations #:nodoc:
      module Dwolla
        module Common
          def verify_signature(checkoutId, amount, notification_signature, secret)
            if secret.nil?
              raise ArgumentError, "You need to provide the Application secret as the option :credential3 to verify that the notification originated from Dwolla"
            end

            expected_signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA1.new, secret, "%s&%.2f" % [checkoutId, amount])

            if notification_signature != expected_signature
              raise StandardError, "Dwolla signature verification failed."
            end
          end
        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/common.rb
tanga_activemerchant-1.38.0.4 lib/active_merchant/billing/integrations/dwolla/common.rb
tanga_activemerchant-1.38.0.3 lib/active_merchant/billing/integrations/dwolla/common.rb
tanga_activemerchant-1.38.0.2 lib/active_merchant/billing/integrations/dwolla/common.rb
tanga_activemerchant-1.38.0.1 lib/active_merchant/billing/integrations/dwolla/common.rb
tanga_activemerchant-1.38.0 lib/active_merchant/billing/integrations/dwolla/common.rb
tanga_activemerchant-1.37.0 lib/active_merchant/billing/integrations/dwolla/common.rb
activemerchant-1.43.3 lib/active_merchant/billing/integrations/dwolla/common.rb
activemerchant-1.43.1 lib/active_merchant/billing/integrations/dwolla/common.rb
activemerchant-1.43.0 lib/active_merchant/billing/integrations/dwolla/common.rb
activemerchant-1.42.9 lib/active_merchant/billing/integrations/dwolla/common.rb
activemerchant-1.42.8 lib/active_merchant/billing/integrations/dwolla/common.rb
activemerchant-1.42.7 lib/active_merchant/billing/integrations/dwolla/common.rb
activemerchant-1.42.6 lib/active_merchant/billing/integrations/dwolla/common.rb
activemerchant-1.42.5 lib/active_merchant/billing/integrations/dwolla/common.rb
activemerchant-1.42.4 lib/active_merchant/billing/integrations/dwolla/common.rb
activemerchant-1.42.3 lib/active_merchant/billing/integrations/dwolla/common.rb
activemerchant-1.42.2 lib/active_merchant/billing/integrations/dwolla/common.rb
activemerchant-1.42.1 lib/active_merchant/billing/integrations/dwolla/common.rb
activemerchant-1.42.0 lib/active_merchant/billing/integrations/dwolla/common.rb