Class: Gateway::AuthorizeNet

Inherits:
Gateway
  • Object
show all
Defined in:
app/models/spree/gateway/authorize_net.rb

Instance Method Summary collapse

Instance Method Details

#cancel(response_code) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'app/models/spree/gateway/authorize_net.rb', line 18

def cancel(response_code)
  provider
  # From: http://community.developer.authorize.net/t5/The-Authorize-Net-Developer-Blog/Refunds-in-Retail-A-user-friendly-approach-using-AIM/ba-p/9848
  # DD: if unsettled, void needed
  response = provider.void(response_code)
  # DD: if settled, credit/refund needed (CAN'T DO WITHOUT CREDIT CARD ON AUTH.NET)
  #response = provider.refund(response_code) unless response.success?

  response
end

#credit(amount, response_code, refund, gateway_options = {}) ⇒ Object



29
30
31
32
# File 'app/models/spree/gateway/authorize_net.rb', line 29

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

#optionsObject



11
12
13
14
15
16
# File 'app/models/spree/gateway/authorize_net.rb', line 11

def options
  if !['live','test'].include?(self.preferred_server)
    raise "You must set the 'server' preference in your payment method (Gateway::AuthorizeNet) to either 'live' or 'test'"
  end
  super().merge(test: (self.preferred_server != "live"))
end

#provider_classObject



7
8
9
# File 'app/models/spree/gateway/authorize_net.rb', line 7

def provider_class
  ActiveMerchant::Billing::AuthorizeNetGateway
end