Class: ActiveMerchant::Billing::AuthorizeNetGateway

Inherits:
Gateway
  • Object
show all
Defined in:
lib/active_merchant/billing/gateways/authorize_net.rb

Constant Summary collapse

API_VERSION =
'3.1'
LIVE_URL =
"https://secure.authorize.net/gateway/transact.dll"
TEST_URL =
"https://test.authorize.net/gateway/transact.dll"
CARD_CODE_ERRORS =
%w( N S )
CARD_CODE_MESSAGES =
{
  "M" => "Card verification number matched",
  "N" => "Card verification number didn't match",
  "P" => "Card verification number was not processed",
  "S" => "Card verification number should be on card but was not indicated",
  "U" => "Issuer was not certified for card verification"
}
AVS_ERRORS =
%w( A E N R W Z )
AVS_MESSAGES =
{
  "A" => "Street address matches billing information, zip/postal code does not",
  "B" => "Address information not provided for address verification check",
  "E" => "Address verification service error",
  "G" => "Non-U.S. card-issuing bank",
  "N" => "Neither street address nor zip/postal match billing information",
  "P" => "Address verification not applicable for this transaction",
  "R" => "Payment gateway was unavailable or timed out",
  "S" => "Address verification service not supported by issuer",
  "U" => "Address information is unavailable",
  "W" => "9-digit zip/postal code matches billing information, street address does not",
  "X" => "Street address and 9-digit zip/postal code matches billing information",
  "Y" => "Street address and 5-digit zip/postal code matches billing information",
  "Z" => "5-digit zip/postal code matches billing information, street address does not",
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Gateway

gateway, supports?, #test?

Methods included from RequiresParameters

#requires!

Methods included from PostsData

#included?, #ssl_post

Constructor Details

#initialize(options = {}) ⇒ AuthorizeNetGateway

Returns a new instance of AuthorizeNetGateway.



47
48
49
50
51
# File 'lib/active_merchant/billing/gateways/authorize_net.rb', line 47

def initialize(options = {})
  requires!(options, :login, :password)
  @options = options
  super
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



45
46
47
# File 'lib/active_merchant/billing/gateways/authorize_net.rb', line 45

def options
  @options
end

#responseObject (readonly)

Returns the value of attribute response.



44
45
46
# File 'lib/active_merchant/billing/gateways/authorize_net.rb', line 44

def response
  @response
end

#urlObject (readonly)

URL



43
44
45
# File 'lib/active_merchant/billing/gateways/authorize_net.rb', line 43

def url
  @url
end

Class Method Details

.supported_cardtypesObject

We support visa and master card



85
86
87
# File 'lib/active_merchant/billing/gateways/authorize_net.rb', line 85

def self.supported_cardtypes
  [:visa, :master, :american_express, :discover]
end

Instance Method Details

#authorize(money, creditcard, options = {}) ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'lib/active_merchant/billing/gateways/authorize_net.rb', line 53

def authorize(money, creditcard, options = {})
  post = {}
  add_invoice(post, options)
  add_creditcard(post, creditcard)        
  add_address(post, options)        
  add_customer_data(post, options)
  
  commit('AUTH_ONLY', money, post)
end

#capture(money, authorization, options = {}) ⇒ Object



73
74
75
76
77
# File 'lib/active_merchant/billing/gateways/authorize_net.rb', line 73

def capture(money, authorization, options = {})
  post = {:trans_id => authorization}
  add_customer_data(post, options)
  commit('PRIOR_AUTH_CAPTURE', money, post)
end

#purchase(money, creditcard, options = {}) ⇒ Object



63
64
65
66
67
68
69
70
71
# File 'lib/active_merchant/billing/gateways/authorize_net.rb', line 63

def purchase(money, creditcard, options = {})
  post = {}
  add_invoice(post, options)
  add_creditcard(post, creditcard)        
  add_address(post, options)   
  add_customer_data(post, options)
       
  commit('AUTH_CAPTURE', money, post)
end

#void(authorization, options = {}) ⇒ Object



79
80
81
82
# File 'lib/active_merchant/billing/gateways/authorize_net.rb', line 79

def void(authorization, options = {})
  post = {:trans_id => authorization}
  commit('VOID', nil, post)
end