authorizenet 1.8.7 → 1.8.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/app/helpers/authorize_net_helper.rb +23 -23
- data/lib/authorize_net.rb +107 -103
- data/lib/authorize_net/addresses/address.rb +28 -28
- data/lib/authorize_net/addresses/shipping_address.rb +25 -25
- data/lib/authorize_net/aim/response.rb +130 -130
- data/lib/authorize_net/aim/transaction.rb +190 -190
- data/lib/authorize_net/api/api_transaction.rb +103 -102
- data/lib/authorize_net/api/schema.rb +4283 -4283
- data/lib/authorize_net/api/transaction.rb +240 -240
- data/lib/authorize_net/arb/fields.rb +24 -24
- data/lib/authorize_net/arb/paging.rb +33 -33
- data/lib/authorize_net/arb/response.rb +33 -33
- data/lib/authorize_net/arb/sorting.rb +43 -43
- data/lib/authorize_net/arb/subscription.rb +71 -71
- data/lib/authorize_net/arb/subscription_detail.rb +14 -14
- data/lib/authorize_net/arb/subscription_list_response.rb +43 -43
- data/lib/authorize_net/arb/transaction.rb +177 -177
- data/lib/authorize_net/authorize_net.rb +153 -153
- data/lib/authorize_net/cim/customer_profile.rb +18 -18
- data/lib/authorize_net/cim/payment_profile.rb +36 -36
- data/lib/authorize_net/cim/response.rb +115 -115
- data/lib/authorize_net/cim/transaction.rb +727 -727
- data/lib/authorize_net/customer.rb +26 -26
- data/lib/authorize_net/email_receipt.rb +23 -23
- data/lib/authorize_net/fields.rb +779 -779
- data/lib/authorize_net/key_value_response.rb +116 -116
- data/lib/authorize_net/key_value_transaction.rb +290 -290
- data/lib/authorize_net/line_item.rb +24 -24
- data/lib/authorize_net/order.rb +41 -41
- data/lib/authorize_net/payment_methods/credit_card.rb +62 -62
- data/lib/authorize_net/payment_methods/echeck.rb +71 -71
- data/lib/authorize_net/reporting/batch.rb +18 -18
- data/lib/authorize_net/reporting/batch_statistics.rb +18 -18
- data/lib/authorize_net/reporting/fds_filter.rb +10 -10
- data/lib/authorize_net/reporting/response.rb +162 -162
- data/lib/authorize_net/reporting/returned_item.rb +46 -46
- data/lib/authorize_net/reporting/transaction.rb +133 -133
- data/lib/authorize_net/reporting/transaction_details.rb +24 -24
- data/lib/authorize_net/response.rb +26 -26
- data/lib/authorize_net/sim/hosted_payment_form.rb +37 -37
- data/lib/authorize_net/sim/hosted_receipt_page.rb +36 -36
- data/lib/authorize_net/sim/response.rb +141 -141
- data/lib/authorize_net/sim/transaction.rb +137 -137
- data/lib/authorize_net/transaction.rb +65 -65
- data/lib/authorize_net/xml_response.rb +171 -171
- data/lib/authorize_net/xml_transaction.rb +280 -280
- data/lib/authorizenet.rb +4 -4
- data/lib/generators/authorize_net/direct_post/direct_post_generator.rb +53 -53
- data/lib/generators/authorize_net/direct_post/templates/README-AuthorizeNet +48 -48
- data/lib/generators/authorize_net/direct_post/templates/config.yml.erb +8 -8
- data/lib/generators/authorize_net/direct_post/templates/config.yml.rails3.erb +8 -8
- data/lib/generators/authorize_net/direct_post/templates/controller.rb.erb +30 -30
- data/lib/generators/authorize_net/direct_post/templates/initializer.rb +4 -4
- data/lib/generators/authorize_net/direct_post/templates/layout.erb +17 -17
- data/lib/generators/authorize_net/direct_post/templates/payment.erb +9 -9
- data/lib/generators/authorize_net/direct_post/templates/payment.rails3.erb +9 -9
- data/lib/generators/authorize_net/sim/sim_generator.rb +47 -47
- data/lib/generators/authorize_net/sim/templates/README-AuthorizeNet +51 -51
- data/lib/generators/authorize_net/sim/templates/config.yml.erb +8 -8
- data/lib/generators/authorize_net/sim/templates/config.yml.rails3.erb +8 -8
- data/lib/generators/authorize_net/sim/templates/controller.rb.erb +20 -20
- data/lib/generators/authorize_net/sim/templates/initializer.rb +4 -4
- data/lib/generators/authorize_net/sim/templates/layout.erb +17 -17
- data/lib/generators/authorize_net/sim/templates/payment.erb +5 -5
- data/lib/generators/authorize_net/sim/templates/payment.rails3.erb +5 -5
- data/lib/generators/generator_extensions.rb +74 -74
- metadata +4 -3
@@ -1,11 +1,11 @@
|
|
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
|
-
|
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
11
|
end
|
@@ -1,163 +1,163 @@
|
|
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
|
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
163
|
end
|
@@ -1,46 +1,46 @@
|
|
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
|
+
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 +1,133 @@
|
|
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
|
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
|