Class: AuthorizeNet::Reporting::Transaction

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

Overview

The Reporting API transaction class.

Constant Summary collapse

@@datetime_fields =

Fields to convert to/from Date.

[:first_settlement_date, :last_settlement_date]

Constants included from Fields

Fields::BATCH_ENTITY_DESCRIPTION, Fields::BATCH_STATISTICS_ENTITY_DESCRIPTION, Fields::CUSTOMER_ENTITY_DESCRIPTION, Fields::FDSFILTER_ENTITY_DESCRIPTION, Fields::FIELDS, Fields::GET_BATCH_LIST, Fields::GET_TRANSACTION_DETAILS, Fields::GET_TRANSACTION_LIST, Fields::LINE_ITEM_ENTITY_DESCRIPTION, Fields::ORDER_ENTITY_DESCRIPTION, Fields::TRANSACTION_DETAILS_ENTITY_DESCRIPTION

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



27
28
29
# File 'lib/authorize_net/reporting/transaction.rb', line 27

def initialize(, api_transaction_key, options = {})
  super
end

Instance Method Details

#get_settled_batch_list(from_date = nil, to_date = nil, include_stats = false) ⇒ Object

Sets up and submits a getSettledBatchListRequest transaction. If this transaction has already been run, this method will return nil. Otherwise it will return an AuthorizeNet::Reporting::Response object. The response object will have an array of Batch objects available via its batch_list method if the request was successful.

from_date

Takes either a DateTime or a String representing a date and time. Only settled batches >= this value will be returned. Defaults to nil (which returns >= 24hrs ago). A to_date must be specified if a from_date is.

to_date

Takes either a DateTime or a String representing a date and time. Only settled batches <= this value will be returned. Defaults to nil. The maximum date range is 31 days, and a from_date must be supplied if a to_date is.

include_stats

Takes a Boolean. Determines if BatchStatistics should be returned with the Batch objects. Defaults to false.

Typical usage:

response = transaction.get_settled_batch_list(DateTime.now() - (1 * 3600 * 48), DateTime.now(), true)
batches = response.batch_list if response.success?


46
47
48
49
50
# File 'lib/authorize_net/reporting/transaction.rb', line 46

def get_settled_batch_list(from_date = nil, to_date = nil, include_stats = false)
  @type = Type::REPORT_GET_BATCH_LIST
  set_fields({:first_settlement_date => from_date, :last_settlement_date => to_date, :include_statistics => include_stats})
  make_request
end

#get_transaction_details(transaction_id) ⇒ Object

Sets up and submits a getTransactionDetailsRequest transaction. If this transaction has already been run, this method will return nil. Otherwise it will return an AuthorizeNet::Reporting::Response object. The response object will have a TransactionDetail object available via its transactions method if the request was successful. This TransactionDetail object will have more data than the limited version returned by get_transaction_list.

transaction_id

Takes either a TransactionDetail object with its id attribute populated, or a String representing the ID of the transaction to retrieve the details from.

Typical usage:

response = transaction.get_transaction_details('123456789')
transactions = response.transactions if response.success?


86
87
88
89
90
# File 'lib/authorize_net/reporting/transaction.rb', line 86

def get_transaction_details(transaction_id)
  @type = Type::REPORT_GET_TRANSACTION_DETAILS
  handle_transaction_id(transaction_id)
  make_request
end

#get_transaction_list(batch_id) ⇒ Object

Sets up and submits a getTransactionListRequest transaction. If this transaction has already been run, this method will return nil. Otherwise it will return an AuthorizeNet::Reporting::Response object. The response object will have an array of TransactionDetail objects available via its transactions method if the request was successful. These TransactionDetail objects will not be fully populated. Use get_transaction_details to get all the details.

batch_id

Takes either a Batch object with its id attribute populated, or a String representing the ID of the batch to retrieve the transaction list from.

Typical usage:

response = transaction.get_transaction_list('123456')
transactions = response.transactions if response.success?


66
67
68
69
70
# File 'lib/authorize_net/reporting/transaction.rb', line 66

def get_transaction_list(batch_id)
  @type = Type::REPORT_GET_TRANSACTION_LIST
  handle_batch_id(batch_id)
  make_request
end