Class: AuthorizeNet::CIM::Transaction

Inherits:
XmlTransaction show all
Includes:
Fields
Defined in:
lib/authorize_net/cim/transaction.rb

Overview

The CIM transaction class.

Constant Summary collapse

@@option_defaults =

The default options for the constructor.

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

The default options for create_profile.

{
  :validation_mode => :none
}
@@create_payment_profile_option_defaults =

The default options for create_payment_profile.

{
  :validation_mode => :none
}
@@update_payment_profile_option_defaults =

The default options for update_payment_profile.

{
  :validation_mode => :none
}
@@create_transaction_option_defaults =

The default options for create_transaction and the various type specific create transaction methods.

{
  :address_id => nil,
  :split_tender_id => nil,
  :aim_options => nil,
  :custom_fields => nil
}
@@validate_payment_profile_option_defaults =

The default options for validate_payment_profile.

{
  :address_id => nil,
  :card_code => nil,
  :validation_mode => :testMode
}
@@aim_response_options =

A list of keys that should be stored if passed as aim_options.

[:delim_char, :encap_char]

Constants included from Fields

Fields::ADDRESS_ENTITY_DESCRIPTION, Fields::ADDRESS_FIELDS, Fields::BILL_TO_FIELDS, Fields::CREATE_ADDRESS_FIELDS, Fields::CREATE_PAYMENT_FIELDS, Fields::CREATE_PROFILE_FIELDS, Fields::CREATE_TRANSACTION_FIELDS, Fields::CREDIT_CARD_ENTITY_DESCRIPTION, Fields::CUSTOMER_PAYMENT_PROFILE_ID_FIELDS, Fields::CUSTOMER_PROFILE_ID_FIELDS, Fields::DELETE_ADDRESS_FIELDS, Fields::DELETE_PAYMENT_FIELDS, Fields::DELETE_PROFILE_FIELDS, Fields::ECHECK_ENTITY_DESCRIPTION, Fields::FIELDS, Fields::GET_ADDRESS_FIELDS, Fields::GET_PAYMENT_FIELDS, Fields::GET_PROFILE_FIELDS, Fields::GET_PROFILE_IDS_FIELDS, Fields::PAYMENT_PROFILE_ENTITY_DESCRIPTION, Fields::PAYMENT_PROFILE_FIELDS, Fields::PROFILE_ENTITY_DESCRIPTION, Fields::PROFILE_FIELDS, Fields::REFID_FIELDS, Fields::SHIP_TO_FIELDS, Fields::TRANSACTION_AUTH_CAPTURE_FIELDS, Fields::TRANSACTION_AUTH_FIELDS, Fields::TRANSACTION_CAPTURE_FIELDS, Fields::TRANSACTION_FIELDS, Fields::TRANSACTION_PRIOR_AUTH_CAPTURE_FIELDS, Fields::TRANSACTION_REFUND_FIELDS, Fields::TRANSACTION_VOID_FIELDS, Fields::UPDATE_ADDRESS_FIELDS, Fields::UPDATE_PAYMENT_FIELDS, Fields::UPDATE_PROFILE_FIELDS, Fields::UPDATE_SPLIT_FIELDS, Fields::VALIDATE_PAYMENT_FIELDS, Fields::VALIDATION_MODE_FIELDS

Constants inherited from XmlTransaction

XmlTransaction::XML_NAMESPACE

Constants included from TypeConversions

TypeConversions::API_FIELD_PREFIX

Instance Method Summary collapse

Methods inherited from XmlTransaction

#has_response?, #response, #run, #test?, #xml

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 = {}) ⇒ Transaction

Constructs a CIM transaction. You can use the new CIM transaction object to issue a request to the payment gateway and parse the response into a new AuthorizeNet::CIM::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

gateway

The gateway to submit the transaction to. Can be a URL string, an AuthorizeNet::CIM::Transaction::Gateway constant, or one of the convenience symbols :sandbox, :test, :production, or :live (:test is an alias for :sandbox, and :live is an alias for :production).

verify_ssl

A boolean indicating if the SSL certificate of the gateway should be verified. Defaults to false.

reference_id

A string that can be used to identify a particular transaction with its response. Will be echo’d in the response, only if it was provided in the transaction. Defaults to nil.



31
32
33
34
35
36
# File 'lib/authorize_net/cim/transaction.rb', line 31

def initialize(, api_transaction_key, options = {})
  super
  @delim_char = ','
  @encap_char = nil
  @custom_fields = {}
end

Instance Method Details

#cp_versionObject

Always nil.



572
573
574
# File 'lib/authorize_net/cim/transaction.rb', line 572

def cp_version
  nil
end

#create_address(address, profile_id) ⇒ Object

Sets up and submits a createCustomerShippingAddressRequest transaction. If this transaction has already been run, this method will return nil. Otherwise it will return an AuthorizeNet::CIM::Response object. The response object will have a address_id if the request was successful.

address

An AuthorizeNet::Address object describing the profile to create.

profile_id

Takes either a String containing the ID of the CustomerProfile who will own this Address, or a CustomerProfile object with the ID populated.

Typical usage:

address = AuthorizeNet::Address.new(:first_name => 'Jane', :last_name => 'Doe', :address => '123 Fake St', :city => 'Raccoon Junction', :state => 'WY', :zip => '99999')
response = transaction.create_address(address, '123456')
puts response.address_id if response.success?


285
286
287
288
289
290
# File 'lib/authorize_net/cim/transaction.rb', line 285

def create_address(address, profile_id)
  @type = Type::CIM_CREATE_ADDRESS
  @fields.merge!(address.to_hash)
  handle_profile_id(profile_id)
  make_request
end

#create_payment_profile(payment_profile, profile_id, options = {}) ⇒ Object

Sets up and submits a createCustomerPaymentProfileRequest transaction. If this transaction has already been run, this method will return nil. Otherwise it will return an AuthorizeNet::CIM::Response object. The response object will have a payment_profile_id if the request was successful.

profile

An AuthorizeNet::CIM::PaymentProfile object describing the profile to create.

profile_id

Takes either a String containing the ID of the CustomerProfile who will own the PaymentProfile, or a CustomerProfile object with the ID populated.

options

An optional hash of options.

Options:

validation_mode

Set to :testMode, :liveMode or :none (the default) to indicate what sort of PaymentProfile validation to do (assuming a PaymentProfile is included with the CustomerProfile)

Typical usage:

credit_card = AuthorizeNet::CreditCard.new('4111111111111111', '0120')
payment_profile = AuthorizeNet::CIM::PaymentProfile.new(:payment_method => credit_card)
response = transaction.create_payment_profile(payment_profile, '123456')
puts response.payment_profile_id if response.success?


170
171
172
173
174
175
176
177
# File 'lib/authorize_net/cim/transaction.rb', line 170

def create_payment_profile(payment_profile, profile_id, options = {})
  options = @@create_payment_profile_option_defaults.merge(options)
  @type = Type::CIM_CREATE_PAYMENT
  @fields.merge!(payment_profile.to_hash)
  set_fields(:validation_mode => options[:validation_mode])
  handle_profile_id(profile_id)
  make_request
end

#create_profile(profile, options = {}) ⇒ Object

Sets up and submits a createCustomerProfileRequest transaction. If this transaction has already been run, this method will return nil. Otherwise it will return an AuthorizeNet::CIM::Response object. The response object will have a profile_id if the request was successful. If any PaymentProfiles or Addresses were included, you can find their IDs in the response objects payment_profile_ids and address_ids methods.

profile

An AuthorizeNet::CIM::CustomerProfile object describing the profile to create.

options

An optional hash of options.

Options:

validation_mode

Set to :testMode, :liveMode or :none (the default) to indicate what sort of PaymentProfile validation to do (assuming a PaymentProfile is included with the CustomerProfile)

Typical usage:

profile = AuthorizeNet::CIM::CustomerProfile.new(
  :email => '[email protected]',
  :id => 'userassignedid'
)
response = transaction.create_profile(profile)
puts response.profile_id if response.success?


91
92
93
94
95
96
97
# File 'lib/authorize_net/cim/transaction.rb', line 91

def create_profile(profile, options = {})
  options = @@create_profile_option_defaults.merge(options)
  @type = Type::CIM_CREATE_PROFILE
  @fields.merge!(profile.to_hash)
  set_fields(:validation_mode => options[:validation_mode])
  make_request
end

#create_transaction(type, amount, profile_id, payment_profile_id, order, options = {}) ⇒ Object

Sets up and submits a createCustomerProfileTransactionRequest transaction. If this transaction has already been run, this method will return nil. Otherwise it will return an AuthorizeNet::CIM::Response object. It is recommend to use the connivence methods for each type of payment transaction rather than this method.

type

The type of payment transaction to run. Can be :auth_capture, :auth_only, :prior_auth_capture, :void, or :refund.

amount

The amount of the transaction. This is required for every transaction type except :void.

profile_id

Takes either a String containing the ID of the CustomerProfile who owns the PaymentProfile to be charged, or a CustomerProfile object with the ID populated.

payment_profile_id

Takes either a String containing the ID of the PaymentProfile you want to charge, or a PaymentProfile object with the ID populated.

order

An Order object describing the order that this payment transaction is for. Pass nil for no order.

options

An optional hash of options.

Options:

address_id

Takes either a String containing the ID of the an Address, or an Address object with the ID populated. Used as the shipping address for the payment transaction. Defaults to nil.

split_tender_id

A split tender transaction ID as a string. If the transaction is to be part of a split tender batch, this must be included. Defaults to nil.

aim_options

A hash of AIM options to be included with the payment transaction. Since the payment transactions in CIM are just encapsulated AIM transactions, any field used by AIM can be set here. Defaults to nil.

custom_fields

A hash of custom fields to pass along with the payment transaction. These fields will be stored with the AIM transaction generated by the CIM transaction. Defaults to nil.

Typical usage:

response = transaction.create_transaction(:auth_capture, 10.00, '123456', '654321', nil)
if response.success?
  puts response.direct_response if direct_response.success?


376
377
378
379
380
381
382
383
384
385
386
387
388
389
# File 'lib/authorize_net/cim/transaction.rb', line 376

def create_transaction(type, amount, profile_id, payment_profile_id, order, options = {})
  @type = Type::CIM_CREATE_TRANSACTION
  options = @@create_transaction_option_defaults.merge(options)
  handle_profile_id(profile_id)
  handle_payment_profile_id(payment_profile_id)
  handle_address_id(options[:address_id]) unless options[:address_id].nil?
  set_fields(:split_tender_id => options[:split_tender_id])
  @transaction_type = type
  @fields.merge!(order.to_hash) unless order.nil?
  set_fields(:amount => amount)
  handle_aim_options(options[:aim_options])
  handle_custom_fields(options[:custom_fields])
  make_request
end

#create_transaction_auth_capture(amount, profile_id, payment_profile_id, order = nil, options = {}) ⇒ Object

Sets up and submits an AUTHORIZE_AND_CAPTURE transaction using stored payment information. If this transaction has already been run, this method will return nil. Otherwise it will return an AuthorizeNet::CIM::Response object.

amount

The amount of the transaction.

profile_id

Takes either a String containing the ID of the CustomerProfile who owns the PaymentProfile to be charged, or a CustomerProfile object with the ID populated.

payment_profile_id

Takes either a String containing the ID of the PaymentProfile you want to charge, or a PaymentProfile object with the ID populated.

order

An Order object describing the order that this payment transaction is for. Pass nil for no order.

options

An optional hash of options.

Options:

address_id

Takes either a String containing the ID of the an Address, or an Address object with the ID populated. Used as the shipping address for the payment transaction. Defaults to nil.

split_tender_id

A split tender transaction ID as a string. If the transaction is to be part of a split tender batch, this must be included. Defaults to nil.

aim_options

A hash of AIM options to be included with the payment transaction. Since the payment transactions in CIM are just encapsulated AIM transactions, any field used by AIM can be set here. Defaults to nil.

custom_fields

A hash of custom fields to pass along with the payment transaction. These fields will be stored with the AIM transaction generated by the CIM transaction. Defaults to nil.

Typical usage:

response = transaction.create_transaction_auth_capture(10.00, '123456', '654321', nil)
if response.success?
  puts response.direct_response if direct_response.success?


414
415
416
# File 'lib/authorize_net/cim/transaction.rb', line 414

def create_transaction_auth_capture(amount, profile_id, payment_profile_id, order = nil, options = {})
  create_transaction(:auth_capture, amount, profile_id, payment_profile_id, order, options)
end

#create_transaction_auth_only(amount, profile_id, payment_profile_id, order = nil, options = {}) ⇒ Object

Sets up and submits an AUTH_ONLY transaction using stored payment information. If this transaction has already been run, this method will return nil. Otherwise it will return an AuthorizeNet::CIM::Response object.

amount

The amount of the transaction.

profile_id

Takes either a String containing the ID of the CustomerProfile who owns the PaymentProfile to be charged, or a CustomerProfile object with the ID populated.

payment_profile_id

Takes either a String containing the ID of the PaymentProfile you want to charge, or a PaymentProfile object with the ID populated.

order

An Order object describing the order that this payment transaction is for. Pass nil for no order.

options

An optional hash of options.

Options:

address_id

Takes either a String containing the ID of the an Address, or an Address object with the ID populated. Used as the shipping address for the payment transaction. Defaults to nil.

split_tender_id

A split tender transaction ID as a string. If the transaction is to be part of a split tender batch, this must be included. Defaults to nil.

aim_options

A hash of AIM options to be included with the payment transaction. Since the payment transactions in CIM are just encapsulated AIM transactions, any field used by AIM can be set here. Defaults to nil.

custom_fields

A hash of custom fields to pass along with the payment transaction. These fields will be stored with the AIM transaction generated by the CIM transaction. Defaults to nil.

Typical usage:

response = transaction.create_transaction_auth_only(10.00, '123456', '654321', nil)
if response.success?
  puts response.direct_response if direct_response.success?


440
441
442
# File 'lib/authorize_net/cim/transaction.rb', line 440

def create_transaction_auth_only(amount, profile_id, payment_profile_id, order = nil, options = {})
  create_transaction(:auth_only, amount, profile_id, payment_profile_id, order, options)
end

#create_transaction_prior_auth_capture(transaction_id, amount, order = nil, options = {}) ⇒ Object

Sets up and submits a PRIOR_AUTHORIZATION_AND_CAPTURE transaction using stored payment information. If this transaction has already been run, this method will return nil. Otherwise it will return an AuthorizeNet::CIM::Response object.

transaction_id

A string containing a transaction ID that was generated via an AUTH_ONLY transaction.

amount

The amount to capture. Must be <= the amount authorized via the AUTH_ONLY transaction.

order

An Order object describing the order that this payment transaction is for. Pass nil for no order.

options

An optional hash of options.

Options:

aim_options

A hash of AIM options to be included with the payment transaction. Since the payment transactions in CIM are just encapsulated AIM transactions, any field used by AIM can be set here. Defaults to nil.

custom_fields

A hash of custom fields to pass along with the payment transaction. These fields will be stored with the AIM transaction generated by the CIM transaction. Defaults to nil.

Typical usage:

response = transaction.create_transaction_prior_auth_capture('111222', 10.00)
if response.success?
  puts response.direct_response if direct_response.success?


463
464
465
466
# File 'lib/authorize_net/cim/transaction.rb', line 463

def create_transaction_prior_auth_capture(transaction_id, amount, order = nil, options = {})
  handle_transaction_id(transaction_id)
  create_transaction(:prior_auth_capture, amount, nil, nil, order, options)
end

#create_transaction_refund(transaction_id, amount, profile_id, payment_profile_id, order = nil, options = {}) ⇒ Object

Sets up and submits a REFUND transaction using stored payment information. If this transaction has already been run, this method will return nil. Otherwise it will return an AuthorizeNet::CIM::Response object.

transaction_id

A string containing a transaction ID to refund. Pass nil for an unlinked refund.

amount

The amount to refund.

profile_id

Takes either a String containing the ID of the CustomerProfile who owns the PaymentProfile to be credited, or a CustomerProfile object with the ID populated. Pass nil for an unlinked refund.

payment_profile_id

Takes either a String containing the ID of the PaymentProfile you want to credit, or a PaymentProfile object with the ID populated. Pass nil for an unlinked refund.

order

An Order object describing the order that is being refunded. Pass nil for no order.

options

An optional hash of options.

Options:

aim_options

A hash of AIM options to be included with the payment transaction. Since the payment transactions in CIM are just encapsulated AIM transactions, any field used by AIM can be set here. Defaults to nil.

custom_fields

A hash of custom fields to pass along with the payment transaction. These fields will be stored with the AIM transaction generated by the CIM transaction. Defaults to nil.

Typical usage:

response = transaction.create_transaction_refund('111222', 10.00, '123456', '654321')
if response.success?
  puts response.direct_response if direct_response.success?


511
512
513
514
# File 'lib/authorize_net/cim/transaction.rb', line 511

def create_transaction_refund(transaction_id, amount, profile_id, payment_profile_id, order = nil, options = {})
  handle_transaction_id(transaction_id)
  create_transaction(:refund, amount, profile_id, payment_profile_id, order, options)
end

#create_transaction_void(transaction_id, options = {}) ⇒ Object

Sets up and submits a VOID transaction using stored payment information. If this transaction has already been run, this method will return nil. Otherwise it will return an AuthorizeNet::CIM::Response object.

transaction_id

A string containing a transaction ID to void.

options

An optional hash of options.

Options:

aim_options

A hash of AIM options to be included with the payment transaction. Since the payment transactions in CIM are just encapsulated AIM transactions, any field used by AIM can be set here. Defaults to nil.

custom_fields

A hash of custom fields to pass along with the payment transaction. These fields will be stored with the AIM transaction generated by the CIM transaction. Defaults to nil.

Typical usage:

response = transaction.create_transaction_void('111222')
if response.success?
  puts response.direct_response if direct_response.success?


485
486
487
488
# File 'lib/authorize_net/cim/transaction.rb', line 485

def create_transaction_void(transaction_id, options = {})
  handle_transaction_id(transaction_id)
  create_transaction(:void, nil, nil, nil, nil, options)
end

#custom_fieldsObject

Custom fields accessor.



562
563
564
# File 'lib/authorize_net/cim/transaction.rb', line 562

def custom_fields
  @custom_fields
end

#delete_address(address_id, profile_id) ⇒ Object

Sets up and submits a deleteCustomerShippingAddressRequest transaction. If this transaction has already been run, this method will return nil. Otherwise it will return an AuthorizeNet::CIM::Response object.

address_id

Takes either a String containing the ID of the Address you want to delete, or an Address object with the ID populated.

profile_id

Takes either a String containing the ID of the CustomerProfile who owns this Address, or a CustomerProfile object with the ID populated.

Typical usage:

response = transaction.delete_address('654321', '123456')
puts response.success?


345
346
347
348
349
350
# File 'lib/authorize_net/cim/transaction.rb', line 345

def delete_address(address_id, profile_id)
  @type = Type::CIM_DELETE_ADDRESS
  handle_address_id(address_id)
  handle_profile_id(profile_id)
  make_request
end

#delete_payment_profile(payment_profile_id, profile_id) ⇒ Object

Sets up and submits a deleteCustomerPaymentProfileRequest transaction. If this transaction has already been run, this method will return nil. Otherwise it will return an AuthorizeNet::CIM::Response object.

payment_profile_id

Takes either a String containing the ID of the PaymentProfile you want to retrieve, or a PaymentProfile object with the ID populated.

profile_id

Takes either a String containing the ID of the CustomerProfile who owns this PaymentProfile, or a CustomerProfile object with the ID populated.

Typical usage:

response = transaction.delete_profile('123456')
puts response.success?


236
237
238
239
240
241
# File 'lib/authorize_net/cim/transaction.rb', line 236

def delete_payment_profile(payment_profile_id, profile_id)
  @type = Type::CIM_DELETE_PAYMENT
  handle_payment_profile_id(payment_profile_id)
  handle_profile_id(profile_id)
  make_request
end

#delete_profile(profile_id) ⇒ Object

Sets up and submits a deleteCustomerProfileRequest transaction. If this transaction has already been run, this method will return nil. Otherwise it will return an AuthorizeNet::CIM::Response object.

profile_id

Takes either a String containing the ID of the CustomerProfile you want to delete, or a CustomerProfile object with the ID populated.

Typical usage:

response = transaction.delete_profile('123456')
puts response.success?


146
147
148
149
150
# File 'lib/authorize_net/cim/transaction.rb', line 146

def delete_profile(profile_id)
  @type = Type::CIM_DELETE_PROFILE
  handle_profile_id(profile_id)
  make_request
end

#delimiterObject

Comma delimited.



557
558
559
# File 'lib/authorize_net/cim/transaction.rb', line 557

def delimiter
  @delim_char
end

#encapsulation_characterObject

No encapsulation_character.



552
553
554
# File 'lib/authorize_net/cim/transaction.rb', line 552

def encapsulation_character
  @encap_char
end

#get_address(address_id, profile_id) ⇒ Object

Sets up and submits a getCustomerShippingAddressRequest transaction. If this transaction has already been run, this method will return nil. Otherwise it will return an AuthorizeNet::CIM::Response object. The response object will have the Address object requested available via its address method if the request was successful.

address_id

Takes either a String containing the ID of the Address you want to retrieve, or an Address object with the ID populated.

profile_id

Takes either a String containing the ID of the CustomerProfile who owns this Address, or a CustomerProfile object with the ID populated.

Typical usage:

response = transaction.get_address('654321', '123456')
address = response.address if response.success?


306
307
308
309
310
311
# File 'lib/authorize_net/cim/transaction.rb', line 306

def get_address(address_id, profile_id)
  @type = Type::CIM_GET_ADDRESS
  handle_address_id(address_id)
  handle_profile_id(profile_id)
  make_request
end

#get_payment_profile(payment_profile_id, profile_id) ⇒ Object

Sets up and submits a getCustomerPaymentProfileRequest transaction. If this transaction has already been run, this method will return nil. Otherwise it will return an AuthorizeNet::CIM::Response object. The response object will have the PaymentProfile object requested available via its payment_profile method if the request was successful.

payment_profile_id

Takes either a String containing the ID of the PaymentProfile you want to retrieve, or a PaymentProfile object with the ID populated.

profile_id

Takes either a String containing the ID of the CustomerProfile who owns this PaymentProfile, or a CustomerProfile object with the ID populated.

Typical usage:

response = transaction.get_payment_profile('654321', '123456')
payment_profile = response.payment_profile if response.success?


192
193
194
195
196
197
# File 'lib/authorize_net/cim/transaction.rb', line 192

def get_payment_profile(payment_profile_id, profile_id)
  @type = Type::CIM_GET_PAYMENT
  handle_payment_profile_id(payment_profile_id)
  handle_profile_id(profile_id)
  make_request
end

#get_profile(profile_id) ⇒ Object

Sets up and submits a getCustomerProfileRequest transaction. If this transaction has already been run, this method will return nil. Otherwise it will return an AuthorizeNet::CIM::Response object. The response object will have the CustomerProfile object requested available via its profile method if the request was successful.

profile_id

Takes either a String containing the ID of the CustomerProfile you want to retrieve, or a CustomerProfile object with the ID populated.

Typical usage:

response = transaction.get_profile('123456')
profile = response.profile if response.success?


111
112
113
114
115
# File 'lib/authorize_net/cim/transaction.rb', line 111

def get_profile(profile_id)
  @type = Type::CIM_GET_PROFILE
  handle_profile_id(profile_id)
  make_request
end

#get_profile_idsObject

Sets up and submits a getCustomerProfileIdsRequest transaction. If this transaction has already been run, this method will return nil. Otherwise it will return an AuthorizeNet::CIM::Response object. The response object will have a list of all CustomerProfile IDs available via its profile_ids method on success.

Typical usage:

response = transaction.get_profile_ids()
puts response.profile_ids if response.success?


543
544
545
546
# File 'lib/authorize_net/cim/transaction.rb', line 543

def get_profile_ids()
  @type = Type::CIM_GET_PROFILE_IDS
  make_request
end

#update_address(address, profile_id) ⇒ Object

Sets up and submits a updateCustomerShippingAddressRequest transaction. If this transaction has already been run, this method will return nil. Otherwise it will return an AuthorizeNet::CIM::Response object.

address

An Address object describing the address to update.

profile_id

Takes either a String containing the ID of the CustomerProfile who owns this Address, or a CustomerProfile object with the ID populated.

Typical usage:

address.city = 'Somewhere Else'
response = transaction.update_address(address, '123456')
puts response.success?


326
327
328
329
330
331
# File 'lib/authorize_net/cim/transaction.rb', line 326

def update_address(address, profile_id)
  @type = Type::CIM_UPDATE_ADDRESS
  @fields.merge!(address.to_hash)
  handle_profile_id(profile_id)
  make_request
end

#update_payment_profile(payment_profile, profile_id, options = {}) ⇒ Object

Sets up and submits a updateCustomerPaymentProfileRequest transaction. If this transaction has already been run, this method will return nil. Otherwise it will return an AuthorizeNet::CIM::Response object.

payment_profile

An AuthorizeNet::CIM::PaymentProfile object describing the profile to update.

profile_id

Takes either a String containing the ID of the CustomerProfile who owns this PaymentProfile, or a CustomerProfile object with the ID populated.

Typical usage:

payment_profile.cust_type = :business
response = transaction.update_payment_profile(payment_profile, '123456')
puts response.success?

Options:

validation_mode

Set to :testMode, :liveMode or :none (the default) to indicate what sort of PaymentProfile validation to do.



215
216
217
218
219
220
221
222
# File 'lib/authorize_net/cim/transaction.rb', line 215

def update_payment_profile(payment_profile, profile_id, options = {})
  options = @@create_payment_profile_option_defaults.merge(options)
  @type = Type::CIM_UPDATE_PAYMENT
  @fields.merge!(payment_profile.to_hash)
  set_fields(:validation_mode => options[:validation_mode])
  handle_profile_id(profile_id)
  make_request
end

#update_profile(profile) ⇒ Object

Sets up and submits a updateCustomerProfileRequest transaction. If this transaction has already been run, this method will return nil. Otherwise it will return an AuthorizeNet::CIM::Response object. Note that any PaymentProfiles will NOT be updated using this method. This is a limitation of the CIM API. See update_payment_profile if you need to update a PaymentProfile.

profile

An AuthorizeNet::CIM::CustomerProfile object describing the profile to update. It must contain the customer_profile_id of the record to update.

Typical usage:

profile.fax = '5555551234'
response = transaction.update_profile(profile)
puts response.success?


130
131
132
133
134
# File 'lib/authorize_net/cim/transaction.rb', line 130

def update_profile(profile)
  @type = Type::CIM_UPDATE_PROFILE
  @fields.merge!(profile.to_hash)
  make_request
end

#update_split_tender(split_tender_id, status) ⇒ Object

Sets up and submits a updateSplitTenderGroupRequest transaction. Use this to end or void a split tender batch. If this transaction has already been run, this method will return nil. Otherwise it will return an AuthorizeNet::CIM::Response object.

split_tender_id

The split tender batch ID you want to change the status of.

status

The new status to set for the batch. Options are :voided or :completed.

Typical usage:

response = transaction.update_split_tender('1111111', :voided)
puts response if response.success?


528
529
530
531
532
# File 'lib/authorize_net/cim/transaction.rb', line 528

def update_split_tender(split_tender_id, status)
  @type = Type::CIM_UPDATE_SPLIT
  set_fields(:split_tender_id => split_tender_id, :split_tender_status => status.to_s)
  make_request
end

#validate_payment_profile(payment_profile_id, profile_id, options = {}) ⇒ Object

Sets up and submits a validateCustomerPaymentProfileRequest transaction. If this transaction has already been run, this method will return nil. Otherwise it will return an AuthorizeNet::CIM::Response object. The results of the validation can be obtained via the direct_response method of the response object.

payment_profile_id

Takes either a String containing the ID of the PaymentProfile you want to validate, or a PaymentProfile object with the ID populated.

profile_id

Takes either a String containing the ID of the CustomerProfile who owns this PaymentProfile, or a CustomerProfile object with the ID populated.

Typical usage:

response = transaction.validate_payment_profile('654321', '123456')
puts response.direct_response.success? if response.success?

Options:

validation_mode

Set to :testMode (the default) or :liveMode to indicate what sort of PaymentProfile validation to do.

address_id

Set a shipping Address to be part of the validation transaction.

card_code

Set a CCV code if one is needed for validation. Defaults to nil.



261
262
263
264
265
266
267
268
269
270
# File 'lib/authorize_net/cim/transaction.rb', line 261

def validate_payment_profile(payment_profile_id, profile_id, options = {})
  @type = Type::CIM_VALIDATE_PAYMENT
  options = @@validate_payment_profile_option_defaults.merge(options)
  handle_payment_profile_id(payment_profile_id)
  handle_profile_id(profile_id)
  handle_address_id(options[:address_id]) unless options[:address_id].nil?
  set_fields(:validation_mode => options[:validation_mode])
  set_fields(:card_code => options[:card_code]) unless options[:card_code].nil?
  make_request
end

#versionObject

Always version 3.1.



567
568
569
# File 'lib/authorize_net/cim/transaction.rb', line 567

def version
  3.1
end