Sha256: 3422d5185d657643272e0b96a911f0d0f695ff3a348671ee07a79fcf3f48f7a8

Contents?: true

Size: 1014 Bytes

Versions: 5

Compression:

Stored size: 1014 Bytes

Contents

module Spree
  class Gateway::AuthorizeNet < Gateway
    preference :login, :string
    preference :password, :string

    def provider_class
      ActiveMerchant::Billing::AuthorizeNetGateway
    end

    def options_with_test_preference
      options_without_test_preference.merge(test: self.preferred_test_mode)
    end
    alias_method_chain :options, :test_preference

    def credit(amount, response_code, refund, gateway_options = {})
      gateway_options[:card_number] = refund[:originator].payment.source.last_digits
      auth_net_gateway.refund(amount, response_code, gateway_options)
    end

    private

    def auth_net_gateway
      @_auth_net_gateway ||= begin
        ActiveMerchant::Billing::Base.gateway_mode = preferred_server.to_sym
        gateway_options = options
        gateway_options[:test_requests] = false # DD: never ever do test requests because just returns transaction_id = 0
        ActiveMerchant::Billing::AuthorizeNetGateway.new(gateway_options)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
solidus_gateway-1.1.1 app/models/spree/gateway/authorize_net.rb
solidus_gateway-1.1.0 app/models/spree/gateway/authorize_net.rb
solidus_gateway-1.0.1 app/models/spree/gateway/authorize_net.rb
solidus_gateway-0.9.0 app/models/spree/gateway/authorize_net.rb
solidus_gateway-1.0.0 app/models/spree/gateway/authorize_net.rb