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: true,
  reference_id: nil
}
@@create_profile_option_defaults =

The default options for create_profile.

{
  validation_mode: :none
}
@@get_hosted_profile_token_option_defaults =

The default options for get_hosted_profile_token.

{
  border_visible: true,
  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.

%i[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_HOSTED_PROFILE_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 Attribute Summary collapse

Attributes inherited from XmlTransaction

#response, #xml

Attributes inherited from Transaction

#fields

Instance Method Summary collapse

Methods inherited from XmlTransaction

#has_response?, #run, #setOAuthOptions, #test?

Methods inherited from Transaction

#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 true.

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.



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

def initialize(, api_transaction_key, options = {})
  ActiveSupport::Deprecation.warn "use AuthorizeNet::API::Transaction"
  super
  @delim_char = ','
  @encap_char = nil
  @custom_fields = {}
end

Instance Attribute Details

#custom_fieldsObject (readonly)

Custom fields accessor.



590
591
592
# File 'lib/authorize_net/cim/transaction.rb', line 590

def custom_fields
  @custom_fields
end

Instance Method Details

#cp_versionObject

Always nil.



598
599
600
# File 'lib/authorize_net/cim/transaction.rb', line 598

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?


314
315
316
317
318
319
# File 'lib/authorize_net/cim/transaction.rb', line 314

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?


199
200
201
202
203
204
205
206
# File 'lib/authorize_net/cim/transaction.rb', line 199

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?


96
97
98
99
100
101
102
# File 'lib/authorize_net/cim/transaction.rb', line 96

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 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?


405
406
407
408
409
410
411
412
413
414
415
416
417
418
# File 'lib/authorize_net/cim/transaction.rb', line 405

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 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?


442
443
444
# File 'lib/authorize_net/cim/transaction.rb', line 442

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 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?


468
469
470
# File 'lib/authorize_net/cim/transaction.rb', line 468

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?


491
492
493
494
# File 'lib/authorize_net/cim/transaction.rb', line 491

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?


539
540
541
542
# File 'lib/authorize_net/cim/transaction.rb', line 539

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?


513
514
515
516
# File 'lib/authorize_net/cim/transaction.rb', line 513

def create_transaction_void(transaction_id, options = {})
  handle_transaction_id(transaction_id)
  create_transaction(:void, nil, nil, nil, nil, options)
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?


374
375
376
377
378
379
# File 'lib/authorize_net/cim/transaction.rb', line 374

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?


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

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?


151
152
153
154
155
# File 'lib/authorize_net/cim/transaction.rb', line 151

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

#delimiterObject

Comma delimited.



585
586
587
# File 'lib/authorize_net/cim/transaction.rb', line 585

def delimiter
  @delim_char
end

#encapsulation_characterObject

No encapsulation_character.



580
581
582
# File 'lib/authorize_net/cim/transaction.rb', line 580

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?


335
336
337
338
339
340
# File 'lib/authorize_net/cim/transaction.rb', line 335

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_hosted_profile_token(profile_id, options = {}) ⇒ Object

Sets up and submits a getHostedProfilePageRequest 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.

Options:

return_url

Enter the URL for the page that the customer returns to when the hosted session ends. Do not pass this setting for iframes or popups.

return_url_text

Enter the text to display on the button that returns the customer to your web site. The value can be any text up to 200 characters. If you do not pass this parameter, the default button text is Continue. Do not pass this setting for iframes or popups.

heading_color

Enter a hex color string such as #e0e0e0. The background color of the section headers changes from gray to a custom color.

border_visible

Enter true or false. Must be false for iframes or popups, and must be true for redirects.

iframe_communicator_url

Enter the URL to a page that can communicate with the merchant’s main page using javascript. This parameter enables you to dynamically change the size of the popup so that there are no scroll bars. This parameter is required only for iframe or lightbox applications.

validation_mode

Set to :testMode, :liveMode or :none (the default) to set hostedProfileValidationMode mode



173
174
175
176
177
178
179
# File 'lib/authorize_net/cim/transaction.rb', line 173

def get_hosted_profile_token(profile_id, options = {})
  options = @@get_hosted_profile_token_option_defaults.merge(options)
  @type = Type::CIM_GET_HOSTED_PROFILE
  handle_profile_id(profile_id)
  handle_hosted_profile_settings(options)
  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?


221
222
223
224
225
226
# File 'lib/authorize_net/cim/transaction.rb', line 221

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?


116
117
118
119
120
# File 'lib/authorize_net/cim/transaction.rb', line 116

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?


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

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?


355
356
357
358
359
360
# File 'lib/authorize_net/cim/transaction.rb', line 355

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.



244
245
246
247
248
249
250
251
# File 'lib/authorize_net/cim/transaction.rb', line 244

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?


135
136
137
138
139
# File 'lib/authorize_net/cim/transaction.rb', line 135

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?


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

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.



290
291
292
293
294
295
296
297
298
299
# File 'lib/authorize_net/cim/transaction.rb', line 290

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.



593
594
595
# File 'lib/authorize_net/cim/transaction.rb', line 593

def version
  3.1
end