authorizenet 1.9.4 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +5 -5
  2. data/lib/app/helpers/authorize_net_helper.rb +2 -3
  3. data/lib/authorize_net.rb +11 -56
  4. data/lib/authorize_net/api/LogHelper.rb +97 -0
  5. data/lib/authorize_net/api/SensitiveDataFilter.rb +92 -0
  6. data/lib/authorize_net/api/api_transaction.rb +95 -90
  7. data/lib/authorize_net/api/constants.yml +1 -1
  8. data/lib/authorize_net/api/schema.rb +1353 -994
  9. data/lib/authorize_net/api/transaction.rb +104 -102
  10. data/lib/authorize_net/authorize_net.rb +20 -27
  11. data/lib/authorize_net/response.rb +9 -15
  12. data/lib/authorize_net/transaction.rb +18 -26
  13. data/lib/authorize_net/xml_response.rb +36 -54
  14. data/lib/authorize_net/xml_transaction.rb +115 -134
  15. metadata +59 -73
  16. data/lib/authorize_net/addresses/address.rb +0 -29
  17. data/lib/authorize_net/addresses/shipping_address.rb +0 -26
  18. data/lib/authorize_net/aim/response.rb +0 -131
  19. data/lib/authorize_net/aim/transaction.rb +0 -190
  20. data/lib/authorize_net/arb/fields.rb +0 -24
  21. data/lib/authorize_net/arb/paging.rb +0 -33
  22. data/lib/authorize_net/arb/response.rb +0 -34
  23. data/lib/authorize_net/arb/sorting.rb +0 -43
  24. data/lib/authorize_net/arb/subscription.rb +0 -72
  25. data/lib/authorize_net/arb/subscription_detail.rb +0 -14
  26. data/lib/authorize_net/arb/subscription_list_response.rb +0 -43
  27. data/lib/authorize_net/arb/transaction.rb +0 -177
  28. data/lib/authorize_net/cim/customer_profile.rb +0 -19
  29. data/lib/authorize_net/cim/payment_profile.rb +0 -37
  30. data/lib/authorize_net/cim/response.rb +0 -116
  31. data/lib/authorize_net/cim/transaction.rb +0 -727
  32. data/lib/authorize_net/customer.rb +0 -27
  33. data/lib/authorize_net/email_receipt.rb +0 -24
  34. data/lib/authorize_net/fields.rb +0 -779
  35. data/lib/authorize_net/key_value_response.rb +0 -117
  36. data/lib/authorize_net/key_value_transaction.rb +0 -291
  37. data/lib/authorize_net/line_item.rb +0 -25
  38. data/lib/authorize_net/order.rb +0 -42
  39. data/lib/authorize_net/payment_methods/credit_card.rb +0 -62
  40. data/lib/authorize_net/payment_methods/echeck.rb +0 -72
  41. data/lib/authorize_net/reporting/batch.rb +0 -19
  42. data/lib/authorize_net/reporting/batch_statistics.rb +0 -19
  43. data/lib/authorize_net/reporting/fds_filter.rb +0 -11
  44. data/lib/authorize_net/reporting/response.rb +0 -163
  45. data/lib/authorize_net/reporting/returned_item.rb +0 -46
  46. data/lib/authorize_net/reporting/transaction.rb +0 -133
  47. data/lib/authorize_net/reporting/transaction_details.rb +0 -25
  48. data/lib/authorize_net/sim/hosted_payment_form.rb +0 -38
  49. data/lib/authorize_net/sim/hosted_receipt_page.rb +0 -37
  50. data/lib/authorize_net/sim/response.rb +0 -142
  51. data/lib/authorize_net/sim/transaction.rb +0 -138
  52. data/lib/generators/authorize_net/direct_post/direct_post_generator.rb +0 -53
  53. data/lib/generators/authorize_net/direct_post/templates/README-AuthorizeNet +0 -49
  54. data/lib/generators/authorize_net/direct_post/templates/config.yml.erb +0 -8
  55. data/lib/generators/authorize_net/direct_post/templates/config.yml.rails3.erb +0 -8
  56. data/lib/generators/authorize_net/direct_post/templates/controller.rb.erb +0 -31
  57. data/lib/generators/authorize_net/direct_post/templates/initializer.rb +0 -4
  58. data/lib/generators/authorize_net/direct_post/templates/layout.erb +0 -18
  59. data/lib/generators/authorize_net/direct_post/templates/payment.erb +0 -10
  60. data/lib/generators/authorize_net/direct_post/templates/payment.rails3.erb +0 -10
  61. data/lib/generators/authorize_net/direct_post/templates/receipt.erb +0 -1
  62. data/lib/generators/authorize_net/direct_post/templates/relay_response.erb +0 -1
  63. data/lib/generators/authorize_net/sim/sim_generator.rb +0 -47
  64. data/lib/generators/authorize_net/sim/templates/README-AuthorizeNet +0 -52
  65. data/lib/generators/authorize_net/sim/templates/config.yml.erb +0 -8
  66. data/lib/generators/authorize_net/sim/templates/config.yml.rails3.erb +0 -8
  67. data/lib/generators/authorize_net/sim/templates/controller.rb.erb +0 -21
  68. data/lib/generators/authorize_net/sim/templates/initializer.rb +0 -4
  69. data/lib/generators/authorize_net/sim/templates/layout.erb +0 -18
  70. data/lib/generators/authorize_net/sim/templates/payment.erb +0 -6
  71. data/lib/generators/authorize_net/sim/templates/payment.rails3.erb +0 -6
  72. data/lib/generators/authorize_net/sim/templates/thank_you.erb +0 -1
  73. data/lib/generators/generator_extensions.rb +0 -75
@@ -1,117 +0,0 @@
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
@@ -1,291 +0,0 @@
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://secure2.authorize.net/gateway/transact.dll'
10
- TEST = 'https://test.authorize.net/gateway/transact.dll'
11
- CARD_PRESENT_LIVE = 'https://cardpresent.authorize.net/gateway/transact.dll'
12
- CARD_PRESENT_TEST = 'https://test.authorize.net/gateway/transact.dll'
13
- end
14
-
15
- # Constants for both the various Authorize.Net payment transaction types are defined here.
16
- module Type
17
- AUTHORIZE_AND_CAPTURE = "AUTH_CAPTURE"
18
- AUTHORIZE_ONLY = "AUTH_ONLY"
19
- CAPTURE_ONLY = "CAPTURE_ONLY"
20
- CREDIT = "CREDIT"
21
- PRIOR_AUTHORIZATION_AND_CAPTURE = "PRIOR_AUTH_CAPTURE"
22
- VOID = "VOID"
23
- end
24
-
25
- # Constants for the various device types used in card present transactions.
26
- module DeviceType
27
- UNKNOWN = 1
28
- UNATTENDED = 2
29
- SELF_SERVICE = 3
30
- CASH_REGISTER = 4
31
- PC_TERMINAL = 5
32
- AIRPAY = 6
33
- WIRELESS_POS = 7
34
- WEBSITE_TERMINAL = 8
35
- DIAL_TERMINAL = 9
36
- VIRTUAL_TERMINAL = 10
37
- end
38
-
39
- # Constants for the various market types used in card present transactions.
40
- module MarketType
41
- RETAIL = 2
42
- end
43
-
44
- # The default options for purchase.
45
- @@purchase_option_defaults = {
46
- :cardholder_auth_value => nil,
47
- :cardholder_auth_indicator => nil
48
- }
49
-
50
- # The default options for authorize.
51
- @@authorize_option_defaults = {
52
- :cardholder_auth_value => nil,
53
- :cardholder_auth_indicator => nil
54
- }
55
-
56
- # Fields to convert to/from booleans.
57
- @@boolean_fields = []
58
-
59
- # Fields to convert to/from BigDecimal.
60
- @@decimal_fields = []
61
-
62
- # DO NOT USE. Instantiate AuthorizeNet::AIM::Transaction or AuthorizeNet::SIM::Transaction instead.
63
- def initialize()
64
- super
65
- @custom_fields ||= {}
66
- @test_mode ||= false
67
- @version = '3.1'
68
- end
69
-
70
- # Checks if the transaction has been configured for test mode or not. Return TRUE if the
71
- # transaction is a test transaction, FALSE otherwise. All transactions run against the sandbox
72
- # are considered test transactions.
73
- def test?
74
- !!@test_mode
75
- end
76
-
77
- # Returns the current API version that we are adhering to
78
- def version
79
- @version
80
- end
81
-
82
- # Sets arbitrary custom fields, overwriting existing values if they exist. Takes a hash of key/value pairs,
83
- # where the keys are the field names. You can set a field to Nil to unset it.
84
- def set_custom_fields(fields = {})
85
- @custom_fields.merge!(fields)
86
- end
87
-
88
- # Returns the current hash of custom fields.
89
- def custom_fields
90
- @custom_fields
91
- end
92
-
93
- # Convenience method for adding line items to a transaction.
94
- def add_line_item(id = nil, name = nil, description = nil, quantity = nil, price = nil, taxable = nil)
95
- line_item = "#{id}<|>#{name}<|>#{description}<|>#{quantity}<|>#{price}<|>#{taxable}"
96
- if @fields.has_key?(:line_item)
97
- @fields[:line_item] = @fields[:line_item].to_a << line_item
98
- else
99
- @fields[:line_item] = [line_item]
100
- end
101
- end
102
-
103
- # Takes an instance of AuthorizeNet::EmailReceipt and adds it to the transaction.
104
- def set_email_receipt(email)
105
- @fields.merge!(email.to_hash)
106
- end
107
-
108
- # Returns the type of transaction.
109
- def type
110
- @type
111
- end
112
-
113
- # Sets the type of transaction.
114
- def type=(type)
115
- case type
116
- when :authorize, :auth_only
117
- @type = Type::AUTHORIZE_ONLY
118
- when :purchase, :auth_and_capture
119
- @type = Type::AUTHORIZE_AND_CAPTURE
120
- when :refund, :credit
121
- @type = Type::CREDIT
122
- when :void
123
- @type = Type::VOID
124
- when :capture, :capture_only
125
- @type = Type::CAPTURE_ONLY
126
- when :prior_auth_capture
127
- @type = Type::PRIOR_AUTHORIZATION_AND_CAPTURE
128
- else
129
- @type = type
130
- end
131
- end
132
-
133
- # Sets up and submits a standard purchase (AUTHORIZE_AND_CAPTURE) transaction. Returns a response object. If the transaction
134
- # has already been run, it will return nil.
135
- #
136
- # +amount+:: The amount to charge. Accepts a string in the format "%0.2f", a Float or a BigDecimal.
137
- # +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).
138
- # +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.
139
- #
140
- #
141
- # Typical usage:
142
- #
143
- # credit_card = AuthorizeNet::CreditCard.new('4111111111111111', '1120')
144
- # response = transaction.purchase(10.0, credit_card)
145
- #
146
- def purchase(amount, credit_card, options = {})
147
- handle_payment_argument(credit_card)
148
- options = @@purchase_option_defaults.merge(options)
149
- handle_cavv_options(options)
150
- set_fields(:amount => amount)
151
- self.type = Type::AUTHORIZE_AND_CAPTURE
152
- run
153
- end
154
-
155
- # Sets up and submits a refund (CREDIT) transaction. Returns a response object. If the transaction
156
- # has already been run, it will return nil.
157
- #
158
- # +amount+:: The amount to refund. Accepts a string in the format "%0.2f", a Float or a BigDecimal.
159
- # +transaction+:: The transaction ID to apply the refund to. Accepts a string of the transaction ID, an instance of AuthorizeNet::Transaction or AuthorizeNet::Response.
160
- # +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.
161
- #
162
- #
163
- # Typical usage:
164
- #
165
- # response = transaction.refund(10.0, '123456789', '1212')
166
- #
167
- def refund(amount, transaction, credit_card)
168
- handle_payment_argument(credit_card)
169
- handle_transaction_argument(transaction)
170
- set_fields(:amount => amount)
171
- self.type = Type::CREDIT
172
- run
173
- end
174
-
175
- # Sets up and submits a refund (CREDIT) transaction for a transaction that was not originally
176
- # submitted via the payment gateway. Note that this is a special feature which requires your
177
- # account to support ECC (expanded credits capability) transactions.
178
- #
179
- # +amount+:: The amount to refund. Accepts a string in the format "%0.2f", a Float or a BigDecimal.
180
- # +credit_card+:: The credit card or eCheck to charge. Accepts an instance of AuthorizeNet::CreditCard, AuthorizeNet::ECheck, or a string of digits.
181
- #
182
- # Typical usage:
183
- #
184
- # response = transaction.unlinked_credit(10.0, '4111111111111111')
185
- #
186
- def unlinked_credit(amount, credit_card)
187
- handle_payment_argument(credit_card)
188
- set_fields(:amount => amount)
189
- self.type = Type::CREDIT
190
- run
191
- end
192
-
193
- # Sets up and submits a void (VOID) transaction. Returns a response object. If the transaction
194
- # has already been run, it will return nil. Note that you can only void unsettled transactions.
195
- #
196
- # +transaction+:: The transaction ID of the transaction to void. Accepts a string of the transaction ID, an instance of AuthorizeNet::Transaction or AuthorizeNet::Response.
197
- #
198
- #
199
- # Typical usage:
200
- #
201
- # response = transaction.void('123456789')
202
- #
203
- def void(transaction)
204
- handle_transaction_argument(transaction)
205
- self.type = Type::VOID
206
- run
207
- end
208
-
209
- # Sets up and submits an authorize (AUTH_ONLY) transaction. Returns a response object. If the transaction
210
- # has already been run, it will return nil. Use this to put a hold on funds, but don't actually charge
211
- # the card yet.
212
- #
213
- # +amount+:: The amount to authorize. Accepts a string in the format "%0.2f", a Float or a BigDecimal.
214
- # +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).
215
- # +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.
216
- #
217
- #
218
- # Typical usage:
219
- #
220
- # credit_card = AuthorizeNet::CreditCard.new('4111111111111111', '1120')
221
- # response = transaction.authorize(10.0, credit_card)
222
- #
223
- def authorize(amount, credit_card, options = {})
224
- handle_payment_argument(credit_card)
225
- options = @@authorize_option_defaults.merge(options)
226
- handle_cavv_options(options)
227
- set_fields(:amount => amount)
228
- self.type = Type::AUTHORIZE_ONLY
229
- run
230
- end
231
-
232
- # Sets up and submits a capture (CAPTURE_ONLY) transaction. Returns a response object. If the transaction
233
- # has already been run, it will return nil. Note that you can not capture a transaction that was made
234
- # though the AIM API using this method. Use prior_auth_capture instead.
235
- #
236
- # +amount+:: The amount to capture. Accepts a string in the format "%0.2f", a Float or a BigDecimal.
237
- # +authorization_code+:: The authorization code of the transaction to capture. Accepts a string.
238
- #
239
- #
240
- # Typical usage:
241
- #
242
- # response = transaction.capture(10.0, '123FAKE')
243
- #
244
- def capture(amount, authorization_code)
245
- set_fields(:amount => amount, :auth_code => authorization_code)
246
- self.type = Type::CAPTURE_ONLY
247
- run
248
- end
249
-
250
- # Sets up and submits a capture (PRIOR_AUTH_CAPTURE) transaction. Returns a response object. Use this method
251
- # to actually charge a card that you previously put a hold on (using authorize).
252
- #
253
- # +transaction+:: The transaction ID to capture. Accepts a string of the transaction ID, an instance of AuthorizeNet::Transaction or AuthorizeNet::Response.
254
- # +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.
255
- #
256
- #
257
- # Typical usage:
258
- #
259
- # response = transaction.prior_auth_capture('123456789')
260
- #
261
- def prior_auth_capture(transaction, amount = nil)
262
- handle_transaction_argument(transaction)
263
- set_fields(:amount => amount)
264
- self.type = Type::PRIOR_AUTHORIZATION_AND_CAPTURE
265
- run
266
- end
267
-
268
- #:enddoc:
269
- protected
270
-
271
- # Internal method to handle multiple types of transaction arguments.
272
- def handle_transaction_argument(transaction)
273
- case transaction
274
- when Transaction
275
- set_fields(:trans_id => transaction.response.transaction_id)
276
- when Response
277
- set_fields(:trans_id => transaction.transaction_id)
278
- else
279
- set_fields(:trans_id => transaction)
280
- end
281
- end
282
-
283
- # Internal method to handle CAVV options.
284
- def handle_cavv_options(options)
285
- set_fields(:authentication_indicator => options[:cardholder_auth_indicator]) unless options[:cardholder_auth_indicator].nil?
286
- set_fields(:cardholder_authentication_value => options[:cardholder_auth_value]) unless options[:cardholder_auth_value].nil?
287
- end
288
-
289
- end
290
-
291
- end
@@ -1,25 +0,0 @@
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_unit_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
@@ -1,42 +0,0 @@
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({:id => id, :name => name, :description => description, :quantity => quantity, :price => price, :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