authorizenet 1.9.4 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. checksums.yaml +5 -5
  2. data/lib/app/helpers/authorize_net_helper.rb +2 -3
  3. data/lib/authorize_net.rb +11 -56
  4. data/lib/authorize_net/api/LogHelper.rb +97 -0
  5. data/lib/authorize_net/api/SensitiveDataFilter.rb +92 -0
  6. data/lib/authorize_net/api/api_transaction.rb +95 -90
  7. data/lib/authorize_net/api/constants.yml +1 -1
  8. data/lib/authorize_net/api/schema.rb +1353 -994
  9. data/lib/authorize_net/api/transaction.rb +104 -102
  10. data/lib/authorize_net/authorize_net.rb +20 -27
  11. data/lib/authorize_net/response.rb +9 -15
  12. data/lib/authorize_net/transaction.rb +18 -26
  13. data/lib/authorize_net/xml_response.rb +36 -54
  14. data/lib/authorize_net/xml_transaction.rb +115 -134
  15. metadata +59 -73
  16. data/lib/authorize_net/addresses/address.rb +0 -29
  17. data/lib/authorize_net/addresses/shipping_address.rb +0 -26
  18. data/lib/authorize_net/aim/response.rb +0 -131
  19. data/lib/authorize_net/aim/transaction.rb +0 -190
  20. data/lib/authorize_net/arb/fields.rb +0 -24
  21. data/lib/authorize_net/arb/paging.rb +0 -33
  22. data/lib/authorize_net/arb/response.rb +0 -34
  23. data/lib/authorize_net/arb/sorting.rb +0 -43
  24. data/lib/authorize_net/arb/subscription.rb +0 -72
  25. data/lib/authorize_net/arb/subscription_detail.rb +0 -14
  26. data/lib/authorize_net/arb/subscription_list_response.rb +0 -43
  27. data/lib/authorize_net/arb/transaction.rb +0 -177
  28. data/lib/authorize_net/cim/customer_profile.rb +0 -19
  29. data/lib/authorize_net/cim/payment_profile.rb +0 -37
  30. data/lib/authorize_net/cim/response.rb +0 -116
  31. data/lib/authorize_net/cim/transaction.rb +0 -727
  32. data/lib/authorize_net/customer.rb +0 -27
  33. data/lib/authorize_net/email_receipt.rb +0 -24
  34. data/lib/authorize_net/fields.rb +0 -779
  35. data/lib/authorize_net/key_value_response.rb +0 -117
  36. data/lib/authorize_net/key_value_transaction.rb +0 -291
  37. data/lib/authorize_net/line_item.rb +0 -25
  38. data/lib/authorize_net/order.rb +0 -42
  39. data/lib/authorize_net/payment_methods/credit_card.rb +0 -62
  40. data/lib/authorize_net/payment_methods/echeck.rb +0 -72
  41. data/lib/authorize_net/reporting/batch.rb +0 -19
  42. data/lib/authorize_net/reporting/batch_statistics.rb +0 -19
  43. data/lib/authorize_net/reporting/fds_filter.rb +0 -11
  44. data/lib/authorize_net/reporting/response.rb +0 -163
  45. data/lib/authorize_net/reporting/returned_item.rb +0 -46
  46. data/lib/authorize_net/reporting/transaction.rb +0 -133
  47. data/lib/authorize_net/reporting/transaction_details.rb +0 -25
  48. data/lib/authorize_net/sim/hosted_payment_form.rb +0 -38
  49. data/lib/authorize_net/sim/hosted_receipt_page.rb +0 -37
  50. data/lib/authorize_net/sim/response.rb +0 -142
  51. data/lib/authorize_net/sim/transaction.rb +0 -138
  52. data/lib/generators/authorize_net/direct_post/direct_post_generator.rb +0 -53
  53. data/lib/generators/authorize_net/direct_post/templates/README-AuthorizeNet +0 -49
  54. data/lib/generators/authorize_net/direct_post/templates/config.yml.erb +0 -8
  55. data/lib/generators/authorize_net/direct_post/templates/config.yml.rails3.erb +0 -8
  56. data/lib/generators/authorize_net/direct_post/templates/controller.rb.erb +0 -31
  57. data/lib/generators/authorize_net/direct_post/templates/initializer.rb +0 -4
  58. data/lib/generators/authorize_net/direct_post/templates/layout.erb +0 -18
  59. data/lib/generators/authorize_net/direct_post/templates/payment.erb +0 -10
  60. data/lib/generators/authorize_net/direct_post/templates/payment.rails3.erb +0 -10
  61. data/lib/generators/authorize_net/direct_post/templates/receipt.erb +0 -1
  62. data/lib/generators/authorize_net/direct_post/templates/relay_response.erb +0 -1
  63. data/lib/generators/authorize_net/sim/sim_generator.rb +0 -47
  64. data/lib/generators/authorize_net/sim/templates/README-AuthorizeNet +0 -52
  65. data/lib/generators/authorize_net/sim/templates/config.yml.erb +0 -8
  66. data/lib/generators/authorize_net/sim/templates/config.yml.rails3.erb +0 -8
  67. data/lib/generators/authorize_net/sim/templates/controller.rb.erb +0 -21
  68. data/lib/generators/authorize_net/sim/templates/initializer.rb +0 -4
  69. data/lib/generators/authorize_net/sim/templates/layout.erb +0 -18
  70. data/lib/generators/authorize_net/sim/templates/payment.erb +0 -6
  71. data/lib/generators/authorize_net/sim/templates/payment.rails3.erb +0 -6
  72. data/lib/generators/authorize_net/sim/templates/thank_you.erb +0 -1
  73. data/lib/generators/generator_extensions.rb +0 -75
@@ -1,62 +0,0 @@
1
- module AuthorizeNet
2
-
3
- # Defines constants for each payment method type.
4
- module PaymentMethodType
5
- CREDIT_CARD = 'CC'
6
- end
7
-
8
- # Models a credit card.
9
- class CreditCard
10
- PAYMENT_METHOD_CODE = AuthorizeNet::PaymentMethodType::CREDIT_CARD
11
-
12
- # The option defaults for the constructor.
13
- @@option_defaults = {
14
- :card_code => nil,
15
- :card_type => nil
16
- }
17
-
18
- attr_accessor :card_number, :expiration, :card_code, :card_type, :track_1, :track_2
19
-
20
- # Constructs a new credit card object. Takes a credit card number
21
- # and an expiration date. The CCV code can be passed as an option. So can
22
- # the data tracks (1 & 2). When passing in data tracks, please pass the
23
- # whole track. Sentinels and the LRC will be removed by the SDK. Track data
24
- # must be passed along as ASCII. The raw bit stream from the card is not acceptable.
25
- #
26
- # Field separators on
27
- #
28
- # +card_number+:: The credit card number as a string.
29
- # +expiration+:: The credit card expiration date as a string with format MMYY.
30
- # +options+:: A hash of options.
31
- #
32
- # Options
33
- # +card_code+:: Sets the CCV code for the credit card.
34
- # +card_type+:: Sets the type of card (Visa, MasterCard, Dinners Club, etc.)
35
- # +track_1+:: Sets the track 1 data. Either track 1 or track 2 data needs to be included for card present transactions (otherwise fee structure will change).
36
- # +track_2+:: Sets the track 2 data. Either track 1 or track 2 data needs to be included for card present transactions (otherwise fee structure will change).
37
- #
38
- #
39
- def initialize(card_number, expiration, options = {})
40
- @card_number = card_number
41
- @expiration = expiration
42
- options = @@option_defaults.merge(options)
43
- @card_code = options[:card_code]
44
- @card_type = options[:card_type]
45
- @track_1 = options[:track_1]
46
- @track_2 = options[:track_2]
47
- end
48
-
49
- def to_hash
50
- Hash.new.tap do |ch|
51
- ch[:method] = PAYMENT_METHOD_CODE
52
- ch[:card_num] = @card_number
53
- ch[:exp_date] = @expiration
54
- ch[:card_code] = @card_code if @card_code
55
- ch[:track1] = @track_1.match(/(%|^)(.*?)(\?|$)/)[2] if @track_1
56
- ch[:track2] = @track_2.match(/(;|^)(.*?)(\?|$)/)[2] if @track_2
57
- #ch[:track1] = @track_1.match(/^%(?<fc>.)(?<p>[\d]{1,19}+)\^(?<n>.{2,26})\^(?<e>[\d]{0,4}|\^)(?<sc>[\d]{0,3}|\^)(?<dd>.*)\?\Z/) if @track_1
58
- #ch[:track2] = @track_2.match(/\A;(?<pan>[\d]{1,19}+)=(?<expiration>[\d]{0,4}|=)(?<service_code>[\d]{0,3}|=)(?<discretionary_data>.*)\?\Z/) if @track_2
59
- end
60
- end
61
- end
62
- end
@@ -1,72 +0,0 @@
1
- module AuthorizeNet
2
-
3
- # Defines constants for each payment method type.
4
- module PaymentMethodType
5
- ECHECK = 'ECHECK'
6
- end
7
-
8
- # Models an eCheck.
9
- class ECheck
10
- PAYMENT_METHOD_CODE = AuthorizeNet::PaymentMethodType::ECHECK
11
-
12
- # Defines constants for each bank account type.
13
- module AccountType
14
- CHECKING = 'CHECKING'
15
- SAVINGS = 'SAVINGS'
16
- BUSINESS_CHECKING = 'BUSINESSCHECKING'
17
- end
18
-
19
- # Defines constants for each check type.
20
- module CheckType
21
- ACCOUNTS_RECEIVABLE_CONVERSION = 'ARC'
22
- BACK_OFFICE_CONVERSION = 'BOC'
23
- CASH_CONCENTRATION_DISBURSEMENT = 'CCD'
24
- PREARRANGED_PAYMENT_DEPOSIT = 'PPD'
25
- TELEPHONE_INITIATED = 'TEL'
26
- INTERNET_INITIATED = 'WEB'
27
- end
28
-
29
- # The option defaults for the constructor.
30
- @@option_defaults = {
31
- :echeck_type => CheckType::INTERNET_INITIATED,
32
- :check_number => nil,
33
- :account_type => AccountType::CHECKING
34
- }
35
-
36
- attr_accessor :routing_number, :account_number, :bank_name, :account_holder_name, :echeck_type, :check_number, :account_type
37
-
38
- # Constructs a new eCheck object.
39
- #
40
- # +routing_number+:: The bank routing number as a string.
41
- # +account_number+:: The bank account number as a string.
42
- # +bank_name+:: The legal name of the bank. This should match the name associated with the +routing_number+.
43
- # +account_holder_name+:: The full name on the bank account represented by +account_number+.
44
- # +options+:: A hash of options. Accepts +echeck_type+ (the type of check, can usually be ignored), +check_number+ (the number on the check, only needed for some check types), and +account_type+ (the type of bank account the check draws from). All values should be passed as strings.
45
- #
46
- def initialize(routing_number, account_number, bank_name, account_holder_name, options = {})
47
- @routing_number = routing_number
48
- @account_number = account_number
49
- @bank_name = bank_name
50
- @account_holder_name = account_holder_name
51
- options = @@option_defaults.merge(options)
52
- @echeck_type = options[:echeck_type]
53
- @check_number = options[:check_number]
54
- @account_type = options[:account_type]
55
- end
56
-
57
- def to_hash
58
- hash = {
59
- :method => PAYMENT_METHOD_CODE,
60
- :bank_aba_code => @routing_number,
61
- :bank_acct_num => @account_number,
62
- :bank_acct_type => @account_type,
63
- :bank_name => @bank_name,
64
- :bank_acct_name => @account_holder_name,
65
- :echeck_type => @echeck_type
66
- }
67
- hash[:bank_check_number] = @check_number unless @check_number.nil?
68
- hash
69
- end
70
- end
71
-
72
- end
@@ -1,19 +0,0 @@
1
- module AuthorizeNet::Reporting
2
-
3
- # Models a batch of credit cards.
4
- class Batch
5
-
6
- include AuthorizeNet::Model
7
-
8
- attr_accessor :id, :settled_at, :state, :statistics, :payment_method
9
-
10
- def settled_at=(time)
11
- if time.kind_of?(DateTime)
12
- @settled_at = time
13
- else
14
- @settled_at = DateTime.parse(time.to_s)
15
- end
16
- end
17
- end
18
-
19
- end
@@ -1,19 +0,0 @@
1
- module AuthorizeNet::Reporting
2
-
3
- # Models a batch of credit cards.
4
- class BatchStatistics
5
-
6
- include AuthorizeNet::Model
7
-
8
- attr_accessor :account_type, :charge_count, :charge_amount, :refund_count,
9
- :refund_amount, :void_count, :decline_count, :error_count,
10
- :returned_item_amount, :returned_item_count, :chargeback_count,
11
- :chargeback_amount, :correction_notice_count, :charge_chageback_count,
12
- :charge_chargeback_amount, :refund_chargeback_amount,
13
- :refund_chargeback_count, :charge_returned_items_amount,
14
- :charge_returned_items_count, :refund_returned_items_amount,
15
- :refund_returned_items_count
16
-
17
- end
18
-
19
- end
@@ -1,11 +0,0 @@
1
- module AuthorizeNet::Reporting
2
-
3
- # Models a fraud detection filter.
4
- class FDSFilter
5
-
6
- include AuthorizeNet::Model
7
-
8
- attr_accessor :name, :action
9
- end
10
-
11
- end
@@ -1,163 +0,0 @@
1
- module AuthorizeNet::Reporting
2
-
3
- # The CIM response class.
4
- class Response < AuthorizeNet::XmlResponse
5
-
6
- include AuthorizeNet::CIM::Fields
7
-
8
- # Constructs a new response object from raw_response in the context of transaction.
9
- # You don‘t typically construct this object yourself, as AuthorizeNet::Reeporting::Transaction
10
- # will build one for you when it makes the request to the gateway.
11
- def initialize(raw_response, transaction)
12
- super
13
- unless connection_failure?
14
- begin
15
- @batch_list = @root.at_css('batchList')
16
- @transactions = @root.at_css('transactions')
17
- @transaction = @root.at_css('transaction')
18
- rescue
19
- @raw_response = $!
20
- end
21
- end
22
- end
23
-
24
-
25
- # Returns an Array of Batch objects built from the entities returned in the response. Returns nil if no batchList was returned.
26
- def batch_list
27
- unless @batch_list.nil?
28
- batches = []
29
- @batch_list.element_children.each do |child|
30
- batches <<= build_entity(child, Fields::BATCH_ENTITY_DESCRIPTION) unless child.nil?
31
- end
32
- return batches unless batches.length == 0
33
- end
34
- end
35
-
36
- # Returns an Array of TransactionDetail objects built from the entities returned in the response. Returns nil if no transactions were returned.
37
- def transactions
38
- unless @transactions.nil?
39
- transactions = []
40
- @transactions.element_children.each do |child|
41
- unless child.nil?
42
- transaction = build_entity(child, Fields::TRANSACTION_DETAILS_ENTITY_DESCRIPTION)
43
-
44
- # handle some stuff thats too tricky for EntityDecription to handle
45
- first_name = node_content_unless_nil(child.at_css('firstName'))
46
- last_name = node_content_unless_nil(child.at_css('lastName'))
47
- unless first_name.nil? && last_name.nil?
48
- address = AuthorizeNet::Address.new(:first_name => first_name, :last_name => last_name)
49
- transaction.customer = AuthorizeNet::Customer.new(:address => address)
50
- end
51
- invoice_number = node_content_unless_nil(child.at_css('invoiceNumber'))
52
- unless invoice_number.nil?
53
- transaction.order = AuthorizeNet::Order.new(:invoice_num => invoice_number)
54
- end
55
- subscription = child.at_css('subscription')
56
- unless subscription.nil?
57
- subscription_id = node_content_unless_nil(child.at_css('subscription').at_css('id'))
58
- transaction.subscription_id = subscription_id unless subscription_id.nil?
59
-
60
- pay_num = node_content_unless_nil(child.at_css('subscription').at_css('payNum'))
61
- transaction.subscription_paynum = pay_num unless pay_num.nil?
62
- end
63
-
64
-
65
- transactions <<= transaction
66
- end
67
- end
68
- return transactions unless transactions.length == 0
69
- end
70
- end
71
-
72
- # Builds and returns a TransactionDetail entity built from the response. If no transaction was found, returns nil.
73
- def transaction
74
- unless @transaction.nil?
75
- transaction = build_entity(@transaction, Fields::TRANSACTION_DETAILS_ENTITY_DESCRIPTION)
76
-
77
- ip = node_content_unless_nil(@transaction.at_css('customerIP'))
78
- unless ip.nil?
79
- transaction.customer ||= AuthorizeNet::CIM::CustomerProfile.new()
80
- transaction.customer.ip = ip
81
- end
82
-
83
- tax_exempt = node_content_unless_nil(@transaction.at_css('taxExempt'))
84
- unless tax_exempt.nil?
85
- transaction.order ||= AuthorizeNet::Order.new()
86
- transaction.order.tax_exempt = value_to_boolean(tax_exempt)
87
- end
88
-
89
- tax = @transaction.at_css('tax')
90
- unless tax.nil?
91
- transaction.order ||= AuthorizeNet::Order.new()
92
- tax_amount = node_content_unless_nil(tax.at_css('amount'))
93
- transaction.order.tax_amount = value_to_decimal(tax_amount) unless tax_amount.nil?
94
- transaction.order.tax_name = node_content_unless_nil(tax.at_css('name'))
95
- transaction.order.tax_description = node_content_unless_nil(tax.at_css('description'))
96
- end
97
-
98
- shipping = @transaction.at_css('shipping')
99
- unless shipping.nil?
100
- transaction.order ||= AuthorizeNet::Order.new()
101
- shipping_amount = node_content_unless_nil(shipping.at_css('amount'))
102
- transaction.order.shipping_amount = value_to_decimal(shipping_amount) unless shipping_amount.nil?
103
- transaction.order.shipping_name = node_content_unless_nil(shipping.at_css('name'))
104
- transaction.order.shipping_description = node_content_unless_nil(shipping.at_css('description'))
105
- end
106
-
107
- duty = @transaction.at_css('duty')
108
- unless duty.nil?
109
- transaction.order ||= AuthorizeNet::Order.new()
110
- duty_amount = node_content_unless_nil(duty.at_css('amount'))
111
- transaction.order.duty_amount = value_to_decimal(duty_amount) unless duty_amount.nil?
112
- transaction.order.duty_name = node_content_unless_nil(duty.at_css('name'))
113
- transaction.order.duty_description = node_content_unless_nil(duty.at_css('description'))
114
- end
115
-
116
- line_items = @transaction.at_css('lineItems')
117
- unless line_items.nil?
118
- transaction.order ||= AuthorizeNet::Order.new()
119
- line_items.element_children.each do |child|
120
- line_item = build_entity(child, Fields::LINE_ITEM_ENTITY_DESCRIPTION)
121
- transaction.order.add_line_item(line_item)
122
- end
123
- end
124
-
125
- # Really not sure what to do with customer type here. It should go on a payment
126
- customer_type = node_content_unless_nil(@transaction.at_css('customer type'))
127
- unless customer_type.nil?
128
- transaction.customer ||= AuthorizeNet::CIM::CustomerProfile.new()
129
- transaction.customer.payment_profiles = [AuthorizeNet::CIM::PaymentProfile.new(:cust_type => customer_type)]
130
- end
131
-
132
- subscription = @transaction.at_css('subscription')
133
- unless subscription.nil?
134
- subscription_id = node_content_unless_nil(@transaction.at_css('subscription').at_css('id'))
135
- transaction.subscription_id = value_to_decimal(subscription_id) unless subscription_id.nil?
136
-
137
- pay_num = node_content_unless_nil(@transaction.at_css('subscription').at_css('payNum'))
138
- transaction.subscription_paynum = value_to_decimal(pay_num) unless pay_num.nil?
139
- end
140
-
141
- solution = @transaction.at_css('solution')
142
- unless solution.nil?
143
- solution_id = node_content_unless_nil(@transaction.at_css('solution').at_css('id'))
144
- transaction.solution_id = value_to_decimal(solution_id) unless solution_id.nil?
145
-
146
- transaction.solution_name = node_content_unless_nil(@transaction.at_css('solution').at_css('name'))
147
- end
148
-
149
- returned_items = @transaction.at_css('returnedItems')
150
- unless returned_items.nil?
151
- transaction.returns ||= AuthorizeNet::Reporting::ReturnedItem.new
152
- returned_items.element_children.each do |child|
153
- returned_item = build_entity(child, Fields::RETURNED_ITEM_ENTITY_DESCRIPTION)
154
- transaction.returns.add_returned_item(returned_item)
155
- end
156
- end
157
-
158
- return transaction
159
- end
160
- end
161
-
162
- end
163
- end
@@ -1,46 +0,0 @@
1
- module AuthorizeNet::Reporting
2
-
3
- class ReturnedItem
4
- include AuthorizeNet::Model
5
-
6
- attr_accessor :id, :date_utc, :date_local, :code, :description, :returned_items
7
-
8
- def date_utc=(time)
9
- if time.kind_of?(DateTime)
10
- @date_utc = time
11
- else
12
- @date_utc = DateTime.parse(time.to_s)
13
- end
14
- end
15
-
16
- def date_local=(time)
17
- if time.kind_of?(DateTime)
18
- @date_local = time
19
- else
20
- @date_local = DateTime.parse(time.to_s)
21
- end
22
- end
23
-
24
- def add_returned_item(id = nil, date_utc = nil, date_local = nil, code = nil, description = nil)
25
- if id.kind_of?(AuthorizeNet::Reporting::ReturnedItem)
26
- returned_item = id
27
- else
28
- returned_item = AuthorizeNet::Reporting::ReturnedItem.new({:return_item_id => id, :return_item_date_utc => date_utc, :return_item_date_local => date_local, :return_item_code => code, :line_item_description => description})
29
- end
30
- @returned_items = @returned_items.to_a << returned_item
31
- end
32
-
33
- def to_hash
34
- hash = {
35
- :id => @id,
36
- :date_utc => @date_utc,
37
- :date_local => @date_local,
38
- :code => @code,
39
- :description => @description,
40
- :returned_items => handle_multivalue_hashing(@returned_items)
41
- }
42
- hash.delete_if { |k, v| v.nil? }
43
- hash
44
- end
45
- end
46
- end
@@ -1,133 +0,0 @@
1
- module AuthorizeNet::Reporting
2
-
3
- # The Reporting API transaction class.
4
- class Transaction < AuthorizeNet::XmlTransaction
5
-
6
- include AuthorizeNet::Reporting::Fields
7
-
8
- # The class to wrap our response in.
9
- @response_class = AuthorizeNet::Reporting::Response
10
-
11
- # Fields to convert to/from Date.
12
- @@datetime_fields = [:first_settlement_date, :last_settlement_date]
13
-
14
- # Constructs a Reporting transaction. You can use the new Reporting transaction object
15
- # to issue a request to the payment gateway and parse the response into a new
16
- # AuthorizeNet::Reporting::Response object.
17
- #
18
- # +api_login_id+:: Your API login ID, as a string.
19
- # +api_transaction_key+:: Your API transaction key, as a string.
20
- # +options+:: A hash of options. See below for values.
21
- #
22
- # Options
23
- # +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).
24
- # +verify_ssl+:: A boolean indicating if the SSL certificate of the +gateway+ should be verified. Defaults to true.
25
- # +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.
26
- #
27
- def initialize(api_login_id, api_transaction_key, options = {})
28
- super
29
- end
30
-
31
- # Sets up and submits a getSettledBatchListRequest transaction. If this transaction has already been
32
- # run, this method will return nil. Otherwise it will return an AuthorizeNet::Reporting::Response object. The
33
- # response object will have an array of Batch objects available via its batch_list method if
34
- # the request was successful.
35
- #
36
- #
37
- # +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.
38
- # +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.
39
- # +include_stats+:: Takes a Boolean. Determines if BatchStatistics should be returned with the Batch objects. Defaults to false.
40
- #
41
- # Typical usage:
42
- #
43
- # response = transaction.get_settled_batch_list(DateTime.now() - (1 * 3600 * 48), DateTime.now(), true)
44
- # batches = response.batch_list if response.success?
45
- #
46
- def get_settled_batch_list(from_date = nil, to_date = nil, include_stats = false)
47
- @type = Type::REPORT_GET_BATCH_LIST
48
- set_fields({:first_settlement_date => from_date, :last_settlement_date => to_date, :include_statistics => include_stats})
49
- make_request
50
- end
51
-
52
- # Sets up and submits a getTransactionListRequest transaction. If this transaction has already been
53
- # run, this method will return nil. Otherwise it will return an AuthorizeNet::Reporting::Response object. The
54
- # response object will have an array of TransactionDetail objects available via its transactions method if
55
- # the request was successful. These TransactionDetail objects will not be fully populated. Use get_transaction_details
56
- # to get all the details.
57
- #
58
- #
59
- # +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.
60
- #
61
- # Typical usage:
62
- #
63
- # response = transaction.get_transaction_list('123456')
64
- # transactions = response.transactions if response.success?
65
- #
66
- def get_transaction_list(batch_id)
67
- @type = Type::REPORT_GET_TRANSACTION_LIST
68
- handle_batch_id(batch_id)
69
- make_request
70
- end
71
-
72
- # Sets up and submits a getUnsettledTransactionListRequest transaction. If this transaction has already been
73
- # run, this method will return nil. Otherwise it will return an AuthorizeNet::Reporting::Response object. The
74
- # response object will have an array of TransactionDetail objects available via its transactions method if
75
- # the request was successful. These TransactionDetail objects will not be fully populated. Use get_transaction_details
76
- # to get all the details.
77
- #
78
- #
79
- # Typical usage:
80
- #
81
- # response = transaction.get_unsettled_transaction_list
82
- # transactions = response.transactions if response.success?
83
- #
84
- def get_unsettled_transaction_list
85
- @type = Type::REPORT_GET_UNSETTLED_TRANSACTION_LIST
86
- make_request
87
- end
88
-
89
- # Sets up and submits a getTransactionDetailsRequest transaction. If this transaction has already been
90
- # run, this method will return nil. Otherwise it will return an AuthorizeNet::Reporting::Response object. The
91
- # response object will have a TransactionDetail object available via its transactions method if
92
- # the request was successful. This TransactionDetail object will have more data than the limited version
93
- # returned by get_transaction_list.
94
- #
95
- #
96
- # +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.
97
- #
98
- # Typical usage:
99
- #
100
- # response = transaction.get_transaction_details('123456789')
101
- # transactions = response.transactions if response.success?
102
- #
103
- def get_transaction_details(transaction_id)
104
- @type = Type::REPORT_GET_TRANSACTION_DETAILS
105
- handle_transaction_id(transaction_id)
106
- make_request
107
- end
108
-
109
- #:enddoc:
110
- protected
111
-
112
- # Handles batch id type massaging.
113
- def handle_batch_id(id)
114
- case id
115
- when Batch
116
- set_fields(:batch_id => id.id.to_s)
117
- else
118
- set_fields(:batch_id => id.to_s)
119
- end
120
- end
121
-
122
- # Handles transaction id type massaging.
123
- def handle_transaction_id(id)
124
- case id
125
- when TransactionDetails
126
- set_fields(:transaction_id => id.id.to_s)
127
- else
128
- set_fields(:transaction_id => id.to_s)
129
- end
130
- end
131
- end
132
-
133
- end