class AuthorizeNet::AIM::Transaction
The AIM
transaction class. Handles building the transaction payload and transmitting it to the gateway.
Public Class Methods
Constructs an AIM
transaction. You can use the new AIM
transaction object to issue a request to the payment gateway and parse the response into a new AuthorizeNet::AIM::Response
object.
api_login_id
-
Your API login ID, as a string.
api_transaction_key
-
Your API transaction key, as a string.
options
-
A hash of options. See below for values.
Options
transaction_type
-
The type of transaction to perform. Defaults to AuthorizeNet::Type::AUTHORIZE_AND_CAPTURE. This value is only used if run is called directly.
gateway
-
The gateway to submit the transaction to. Can be a URL string, an AuthorizeNet::AIM::Transaction::Gateway constant, or one of the convenience symbols :sandbox, :test, :card_present_test, :card_present_live, :card_present_sandbox, :card_present_production, :production, or :live (:test is an alias for :sandbox, :card_present_test is an alias for :card_present_sandbox, :card_present_production is an alias for :card_present_live, and :live is an alias for :production).
test
-
A boolean indicating if the transaction should be run in test mode or not (defaults to false).
allow_split
-
A boolean indicating if split transactions should be allowed (defaults to false).
delimiter
-
A single character (as a string) that will be used to delimit the response from the gateway. Defaults to ‘,’.
encapsulation_character
-
A single character (as a string) that will be used to encapsulate each field in the response from the gateway. Defaults to nil.
verify_ssl
-
A boolean indicating if the SSL certificate of the
gateway
should be verified. Defaults to false. device_type
-
A constant from DeviceType indicating the type of POS device used in a card present transaction. Defaults to DeviceType::UNKNOWN.
market_type
-
A constant from MarketType indicating your industry. Used for card present transactions. Defaults to MarketType::RETAIL.
AuthorizeNet::KeyValueTransaction::new
# File lib/authorize_net/aim/transaction.rb, line 45 def initialize(api_login_id, api_transaction_key, options = {}) super() options = @@option_defaults.merge(options) @api_login_id = api_login_id @api_transaction_key = api_transaction_key @test_mode = options[:test] @response ||= nil @delimiter = options[:delimiter] @type = options[:transaction_type] @cp_version = nil case options[:gateway] when :sandbox, :test @gateway = Gateway::TEST when :production, :live @gateway = Gateway::LIVE when :card_present_live, :card_present_production @gateway = Gateway::CARD_PRESENT_LIVE @cp_version = '1.0' when :card_present_test, :card_present_sandbox @gateway = Gateway::CARD_PRESENT_TEST @cp_version = '1.0' else @gateway = options[:gateway] end @allow_split_transaction = options[:allow_split] @encapsulation_character = options[:encapsulation_character] @verify_ssl = options[:verify_ssl] @market_type = options[:market_type] @device_type = options[:device_type] end
Public Instance Methods
Returns the current card present API version that we are adhering to.
# File lib/authorize_net/aim/transaction.rb, line 127 def cp_version @cp_version end
Returns the current delimiter we are using to parse the fields returned by the gateway.
# File lib/authorize_net/aim/transaction.rb, line 111 def delimiter @delimiter end
Sets the delimiter used to parse the response from the gateway.
# File lib/authorize_net/aim/transaction.rb, line 116 def delimiter=(delimiter) @delimiter = delimiter end
Returns the current encapsulation character unless there is none, in which case Nil is returned.
# File lib/authorize_net/aim/transaction.rb, line 89 def encapsulation_character @encapsulation_character end
Returns the gateway to be used for this transaction.
# File lib/authorize_net/aim/transaction.rb, line 94 def gateway @gateway end
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.
# File lib/authorize_net/aim/transaction.rb, line 100 def has_response? !@response.nil? end
Retrieve the response object (or Nil if transaction hasn’t been sent to the gateway).
# File lib/authorize_net/aim/transaction.rb, line 105 def response @response end
Submits the transaction to the gateway for processing. Returns a response object. If the transaction has already been run, it will return nil.
# File lib/authorize_net/aim/transaction.rb, line 122 def run make_request end
Returns TRUE if split transactions are allowed, FALSE otherwise.
# File lib/authorize_net/aim/transaction.rb, line 84 def split_transaction_allowed? !!@allow_split_transaction end
Checks if the transaction has been configured for test mode or not. Return TRUE if the transaction is a test transaction, FALSE otherwise. All transactions run against the sandbox are considered test transactions.
AuthorizeNet::KeyValueTransaction#test?
# File lib/authorize_net/aim/transaction.rb, line 79 def test? super || @gateway == Gateway::TEST end