yankl 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/app/helpers/authorize_net_helper.rb +24 -0
- data/lib/authorize-net.rb +4 -0
- data/lib/authorize_net.rb +92 -0
- data/lib/authorize_net/addresses/address.rb +29 -0
- data/lib/authorize_net/addresses/shipping_address.rb +26 -0
- data/lib/authorize_net/aim/response.rb +131 -0
- data/lib/authorize_net/aim/transaction.rb +184 -0
- data/lib/authorize_net/arb/response.rb +34 -0
- data/lib/authorize_net/arb/subscription.rb +72 -0
- data/lib/authorize_net/arb/transaction.rb +146 -0
- data/lib/authorize_net/authorize_net.rb +154 -0
- data/lib/authorize_net/cim/customer_profile.rb +19 -0
- data/lib/authorize_net/cim/payment_profile.rb +37 -0
- data/lib/authorize_net/cim/response.rb +110 -0
- data/lib/authorize_net/cim/transaction.rb +678 -0
- data/lib/authorize_net/customer.rb +27 -0
- data/lib/authorize_net/email_receipt.rb +24 -0
- data/lib/authorize_net/fields.rb +736 -0
- data/lib/authorize_net/key_value_response.rb +117 -0
- data/lib/authorize_net/key_value_transaction.rb +297 -0
- data/lib/authorize_net/line_item.rb +25 -0
- data/lib/authorize_net/order.rb +42 -0
- data/lib/authorize_net/payment_methods/credit_card.rb +74 -0
- data/lib/authorize_net/payment_methods/echeck.rb +72 -0
- data/lib/authorize_net/reporting/batch.rb +19 -0
- data/lib/authorize_net/reporting/batch_statistics.rb +19 -0
- data/lib/authorize_net/reporting/fds_filter.rb +11 -0
- data/lib/authorize_net/reporting/response.rb +127 -0
- data/lib/authorize_net/reporting/transaction.rb +116 -0
- data/lib/authorize_net/reporting/transaction_details.rb +25 -0
- data/lib/authorize_net/response.rb +27 -0
- data/lib/authorize_net/sim/hosted_payment_form.rb +38 -0
- data/lib/authorize_net/sim/hosted_receipt_page.rb +37 -0
- data/lib/authorize_net/sim/response.rb +142 -0
- data/lib/authorize_net/sim/transaction.rb +138 -0
- data/lib/authorize_net/transaction.rb +66 -0
- data/lib/authorize_net/xml +65 -0
- data/lib/authorize_net/xml_response.rb +172 -0
- data/lib/authorize_net/xml_transaction.rb +277 -0
- data/lib/generators/authorize_net/direct_post_generator.rb +51 -0
- data/lib/generators/authorize_net/sim_generator.rb +47 -0
- data/lib/yankl.rb +4 -0
- metadata +105 -0
@@ -0,0 +1,117 @@
|
|
1
|
+
module AuthorizeNet
|
2
|
+
|
3
|
+
# The core, key/value response class. You shouldn't instantiate this one.
|
4
|
+
# Instead you should use AuthorizeNet::AIM::Response or AuthorizeNet::SIM::Response.
|
5
|
+
class KeyValueResponse < AuthorizeNet::Response
|
6
|
+
|
7
|
+
# Defines constants for each response code.
|
8
|
+
module ResponseCode
|
9
|
+
APPROVED = '1'
|
10
|
+
DECLINED = '2'
|
11
|
+
ERROR = '3'
|
12
|
+
HELD = '4'
|
13
|
+
end
|
14
|
+
|
15
|
+
# Defines constants for each address verification response code.
|
16
|
+
module AVSResponseCode
|
17
|
+
ADDRESS_MATCH_NOT_ZIP = 'A'
|
18
|
+
NO_INFO = 'B'
|
19
|
+
ERROR = 'E'
|
20
|
+
NON_US = 'G'
|
21
|
+
NO_MATCH = 'N'
|
22
|
+
NOT_APPLICABLE = 'P'
|
23
|
+
RETRY = 'R'
|
24
|
+
NOT_SUPPOPRTED = 'S'
|
25
|
+
UNAVAILABLE = 'U'
|
26
|
+
ZIP9_MATCH_NOT_ADDRESS = 'W'
|
27
|
+
ADDRESS_AND_ZIP9_MATCH = 'X'
|
28
|
+
ADDRESS_AND_ZIP5_MATCH = 'Y'
|
29
|
+
ZIP5_MATCH_NOT_ADDRESS = 'Z'
|
30
|
+
end
|
31
|
+
|
32
|
+
# Defines constants for each supported credit card type.
|
33
|
+
module CardType
|
34
|
+
VISA = 'Visa'
|
35
|
+
MASTER_CARD = 'MasterCard'
|
36
|
+
AMEX = 'American Express'
|
37
|
+
DISCOVER = 'Discover'
|
38
|
+
DINERS_CLUB = 'Diners Club'
|
39
|
+
JCB = 'JCB'
|
40
|
+
end
|
41
|
+
|
42
|
+
# Defines constants for CCV code validation responses.
|
43
|
+
module CCVResponseCode
|
44
|
+
MATCH = 'M'
|
45
|
+
NO_MATCH = 'N'
|
46
|
+
NOT_PROCESSED = 'P'
|
47
|
+
SHOULD_HAVE_BEEN_PRESENT = 'S'
|
48
|
+
UNABLE_TO_PROCESS = 'U'
|
49
|
+
end
|
50
|
+
|
51
|
+
# Defines constants for CAVV code validation responses.
|
52
|
+
module CAVVResponseCode
|
53
|
+
ERRONEOUS_DATA = '0'
|
54
|
+
FAILED_VALIDATION = '1'
|
55
|
+
PASSED_VALIDATION = '2'
|
56
|
+
ISSUER_ATTEMPT_INCOMPLETE = '3'
|
57
|
+
ISSUER_SYSTEM_ERROR = '4'
|
58
|
+
FAILED_ISSUER_AVAILABLE = '7'
|
59
|
+
PASSED_ISSUER_AVAILABLE = '8'
|
60
|
+
FAILED_ISSUER_UNAVAILABLE = '9'
|
61
|
+
PASSED_ISSUER_UNAVAILABLE = 'A'
|
62
|
+
PASSED_NO_LIABILITY_SHIFT = 'B'
|
63
|
+
end
|
64
|
+
|
65
|
+
# Check to see if the transaction was approved.
|
66
|
+
def approved?
|
67
|
+
@fields[:response_code] == ResponseCode::APPROVED
|
68
|
+
end
|
69
|
+
|
70
|
+
# Check to see if the transaction was declined.
|
71
|
+
def declined?
|
72
|
+
@fields[:response_code] == ResponseCode::DECLINED
|
73
|
+
end
|
74
|
+
|
75
|
+
# Check to see if the transaction was returned with an error.
|
76
|
+
def error?
|
77
|
+
@fields[:response_code] == ResponseCode::ERROR
|
78
|
+
end
|
79
|
+
|
80
|
+
# Check to see if the transaction was held for review by Authorize.Net.
|
81
|
+
def held?
|
82
|
+
@fields[:response_code] == ResponseCode::HELD
|
83
|
+
end
|
84
|
+
|
85
|
+
# Returns the response code received from the gateway. Note: its better to use
|
86
|
+
# success?, approved?, etc. to check the response code.
|
87
|
+
def response_code
|
88
|
+
@fields[:response_code]
|
89
|
+
end
|
90
|
+
|
91
|
+
# Returns the response reason code received from the gateway. This code can be used
|
92
|
+
# to identify why something failed by referencing the AIM documentation.
|
93
|
+
def response_reason_code
|
94
|
+
@fields[:response_reason_code]
|
95
|
+
end
|
96
|
+
|
97
|
+
# Returns the response reason text received from the gateway. This is a brief, human readable
|
98
|
+
# explanation of why you got the response code that you got. Note that these strings tend to be
|
99
|
+
# a bit vague. More detail can be gleaned from the response_reason_code.
|
100
|
+
def response_reason_text
|
101
|
+
@fields[:response_reason_text]
|
102
|
+
end
|
103
|
+
|
104
|
+
# Returns all the fields returned in the response, keyed by their API name. Custom fields are NOT
|
105
|
+
# included (see custom_fields).
|
106
|
+
def fields
|
107
|
+
@fields
|
108
|
+
end
|
109
|
+
|
110
|
+
# Returns all the custom fields returned in the response, keyed by their field name.
|
111
|
+
def custom_fields
|
112
|
+
@custom_fields
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
@@ -0,0 +1,297 @@
|
|
1
|
+
module AuthorizeNet
|
2
|
+
|
3
|
+
# The core, key/value transaction class. You shouldn't instantiate this one.
|
4
|
+
# Instead you should use AuthorizeNet::AIM::Transaction or AuthorizeNet::SIM::Transaction.
|
5
|
+
class KeyValueTransaction < AuthorizeNet::Transaction
|
6
|
+
|
7
|
+
# Constants for both the various Authorize.Net payment gateways are defined here.
|
8
|
+
module Gateway
|
9
|
+
LIVE = 'https://secure.authorize.net/gateway/transact.dll'
|
10
|
+
TEST = 'https://test.authorize.net/gateway/transact.dll'
|
11
|
+
#TEST = 'https://qaverta1d.qa.intra/gateway/transact.dll'
|
12
|
+
#TEST = 'http://10.43.73.163/gateway/transact.dll'
|
13
|
+
#TEST = 'http://localhost:7000'
|
14
|
+
|
15
|
+
CARD_PRESENT_LIVE = 'https://cardpresent.authorize.net/gateway/transact.dll'
|
16
|
+
CARD_PRESENT_TEST = 'https://test.authorize.net/gateway/transact.dll'
|
17
|
+
#CARD_PRESENT_TEST = 'https://qaverta1d.qa.intra/gateway/transact.dll'
|
18
|
+
#CARD_PRESENT_TEST = 'http://10.43.73.163/gateway/transact.dll'
|
19
|
+
end
|
20
|
+
|
21
|
+
# Constants for both the various Authorize.Net payment transaction types are defined here.
|
22
|
+
module Type
|
23
|
+
AUTHORIZE_AND_CAPTURE = "AUTH_CAPTURE"
|
24
|
+
AUTHORIZE_ONLY = "AUTH_ONLY"
|
25
|
+
CAPTURE_ONLY = "CAPTURE_ONLY"
|
26
|
+
CREDIT = "CREDIT"
|
27
|
+
PRIOR_AUTHORIZATION_AND_CAPTURE = "PRIOR_AUTH_CAPTURE"
|
28
|
+
VOID = "VOID"
|
29
|
+
end
|
30
|
+
|
31
|
+
# Constants for the various device types used in card present transactions.
|
32
|
+
module DeviceType
|
33
|
+
UNKNOWN = 1
|
34
|
+
UNATTENDED = 2
|
35
|
+
SELF_SERVICE = 3
|
36
|
+
CASH_REGISTER = 4
|
37
|
+
PC_TERMINAL = 5
|
38
|
+
AIRPAY = 6
|
39
|
+
WIRELESS_POS = 7
|
40
|
+
WEBSITE_TERMINAL = 8
|
41
|
+
DIAL_TERMINAL = 9
|
42
|
+
VIRTUAL_TERMINAL = 10
|
43
|
+
end
|
44
|
+
|
45
|
+
# Constants for the various market types used in card present transactions.
|
46
|
+
module MarketType
|
47
|
+
RETAIL = 2
|
48
|
+
end
|
49
|
+
|
50
|
+
# The default options for purchase.
|
51
|
+
@@purchase_option_defaults = {
|
52
|
+
:cardholder_auth_value => nil,
|
53
|
+
:cardholder_auth_indicator => nil
|
54
|
+
}
|
55
|
+
|
56
|
+
# The default options for authorize.
|
57
|
+
@@authorize_option_defaults = {
|
58
|
+
:cardholder_auth_value => nil,
|
59
|
+
:cardholder_auth_indicator => nil
|
60
|
+
}
|
61
|
+
|
62
|
+
# Fields to convert to/from booleans.
|
63
|
+
@@boolean_fields = []
|
64
|
+
|
65
|
+
# Fields to convert to/from BigDecimal.
|
66
|
+
@@decimal_fields = []
|
67
|
+
|
68
|
+
# DO NOT USE. Instantiate AuthorizeNet::AIM::Transaction or AuthorizeNet::SIM::Transaction instead.
|
69
|
+
def initialize()
|
70
|
+
super
|
71
|
+
@custom_fields ||= {}
|
72
|
+
@test_mode ||= false
|
73
|
+
@version = '3.1'
|
74
|
+
end
|
75
|
+
|
76
|
+
# Checks if the transaction has been configured for test mode or not. Return TRUE if the
|
77
|
+
# transaction is a test transaction, FALSE otherwise. All transactions run against the sandbox
|
78
|
+
# are considered test transactions.
|
79
|
+
def test?
|
80
|
+
!!@test_mode
|
81
|
+
end
|
82
|
+
|
83
|
+
# Returns the current API version that we are adhering to
|
84
|
+
def version
|
85
|
+
@version
|
86
|
+
end
|
87
|
+
|
88
|
+
# Sets arbitrary custom fields, overwriting existing values if they exist. Takes a hash of key/value pairs,
|
89
|
+
# where the keys are the field names. You can set a field to Nil to unset it.
|
90
|
+
def set_custom_fields(fields = {})
|
91
|
+
@custom_fields.merge!(fields)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Returns the current hash of custom fields.
|
95
|
+
def custom_fields
|
96
|
+
@custom_fields
|
97
|
+
end
|
98
|
+
|
99
|
+
# Convenience method for adding line items to a transaction.
|
100
|
+
def add_line_item(id = nil, name = nil, description = nil, quantity = nil, price = nil, taxable = nil)
|
101
|
+
line_item = "#{id}<|>#{name}<|>#{description}<|>#{quantity}<|>#{price}<|>#{taxable}"
|
102
|
+
if @fields.has_key?(:line_item)
|
103
|
+
@fields[:line_item] = @fields[:line_item].to_a << line_item
|
104
|
+
else
|
105
|
+
@fields[:line_item] = [line_item]
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# Takes an instance of AuthorizeNet::EmailReceipt and adds it to the transaction.
|
110
|
+
def set_email_receipt(email)
|
111
|
+
@fields.merge!(email.to_hash)
|
112
|
+
end
|
113
|
+
|
114
|
+
# Returns the type of transaction.
|
115
|
+
def type
|
116
|
+
@type
|
117
|
+
end
|
118
|
+
|
119
|
+
# Sets the type of transaction.
|
120
|
+
def type=(type)
|
121
|
+
case type
|
122
|
+
when :authorize, :auth_only
|
123
|
+
@type = Type::AUTHORIZE_ONLY
|
124
|
+
when :purchase, :auth_and_capture
|
125
|
+
@type = Type::AUTHORIZE_AND_CAPTURE
|
126
|
+
when :refund, :credit
|
127
|
+
@type = Type::CREDIT
|
128
|
+
when :void
|
129
|
+
@type = Type::VOID
|
130
|
+
when :capture, :capture_only
|
131
|
+
@type = Type::CAPTURE_ONLY
|
132
|
+
when :prior_auth_capture
|
133
|
+
@type = Type::PRIOR_AUTHORIZATION_AND_CAPTURE
|
134
|
+
else
|
135
|
+
@type = type
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
# Sets up and submits a standard purchase (AUTHORIZE_AND_CAPTURE) transaction. Returns a response object. If the transaction
|
140
|
+
# has already been run, it will return nil.
|
141
|
+
#
|
142
|
+
# +amount+:: The amount to charge. Accepts a string in the format "%0.2f", a Float or a BigDecimal.
|
143
|
+
# +credit_card+:: The credit card or eCheck to charge. Accepts an instance of AuthorizeNet::CreditCard, AuthorizeNet::ECheck, or a string of digits (in which case the expiration should be added using set_fields).
|
144
|
+
# +options+:: A hash with any of following keys: cardholder_auth_indicator, cardholder_auth_value. These are for CAVV and can be ignored in most cases.
|
145
|
+
#
|
146
|
+
#
|
147
|
+
# Typical usage:
|
148
|
+
#
|
149
|
+
# credit_card = AuthorizeNet::CreditCard.new('4111111111111111', '1120')
|
150
|
+
# response = transaction.purchase(10.0, credit_card)
|
151
|
+
#
|
152
|
+
def purchase(amount, credit_card, options = {})
|
153
|
+
handle_payment_argument(credit_card)
|
154
|
+
options = @@purchase_option_defaults.merge(options)
|
155
|
+
handle_cavv_options(options)
|
156
|
+
set_fields(:amount => amount)
|
157
|
+
self.type = Type::AUTHORIZE_AND_CAPTURE
|
158
|
+
run
|
159
|
+
end
|
160
|
+
|
161
|
+
# Sets up and submits a refund (CREDIT) transaction. Returns a response object. If the transaction
|
162
|
+
# has already been run, it will return nil.
|
163
|
+
#
|
164
|
+
# +amount+:: The amount to refund. Accepts a string in the format "%0.2f", a Float or a BigDecimal.
|
165
|
+
# +transaction+:: The transaction ID to apply the refund to. Accepts a string of the transaction ID, an instance of AuthorizeNet::Transaction or AuthorizeNet::Response.
|
166
|
+
# +credit_card+:: The credit card or eCheck to charge. Accepts an instance of AuthorizeNet::CreditCard, AuthorizeNet::ECheck, or a string of digits. In many cases you only need the last 4 digits of the credit card here.
|
167
|
+
#
|
168
|
+
#
|
169
|
+
# Typical usage:
|
170
|
+
#
|
171
|
+
# response = transaction.refund(10.0, '123456789', '1212')
|
172
|
+
#
|
173
|
+
def refund(amount, transaction, credit_card)
|
174
|
+
handle_payment_argument(credit_card)
|
175
|
+
handle_transaction_argument(transaction)
|
176
|
+
set_fields(:amount => amount)
|
177
|
+
self.type = Type::CREDIT
|
178
|
+
run
|
179
|
+
end
|
180
|
+
|
181
|
+
# Sets up and submits a refund (CREDIT) transaction for a transaction that was not originally
|
182
|
+
# submitted via the payment gateway. Note that this is a special feature which requires your
|
183
|
+
# account to support ECC (expanded credits capability) transactions.
|
184
|
+
#
|
185
|
+
# +amount+:: The amount to refund. Accepts a string in the format "%0.2f", a Float or a BigDecimal.
|
186
|
+
# +credit_card+:: The credit card or eCheck to charge. Accepts an instance of AuthorizeNet::CreditCard, AuthorizeNet::ECheck, or a string of digits.
|
187
|
+
#
|
188
|
+
# Typical usage:
|
189
|
+
#
|
190
|
+
# response = transaction.unlinked_credit(10.0, '4111111111111111')
|
191
|
+
#
|
192
|
+
def unlinked_credit(amount, credit_card)
|
193
|
+
handle_payment_argument(credit_card)
|
194
|
+
set_fields(:amount => amount)
|
195
|
+
self.type = Type::CREDIT
|
196
|
+
run
|
197
|
+
end
|
198
|
+
|
199
|
+
# Sets up and submits a void (VOID) transaction. Returns a response object. If the transaction
|
200
|
+
# has already been run, it will return nil. Note that you can only void unsettled transactions.
|
201
|
+
#
|
202
|
+
# +transaction+:: The transaction ID of the transaction to void. Accepts a string of the transaction ID, an instance of AuthorizeNet::Transaction or AuthorizeNet::Response.
|
203
|
+
#
|
204
|
+
#
|
205
|
+
# Typical usage:
|
206
|
+
#
|
207
|
+
# response = transaction.void('123456789')
|
208
|
+
#
|
209
|
+
def void(transaction)
|
210
|
+
handle_transaction_argument(transaction)
|
211
|
+
self.type = Type::VOID
|
212
|
+
run
|
213
|
+
end
|
214
|
+
|
215
|
+
# Sets up and submits an authorize (AUTH_ONLY) transaction. Returns a response object. If the transaction
|
216
|
+
# has already been run, it will return nil. Use this to put a hold on funds, but don't actually charge
|
217
|
+
# the card yet.
|
218
|
+
#
|
219
|
+
# +amount+:: The amount to authorize. Accepts a string in the format "%0.2f", a Float or a BigDecimal.
|
220
|
+
# +credit_card+:: The credit card or eCheck to charge. Accepts an instance of AuthorizeNet::CreditCard, AuthorizeNet::ECheck, or a string of digits (in which case the expiration should be added using set_fields).
|
221
|
+
# +options+:: A hash with any of following keys: cardholder_auth_indicator, cardholder_auth_value. These are for CAVV and can be ignored in most cases.
|
222
|
+
#
|
223
|
+
#
|
224
|
+
# Typical usage:
|
225
|
+
#
|
226
|
+
# credit_card = AuthorizeNet::CreditCard.new('4111111111111111', '1120')
|
227
|
+
# response = transaction.authorize(10.0, credit_card)
|
228
|
+
#
|
229
|
+
def authorize(amount, credit_card, options = {})
|
230
|
+
handle_payment_argument(credit_card)
|
231
|
+
options = @@authorize_option_defaults.merge(options)
|
232
|
+
handle_cavv_options(options)
|
233
|
+
set_fields(:amount => amount)
|
234
|
+
self.type = Type::AUTHORIZE_ONLY
|
235
|
+
run
|
236
|
+
end
|
237
|
+
|
238
|
+
# Sets up and submits a capture (CAPTURE_ONLY) transaction. Returns a response object. If the transaction
|
239
|
+
# has already been run, it will return nil. Note that you can not capture a transaction that was made
|
240
|
+
# though the AIM API using this method. Use prior_auth_capture instead.
|
241
|
+
#
|
242
|
+
# +amount+:: The amount to capture. Accepts a string in the format "%0.2f", a Float or a BigDecimal.
|
243
|
+
# +authorization_code+:: The authorization code of the transaction to capture. Accepts a string.
|
244
|
+
#
|
245
|
+
#
|
246
|
+
# Typical usage:
|
247
|
+
#
|
248
|
+
# response = transaction.capture(10.0, '123FAKE')
|
249
|
+
#
|
250
|
+
def capture(amount, authorization_code)
|
251
|
+
set_fields(:amount => amount, :auth_code => authorization_code)
|
252
|
+
self.type = Type::CAPTURE_ONLY
|
253
|
+
run
|
254
|
+
end
|
255
|
+
|
256
|
+
# Sets up and submits a capture (PRIOR_AUTH_CAPTURE) transaction. Returns a response object. Use this method
|
257
|
+
# to actually charge a card that you previously put a hold on (using authorize).
|
258
|
+
#
|
259
|
+
# +transaction+:: The transaction ID to capture. Accepts a string of the transaction ID, an instance of AuthorizeNet::Transaction or AuthorizeNet::Response.
|
260
|
+
# +amount+:: The amount to capture (only if less than the amount originally authorized, otherwise leave as Nil). Accepts a string in the format "%0.2f", a Float, a BigDecimal or Nil.
|
261
|
+
#
|
262
|
+
#
|
263
|
+
# Typical usage:
|
264
|
+
#
|
265
|
+
# response = transaction.prior_auth_capture('123456789')
|
266
|
+
#
|
267
|
+
def prior_auth_capture(transaction, amount = nil)
|
268
|
+
handle_transaction_argument(transaction)
|
269
|
+
set_fields(:amount => amount)
|
270
|
+
self.type = Type::PRIOR_AUTHORIZATION_AND_CAPTURE
|
271
|
+
run
|
272
|
+
end
|
273
|
+
|
274
|
+
#:enddoc:
|
275
|
+
protected
|
276
|
+
|
277
|
+
# Internal method to handle multiple types of transaction arguments.
|
278
|
+
def handle_transaction_argument(transaction)
|
279
|
+
case transaction
|
280
|
+
when Transaction
|
281
|
+
set_fields(:trans_id => transaction.response.transaction_id)
|
282
|
+
when Response
|
283
|
+
set_fields(:trans_id => transaction.transaction_id)
|
284
|
+
else
|
285
|
+
set_fields(:trans_id => transaction)
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
# Internal method to handle CAVV options.
|
290
|
+
def handle_cavv_options(options)
|
291
|
+
set_fields(:authentication_indicator => options[:cardholder_auth_indicator]) unless options[:cardholder_auth_indicator].nil?
|
292
|
+
set_fields(:cardholder_authentication_value => options[:cardholder_auth_value]) unless options[:cardholder_auth_value].nil?
|
293
|
+
end
|
294
|
+
|
295
|
+
end
|
296
|
+
|
297
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module AuthorizeNet
|
2
|
+
|
3
|
+
# Models an line item.
|
4
|
+
class LineItem
|
5
|
+
|
6
|
+
include AuthorizeNet::Model
|
7
|
+
|
8
|
+
attr_accessor :id, :name, :description, :quantity, :price, :taxable
|
9
|
+
|
10
|
+
def to_hash
|
11
|
+
hash = {
|
12
|
+
:line_item_id => @id,
|
13
|
+
:line_item_name => @name,
|
14
|
+
:line_item_description => @description,
|
15
|
+
:line_item_quantity => @quantity,
|
16
|
+
:line_item_price => @price,
|
17
|
+
:line_item_taxable => @taxable
|
18
|
+
}
|
19
|
+
hash.delete_if {|k, v| v.nil?}
|
20
|
+
hash
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module AuthorizeNet
|
2
|
+
|
3
|
+
# Models an order.
|
4
|
+
class Order
|
5
|
+
|
6
|
+
include AuthorizeNet::Model
|
7
|
+
|
8
|
+
attr_accessor :invoice_num, :description, :tax, :tax_name, :tax_description, :freight, :freight_name, :freight_description, :duty, :duty_name, :duty_description, :tax_exempt, :po_num, :line_items
|
9
|
+
|
10
|
+
def add_line_item(id = nil, name = nil, description = nil, quantity = nil, price = nil, taxable = nil)
|
11
|
+
if id.kind_of?(AuthorizeNet::LineItem)
|
12
|
+
line_item = id
|
13
|
+
else
|
14
|
+
line_item = AuthorizeNet::LineItem.new({:line_item_id => id, :line_item_name => name, :line_item_description => description, :line_item_quantity => quantity, :line_item_price => price, :line_item_taxable => taxable})
|
15
|
+
end
|
16
|
+
@line_items = @line_items.to_a << line_item
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_hash
|
20
|
+
hash = {
|
21
|
+
:invoice_num => @invoice_num,
|
22
|
+
:description => @description,
|
23
|
+
:tax => @tax,
|
24
|
+
:tax_name => @tax_name,
|
25
|
+
:tax_description => @tax_description,
|
26
|
+
:freight => @freight,
|
27
|
+
:freight_name => @freight_name,
|
28
|
+
:freight_description => @freight_description,
|
29
|
+
:duty => @duty,
|
30
|
+
:duty_name => @duty_name,
|
31
|
+
:duty_description => @duty_description,
|
32
|
+
:tax_exempt => @tax_exempt,
|
33
|
+
:po_num => @po_num,
|
34
|
+
:line_items => handle_multivalue_hashing(@line_items)
|
35
|
+
}
|
36
|
+
hash.delete_if {|k, v| v.nil?}
|
37
|
+
hash
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|