Class: AuthorizeNet::XmlTransaction

Inherits:
Transaction show all
Defined in:
lib/authorize_net/xml_transaction.rb

Overview

The ARB transaction class.

Defined Under Namespace

Modules: Gateway, Type

Constant Summary collapse

XML_NAMESPACE =

The XML namespace used by the ARB API.

'AnetApi/xml/v1/schema/AnetApiSchema.xsd'
@@boolean_fields =

Fields to convert to/from booleans.

[]
@@decimal_fields =

Fields to convert to/from BigDecimal.

[]
@@date_fields =

Fields to convert to/from Date.

[]
@@datetime_fields =

Fields to convert to/from DateTime.

[]
@@option_defaults =

The default options for the constructor.

{
  :gateway => :production,
  :verify_ssl => false,
  :reference_id => nil
}

Constants included from TypeConversions

TypeConversions::API_FIELD_PREFIX

Instance Method Summary collapse

Methods inherited from Transaction

#fields, #set_address, #set_customer, #set_fields, #set_shipping_address

Methods included from TypeConversions

#boolean_to_value, #date_to_value, #datetime_to_value, #decimal_to_value, #integer_to_value, #to_external_field, #to_internal_field, #to_param, #value_to_boolean, #value_to_date, #value_to_datetime, #value_to_decimal, #value_to_integer

Constructor Details

#initialize(api_login_id, api_transaction_key, options = {}) ⇒ XmlTransaction

DO NOT USE. Instantiate AuthorizeNet::ARB::Transaction or AuthorizeNet::CIM::Transaction instead.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/authorize_net/xml_transaction.rb', line 65

def initialize(, api_transaction_key, options = {})
  super()
  @api_login_id = 
  @api_transaction_key = api_transaction_key
  
  @response ||= nil
  @type ||= nil
  
  options = @@option_defaults.merge(options)
  @verify_ssl = options[:verify_ssl]
  @reference_id = options[:reference_id]
  case options[:gateway]
  when :sandbox, :test
    @gateway = Gateway::TEST
  when :production, :live
    @gateway = Gateway::LIVE
  else
    @gateway = options[:gateway]
  end
end

Instance Method Details

#has_response?Boolean

Checks to see if the transaction has a response (meaning it has been submitted to the gateway). Returns TRUE if a response is present, FALSE otherwise.

Returns:

  • (Boolean)


94
95
96
# File 'lib/authorize_net/xml_transaction.rb', line 94

def has_response?
  !@response.nil?
end

#responseObject

Retrieve the response object (or Nil if transaction hasn’t been sent to the gateway).



99
100
101
# File 'lib/authorize_net/xml_transaction.rb', line 99

def response
  @response
end

#runObject

Submits the transaction to the gateway for processing. Returns a response object. If the transaction has already been run, it will return nil.



105
106
107
# File 'lib/authorize_net/xml_transaction.rb', line 105

def run
  make_request
end

#test?Boolean

Checks if the transaction has been configured for the sandbox or not. Return FALSE if the transaction is running against the production, TRUE otherwise.

Returns:

  • (Boolean)


88
89
90
# File 'lib/authorize_net/xml_transaction.rb', line 88

def test?
  @gateway != Gateway::LIVE
end

#xmlObject

Returns a deep-copy of the XML object sent to the payment gateway. Or nil if there was no XML payload.



110
111
112
# File 'lib/authorize_net/xml_transaction.rb', line 110

def xml
  @xml
end