authorizenet 1.9.5 → 1.9.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/lib/app/helpers/authorize_net_helper.rb +23 -23
  3. data/lib/authorize_net.rb +107 -107
  4. data/lib/authorize_net/addresses/address.rb +25 -25
  5. data/lib/authorize_net/addresses/shipping_address.rb +22 -22
  6. data/lib/authorize_net/aim/response.rb +120 -120
  7. data/lib/authorize_net/aim/transaction.rb +171 -171
  8. data/lib/authorize_net/api/api_transaction.rb +119 -119
  9. data/lib/authorize_net/api/constants.yml +1 -1
  10. data/lib/authorize_net/api/schema.rb +5165 -5153
  11. data/lib/authorize_net/api/transaction.rb +261 -261
  12. data/lib/authorize_net/arb/fields.rb +24 -24
  13. data/lib/authorize_net/arb/paging.rb +29 -29
  14. data/lib/authorize_net/arb/response.rb +26 -26
  15. data/lib/authorize_net/arb/sorting.rb +39 -39
  16. data/lib/authorize_net/arb/subscription.rb +68 -68
  17. data/lib/authorize_net/arb/subscription_detail.rb +10 -10
  18. data/lib/authorize_net/arb/subscription_list_response.rb +36 -36
  19. data/lib/authorize_net/arb/transaction.rb +171 -171
  20. data/lib/authorize_net/authorize_net.rb +154 -154
  21. data/lib/authorize_net/cim/customer_profile.rb +15 -15
  22. data/lib/authorize_net/cim/payment_profile.rb +35 -35
  23. data/lib/authorize_net/cim/response.rb +111 -111
  24. data/lib/authorize_net/cim/transaction.rb +721 -721
  25. data/lib/authorize_net/customer.rb +24 -24
  26. data/lib/authorize_net/email_receipt.rb +20 -20
  27. data/lib/authorize_net/fields.rb +760 -760
  28. data/lib/authorize_net/key_value_response.rb +109 -109
  29. data/lib/authorize_net/key_value_transaction.rb +281 -281
  30. data/lib/authorize_net/line_item.rb +21 -21
  31. data/lib/authorize_net/order.rb +38 -38
  32. data/lib/authorize_net/payment_methods/credit_card.rb +61 -61
  33. data/lib/authorize_net/payment_methods/echeck.rb +70 -70
  34. data/lib/authorize_net/reporting/batch.rb +16 -16
  35. data/lib/authorize_net/reporting/batch_statistics.rb +15 -15
  36. data/lib/authorize_net/reporting/fds_filter.rb +8 -8
  37. data/lib/authorize_net/reporting/response.rb +157 -157
  38. data/lib/authorize_net/reporting/returned_item.rb +45 -45
  39. data/lib/authorize_net/reporting/transaction.rb +131 -131
  40. data/lib/authorize_net/reporting/transaction_details.rb +22 -22
  41. data/lib/authorize_net/response.rb +25 -25
  42. data/lib/authorize_net/sim/hosted_payment_form.rb +34 -34
  43. data/lib/authorize_net/sim/hosted_receipt_page.rb +32 -32
  44. data/lib/authorize_net/sim/response.rb +133 -133
  45. data/lib/authorize_net/sim/transaction.rb +128 -128
  46. data/lib/authorize_net/transaction.rb +66 -66
  47. data/lib/authorize_net/xml_response.rb +154 -154
  48. data/lib/authorize_net/xml_transaction.rb +279 -279
  49. data/lib/authorizenet.rb +4 -4
  50. data/lib/generators/authorize_net/direct_post/direct_post_generator.rb +52 -52
  51. data/lib/generators/authorize_net/direct_post/templates/README-AuthorizeNet +48 -48
  52. data/lib/generators/authorize_net/direct_post/templates/config.yml.erb +8 -8
  53. data/lib/generators/authorize_net/direct_post/templates/config.yml.rails3.erb +8 -8
  54. data/lib/generators/authorize_net/direct_post/templates/controller.rb.erb +30 -30
  55. data/lib/generators/authorize_net/direct_post/templates/initializer.rb +4 -4
  56. data/lib/generators/authorize_net/direct_post/templates/layout.erb +17 -17
  57. data/lib/generators/authorize_net/direct_post/templates/payment.erb +9 -9
  58. data/lib/generators/authorize_net/direct_post/templates/payment.rails3.erb +9 -9
  59. data/lib/generators/authorize_net/sim/sim_generator.rb +46 -46
  60. data/lib/generators/authorize_net/sim/templates/README-AuthorizeNet +51 -51
  61. data/lib/generators/authorize_net/sim/templates/config.yml.erb +8 -8
  62. data/lib/generators/authorize_net/sim/templates/config.yml.rails3.erb +8 -8
  63. data/lib/generators/authorize_net/sim/templates/controller.rb.erb +20 -20
  64. data/lib/generators/authorize_net/sim/templates/initializer.rb +4 -4
  65. data/lib/generators/authorize_net/sim/templates/layout.erb +17 -17
  66. data/lib/generators/authorize_net/sim/templates/payment.erb +5 -5
  67. data/lib/generators/authorize_net/sim/templates/payment.rails3.erb +5 -5
  68. data/lib/generators/generator_extensions.rb +73 -73
  69. metadata +84 -102
@@ -1,8 +1,8 @@
1
- module AuthorizeNet::Reporting
2
- # Models a fraud detection filter.
3
- class FDSFilter
4
- include AuthorizeNet::Model
5
-
6
- attr_accessor :name, :action
7
- end
8
- end
1
+ module AuthorizeNet::Reporting
2
+ # Models a fraud detection filter.
3
+ class FDSFilter
4
+ include AuthorizeNet::Model
5
+
6
+ attr_accessor :name, :action
7
+ end
8
+ end
@@ -1,157 +1,157 @@
1
- module AuthorizeNet::Reporting
2
- # The CIM response class.
3
- class Response < AuthorizeNet::XmlResponse
4
- include AuthorizeNet::CIM::Fields
5
-
6
- # Constructs a new response object from raw_response in the context of transaction.
7
- # You don‘t typically construct this object yourself, as AuthorizeNet::Reeporting::Transaction
8
- # will build one for you when it makes the request to the gateway.
9
- def initialize(raw_response, transaction)
10
- super
11
- unless connection_failure?
12
- begin
13
- @batch_list = @root.at_css('batchList')
14
- @transactions = @root.at_css('transactions')
15
- @transaction = @root.at_css('transaction')
16
- rescue StandardError
17
- @raw_response = $ERROR_INFO
18
- end
19
- end
20
- end
21
-
22
- # Returns an Array of Batch objects built from the entities returned in the response. Returns nil if no batchList was returned.
23
- def batch_list
24
- unless @batch_list.nil?
25
- batches = []
26
- @batch_list.element_children.each do |child|
27
- batches <<= build_entity(child, Fields::BATCH_ENTITY_DESCRIPTION) unless child.nil?
28
- end
29
- return batches unless batches.empty?
30
- end
31
- end
32
-
33
- # Returns an Array of TransactionDetail objects built from the entities returned in the response. Returns nil if no transactions were returned.
34
- def transactions
35
- unless @transactions.nil?
36
- transactions = []
37
- @transactions.element_children.each do |child|
38
- next if child.nil?
39
- transaction = build_entity(child, Fields::TRANSACTION_DETAILS_ENTITY_DESCRIPTION)
40
-
41
- # handle some stuff thats too tricky for EntityDecription to handle
42
- first_name = node_content_unless_nil(child.at_css('firstName'))
43
- last_name = node_content_unless_nil(child.at_css('lastName'))
44
- unless first_name.nil? && last_name.nil?
45
- address = AuthorizeNet::Address.new(first_name: first_name, last_name: last_name)
46
- transaction.customer = AuthorizeNet::Customer.new(address: address)
47
- end
48
- invoice_number = node_content_unless_nil(child.at_css('invoiceNumber'))
49
- unless invoice_number.nil?
50
- transaction.order = AuthorizeNet::Order.new(invoice_num: invoice_number)
51
- end
52
- subscription = child.at_css('subscription')
53
- unless subscription.nil?
54
- subscription_id = node_content_unless_nil(child.at_css('subscription').at_css('id'))
55
- transaction.subscription_id = subscription_id unless subscription_id.nil?
56
-
57
- pay_num = node_content_unless_nil(child.at_css('subscription').at_css('payNum'))
58
- transaction.subscription_paynum = pay_num unless pay_num.nil?
59
- end
60
-
61
- transactions <<= transaction
62
- end
63
- return transactions unless transactions.empty?
64
- end
65
- end
66
-
67
- # Builds and returns a TransactionDetail entity built from the response. If no transaction was found, returns nil.
68
- def transaction
69
- unless @transaction.nil?
70
- transaction = build_entity(@transaction, Fields::TRANSACTION_DETAILS_ENTITY_DESCRIPTION)
71
-
72
- ip = node_content_unless_nil(@transaction.at_css('customerIP'))
73
- unless ip.nil?
74
- transaction.customer ||= AuthorizeNet::CIM::CustomerProfile.new
75
- transaction.customer.ip = ip
76
- end
77
-
78
- tax_exempt = node_content_unless_nil(@transaction.at_css('taxExempt'))
79
- unless tax_exempt.nil?
80
- transaction.order ||= AuthorizeNet::Order.new
81
- transaction.order.tax_exempt = value_to_boolean(tax_exempt)
82
- end
83
-
84
- tax = @transaction.at_css('tax')
85
- unless tax.nil?
86
- transaction.order ||= AuthorizeNet::Order.new
87
- tax_amount = node_content_unless_nil(tax.at_css('amount'))
88
- transaction.order.tax = value_to_decimal(tax_amount) unless tax_amount.nil?
89
- transaction.order.tax_name = node_content_unless_nil(tax.at_css('name'))
90
- transaction.order.tax_description = node_content_unless_nil(tax.at_css('description'))
91
- end
92
-
93
- shipping = @transaction.at_css('shipping')
94
- unless shipping.nil?
95
- transaction.order ||= AuthorizeNet::Order.new
96
- shipping_amount = node_content_unless_nil(shipping.at_css('amount'))
97
- transaction.order.freight = value_to_decimal(shipping_amount) unless shipping_amount.nil?
98
- transaction.order.freight_name = node_content_unless_nil(shipping.at_css('name'))
99
- transaction.order.freight_description = node_content_unless_nil(shipping.at_css('description'))
100
- end
101
-
102
- duty = @transaction.at_css('duty')
103
- unless duty.nil?
104
- transaction.order ||= AuthorizeNet::Order.new
105
- duty_amount = node_content_unless_nil(duty.at_css('amount'))
106
- transaction.order.duty = value_to_decimal(duty_amount) unless duty_amount.nil?
107
- transaction.order.duty_name = node_content_unless_nil(duty.at_css('name'))
108
- transaction.order.duty_description = node_content_unless_nil(duty.at_css('description'))
109
- end
110
-
111
- line_items = @transaction.at_css('lineItems')
112
- unless line_items.nil?
113
- transaction.order ||= AuthorizeNet::Order.new
114
- line_items.element_children.each do |child|
115
- line_item = build_entity(child, Fields::LINE_ITEM_ENTITY_DESCRIPTION)
116
- transaction.order.add_line_item(line_item)
117
- end
118
- end
119
-
120
- # Really not sure what to do with customer type here. It should go on a payment
121
- customer_type = node_content_unless_nil(@transaction.at_css('customer type'))
122
- unless customer_type.nil?
123
- transaction.customer ||= AuthorizeNet::CIM::CustomerProfile.new
124
- transaction.customer.payment_profiles = [AuthorizeNet::CIM::PaymentProfile.new(cust_type: customer_type)]
125
- end
126
-
127
- subscription = @transaction.at_css('subscription')
128
- unless subscription.nil?
129
- subscription_id = node_content_unless_nil(@transaction.at_css('subscription').at_css('id'))
130
- transaction.subscription_id = value_to_decimal(subscription_id) unless subscription_id.nil?
131
-
132
- pay_num = node_content_unless_nil(@transaction.at_css('subscription').at_css('payNum'))
133
- transaction.subscription_paynum = value_to_decimal(pay_num) unless pay_num.nil?
134
- end
135
-
136
- solution = @transaction.at_css('solution')
137
- unless solution.nil?
138
- solution_id = node_content_unless_nil(@transaction.at_css('solution').at_css('id'))
139
- transaction.solution_id = solution_id unless solution_id.nil?
140
-
141
- transaction.solution_name = node_content_unless_nil(@transaction.at_css('solution').at_css('name'))
142
- end
143
-
144
- returned_items = @transaction.at_css('returnedItems')
145
- unless returned_items.nil?
146
- transaction.returns ||= AuthorizeNet::Reporting::ReturnedItem.new
147
- returned_items.element_children.each do |child|
148
- returned_item = build_entity(child, Fields::RETURNED_ITEM_ENTITY_DESCRIPTION)
149
- transaction.returns.add_returned_item(returned_item)
150
- end
151
- end
152
-
153
- transaction
154
- end
155
- end
156
- end
157
- end
1
+ module AuthorizeNet::Reporting
2
+ # The CIM response class.
3
+ class Response < AuthorizeNet::XmlResponse
4
+ include AuthorizeNet::CIM::Fields
5
+
6
+ # Constructs a new response object from raw_response in the context of transaction.
7
+ # You don‘t typically construct this object yourself, as AuthorizeNet::Reeporting::Transaction
8
+ # will build one for you when it makes the request to the gateway.
9
+ def initialize(raw_response, transaction)
10
+ super
11
+ unless connection_failure?
12
+ begin
13
+ @batch_list = @root.at_css('batchList')
14
+ @transactions = @root.at_css('transactions')
15
+ @transaction = @root.at_css('transaction')
16
+ rescue StandardError
17
+ @raw_response = $ERROR_INFO
18
+ end
19
+ end
20
+ end
21
+
22
+ # Returns an Array of Batch objects built from the entities returned in the response. Returns nil if no batchList was returned.
23
+ def batch_list
24
+ unless @batch_list.nil?
25
+ batches = []
26
+ @batch_list.element_children.each do |child|
27
+ batches <<= build_entity(child, Fields::BATCH_ENTITY_DESCRIPTION) unless child.nil?
28
+ end
29
+ return batches unless batches.empty?
30
+ end
31
+ end
32
+
33
+ # Returns an Array of TransactionDetail objects built from the entities returned in the response. Returns nil if no transactions were returned.
34
+ def transactions
35
+ unless @transactions.nil?
36
+ transactions = []
37
+ @transactions.element_children.each do |child|
38
+ next if child.nil?
39
+ transaction = build_entity(child, Fields::TRANSACTION_DETAILS_ENTITY_DESCRIPTION)
40
+
41
+ # handle some stuff thats too tricky for EntityDecription to handle
42
+ first_name = node_content_unless_nil(child.at_css('firstName'))
43
+ last_name = node_content_unless_nil(child.at_css('lastName'))
44
+ unless first_name.nil? && last_name.nil?
45
+ address = AuthorizeNet::Address.new(first_name: first_name, last_name: last_name)
46
+ transaction.customer = AuthorizeNet::Customer.new(address: address)
47
+ end
48
+ invoice_number = node_content_unless_nil(child.at_css('invoiceNumber'))
49
+ unless invoice_number.nil?
50
+ transaction.order = AuthorizeNet::Order.new(invoice_num: invoice_number)
51
+ end
52
+ subscription = child.at_css('subscription')
53
+ unless subscription.nil?
54
+ subscription_id = node_content_unless_nil(child.at_css('subscription').at_css('id'))
55
+ transaction.subscription_id = subscription_id unless subscription_id.nil?
56
+
57
+ pay_num = node_content_unless_nil(child.at_css('subscription').at_css('payNum'))
58
+ transaction.subscription_paynum = pay_num unless pay_num.nil?
59
+ end
60
+
61
+ transactions <<= transaction
62
+ end
63
+ return transactions unless transactions.empty?
64
+ end
65
+ end
66
+
67
+ # Builds and returns a TransactionDetail entity built from the response. If no transaction was found, returns nil.
68
+ def transaction
69
+ unless @transaction.nil?
70
+ transaction = build_entity(@transaction, Fields::TRANSACTION_DETAILS_ENTITY_DESCRIPTION)
71
+
72
+ ip = node_content_unless_nil(@transaction.at_css('customerIP'))
73
+ unless ip.nil?
74
+ transaction.customer ||= AuthorizeNet::CIM::CustomerProfile.new
75
+ transaction.customer.ip = ip
76
+ end
77
+
78
+ tax_exempt = node_content_unless_nil(@transaction.at_css('taxExempt'))
79
+ unless tax_exempt.nil?
80
+ transaction.order ||= AuthorizeNet::Order.new
81
+ transaction.order.tax_exempt = value_to_boolean(tax_exempt)
82
+ end
83
+
84
+ tax = @transaction.at_css('tax')
85
+ unless tax.nil?
86
+ transaction.order ||= AuthorizeNet::Order.new
87
+ tax_amount = node_content_unless_nil(tax.at_css('amount'))
88
+ transaction.order.tax = value_to_decimal(tax_amount) unless tax_amount.nil?
89
+ transaction.order.tax_name = node_content_unless_nil(tax.at_css('name'))
90
+ transaction.order.tax_description = node_content_unless_nil(tax.at_css('description'))
91
+ end
92
+
93
+ shipping = @transaction.at_css('shipping')
94
+ unless shipping.nil?
95
+ transaction.order ||= AuthorizeNet::Order.new
96
+ shipping_amount = node_content_unless_nil(shipping.at_css('amount'))
97
+ transaction.order.freight = value_to_decimal(shipping_amount) unless shipping_amount.nil?
98
+ transaction.order.freight_name = node_content_unless_nil(shipping.at_css('name'))
99
+ transaction.order.freight_description = node_content_unless_nil(shipping.at_css('description'))
100
+ end
101
+
102
+ duty = @transaction.at_css('duty')
103
+ unless duty.nil?
104
+ transaction.order ||= AuthorizeNet::Order.new
105
+ duty_amount = node_content_unless_nil(duty.at_css('amount'))
106
+ transaction.order.duty = value_to_decimal(duty_amount) unless duty_amount.nil?
107
+ transaction.order.duty_name = node_content_unless_nil(duty.at_css('name'))
108
+ transaction.order.duty_description = node_content_unless_nil(duty.at_css('description'))
109
+ end
110
+
111
+ line_items = @transaction.at_css('lineItems')
112
+ unless line_items.nil?
113
+ transaction.order ||= AuthorizeNet::Order.new
114
+ line_items.element_children.each do |child|
115
+ line_item = build_entity(child, Fields::LINE_ITEM_ENTITY_DESCRIPTION)
116
+ transaction.order.add_line_item(line_item)
117
+ end
118
+ end
119
+
120
+ # Really not sure what to do with customer type here. It should go on a payment
121
+ customer_type = node_content_unless_nil(@transaction.at_css('customer type'))
122
+ unless customer_type.nil?
123
+ transaction.customer ||= AuthorizeNet::CIM::CustomerProfile.new
124
+ transaction.customer.payment_profiles = [AuthorizeNet::CIM::PaymentProfile.new(cust_type: customer_type)]
125
+ end
126
+
127
+ subscription = @transaction.at_css('subscription')
128
+ unless subscription.nil?
129
+ subscription_id = node_content_unless_nil(@transaction.at_css('subscription').at_css('id'))
130
+ transaction.subscription_id = value_to_decimal(subscription_id) unless subscription_id.nil?
131
+
132
+ pay_num = node_content_unless_nil(@transaction.at_css('subscription').at_css('payNum'))
133
+ transaction.subscription_paynum = value_to_decimal(pay_num) unless pay_num.nil?
134
+ end
135
+
136
+ solution = @transaction.at_css('solution')
137
+ unless solution.nil?
138
+ solution_id = node_content_unless_nil(@transaction.at_css('solution').at_css('id'))
139
+ transaction.solution_id = solution_id unless solution_id.nil?
140
+
141
+ transaction.solution_name = node_content_unless_nil(@transaction.at_css('solution').at_css('name'))
142
+ end
143
+
144
+ returned_items = @transaction.at_css('returnedItems')
145
+ unless returned_items.nil?
146
+ transaction.returns ||= AuthorizeNet::Reporting::ReturnedItem.new
147
+ returned_items.element_children.each do |child|
148
+ returned_item = build_entity(child, Fields::RETURNED_ITEM_ENTITY_DESCRIPTION)
149
+ transaction.returns.add_returned_item(returned_item)
150
+ end
151
+ end
152
+
153
+ transaction
154
+ end
155
+ end
156
+ end
157
+ end
@@ -1,45 +1,45 @@
1
- module AuthorizeNet::Reporting
2
- class ReturnedItem
3
- include AuthorizeNet::Model
4
-
5
- attr_accessor :id, :date_utc, :date_local, :code, :description, :returned_items
6
-
7
- def date_utc=(time)
8
- if time.is_a?(DateTime)
9
- @date_utc = time
10
- else
11
- @date_utc = DateTime.parse(time.to_s)
12
- end
13
- end
14
-
15
- def date_local=(time)
16
- if time.is_a?(DateTime)
17
- @date_local = time
18
- else
19
- @date_local = DateTime.parse(time.to_s)
20
- end
21
- end
22
-
23
- def add_returned_item(id = nil, date_utc = nil, date_local = nil, code = nil, description = nil)
24
- if id.is_a?(AuthorizeNet::Reporting::ReturnedItem)
25
- returned_item = id
26
- else
27
- 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)
28
- end
29
- @returned_items = @returned_items.to_a << returned_item
30
- end
31
-
32
- def to_hash
33
- hash = {
34
- id: @id,
35
- date_utc: @date_utc,
36
- date_local: @date_local,
37
- code: @code,
38
- description: @description,
39
- returned_items: handle_multivalue_hashing(@returned_items)
40
- }
41
- hash.delete_if { |_k, v| v.nil? }
42
- hash
43
- end
44
- end
45
- end
1
+ module AuthorizeNet::Reporting
2
+ class ReturnedItem
3
+ include AuthorizeNet::Model
4
+
5
+ attr_accessor :id, :date_utc, :date_local, :code, :description, :returned_items
6
+
7
+ def date_utc=(time)
8
+ if time.is_a?(DateTime)
9
+ @date_utc = time
10
+ else
11
+ @date_utc = DateTime.parse(time.to_s)
12
+ end
13
+ end
14
+
15
+ def date_local=(time)
16
+ if time.is_a?(DateTime)
17
+ @date_local = time
18
+ else
19
+ @date_local = DateTime.parse(time.to_s)
20
+ end
21
+ end
22
+
23
+ def add_returned_item(id = nil, date_utc = nil, date_local = nil, code = nil, description = nil)
24
+ if id.is_a?(AuthorizeNet::Reporting::ReturnedItem)
25
+ returned_item = id
26
+ else
27
+ 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)
28
+ end
29
+ @returned_items = @returned_items.to_a << returned_item
30
+ end
31
+
32
+ def to_hash
33
+ hash = {
34
+ id: @id,
35
+ date_utc: @date_utc,
36
+ date_local: @date_local,
37
+ code: @code,
38
+ description: @description,
39
+ returned_items: handle_multivalue_hashing(@returned_items)
40
+ }
41
+ hash.delete_if { |_k, v| v.nil? }
42
+ hash
43
+ end
44
+ end
45
+ end
@@ -1,131 +1,131 @@
1
- module AuthorizeNet::Reporting
2
- # The Reporting API transaction class.
3
- class Transaction < AuthorizeNet::XmlTransaction
4
- include AuthorizeNet::Reporting::Fields
5
-
6
- # The class to wrap our response in.
7
- @response_class = AuthorizeNet::Reporting::Response
8
-
9
- # Fields to convert to/from Date.
10
- @@datetime_fields = %i[first_settlement_date last_settlement_date]
11
-
12
- # Constructs a Reporting transaction. You can use the new Reporting transaction object
13
- # to issue a request to the payment gateway and parse the response into a new
14
- # AuthorizeNet::Reporting::Response object.
15
- #
16
- # +api_login_id+:: Your API login ID, as a string.
17
- # +api_transaction_key+:: Your API transaction key, as a string.
18
- # +options+:: A hash of options. See below for values.
19
- #
20
- # Options
21
- # +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).
22
- # +verify_ssl+:: A boolean indicating if the SSL certificate of the +gateway+ should be verified. Defaults to true.
23
- # +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.
24
- #
25
- def initialize(api_login_id, api_transaction_key, options = {})
26
- ActiveSupport::Deprecation.warn "use AuthorizeNet::API::Transaction"
27
- super
28
- end
29
-
30
- # Sets up and submits a getSettledBatchListRequest transaction. If this transaction has already been
31
- # run, this method will return nil. Otherwise it will return an AuthorizeNet::Reporting::Response object. The
32
- # response object will have an array of Batch objects available via its batch_list method if
33
- # the request was successful.
34
- #
35
- #
36
- # +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.
37
- # +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.
38
- # +include_stats+:: Takes a Boolean. Determines if BatchStatistics should be returned with the Batch objects. Defaults to false.
39
- #
40
- # Typical usage:
41
- #
42
- # response = transaction.get_settled_batch_list(DateTime.now() - (1 * 3600 * 48), DateTime.now(), true)
43
- # batches = response.batch_list if response.success?
44
- #
45
- def get_settled_batch_list(from_date = nil, to_date = nil, include_stats = false)
46
- @type = Type::REPORT_GET_BATCH_LIST
47
- set_fields(first_settlement_date: from_date, last_settlement_date: to_date, include_statistics: include_stats)
48
- make_request
49
- end
50
-
51
- # Sets up and submits a getTransactionListRequest transaction. If this transaction has already been
52
- # run, this method will return nil. Otherwise it will return an AuthorizeNet::Reporting::Response object. The
53
- # response object will have an array of TransactionDetail objects available via its transactions method if
54
- # the request was successful. These TransactionDetail objects will not be fully populated. Use get_transaction_details
55
- # to get all the details.
56
- #
57
- #
58
- # +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.
59
- #
60
- # Typical usage:
61
- #
62
- # response = transaction.get_transaction_list('123456')
63
- # transactions = response.transactions if response.success?
64
- #
65
- def get_transaction_list(batch_id)
66
- @type = Type::REPORT_GET_TRANSACTION_LIST
67
- handle_batch_id(batch_id)
68
- make_request
69
- end
70
-
71
- # Sets up and submits a getUnsettledTransactionListRequest transaction. If this transaction has already been
72
- # run, this method will return nil. Otherwise it will return an AuthorizeNet::Reporting::Response object. The
73
- # response object will have an array of TransactionDetail objects available via its transactions method if
74
- # the request was successful. These TransactionDetail objects will not be fully populated. Use get_transaction_details
75
- # to get all the details.
76
- #
77
- #
78
- # Typical usage:
79
- #
80
- # response = transaction.get_unsettled_transaction_list
81
- # transactions = response.transactions if response.success?
82
- #
83
- def get_unsettled_transaction_list
84
- @type = Type::REPORT_GET_UNSETTLED_TRANSACTION_LIST
85
- make_request
86
- end
87
-
88
- # Sets up and submits a getTransactionDetailsRequest transaction. If this transaction has already been
89
- # run, this method will return nil. Otherwise it will return an AuthorizeNet::Reporting::Response object. The
90
- # response object will have a TransactionDetail object available via its transactions method if
91
- # the request was successful. This TransactionDetail object will have more data than the limited version
92
- # returned by get_transaction_list.
93
- #
94
- #
95
- # +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.
96
- #
97
- # Typical usage:
98
- #
99
- # response = transaction.get_transaction_details('123456789')
100
- # transactions = response.transactions if response.success?
101
- #
102
- def get_transaction_details(transaction_id)
103
- @type = Type::REPORT_GET_TRANSACTION_DETAILS
104
- handle_transaction_id(transaction_id)
105
- make_request
106
- end
107
-
108
- #:enddoc:
109
- protected
110
-
111
- # Handles batch id type massaging.
112
- def handle_batch_id(id)
113
- case id
114
- when Batch
115
- set_fields(batch_id: id.id.to_s)
116
- else
117
- set_fields(batch_id: id.to_s)
118
- end
119
- end
120
-
121
- # Handles transaction id type massaging.
122
- def handle_transaction_id(id)
123
- case id
124
- when TransactionDetails
125
- set_fields(transaction_id: id.id.to_s)
126
- else
127
- set_fields(transaction_id: id.to_s)
128
- end
129
- end
130
- end
131
- end
1
+ module AuthorizeNet::Reporting
2
+ # The Reporting API transaction class.
3
+ class Transaction < AuthorizeNet::XmlTransaction
4
+ include AuthorizeNet::Reporting::Fields
5
+
6
+ # The class to wrap our response in.
7
+ @response_class = AuthorizeNet::Reporting::Response
8
+
9
+ # Fields to convert to/from Date.
10
+ @@datetime_fields = %i[first_settlement_date last_settlement_date]
11
+
12
+ # Constructs a Reporting transaction. You can use the new Reporting transaction object
13
+ # to issue a request to the payment gateway and parse the response into a new
14
+ # AuthorizeNet::Reporting::Response object.
15
+ #
16
+ # +api_login_id+:: Your API login ID, as a string.
17
+ # +api_transaction_key+:: Your API transaction key, as a string.
18
+ # +options+:: A hash of options. See below for values.
19
+ #
20
+ # Options
21
+ # +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).
22
+ # +verify_ssl+:: A boolean indicating if the SSL certificate of the +gateway+ should be verified. Defaults to true.
23
+ # +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.
24
+ #
25
+ def initialize(api_login_id, api_transaction_key, options = {})
26
+ ActiveSupport::Deprecation.warn "use AuthorizeNet::API::Transaction"
27
+ super
28
+ end
29
+
30
+ # Sets up and submits a getSettledBatchListRequest transaction. If this transaction has already been
31
+ # run, this method will return nil. Otherwise it will return an AuthorizeNet::Reporting::Response object. The
32
+ # response object will have an array of Batch objects available via its batch_list method if
33
+ # the request was successful.
34
+ #
35
+ #
36
+ # +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.
37
+ # +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.
38
+ # +include_stats+:: Takes a Boolean. Determines if BatchStatistics should be returned with the Batch objects. Defaults to false.
39
+ #
40
+ # Typical usage:
41
+ #
42
+ # response = transaction.get_settled_batch_list(DateTime.now() - (1 * 3600 * 48), DateTime.now(), true)
43
+ # batches = response.batch_list if response.success?
44
+ #
45
+ def get_settled_batch_list(from_date = nil, to_date = nil, include_stats = false)
46
+ @type = Type::REPORT_GET_BATCH_LIST
47
+ set_fields(first_settlement_date: from_date, last_settlement_date: to_date, include_statistics: include_stats)
48
+ make_request
49
+ end
50
+
51
+ # Sets up and submits a getTransactionListRequest transaction. If this transaction has already been
52
+ # run, this method will return nil. Otherwise it will return an AuthorizeNet::Reporting::Response object. The
53
+ # response object will have an array of TransactionDetail objects available via its transactions method if
54
+ # the request was successful. These TransactionDetail objects will not be fully populated. Use get_transaction_details
55
+ # to get all the details.
56
+ #
57
+ #
58
+ # +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.
59
+ #
60
+ # Typical usage:
61
+ #
62
+ # response = transaction.get_transaction_list('123456')
63
+ # transactions = response.transactions if response.success?
64
+ #
65
+ def get_transaction_list(batch_id)
66
+ @type = Type::REPORT_GET_TRANSACTION_LIST
67
+ handle_batch_id(batch_id)
68
+ make_request
69
+ end
70
+
71
+ # Sets up and submits a getUnsettledTransactionListRequest transaction. If this transaction has already been
72
+ # run, this method will return nil. Otherwise it will return an AuthorizeNet::Reporting::Response object. The
73
+ # response object will have an array of TransactionDetail objects available via its transactions method if
74
+ # the request was successful. These TransactionDetail objects will not be fully populated. Use get_transaction_details
75
+ # to get all the details.
76
+ #
77
+ #
78
+ # Typical usage:
79
+ #
80
+ # response = transaction.get_unsettled_transaction_list
81
+ # transactions = response.transactions if response.success?
82
+ #
83
+ def get_unsettled_transaction_list
84
+ @type = Type::REPORT_GET_UNSETTLED_TRANSACTION_LIST
85
+ make_request
86
+ end
87
+
88
+ # Sets up and submits a getTransactionDetailsRequest transaction. If this transaction has already been
89
+ # run, this method will return nil. Otherwise it will return an AuthorizeNet::Reporting::Response object. The
90
+ # response object will have a TransactionDetail object available via its transactions method if
91
+ # the request was successful. This TransactionDetail object will have more data than the limited version
92
+ # returned by get_transaction_list.
93
+ #
94
+ #
95
+ # +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.
96
+ #
97
+ # Typical usage:
98
+ #
99
+ # response = transaction.get_transaction_details('123456789')
100
+ # transactions = response.transactions if response.success?
101
+ #
102
+ def get_transaction_details(transaction_id)
103
+ @type = Type::REPORT_GET_TRANSACTION_DETAILS
104
+ handle_transaction_id(transaction_id)
105
+ make_request
106
+ end
107
+
108
+ #:enddoc:
109
+ protected
110
+
111
+ # Handles batch id type massaging.
112
+ def handle_batch_id(id)
113
+ case id
114
+ when Batch
115
+ set_fields(batch_id: id.id.to_s)
116
+ else
117
+ set_fields(batch_id: id.to_s)
118
+ end
119
+ end
120
+
121
+ # Handles transaction id type massaging.
122
+ def handle_transaction_id(id)
123
+ case id
124
+ when TransactionDetails
125
+ set_fields(transaction_id: id.id.to_s)
126
+ else
127
+ set_fields(transaction_id: id.to_s)
128
+ end
129
+ end
130
+ end
131
+ end