authorizenet 1.9.7 → 2.0.0

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