class AuthorizeNet::Transaction
The core, API
agnostic transaction class. You shouldn’t instantiate this one.
Attributes
Returns the current hash of API
fields.
Public Class Methods
DO NOT USE.
# File lib/authorize_net/transaction.rb, line 14 def initialize @fields ||= {} end
Public Instance Methods
Takes an instance of AuthorizeNet::Address and adds it to the transaction.
# File lib/authorize_net/transaction.rb, line 36 def set_address(address) @fields.merge!(address.to_hash) end
Takes an instance of AuthorizeNet::Customer and adds it to the transaction.
# File lib/authorize_net/transaction.rb, line 47 def set_customer(customer) @fields.merge!(customer.to_hash) end
Sets arbitrary API
fields, overwriting existing values if they exist. Takes a hash of key/value pairs, where the keys are the field names without the “x_” prefix. You can set a field to Nil to unset it. If the value is an array, each value in the array will be added. For example, set_fields
({:line_item => [“item1<|>golf balls<|><|>2<|>18.95<|>Y”, “item2<|>golf bag<|>Wilson golf carry bag, red<|>1<|>39.99<|>”]}) would generate two x_line_item fields in the transaction, one for each value in the array.
# File lib/authorize_net/transaction.rb, line 26 def set_fields(fields = {}) @fields.merge!(fields) @fields.reject! { |_k, v| v.nil? } @fields end
Takes an instance of AuthorizeNet::ShippingAddress and adds it to the transaction.
# File lib/authorize_net/transaction.rb, line 42 def set_shipping_address(address) @fields.merge!(address.to_hash) end