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.

[: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 Method Summary collapse

Methods inherited from XmlTransaction

#has_response?, #response, #run, #setOAuthOptions, #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 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.



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.



602
603
604
# File 'lib/authorize_net/cim/transaction.rb', line 602

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?


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

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?


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

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?


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

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?


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

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?


444
445
446
# File 'lib/authorize_net/cim/transaction.rb', line 444

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?


470
471
472
# File 'lib/authorize_net/cim/transaction.rb', line 470

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?


493
494
495
496
# File 'lib/authorize_net/cim/transaction.rb', line 493

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?


541
542
543
544
# File 'lib/authorize_net/cim/transaction.rb', line 541

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?


515
516
517
518
# File 'lib/authorize_net/cim/transaction.rb', line 515

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.



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

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?


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

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?


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

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?


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

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

#delimiterObject

Comma delimited.



587
588
589
# File 'lib/authorize_net/cim/transaction.rb', line 587

def delimiter
  @delim_char
end

#encapsulation_characterObject

No encapsulation_character.



582
583
584
# File 'lib/authorize_net/cim/transaction.rb', line 582

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?


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

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



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

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?


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

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?


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

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?


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

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?


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

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.



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

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?


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

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?


558
559
560
561
562
# File 'lib/authorize_net/cim/transaction.rb', line 558

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.



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

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.



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

def version
  3.1
end