authorizenet 1.9.5 → 1.9.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/lib/app/helpers/authorize_net_helper.rb +23 -23
  3. data/lib/authorize_net.rb +107 -107
  4. data/lib/authorize_net/addresses/address.rb +25 -25
  5. data/lib/authorize_net/addresses/shipping_address.rb +22 -22
  6. data/lib/authorize_net/aim/response.rb +120 -120
  7. data/lib/authorize_net/aim/transaction.rb +171 -171
  8. data/lib/authorize_net/api/api_transaction.rb +119 -119
  9. data/lib/authorize_net/api/constants.yml +1 -1
  10. data/lib/authorize_net/api/schema.rb +5165 -5153
  11. data/lib/authorize_net/api/transaction.rb +261 -261
  12. data/lib/authorize_net/arb/fields.rb +24 -24
  13. data/lib/authorize_net/arb/paging.rb +29 -29
  14. data/lib/authorize_net/arb/response.rb +26 -26
  15. data/lib/authorize_net/arb/sorting.rb +39 -39
  16. data/lib/authorize_net/arb/subscription.rb +68 -68
  17. data/lib/authorize_net/arb/subscription_detail.rb +10 -10
  18. data/lib/authorize_net/arb/subscription_list_response.rb +36 -36
  19. data/lib/authorize_net/arb/transaction.rb +171 -171
  20. data/lib/authorize_net/authorize_net.rb +154 -154
  21. data/lib/authorize_net/cim/customer_profile.rb +15 -15
  22. data/lib/authorize_net/cim/payment_profile.rb +35 -35
  23. data/lib/authorize_net/cim/response.rb +111 -111
  24. data/lib/authorize_net/cim/transaction.rb +721 -721
  25. data/lib/authorize_net/customer.rb +24 -24
  26. data/lib/authorize_net/email_receipt.rb +20 -20
  27. data/lib/authorize_net/fields.rb +760 -760
  28. data/lib/authorize_net/key_value_response.rb +109 -109
  29. data/lib/authorize_net/key_value_transaction.rb +281 -281
  30. data/lib/authorize_net/line_item.rb +21 -21
  31. data/lib/authorize_net/order.rb +38 -38
  32. data/lib/authorize_net/payment_methods/credit_card.rb +61 -61
  33. data/lib/authorize_net/payment_methods/echeck.rb +70 -70
  34. data/lib/authorize_net/reporting/batch.rb +16 -16
  35. data/lib/authorize_net/reporting/batch_statistics.rb +15 -15
  36. data/lib/authorize_net/reporting/fds_filter.rb +8 -8
  37. data/lib/authorize_net/reporting/response.rb +157 -157
  38. data/lib/authorize_net/reporting/returned_item.rb +45 -45
  39. data/lib/authorize_net/reporting/transaction.rb +131 -131
  40. data/lib/authorize_net/reporting/transaction_details.rb +22 -22
  41. data/lib/authorize_net/response.rb +25 -25
  42. data/lib/authorize_net/sim/hosted_payment_form.rb +34 -34
  43. data/lib/authorize_net/sim/hosted_receipt_page.rb +32 -32
  44. data/lib/authorize_net/sim/response.rb +133 -133
  45. data/lib/authorize_net/sim/transaction.rb +128 -128
  46. data/lib/authorize_net/transaction.rb +66 -66
  47. data/lib/authorize_net/xml_response.rb +154 -154
  48. data/lib/authorize_net/xml_transaction.rb +279 -279
  49. data/lib/authorizenet.rb +4 -4
  50. data/lib/generators/authorize_net/direct_post/direct_post_generator.rb +52 -52
  51. data/lib/generators/authorize_net/direct_post/templates/README-AuthorizeNet +48 -48
  52. data/lib/generators/authorize_net/direct_post/templates/config.yml.erb +8 -8
  53. data/lib/generators/authorize_net/direct_post/templates/config.yml.rails3.erb +8 -8
  54. data/lib/generators/authorize_net/direct_post/templates/controller.rb.erb +30 -30
  55. data/lib/generators/authorize_net/direct_post/templates/initializer.rb +4 -4
  56. data/lib/generators/authorize_net/direct_post/templates/layout.erb +17 -17
  57. data/lib/generators/authorize_net/direct_post/templates/payment.erb +9 -9
  58. data/lib/generators/authorize_net/direct_post/templates/payment.rails3.erb +9 -9
  59. data/lib/generators/authorize_net/sim/sim_generator.rb +46 -46
  60. data/lib/generators/authorize_net/sim/templates/README-AuthorizeNet +51 -51
  61. data/lib/generators/authorize_net/sim/templates/config.yml.erb +8 -8
  62. data/lib/generators/authorize_net/sim/templates/config.yml.rails3.erb +8 -8
  63. data/lib/generators/authorize_net/sim/templates/controller.rb.erb +20 -20
  64. data/lib/generators/authorize_net/sim/templates/initializer.rb +4 -4
  65. data/lib/generators/authorize_net/sim/templates/layout.erb +17 -17
  66. data/lib/generators/authorize_net/sim/templates/payment.erb +5 -5
  67. data/lib/generators/authorize_net/sim/templates/payment.rails3.erb +5 -5
  68. data/lib/generators/generator_extensions.rb +73 -73
  69. metadata +84 -102
@@ -1,24 +1,24 @@
1
- module AuthorizeNet
2
- # Models a customer.
3
- class Customer
4
- attr_accessor
5
- include AuthorizeNet::Model
6
-
7
- attr_accessor :phone, :fax, :email, :id, :ip, :address, :description
8
-
9
- def to_hash
10
- hash = {
11
- phone: @phone,
12
- fax: @fax,
13
- email: @email,
14
- cust_id: @id,
15
- customer_ip: @ip,
16
- description: @description,
17
- customer_profile_id: @customer_profile_id
18
- }
19
- hash.delete_if { |_k, v| v.nil? }
20
- hash.merge!(@address.to_hash) unless @address.nil?
21
- hash
22
- end
23
- end
24
- end
1
+ module AuthorizeNet
2
+ # Models a customer.
3
+ class Customer
4
+ attr_accessor
5
+ include AuthorizeNet::Model
6
+
7
+ attr_accessor :phone, :fax, :email, :id, :ip, :address, :description
8
+
9
+ def to_hash
10
+ hash = {
11
+ phone: @phone,
12
+ fax: @fax,
13
+ email: @email,
14
+ cust_id: @id,
15
+ customer_ip: @ip,
16
+ description: @description,
17
+ customer_profile_id: @customer_profile_id
18
+ }
19
+ hash.delete_if { |_k, v| v.nil? }
20
+ hash.merge!(@address.to_hash) unless @address.nil?
21
+ hash
22
+ end
23
+ end
24
+ end
@@ -1,20 +1,20 @@
1
- module AuthorizeNet
2
- # Models an email receipt.
3
- class EmailReceipt
4
- include AuthorizeNet::Model
5
-
6
- attr_accessor :header, :footer, :merchant_email, :email_customer
7
-
8
- def to_hash
9
- hash = {
10
- header: @header,
11
- footer: @footer,
12
- merchant_email: @merchant_email,
13
- email_customer: @email_customer
14
- }
15
- hash.delete_if { |_k, v| v.nil? }
16
- hash.merge(@address.to_hash) unless @address.nil?
17
- hash
18
- end
19
- end
20
- end
1
+ module AuthorizeNet
2
+ # Models an email receipt.
3
+ class EmailReceipt
4
+ include AuthorizeNet::Model
5
+
6
+ attr_accessor :header, :footer, :merchant_email, :email_customer
7
+
8
+ def to_hash
9
+ hash = {
10
+ header: @header,
11
+ footer: @footer,
12
+ merchant_email: @merchant_email,
13
+ email_customer: @email_customer
14
+ }
15
+ hash.delete_if { |_k, v| v.nil? }
16
+ hash.merge(@address.to_hash) unless @address.nil?
17
+ hash
18
+ end
19
+ end
20
+ end
@@ -1,760 +1,760 @@
1
- module AuthorizeNet
2
- EntityDescription = Struct.new(:node_structure, :entity_class, :arg_mapping)
3
-
4
- module AIM
5
- # Contains the various lists of fields needed by the AIM API.
6
- module Fields
7
- # Enumeration of the fields found in the AIM response. The index
8
- # of the field name corresponds to its position (+ 1) in the AIM response.
9
- FIELDS = [
10
- :response_code,
11
- :response_subcode,
12
- :response_reason_code,
13
- :response_reason_text,
14
- :authorization_code,
15
- :avs_response,
16
- :transaction_id,
17
- :invoice_number,
18
- :description,
19
- :amount,
20
- :method,
21
- :transaction_type,
22
- :customer_id,
23
- :first_name,
24
- :last_name,
25
- :company,
26
- :address,
27
- :city,
28
- :state,
29
- :zip_code,
30
- :country,
31
- :phone,
32
- :fax,
33
- :email_address,
34
- :ship_to_first_name,
35
- :ship_to_last_name,
36
- :ship_to_company,
37
- :ship_to_address,
38
- :ship_to_city,
39
- :ship_to_state,
40
- :ship_to_zip_code,
41
- :ship_to_country,
42
- :tax,
43
- :duty,
44
- :freight,
45
- :tax_exempt,
46
- :purchase_order_number,
47
- :md5_hash,
48
- :card_code_response,
49
- :cardholder_authentication_verification_response,
50
- :solution_id,
51
- nil,
52
- nil,
53
- nil,
54
- nil,
55
- nil,
56
- nil,
57
- nil,
58
- nil,
59
- nil,
60
- :account_number,
61
- :card_type,
62
- :split_tender_id,
63
- :requested,
64
- :balance_on_card,
65
- nil,
66
- nil,
67
- nil,
68
- nil,
69
- nil,
70
- nil,
71
- nil,
72
- nil,
73
- nil,
74
- nil,
75
- nil,
76
- nil,
77
- nil # Merchant defined fields come after this field (68)
78
- ].freeze
79
-
80
- # Enumeration of the fields found in the card present AIM response. The index
81
- # of the field name corresponds to its position (+ 1) in the card present AIM response.
82
- CP_FIELDS = [
83
- :cp_version,
84
- :response_code,
85
- :response_reason_code,
86
- :response_reason_text,
87
- :authorization_code,
88
- :avs_response,
89
- :card_code_response,
90
- :transaction_id,
91
- :md5_hash,
92
- :reference_id,
93
- nil,
94
- nil,
95
- nil,
96
- nil,
97
- nil,
98
- nil,
99
- nil,
100
- nil,
101
- nil,
102
- nil,
103
- :account_number,
104
- :card_type,
105
- :split_tender_id,
106
- :requested,
107
- :approved_amount,
108
- :balance_on_card
109
- ].freeze
110
- end
111
- end
112
-
113
- module SIM
114
- # Contains the various lists of fields needed by the SIM API.
115
- module Fields
116
- # List of the fields found in a SIM response. Any field not in this list
117
- # is treated as a Merchant Defined Field.
118
- FIELDS = %i[
119
- x_response_code
120
- x_response_subcode
121
- x_response_reason_code
122
- x_response_reason_text
123
- x_auth_code
124
- x_avs_code
125
- x_trans_id
126
- x_invoice_num
127
- x_description
128
- x_amount
129
- x_method
130
- x_type
131
- x_cust_id
132
- x_first_name
133
- x_last_name
134
- x_company
135
- x_address
136
- x_city
137
- x_state
138
- x_zip
139
- x_country
140
- x_phone
141
- x_fax
142
- x_email
143
- x_ship_to_first_name
144
- x_ship_to_last_name
145
- x_ship_to_company
146
- x_ship_to_address
147
- x_ship_to_city
148
- x_ship_to_state
149
- x_ship_to_zip
150
- x_ship_to_country
151
- x_tax
152
- x_duty
153
- x_freight
154
- x_tax_exempt
155
- x_po_num
156
- x_MD5_Hash
157
- x_cvv2_resp_code
158
- x_cavv_response
159
- ].freeze
160
- end
161
- end
162
-
163
- module ARB
164
- # Contains the various lists of fields needed by the ARB API.
165
- module Fields
166
- # Describes the order and nesting of fields in the ARB Subscription XML.
167
- SUBSCRIPTION_FIELDS = { subscription: [
168
- { name: :subscription_name },
169
- { paymentSchedule: [
170
- { interval: [
171
- { length: :subscription_length },
172
- { unit: :subscription_unit }
173
- ] },
174
- { startDate: :subscription_start_date },
175
- { totalOccurrences: :subscription_total_occurrences },
176
- { trialOccurrences: :subscription_trial_occurrences }
177
- ] },
178
- { amount: :subscription_amount },
179
- { trialAmount: :subscription_trial_amount },
180
- { payment: [
181
- { creditCard: [
182
- { cardNumber: :card_num },
183
- { expirationDate: :exp_date },
184
- { cardCode: :card_code }
185
- ] },
186
- { bankAccount: [
187
- { accountType: :bank_acct_type },
188
- { routingNumber: :bank_aba_code },
189
- { accountNumber: :bank_acct_num },
190
- { nameOnAccount: :bank_acct_name },
191
- { echeckType: :echeck_type },
192
- { bankName: :bank_name }
193
- ] }
194
- ] },
195
- { order: [
196
- { invoiceNumber: :invoice_num },
197
- { description: :description }
198
- ] },
199
- { customer: [
200
- { id_: :cust_id },
201
- { email: :email },
202
- { phoneNumber: :phone },
203
- { faxNumber: :fax }
204
- ] },
205
- { billTo: [
206
- { firstName: :first_name },
207
- { lastName: :last_name },
208
- { company: :company },
209
- { address: :address },
210
- { city: :city },
211
- { state: :state },
212
- { zip: :zip },
213
- { country: :country }
214
- ] },
215
- { shipTo: [
216
- { firstName: :ship_to_first_name },
217
- { lastName: :ship_to_last_name },
218
- { company: :ship_to_company },
219
- { address: :ship_to_address },
220
- { city: :ship_to_city },
221
- { state: :ship_to_state },
222
- { zip: :ship_to_zip },
223
- { country: :ship_to_country }
224
- ] }
225
- ] }.freeze
226
-
227
- # Describes the order and nesting of fields in the ARB ARBCreateSubscriptionRequest XML.
228
- CREATE_FIELDS = [
229
- { refId: :reference_id },
230
- SUBSCRIPTION_FIELDS
231
- ].freeze
232
-
233
- # Describes the order and nesting of fields in the ARB ARBUpdateSubscriptionRequest XML.
234
- UPDATE_FIELDS = [
235
- { refId: :reference_id },
236
- { subscriptionId: :subscription_id },
237
- SUBSCRIPTION_FIELDS
238
- ].freeze
239
-
240
- # Describes the order and nesting of fields in the ARB ARBGetSubscriptionStatusRequest XML.
241
- GET_STATUS_FIELDS = [
242
- { refId: :reference_id },
243
- { subscriptionId: :subscription_id }
244
- ].freeze
245
-
246
- # Describes the order and nesting of fields in the ARB ARBCancelSubscriptionRequest XML.
247
- CANCEL_FIELDS = [
248
- { refId: :reference_id },
249
- { subscriptionId: :subscription_id }
250
- ].freeze
251
-
252
- # Describes the order and nesting of fields in the ARB ARBGetSubscriptionListRequest XML.
253
- GET_SUBSCRIPTION_LIST_FIELDS = [
254
- { refId: :reference_id },
255
- { searchType: :search_type },
256
- { sorting: [
257
- { orderBy: :order_by },
258
- { orderDescending: :order_descending }
259
- ] },
260
- { paging: [
261
- { limit: :limit },
262
- { offset: :offset }
263
- ] }
264
- ].freeze
265
-
266
- FIELDS = {
267
- AuthorizeNet::XmlTransaction::Type::ARB_CREATE => CREATE_FIELDS,
268
- AuthorizeNet::XmlTransaction::Type::ARB_UPDATE => UPDATE_FIELDS,
269
- AuthorizeNet::XmlTransaction::Type::ARB_GET_STATUS => GET_STATUS_FIELDS,
270
- AuthorizeNet::XmlTransaction::Type::ARB_CANCEL => CANCEL_FIELDS,
271
- AuthorizeNet::XmlTransaction::Type::ARB_GET_SUBSCRIPTION_LIST => GET_SUBSCRIPTION_LIST_FIELDS
272
- }.freeze
273
- end
274
- end
275
-
276
- module CIM
277
- module Fields
278
- REFID_FIELDS = { refId: :reference_id }.freeze
279
-
280
- VALIDATION_MODE_FIELDS = { validationMode: :validation_mode }.freeze
281
-
282
- CUSTOMER_PROFILE_ID_FIELDS = { customerProfileId: :customer_profile_id }.freeze
283
-
284
- CUSTOMER_PAYMENT_PROFILE_ID_FIELDS = { customerPaymentProfileId: :customer_payment_profile_id }.freeze
285
-
286
- BILL_TO_FIELDS = { billTo: [
287
- { firstName: :first_name },
288
- { lastName: :last_name },
289
- { company: :company },
290
- { address: :address },
291
- { city: :city },
292
- { state: :state },
293
- { zip: :zip },
294
- { country: :country },
295
- { phoneNumber: :phone },
296
- { faxNumber: :fax }
297
- ] }.freeze
298
-
299
- SHIP_TO_FIELDS = { shipTo: [
300
- { firstName: :ship_to_first_name },
301
- { lastName: :ship_to_last_name },
302
- { company: :ship_to_company },
303
- { address: :ship_to_address },
304
- { city: :ship_to_city },
305
- { state: :ship_to_state },
306
- { zip: :ship_to_zip },
307
- { country: :ship_to_country },
308
- { phoneNumber: :ship_to_phone },
309
- { faxNumber: :ship_to_fax }
310
- ], _multivalue: :addresses }.freeze
311
-
312
- ADDRESS_FIELDS = { address: [
313
- { firstName: :first_name },
314
- { lastName: :last_name },
315
- { company: :company },
316
- { address: :address },
317
- { city: :city },
318
- { state: :state },
319
- { zip: :zip },
320
- { country: :country },
321
- { phoneNumber: :phone },
322
- { faxNumber: :fax }
323
- ] }.freeze
324
-
325
- PAYMENT_PROFILE_FIELDS = [
326
- { customerType: :cust_type },
327
- BILL_TO_FIELDS,
328
- { payment: [
329
- { creditCard: [
330
- { cardNumber: :card_num },
331
- { expirationDate: :exp_date },
332
- { cardCode: :card_code }
333
- ] },
334
- { bankAccount: [
335
- { accountType: :bank_acct_type },
336
- { routingNumber: :bank_aba_code },
337
- { accountNumber: :bank_acct_num },
338
- { nameOnAccount: :bank_acct_name },
339
- { echeckType: :echeck_type },
340
- { bankName: :bank_name }
341
- ] }
342
- ] }
343
- ].freeze
344
-
345
- PROFILE_FIELDS = { profile: [
346
- { merchantCustomerId: :cust_id },
347
- { description: :description },
348
- { email: :email },
349
- { paymentProfiles: PAYMENT_PROFILE_FIELDS, _multivalue: :payment_profiles },
350
- SHIP_TO_FIELDS
351
- ] }.freeze
352
-
353
- TRANSACTION_FIELDS = [
354
- { amount: :amount },
355
- { tax: [
356
- { amount: :tax },
357
- { name: :tax_name },
358
- { description: :tax_description }
359
- ] },
360
- { shipping: [
361
- { amount: :freight },
362
- { name: :freight_name },
363
- { description: :freight_description }
364
- ] },
365
- { duty: [
366
- { amount: :duty },
367
- { name: :duty_name },
368
- { description: :duty_description }
369
- ] },
370
- { lineItems: [
371
- { itemId: :line_item_id },
372
- { name: :line_item_name },
373
- { description: :line_item_description },
374
- { quantity: :line_item_quantity },
375
- { unitPrice: :line_item_unit_price },
376
- { taxable: :line_item_taxable }
377
- ], _multivalue: :line_items },
378
- CUSTOMER_PROFILE_ID_FIELDS,
379
- CUSTOMER_PAYMENT_PROFILE_ID_FIELDS,
380
- { customerShippingAddressId: :customer_address_id },
381
- { creditCardNumberMasked: :card_num_masked },
382
- { bankRoutingNumberMasked: :bank_aba_code_masked },
383
- { bankAccountNumberMasked: :bank_acct_num_masked },
384
- { order: [
385
- { invoiceNumber: :invoice_num },
386
- { description: :description },
387
- { purchaseOrderNumber: :po_num }
388
- ] },
389
- { taxExempt: :tax_exempt },
390
- { recurringBilling: :recurring_billing },
391
- { cardCode: :card_code },
392
- { splitTenderId: :split_tender_id },
393
- { approvalCode: :auth_code },
394
- { transId: :trans_id }
395
- ].freeze
396
-
397
- TRANSACTION_AUTH_FIELDS = [
398
- { profileTransAuthOnly: TRANSACTION_FIELDS }
399
- ].freeze
400
-
401
- TRANSACTION_AUTH_CAPTURE_FIELDS = [
402
- { profileTransAuthCapture: TRANSACTION_FIELDS }
403
- ].freeze
404
-
405
- TRANSACTION_CAPTURE_FIELDS = [
406
- { profileTransCaptureOnly: TRANSACTION_FIELDS }
407
- ].freeze
408
-
409
- TRANSACTION_PRIOR_AUTH_CAPTURE_FIELDS = [
410
- { profileTransPriorAuthCapture: TRANSACTION_FIELDS }
411
- ].freeze
412
-
413
- TRANSACTION_REFUND_FIELDS = [
414
- { profileTransRefund: TRANSACTION_FIELDS }
415
- ].freeze
416
-
417
- TRANSACTION_VOID_FIELDS = [
418
- { profileTransVoid: [
419
- CUSTOMER_PROFILE_ID_FIELDS,
420
- CUSTOMER_PAYMENT_PROFILE_ID_FIELDS,
421
- { transId: :trans_id }
422
- ] }
423
- ].freeze
424
-
425
- CREATE_PROFILE_FIELDS = [
426
- REFID_FIELDS,
427
- PROFILE_FIELDS,
428
- VALIDATION_MODE_FIELDS
429
- ].freeze
430
-
431
- CREATE_PAYMENT_FIELDS = [
432
- REFID_FIELDS,
433
- CUSTOMER_PROFILE_ID_FIELDS,
434
- { paymentProfile: PAYMENT_PROFILE_FIELDS },
435
- VALIDATION_MODE_FIELDS
436
- ].freeze
437
-
438
- CREATE_ADDRESS_FIELDS = [
439
- REFID_FIELDS,
440
- CUSTOMER_PROFILE_ID_FIELDS,
441
- ADDRESS_FIELDS
442
- ].freeze
443
-
444
- CREATE_TRANSACTION_FIELDS = [
445
- REFID_FIELDS,
446
- { transaction: [], _conditional: :select_transaction_type_fields },
447
- { extraOptions: :extra_options }
448
- ].freeze
449
-
450
- DELETE_PROFILE_FIELDS = [
451
- REFID_FIELDS,
452
- CUSTOMER_PROFILE_ID_FIELDS
453
- ].freeze
454
-
455
- DELETE_PAYMENT_FIELDS = [
456
- REFID_FIELDS,
457
- CUSTOMER_PROFILE_ID_FIELDS,
458
- CUSTOMER_PAYMENT_PROFILE_ID_FIELDS
459
- ].freeze
460
-
461
- DELETE_ADDRESS_FIELDS = [
462
- REFID_FIELDS,
463
- CUSTOMER_PROFILE_ID_FIELDS,
464
- { customerAddressId: :customer_address_id }
465
- ].freeze
466
-
467
- GET_PROFILE_IDS_FIELDS = [].freeze
468
-
469
- GET_PROFILE_FIELDS = [
470
- CUSTOMER_PROFILE_ID_FIELDS
471
- ].freeze
472
-
473
- GET_PAYMENT_FIELDS = [
474
- CUSTOMER_PROFILE_ID_FIELDS,
475
- CUSTOMER_PAYMENT_PROFILE_ID_FIELDS
476
- ].freeze
477
-
478
- GET_ADDRESS_FIELDS = [
479
- CUSTOMER_PROFILE_ID_FIELDS,
480
- { customerAddressId: :customer_address_id }
481
- ].freeze
482
-
483
- GET_HOSTED_PROFILE_FIELDS = [
484
- REFID_FIELDS,
485
- CUSTOMER_PROFILE_ID_FIELDS,
486
- { hostedProfileSettings: [{ setting: [{ settingName: :setting_name }, { settingValue: :setting_value }], _multivalue: :hosted_settings }] }
487
- ].freeze
488
-
489
- UPDATE_PROFILE_FIELDS = [
490
- REFID_FIELDS,
491
- { profile: [
492
- { merchantCustomerId: :cust_id },
493
- { description: :description },
494
- { email: :email },
495
- CUSTOMER_PROFILE_ID_FIELDS
496
- ] }
497
- ].freeze
498
-
499
- UPDATE_PAYMENT_FIELDS = [
500
- REFID_FIELDS,
501
- CUSTOMER_PROFILE_ID_FIELDS,
502
- { paymentProfile: PAYMENT_PROFILE_FIELDS + [CUSTOMER_PAYMENT_PROFILE_ID_FIELDS] },
503
- VALIDATION_MODE_FIELDS
504
- ].freeze
505
-
506
- UPDATE_ADDRESS_FIELDS = [
507
- REFID_FIELDS,
508
- CUSTOMER_PROFILE_ID_FIELDS,
509
- { address: [
510
- { firstName: :first_name },
511
- { lastName: :last_name },
512
- { company: :company },
513
- { address: :address },
514
- { city: :city },
515
- { state: :state },
516
- { zip: :zip },
517
- { country: :country },
518
- { phoneNumber: :phone },
519
- { faxNumber: :fax },
520
- { customerAddressId: :customer_address_id }
521
- ] }
522
- ].freeze
523
-
524
- UPDATE_SPLIT_FIELDS = [
525
- { splitTenderId: :split_tender_id },
526
- { splitTenderStatus: :split_tender_status }
527
- ].freeze
528
-
529
- VALIDATE_PAYMENT_FIELDS = [
530
- CUSTOMER_PROFILE_ID_FIELDS,
531
- CUSTOMER_PAYMENT_PROFILE_ID_FIELDS,
532
- { customerShippingAddressId: :customer_address_id },
533
- { cardCode: :card_code },
534
- VALIDATION_MODE_FIELDS
535
- ].freeze
536
-
537
- FIELDS = {
538
- AuthorizeNet::XmlTransaction::Type::CIM_CREATE_PROFILE => CREATE_PROFILE_FIELDS,
539
- AuthorizeNet::XmlTransaction::Type::CIM_CREATE_PAYMENT => CREATE_PAYMENT_FIELDS,
540
- AuthorizeNet::XmlTransaction::Type::CIM_CREATE_ADDRESS => CREATE_ADDRESS_FIELDS,
541
- AuthorizeNet::XmlTransaction::Type::CIM_CREATE_TRANSACTION => CREATE_TRANSACTION_FIELDS,
542
- AuthorizeNet::XmlTransaction::Type::CIM_DELETE_PROFILE => DELETE_PROFILE_FIELDS,
543
- AuthorizeNet::XmlTransaction::Type::CIM_DELETE_PAYMENT => DELETE_PAYMENT_FIELDS,
544
- AuthorizeNet::XmlTransaction::Type::CIM_DELETE_ADDRESS => DELETE_ADDRESS_FIELDS,
545
- AuthorizeNet::XmlTransaction::Type::CIM_GET_PROFILE_IDS => GET_PROFILE_IDS_FIELDS,
546
- AuthorizeNet::XmlTransaction::Type::CIM_GET_PROFILE => GET_PROFILE_FIELDS,
547
- AuthorizeNet::XmlTransaction::Type::CIM_GET_PAYMENT => GET_PAYMENT_FIELDS,
548
- AuthorizeNet::XmlTransaction::Type::CIM_GET_ADDRESS => GET_ADDRESS_FIELDS,
549
- AuthorizeNet::XmlTransaction::Type::CIM_GET_HOSTED_PROFILE => GET_HOSTED_PROFILE_FIELDS,
550
- AuthorizeNet::XmlTransaction::Type::CIM_UPDATE_PROFILE => UPDATE_PROFILE_FIELDS,
551
- AuthorizeNet::XmlTransaction::Type::CIM_UPDATE_PAYMENT => UPDATE_PAYMENT_FIELDS,
552
- AuthorizeNet::XmlTransaction::Type::CIM_UPDATE_ADDRESS => UPDATE_ADDRESS_FIELDS,
553
- AuthorizeNet::XmlTransaction::Type::CIM_UPDATE_SPLIT => UPDATE_SPLIT_FIELDS,
554
- AuthorizeNet::XmlTransaction::Type::CIM_VALIDATE_PAYMENT => VALIDATE_PAYMENT_FIELDS
555
- }.freeze
556
-
557
- ADDRESS_ENTITY_DESCRIPTION = EntityDescription.new(
558
- [
559
- { firstName: :first_name },
560
- { lastName: :last_name },
561
- { company: :company },
562
- { address: :street_address },
563
- { city: :city },
564
- { state: :state },
565
- { zip: :zip },
566
- { country: :country },
567
- { phoneNumber: :phone },
568
- { faxNumber: :fax }
569
- ],
570
- AuthorizeNet::Address
571
- )
572
-
573
- CREDIT_CARD_ENTITY_DESCRIPTION = EntityDescription.new(
574
- [
575
- { cardNumber: :card_num },
576
- { expirationDate: :exp_date },
577
- { cardCode: :card_code },
578
- { cardType: :card_type }
579
- ],
580
- AuthorizeNet::CreditCard,
581
- %i[card_num exp_date]
582
- )
583
-
584
- ECHECK_ENTITY_DESCRIPTION = EntityDescription.new(
585
- [
586
- { accountType: :account_type },
587
- { routingNumber: :routing_number },
588
- { accountNumber: :account_number },
589
- { nameOnAccount: :account_holder_name },
590
- { echeckType: :echeck_type },
591
- { bankName: :bank_name }
592
- ],
593
- AuthorizeNet::ECheck,
594
- %i[routing_number account_number bank_name account_holder_name]
595
- )
596
-
597
- PAYMENT_PROFILE_ENTITY_DESCRIPTION = EntityDescription.new(
598
- [
599
- CUSTOMER_PAYMENT_PROFILE_ID_FIELDS,
600
- { customerType: :cust_type },
601
- { billTo: ADDRESS_ENTITY_DESCRIPTION, _value: :billing_address },
602
- { payment: [
603
- { creditCard: CREDIT_CARD_ENTITY_DESCRIPTION, _value: :payment_method },
604
- { bankAccount: ECHECK_ENTITY_DESCRIPTION, _value: :payment_method }
605
- ] }
606
- ],
607
- AuthorizeNet::CIM::PaymentProfile
608
- )
609
-
610
- PROFILE_ENTITY_DESCRIPTION = EntityDescription.new(
611
- [
612
- { merchantCustomerId: :id },
613
- { description: :description },
614
- { email: :email },
615
- CUSTOMER_PROFILE_ID_FIELDS,
616
- { paymentProfiles: PAYMENT_PROFILE_ENTITY_DESCRIPTION, _multivalue: :payment_profiles },
617
- { shipTo: ADDRESS_ENTITY_DESCRIPTION, _multivalue: :addresses }
618
- ],
619
- AuthorizeNet::CIM::CustomerProfile
620
- )
621
- end
622
- end
623
-
624
- module Reporting
625
- module Fields
626
- GET_BATCH_LIST = [
627
- { includeStatistics: :include_statistics },
628
- { firstSettlementDate: :first_settlement_date },
629
- { lastSettlementDate: :last_settlement_date }
630
- ].freeze
631
-
632
- GET_TRANSACTION_LIST = [
633
- { batchId: :batch_id }
634
- ].freeze
635
-
636
- GET_UNSETTLED_TRANSACTION_LIST = [
637
- ].freeze
638
-
639
- GET_TRANSACTION_DETAILS = [
640
- { transId: :transaction_id }
641
- ].freeze
642
-
643
- BATCH_STATISTICS_ENTITY_DESCRIPTION = EntityDescription.new([
644
- { accountType: :account_type },
645
- { chargeAmount: :charge_amount, _converter: :value_to_decimal },
646
- { chargeCount: :charge_count, _converter: :value_to_integer },
647
- { refundAmount: :refund_amount, _converter: :value_to_decimal },
648
- { refundCount: :refund_count, _converter: :value_to_integer },
649
- { voidCount: :void_count, _converter: :value_to_integer },
650
- { declineCount: :decline_count, _converter: :value_to_integer },
651
- { errorCount: :error_count, _converter: :value_to_integer },
652
- { returnedItemAmount: :returned_item_amount, _converter: :value_to_decimal },
653
- { returnedItemCount: :returned_item_count, _converter: :value_to_integer },
654
- { chargebackAmount: :chargeback_amount, _converter: :value_to_decimal },
655
- { chargebackCount: :chargeback_count, _converter: :value_to_integer },
656
- { correctionNoticeCount: :correction_notice_count, _converter: :value_to_integer },
657
- { chargeChargeBackAmount: :charge_chargeback_amount, _converter: :value_to_decimal },
658
- { chargeChargeBackCount: :charge_chargeback_count, _converter: :value_to_integer },
659
- { refundChargeBackAmount: :refund_chargeback_amount, _converter: :value_to_decimal },
660
- { refundChargeBackCount: :refund_chargeback_count, _converter: :value_to_integer },
661
- { chargeReturnedItemsAmount: :charge_returned_items_amount, _converter: :value_to_decimal },
662
- { chargeReturnedItemsCount: :charge_returned_items_count, _converter: :value_to_integer },
663
- { refundReturnedItemsAmount: :refund_returned_items_amount, _converter: :value_to_decimal },
664
- { refundReturnedItemsCount: :refund_returned_items_count, _converter: :value_to_integer }
665
- ],
666
- AuthorizeNet::Reporting::BatchStatistics)
667
-
668
- BATCH_ENTITY_DESCRIPTION = EntityDescription.new([
669
- { batchId: :id },
670
- { settlementTimeUTC: :settled_at, _converter: :value_to_datetime },
671
- { settlementState: :state },
672
- { paymentMethod: :payment_method },
673
- { statistics: [{ statistic: BATCH_STATISTICS_ENTITY_DESCRIPTION, _multivalue: :statistics }] }
674
- ],
675
- AuthorizeNet::Reporting::Batch)
676
-
677
- FDSFILTER_ENTITY_DESCRIPTION = EntityDescription.new([
678
- { name: :name },
679
- { action: :action }
680
- ],
681
- AuthorizeNet::Reporting::FDSFilter)
682
-
683
- CUSTOMER_ENTITY_DESCRIPTION = EntityDescription.new([
684
- { id: :id },
685
- { email: :email }
686
- ],
687
- AuthorizeNet::CIM::CustomerProfile)
688
-
689
- ORDER_ENTITY_DESCRIPTION = EntityDescription.new([
690
- { invoice_number: :invoice_num },
691
- { description: :description },
692
- { purchaseOrderNumber: :po_num }
693
- ],
694
- AuthorizeNet::Order)
695
-
696
- LINE_ITEM_ENTITY_DESCRIPTION = EntityDescription.new([
697
- { itemId: :id },
698
- { name: :name },
699
- { description: :description },
700
- { quantity: :quantity, _convert: :value_to_integer },
701
- { unityPrice: :price, _convert: :value_to_decimal },
702
- { taxable: :taxable, _convert: :value_to_boolean }
703
- ],
704
- AuthorizeNet::LineItem)
705
-
706
- attr_accessor :id, :date_utc, :date_local, :code, :description
707
- RETURNED_ITEM_ENTITY_DESCRIPTION = EntityDescription.new([
708
- { id: :id },
709
- { dateUTC: :date_utc },
710
- { dateLocal: :date_local },
711
- { code: :code },
712
- { description: :description }
713
- ],
714
- AuthorizeNet::Reporting::ReturnedItem)
715
-
716
- TRANSACTION_DETAILS_ENTITY_DESCRIPTION = EntityDescription.new([
717
- { transId: :id },
718
- { refTransId: :reference_id },
719
- { splitTenderId: :split_tender_id },
720
- { transactionType: :type },
721
- { responseCode: :response_code },
722
- { responseReasonCode: :response_reason_code },
723
- { authCode: :auth_code },
724
- { AVSResponse: :avs_response },
725
- { cardCodeResponse: :card_code_response },
726
- { CAVVResponse: :cavv_response },
727
- { FDSFilterAction: :fds_filter_action },
728
- { FDSFilters: [{ FDSFilter: FDSFILTER_ENTITY_DESCRIPTION, _multivalue: :fds_filters }] },
729
- { batch: BATCH_ENTITY_DESCRIPTION, _value: :batch },
730
- { responseReasonDescription: :response_reason_description },
731
- { submitTimeUTC: :submitted_at, _converter: :value_to_datetime },
732
- { transactionStatus: :status },
733
- { accountType: :account_type },
734
- { accountNumber: :account_number },
735
- { order: ORDER_ENTITY_DESCRIPTION, _value: :order },
736
- { requestedAmount: :requested_amount, _converter: :value_to_decimal },
737
- { authAmount: :auth_amount, _converter: :value_to_decimal },
738
- { settleAmount: :settle_amount, _converter: :value_to_decimal },
739
- { prepaidBalanceRemaining: :prepaid_balance_remaining, _converter: :value_to_decimal },
740
- { payment: [
741
- { creditCard: AuthorizeNet::CIM::Fields::CREDIT_CARD_ENTITY_DESCRIPTION, _value: :payment_method },
742
- { bankAccount: AuthorizeNet::CIM::Fields::ECHECK_ENTITY_DESCRIPTION, _value: :payment_method }
743
- ] },
744
- { customer: CUSTOMER_ENTITY_DESCRIPTION, _value: :customer },
745
- { billTo: AuthorizeNet::CIM::Fields::ADDRESS_ENTITY_DESCRIPTION, _value: :bill_to },
746
- { shipTo: AuthorizeNet::CIM::Fields::ADDRESS_ENTITY_DESCRIPTION, _value: :ship_to },
747
- { recurringBilling: :recurring_billing, _convert: :value_to_boolean },
748
- { hasReturnedItems: :returns, _convert: :value_to_boolean }
749
- ],
750
- AuthorizeNet::Reporting::TransactionDetails)
751
-
752
- FIELDS = {
753
- AuthorizeNet::XmlTransaction::Type::REPORT_GET_BATCH_LIST => GET_BATCH_LIST,
754
- AuthorizeNet::XmlTransaction::Type::REPORT_GET_TRANSACTION_LIST => GET_TRANSACTION_LIST,
755
- AuthorizeNet::XmlTransaction::Type::REPORT_GET_UNSETTLED_TRANSACTION_LIST => GET_UNSETTLED_TRANSACTION_LIST,
756
- AuthorizeNet::XmlTransaction::Type::REPORT_GET_TRANSACTION_DETAILS => GET_TRANSACTION_DETAILS
757
- }.freeze
758
- end
759
- end
760
- end
1
+ module AuthorizeNet
2
+ EntityDescription = Struct.new(:node_structure, :entity_class, :arg_mapping)
3
+
4
+ module AIM
5
+ # Contains the various lists of fields needed by the AIM API.
6
+ module Fields
7
+ # Enumeration of the fields found in the AIM response. The index
8
+ # of the field name corresponds to its position (+ 1) in the AIM response.
9
+ FIELDS = [
10
+ :response_code,
11
+ :response_subcode,
12
+ :response_reason_code,
13
+ :response_reason_text,
14
+ :authorization_code,
15
+ :avs_response,
16
+ :transaction_id,
17
+ :invoice_number,
18
+ :description,
19
+ :amount,
20
+ :method,
21
+ :transaction_type,
22
+ :customer_id,
23
+ :first_name,
24
+ :last_name,
25
+ :company,
26
+ :address,
27
+ :city,
28
+ :state,
29
+ :zip_code,
30
+ :country,
31
+ :phone,
32
+ :fax,
33
+ :email_address,
34
+ :ship_to_first_name,
35
+ :ship_to_last_name,
36
+ :ship_to_company,
37
+ :ship_to_address,
38
+ :ship_to_city,
39
+ :ship_to_state,
40
+ :ship_to_zip_code,
41
+ :ship_to_country,
42
+ :tax,
43
+ :duty,
44
+ :freight,
45
+ :tax_exempt,
46
+ :purchase_order_number,
47
+ :md5_hash,
48
+ :card_code_response,
49
+ :cardholder_authentication_verification_response,
50
+ :solution_id,
51
+ nil,
52
+ nil,
53
+ nil,
54
+ nil,
55
+ nil,
56
+ nil,
57
+ nil,
58
+ nil,
59
+ nil,
60
+ :account_number,
61
+ :card_type,
62
+ :split_tender_id,
63
+ :requested,
64
+ :balance_on_card,
65
+ nil,
66
+ nil,
67
+ nil,
68
+ nil,
69
+ nil,
70
+ nil,
71
+ nil,
72
+ nil,
73
+ nil,
74
+ nil,
75
+ nil,
76
+ nil,
77
+ nil # Merchant defined fields come after this field (68)
78
+ ].freeze
79
+
80
+ # Enumeration of the fields found in the card present AIM response. The index
81
+ # of the field name corresponds to its position (+ 1) in the card present AIM response.
82
+ CP_FIELDS = [
83
+ :cp_version,
84
+ :response_code,
85
+ :response_reason_code,
86
+ :response_reason_text,
87
+ :authorization_code,
88
+ :avs_response,
89
+ :card_code_response,
90
+ :transaction_id,
91
+ :md5_hash,
92
+ :reference_id,
93
+ nil,
94
+ nil,
95
+ nil,
96
+ nil,
97
+ nil,
98
+ nil,
99
+ nil,
100
+ nil,
101
+ nil,
102
+ nil,
103
+ :account_number,
104
+ :card_type,
105
+ :split_tender_id,
106
+ :requested,
107
+ :approved_amount,
108
+ :balance_on_card
109
+ ].freeze
110
+ end
111
+ end
112
+
113
+ module SIM
114
+ # Contains the various lists of fields needed by the SIM API.
115
+ module Fields
116
+ # List of the fields found in a SIM response. Any field not in this list
117
+ # is treated as a Merchant Defined Field.
118
+ FIELDS = %i[
119
+ x_response_code
120
+ x_response_subcode
121
+ x_response_reason_code
122
+ x_response_reason_text
123
+ x_auth_code
124
+ x_avs_code
125
+ x_trans_id
126
+ x_invoice_num
127
+ x_description
128
+ x_amount
129
+ x_method
130
+ x_type
131
+ x_cust_id
132
+ x_first_name
133
+ x_last_name
134
+ x_company
135
+ x_address
136
+ x_city
137
+ x_state
138
+ x_zip
139
+ x_country
140
+ x_phone
141
+ x_fax
142
+ x_email
143
+ x_ship_to_first_name
144
+ x_ship_to_last_name
145
+ x_ship_to_company
146
+ x_ship_to_address
147
+ x_ship_to_city
148
+ x_ship_to_state
149
+ x_ship_to_zip
150
+ x_ship_to_country
151
+ x_tax
152
+ x_duty
153
+ x_freight
154
+ x_tax_exempt
155
+ x_po_num
156
+ x_MD5_Hash
157
+ x_cvv2_resp_code
158
+ x_cavv_response
159
+ ].freeze
160
+ end
161
+ end
162
+
163
+ module ARB
164
+ # Contains the various lists of fields needed by the ARB API.
165
+ module Fields
166
+ # Describes the order and nesting of fields in the ARB Subscription XML.
167
+ SUBSCRIPTION_FIELDS = { subscription: [
168
+ { name: :subscription_name },
169
+ { paymentSchedule: [
170
+ { interval: [
171
+ { length: :subscription_length },
172
+ { unit: :subscription_unit }
173
+ ] },
174
+ { startDate: :subscription_start_date },
175
+ { totalOccurrences: :subscription_total_occurrences },
176
+ { trialOccurrences: :subscription_trial_occurrences }
177
+ ] },
178
+ { amount: :subscription_amount },
179
+ { trialAmount: :subscription_trial_amount },
180
+ { payment: [
181
+ { creditCard: [
182
+ { cardNumber: :card_num },
183
+ { expirationDate: :exp_date },
184
+ { cardCode: :card_code }
185
+ ] },
186
+ { bankAccount: [
187
+ { accountType: :bank_acct_type },
188
+ { routingNumber: :bank_aba_code },
189
+ { accountNumber: :bank_acct_num },
190
+ { nameOnAccount: :bank_acct_name },
191
+ { echeckType: :echeck_type },
192
+ { bankName: :bank_name }
193
+ ] }
194
+ ] },
195
+ { order: [
196
+ { invoiceNumber: :invoice_num },
197
+ { description: :description }
198
+ ] },
199
+ { customer: [
200
+ { id_: :cust_id },
201
+ { email: :email },
202
+ { phoneNumber: :phone },
203
+ { faxNumber: :fax }
204
+ ] },
205
+ { billTo: [
206
+ { firstName: :first_name },
207
+ { lastName: :last_name },
208
+ { company: :company },
209
+ { address: :address },
210
+ { city: :city },
211
+ { state: :state },
212
+ { zip: :zip },
213
+ { country: :country }
214
+ ] },
215
+ { shipTo: [
216
+ { firstName: :ship_to_first_name },
217
+ { lastName: :ship_to_last_name },
218
+ { company: :ship_to_company },
219
+ { address: :ship_to_address },
220
+ { city: :ship_to_city },
221
+ { state: :ship_to_state },
222
+ { zip: :ship_to_zip },
223
+ { country: :ship_to_country }
224
+ ] }
225
+ ] }.freeze
226
+
227
+ # Describes the order and nesting of fields in the ARB ARBCreateSubscriptionRequest XML.
228
+ CREATE_FIELDS = [
229
+ { refId: :reference_id },
230
+ SUBSCRIPTION_FIELDS
231
+ ].freeze
232
+
233
+ # Describes the order and nesting of fields in the ARB ARBUpdateSubscriptionRequest XML.
234
+ UPDATE_FIELDS = [
235
+ { refId: :reference_id },
236
+ { subscriptionId: :subscription_id },
237
+ SUBSCRIPTION_FIELDS
238
+ ].freeze
239
+
240
+ # Describes the order and nesting of fields in the ARB ARBGetSubscriptionStatusRequest XML.
241
+ GET_STATUS_FIELDS = [
242
+ { refId: :reference_id },
243
+ { subscriptionId: :subscription_id }
244
+ ].freeze
245
+
246
+ # Describes the order and nesting of fields in the ARB ARBCancelSubscriptionRequest XML.
247
+ CANCEL_FIELDS = [
248
+ { refId: :reference_id },
249
+ { subscriptionId: :subscription_id }
250
+ ].freeze
251
+
252
+ # Describes the order and nesting of fields in the ARB ARBGetSubscriptionListRequest XML.
253
+ GET_SUBSCRIPTION_LIST_FIELDS = [
254
+ { refId: :reference_id },
255
+ { searchType: :search_type },
256
+ { sorting: [
257
+ { orderBy: :order_by },
258
+ { orderDescending: :order_descending }
259
+ ] },
260
+ { paging: [
261
+ { limit: :limit },
262
+ { offset: :offset }
263
+ ] }
264
+ ].freeze
265
+
266
+ FIELDS = {
267
+ AuthorizeNet::XmlTransaction::Type::ARB_CREATE => CREATE_FIELDS,
268
+ AuthorizeNet::XmlTransaction::Type::ARB_UPDATE => UPDATE_FIELDS,
269
+ AuthorizeNet::XmlTransaction::Type::ARB_GET_STATUS => GET_STATUS_FIELDS,
270
+ AuthorizeNet::XmlTransaction::Type::ARB_CANCEL => CANCEL_FIELDS,
271
+ AuthorizeNet::XmlTransaction::Type::ARB_GET_SUBSCRIPTION_LIST => GET_SUBSCRIPTION_LIST_FIELDS
272
+ }.freeze
273
+ end
274
+ end
275
+
276
+ module CIM
277
+ module Fields
278
+ REFID_FIELDS = { refId: :reference_id }.freeze
279
+
280
+ VALIDATION_MODE_FIELDS = { validationMode: :validation_mode }.freeze
281
+
282
+ CUSTOMER_PROFILE_ID_FIELDS = { customerProfileId: :customer_profile_id }.freeze
283
+
284
+ CUSTOMER_PAYMENT_PROFILE_ID_FIELDS = { customerPaymentProfileId: :customer_payment_profile_id }.freeze
285
+
286
+ BILL_TO_FIELDS = { billTo: [
287
+ { firstName: :first_name },
288
+ { lastName: :last_name },
289
+ { company: :company },
290
+ { address: :address },
291
+ { city: :city },
292
+ { state: :state },
293
+ { zip: :zip },
294
+ { country: :country },
295
+ { phoneNumber: :phone },
296
+ { faxNumber: :fax }
297
+ ] }.freeze
298
+
299
+ SHIP_TO_FIELDS = { shipTo: [
300
+ { firstName: :ship_to_first_name },
301
+ { lastName: :ship_to_last_name },
302
+ { company: :ship_to_company },
303
+ { address: :ship_to_address },
304
+ { city: :ship_to_city },
305
+ { state: :ship_to_state },
306
+ { zip: :ship_to_zip },
307
+ { country: :ship_to_country },
308
+ { phoneNumber: :ship_to_phone },
309
+ { faxNumber: :ship_to_fax }
310
+ ], _multivalue: :addresses }.freeze
311
+
312
+ ADDRESS_FIELDS = { address: [
313
+ { firstName: :first_name },
314
+ { lastName: :last_name },
315
+ { company: :company },
316
+ { address: :address },
317
+ { city: :city },
318
+ { state: :state },
319
+ { zip: :zip },
320
+ { country: :country },
321
+ { phoneNumber: :phone },
322
+ { faxNumber: :fax }
323
+ ] }.freeze
324
+
325
+ PAYMENT_PROFILE_FIELDS = [
326
+ { customerType: :cust_type },
327
+ BILL_TO_FIELDS,
328
+ { payment: [
329
+ { creditCard: [
330
+ { cardNumber: :card_num },
331
+ { expirationDate: :exp_date },
332
+ { cardCode: :card_code }
333
+ ] },
334
+ { bankAccount: [
335
+ { accountType: :bank_acct_type },
336
+ { routingNumber: :bank_aba_code },
337
+ { accountNumber: :bank_acct_num },
338
+ { nameOnAccount: :bank_acct_name },
339
+ { echeckType: :echeck_type },
340
+ { bankName: :bank_name }
341
+ ] }
342
+ ] }
343
+ ].freeze
344
+
345
+ PROFILE_FIELDS = { profile: [
346
+ { merchantCustomerId: :cust_id },
347
+ { description: :description },
348
+ { email: :email },
349
+ { paymentProfiles: PAYMENT_PROFILE_FIELDS, _multivalue: :payment_profiles },
350
+ SHIP_TO_FIELDS
351
+ ] }.freeze
352
+
353
+ TRANSACTION_FIELDS = [
354
+ { amount: :amount },
355
+ { tax: [
356
+ { amount: :tax },
357
+ { name: :tax_name },
358
+ { description: :tax_description }
359
+ ] },
360
+ { shipping: [
361
+ { amount: :freight },
362
+ { name: :freight_name },
363
+ { description: :freight_description }
364
+ ] },
365
+ { duty: [
366
+ { amount: :duty },
367
+ { name: :duty_name },
368
+ { description: :duty_description }
369
+ ] },
370
+ { lineItems: [
371
+ { itemId: :line_item_id },
372
+ { name: :line_item_name },
373
+ { description: :line_item_description },
374
+ { quantity: :line_item_quantity },
375
+ { unitPrice: :line_item_unit_price },
376
+ { taxable: :line_item_taxable }
377
+ ], _multivalue: :line_items },
378
+ CUSTOMER_PROFILE_ID_FIELDS,
379
+ CUSTOMER_PAYMENT_PROFILE_ID_FIELDS,
380
+ { customerShippingAddressId: :customer_address_id },
381
+ { creditCardNumberMasked: :card_num_masked },
382
+ { bankRoutingNumberMasked: :bank_aba_code_masked },
383
+ { bankAccountNumberMasked: :bank_acct_num_masked },
384
+ { order: [
385
+ { invoiceNumber: :invoice_num },
386
+ { description: :description },
387
+ { purchaseOrderNumber: :po_num }
388
+ ] },
389
+ { taxExempt: :tax_exempt },
390
+ { recurringBilling: :recurring_billing },
391
+ { cardCode: :card_code },
392
+ { splitTenderId: :split_tender_id },
393
+ { approvalCode: :auth_code },
394
+ { transId: :trans_id }
395
+ ].freeze
396
+
397
+ TRANSACTION_AUTH_FIELDS = [
398
+ { profileTransAuthOnly: TRANSACTION_FIELDS }
399
+ ].freeze
400
+
401
+ TRANSACTION_AUTH_CAPTURE_FIELDS = [
402
+ { profileTransAuthCapture: TRANSACTION_FIELDS }
403
+ ].freeze
404
+
405
+ TRANSACTION_CAPTURE_FIELDS = [
406
+ { profileTransCaptureOnly: TRANSACTION_FIELDS }
407
+ ].freeze
408
+
409
+ TRANSACTION_PRIOR_AUTH_CAPTURE_FIELDS = [
410
+ { profileTransPriorAuthCapture: TRANSACTION_FIELDS }
411
+ ].freeze
412
+
413
+ TRANSACTION_REFUND_FIELDS = [
414
+ { profileTransRefund: TRANSACTION_FIELDS }
415
+ ].freeze
416
+
417
+ TRANSACTION_VOID_FIELDS = [
418
+ { profileTransVoid: [
419
+ CUSTOMER_PROFILE_ID_FIELDS,
420
+ CUSTOMER_PAYMENT_PROFILE_ID_FIELDS,
421
+ { transId: :trans_id }
422
+ ] }
423
+ ].freeze
424
+
425
+ CREATE_PROFILE_FIELDS = [
426
+ REFID_FIELDS,
427
+ PROFILE_FIELDS,
428
+ VALIDATION_MODE_FIELDS
429
+ ].freeze
430
+
431
+ CREATE_PAYMENT_FIELDS = [
432
+ REFID_FIELDS,
433
+ CUSTOMER_PROFILE_ID_FIELDS,
434
+ { paymentProfile: PAYMENT_PROFILE_FIELDS },
435
+ VALIDATION_MODE_FIELDS
436
+ ].freeze
437
+
438
+ CREATE_ADDRESS_FIELDS = [
439
+ REFID_FIELDS,
440
+ CUSTOMER_PROFILE_ID_FIELDS,
441
+ ADDRESS_FIELDS
442
+ ].freeze
443
+
444
+ CREATE_TRANSACTION_FIELDS = [
445
+ REFID_FIELDS,
446
+ { transaction: [], _conditional: :select_transaction_type_fields },
447
+ { extraOptions: :extra_options }
448
+ ].freeze
449
+
450
+ DELETE_PROFILE_FIELDS = [
451
+ REFID_FIELDS,
452
+ CUSTOMER_PROFILE_ID_FIELDS
453
+ ].freeze
454
+
455
+ DELETE_PAYMENT_FIELDS = [
456
+ REFID_FIELDS,
457
+ CUSTOMER_PROFILE_ID_FIELDS,
458
+ CUSTOMER_PAYMENT_PROFILE_ID_FIELDS
459
+ ].freeze
460
+
461
+ DELETE_ADDRESS_FIELDS = [
462
+ REFID_FIELDS,
463
+ CUSTOMER_PROFILE_ID_FIELDS,
464
+ { customerAddressId: :customer_address_id }
465
+ ].freeze
466
+
467
+ GET_PROFILE_IDS_FIELDS = [].freeze
468
+
469
+ GET_PROFILE_FIELDS = [
470
+ CUSTOMER_PROFILE_ID_FIELDS
471
+ ].freeze
472
+
473
+ GET_PAYMENT_FIELDS = [
474
+ CUSTOMER_PROFILE_ID_FIELDS,
475
+ CUSTOMER_PAYMENT_PROFILE_ID_FIELDS
476
+ ].freeze
477
+
478
+ GET_ADDRESS_FIELDS = [
479
+ CUSTOMER_PROFILE_ID_FIELDS,
480
+ { customerAddressId: :customer_address_id }
481
+ ].freeze
482
+
483
+ GET_HOSTED_PROFILE_FIELDS = [
484
+ REFID_FIELDS,
485
+ CUSTOMER_PROFILE_ID_FIELDS,
486
+ { hostedProfileSettings: [{ setting: [{ settingName: :setting_name }, { settingValue: :setting_value }], _multivalue: :hosted_settings }] }
487
+ ].freeze
488
+
489
+ UPDATE_PROFILE_FIELDS = [
490
+ REFID_FIELDS,
491
+ { profile: [
492
+ { merchantCustomerId: :cust_id },
493
+ { description: :description },
494
+ { email: :email },
495
+ CUSTOMER_PROFILE_ID_FIELDS
496
+ ] }
497
+ ].freeze
498
+
499
+ UPDATE_PAYMENT_FIELDS = [
500
+ REFID_FIELDS,
501
+ CUSTOMER_PROFILE_ID_FIELDS,
502
+ { paymentProfile: PAYMENT_PROFILE_FIELDS + [CUSTOMER_PAYMENT_PROFILE_ID_FIELDS] },
503
+ VALIDATION_MODE_FIELDS
504
+ ].freeze
505
+
506
+ UPDATE_ADDRESS_FIELDS = [
507
+ REFID_FIELDS,
508
+ CUSTOMER_PROFILE_ID_FIELDS,
509
+ { address: [
510
+ { firstName: :first_name },
511
+ { lastName: :last_name },
512
+ { company: :company },
513
+ { address: :address },
514
+ { city: :city },
515
+ { state: :state },
516
+ { zip: :zip },
517
+ { country: :country },
518
+ { phoneNumber: :phone },
519
+ { faxNumber: :fax },
520
+ { customerAddressId: :customer_address_id }
521
+ ] }
522
+ ].freeze
523
+
524
+ UPDATE_SPLIT_FIELDS = [
525
+ { splitTenderId: :split_tender_id },
526
+ { splitTenderStatus: :split_tender_status }
527
+ ].freeze
528
+
529
+ VALIDATE_PAYMENT_FIELDS = [
530
+ CUSTOMER_PROFILE_ID_FIELDS,
531
+ CUSTOMER_PAYMENT_PROFILE_ID_FIELDS,
532
+ { customerShippingAddressId: :customer_address_id },
533
+ { cardCode: :card_code },
534
+ VALIDATION_MODE_FIELDS
535
+ ].freeze
536
+
537
+ FIELDS = {
538
+ AuthorizeNet::XmlTransaction::Type::CIM_CREATE_PROFILE => CREATE_PROFILE_FIELDS,
539
+ AuthorizeNet::XmlTransaction::Type::CIM_CREATE_PAYMENT => CREATE_PAYMENT_FIELDS,
540
+ AuthorizeNet::XmlTransaction::Type::CIM_CREATE_ADDRESS => CREATE_ADDRESS_FIELDS,
541
+ AuthorizeNet::XmlTransaction::Type::CIM_CREATE_TRANSACTION => CREATE_TRANSACTION_FIELDS,
542
+ AuthorizeNet::XmlTransaction::Type::CIM_DELETE_PROFILE => DELETE_PROFILE_FIELDS,
543
+ AuthorizeNet::XmlTransaction::Type::CIM_DELETE_PAYMENT => DELETE_PAYMENT_FIELDS,
544
+ AuthorizeNet::XmlTransaction::Type::CIM_DELETE_ADDRESS => DELETE_ADDRESS_FIELDS,
545
+ AuthorizeNet::XmlTransaction::Type::CIM_GET_PROFILE_IDS => GET_PROFILE_IDS_FIELDS,
546
+ AuthorizeNet::XmlTransaction::Type::CIM_GET_PROFILE => GET_PROFILE_FIELDS,
547
+ AuthorizeNet::XmlTransaction::Type::CIM_GET_PAYMENT => GET_PAYMENT_FIELDS,
548
+ AuthorizeNet::XmlTransaction::Type::CIM_GET_ADDRESS => GET_ADDRESS_FIELDS,
549
+ AuthorizeNet::XmlTransaction::Type::CIM_GET_HOSTED_PROFILE => GET_HOSTED_PROFILE_FIELDS,
550
+ AuthorizeNet::XmlTransaction::Type::CIM_UPDATE_PROFILE => UPDATE_PROFILE_FIELDS,
551
+ AuthorizeNet::XmlTransaction::Type::CIM_UPDATE_PAYMENT => UPDATE_PAYMENT_FIELDS,
552
+ AuthorizeNet::XmlTransaction::Type::CIM_UPDATE_ADDRESS => UPDATE_ADDRESS_FIELDS,
553
+ AuthorizeNet::XmlTransaction::Type::CIM_UPDATE_SPLIT => UPDATE_SPLIT_FIELDS,
554
+ AuthorizeNet::XmlTransaction::Type::CIM_VALIDATE_PAYMENT => VALIDATE_PAYMENT_FIELDS
555
+ }.freeze
556
+
557
+ ADDRESS_ENTITY_DESCRIPTION = EntityDescription.new(
558
+ [
559
+ { firstName: :first_name },
560
+ { lastName: :last_name },
561
+ { company: :company },
562
+ { address: :street_address },
563
+ { city: :city },
564
+ { state: :state },
565
+ { zip: :zip },
566
+ { country: :country },
567
+ { phoneNumber: :phone },
568
+ { faxNumber: :fax }
569
+ ],
570
+ AuthorizeNet::Address
571
+ )
572
+
573
+ CREDIT_CARD_ENTITY_DESCRIPTION = EntityDescription.new(
574
+ [
575
+ { cardNumber: :card_num },
576
+ { expirationDate: :exp_date },
577
+ { cardCode: :card_code },
578
+ { cardType: :card_type }
579
+ ],
580
+ AuthorizeNet::CreditCard,
581
+ %i[card_num exp_date]
582
+ )
583
+
584
+ ECHECK_ENTITY_DESCRIPTION = EntityDescription.new(
585
+ [
586
+ { accountType: :account_type },
587
+ { routingNumber: :routing_number },
588
+ { accountNumber: :account_number },
589
+ { nameOnAccount: :account_holder_name },
590
+ { echeckType: :echeck_type },
591
+ { bankName: :bank_name }
592
+ ],
593
+ AuthorizeNet::ECheck,
594
+ %i[routing_number account_number bank_name account_holder_name]
595
+ )
596
+
597
+ PAYMENT_PROFILE_ENTITY_DESCRIPTION = EntityDescription.new(
598
+ [
599
+ CUSTOMER_PAYMENT_PROFILE_ID_FIELDS,
600
+ { customerType: :cust_type },
601
+ { billTo: ADDRESS_ENTITY_DESCRIPTION, _value: :billing_address },
602
+ { payment: [
603
+ { creditCard: CREDIT_CARD_ENTITY_DESCRIPTION, _value: :payment_method },
604
+ { bankAccount: ECHECK_ENTITY_DESCRIPTION, _value: :payment_method }
605
+ ] }
606
+ ],
607
+ AuthorizeNet::CIM::PaymentProfile
608
+ )
609
+
610
+ PROFILE_ENTITY_DESCRIPTION = EntityDescription.new(
611
+ [
612
+ { merchantCustomerId: :id },
613
+ { description: :description },
614
+ { email: :email },
615
+ CUSTOMER_PROFILE_ID_FIELDS,
616
+ { paymentProfiles: PAYMENT_PROFILE_ENTITY_DESCRIPTION, _multivalue: :payment_profiles },
617
+ { shipTo: ADDRESS_ENTITY_DESCRIPTION, _multivalue: :addresses }
618
+ ],
619
+ AuthorizeNet::CIM::CustomerProfile
620
+ )
621
+ end
622
+ end
623
+
624
+ module Reporting
625
+ module Fields
626
+ GET_BATCH_LIST = [
627
+ { includeStatistics: :include_statistics },
628
+ { firstSettlementDate: :first_settlement_date },
629
+ { lastSettlementDate: :last_settlement_date }
630
+ ].freeze
631
+
632
+ GET_TRANSACTION_LIST = [
633
+ { batchId: :batch_id }
634
+ ].freeze
635
+
636
+ GET_UNSETTLED_TRANSACTION_LIST = [
637
+ ].freeze
638
+
639
+ GET_TRANSACTION_DETAILS = [
640
+ { transId: :transaction_id }
641
+ ].freeze
642
+
643
+ BATCH_STATISTICS_ENTITY_DESCRIPTION = EntityDescription.new([
644
+ { accountType: :account_type },
645
+ { chargeAmount: :charge_amount, _converter: :value_to_decimal },
646
+ { chargeCount: :charge_count, _converter: :value_to_integer },
647
+ { refundAmount: :refund_amount, _converter: :value_to_decimal },
648
+ { refundCount: :refund_count, _converter: :value_to_integer },
649
+ { voidCount: :void_count, _converter: :value_to_integer },
650
+ { declineCount: :decline_count, _converter: :value_to_integer },
651
+ { errorCount: :error_count, _converter: :value_to_integer },
652
+ { returnedItemAmount: :returned_item_amount, _converter: :value_to_decimal },
653
+ { returnedItemCount: :returned_item_count, _converter: :value_to_integer },
654
+ { chargebackAmount: :chargeback_amount, _converter: :value_to_decimal },
655
+ { chargebackCount: :chargeback_count, _converter: :value_to_integer },
656
+ { correctionNoticeCount: :correction_notice_count, _converter: :value_to_integer },
657
+ { chargeChargeBackAmount: :charge_chargeback_amount, _converter: :value_to_decimal },
658
+ { chargeChargeBackCount: :charge_chargeback_count, _converter: :value_to_integer },
659
+ { refundChargeBackAmount: :refund_chargeback_amount, _converter: :value_to_decimal },
660
+ { refundChargeBackCount: :refund_chargeback_count, _converter: :value_to_integer },
661
+ { chargeReturnedItemsAmount: :charge_returned_items_amount, _converter: :value_to_decimal },
662
+ { chargeReturnedItemsCount: :charge_returned_items_count, _converter: :value_to_integer },
663
+ { refundReturnedItemsAmount: :refund_returned_items_amount, _converter: :value_to_decimal },
664
+ { refundReturnedItemsCount: :refund_returned_items_count, _converter: :value_to_integer }
665
+ ],
666
+ AuthorizeNet::Reporting::BatchStatistics)
667
+
668
+ BATCH_ENTITY_DESCRIPTION = EntityDescription.new([
669
+ { batchId: :id },
670
+ { settlementTimeUTC: :settled_at, _converter: :value_to_datetime },
671
+ { settlementState: :state },
672
+ { paymentMethod: :payment_method },
673
+ { statistics: [{ statistic: BATCH_STATISTICS_ENTITY_DESCRIPTION, _multivalue: :statistics }] }
674
+ ],
675
+ AuthorizeNet::Reporting::Batch)
676
+
677
+ FDSFILTER_ENTITY_DESCRIPTION = EntityDescription.new([
678
+ { name: :name },
679
+ { action: :action }
680
+ ],
681
+ AuthorizeNet::Reporting::FDSFilter)
682
+
683
+ CUSTOMER_ENTITY_DESCRIPTION = EntityDescription.new([
684
+ { id: :id },
685
+ { email: :email }
686
+ ],
687
+ AuthorizeNet::CIM::CustomerProfile)
688
+
689
+ ORDER_ENTITY_DESCRIPTION = EntityDescription.new([
690
+ { invoice_number: :invoice_num },
691
+ { description: :description },
692
+ { purchaseOrderNumber: :po_num }
693
+ ],
694
+ AuthorizeNet::Order)
695
+
696
+ LINE_ITEM_ENTITY_DESCRIPTION = EntityDescription.new([
697
+ { itemId: :id },
698
+ { name: :name },
699
+ { description: :description },
700
+ { quantity: :quantity, _convert: :value_to_integer },
701
+ { unityPrice: :price, _convert: :value_to_decimal },
702
+ { taxable: :taxable, _convert: :value_to_boolean }
703
+ ],
704
+ AuthorizeNet::LineItem)
705
+
706
+ attr_accessor :id, :date_utc, :date_local, :code, :description
707
+ RETURNED_ITEM_ENTITY_DESCRIPTION = EntityDescription.new([
708
+ { id: :id },
709
+ { dateUTC: :date_utc },
710
+ { dateLocal: :date_local },
711
+ { code: :code },
712
+ { description: :description }
713
+ ],
714
+ AuthorizeNet::Reporting::ReturnedItem)
715
+
716
+ TRANSACTION_DETAILS_ENTITY_DESCRIPTION = EntityDescription.new([
717
+ { transId: :id },
718
+ { refTransId: :reference_id },
719
+ { splitTenderId: :split_tender_id },
720
+ { transactionType: :type },
721
+ { responseCode: :response_code },
722
+ { responseReasonCode: :response_reason_code },
723
+ { authCode: :auth_code },
724
+ { AVSResponse: :avs_response },
725
+ { cardCodeResponse: :card_code_response },
726
+ { CAVVResponse: :cavv_response },
727
+ { FDSFilterAction: :fds_filter_action },
728
+ { FDSFilters: [{ FDSFilter: FDSFILTER_ENTITY_DESCRIPTION, _multivalue: :fds_filters }] },
729
+ { batch: BATCH_ENTITY_DESCRIPTION, _value: :batch },
730
+ { responseReasonDescription: :response_reason_description },
731
+ { submitTimeUTC: :submitted_at, _converter: :value_to_datetime },
732
+ { transactionStatus: :status },
733
+ { accountType: :account_type },
734
+ { accountNumber: :account_number },
735
+ { order: ORDER_ENTITY_DESCRIPTION, _value: :order },
736
+ { requestedAmount: :requested_amount, _converter: :value_to_decimal },
737
+ { authAmount: :auth_amount, _converter: :value_to_decimal },
738
+ { settleAmount: :settle_amount, _converter: :value_to_decimal },
739
+ { prepaidBalanceRemaining: :prepaid_balance_remaining, _converter: :value_to_decimal },
740
+ { payment: [
741
+ { creditCard: AuthorizeNet::CIM::Fields::CREDIT_CARD_ENTITY_DESCRIPTION, _value: :payment_method },
742
+ { bankAccount: AuthorizeNet::CIM::Fields::ECHECK_ENTITY_DESCRIPTION, _value: :payment_method }
743
+ ] },
744
+ { customer: CUSTOMER_ENTITY_DESCRIPTION, _value: :customer },
745
+ { billTo: AuthorizeNet::CIM::Fields::ADDRESS_ENTITY_DESCRIPTION, _value: :bill_to },
746
+ { shipTo: AuthorizeNet::CIM::Fields::ADDRESS_ENTITY_DESCRIPTION, _value: :ship_to },
747
+ { recurringBilling: :recurring_billing, _convert: :value_to_boolean },
748
+ { hasReturnedItems: :returns, _convert: :value_to_boolean }
749
+ ],
750
+ AuthorizeNet::Reporting::TransactionDetails)
751
+
752
+ FIELDS = {
753
+ AuthorizeNet::XmlTransaction::Type::REPORT_GET_BATCH_LIST => GET_BATCH_LIST,
754
+ AuthorizeNet::XmlTransaction::Type::REPORT_GET_TRANSACTION_LIST => GET_TRANSACTION_LIST,
755
+ AuthorizeNet::XmlTransaction::Type::REPORT_GET_UNSETTLED_TRANSACTION_LIST => GET_UNSETTLED_TRANSACTION_LIST,
756
+ AuthorizeNet::XmlTransaction::Type::REPORT_GET_TRANSACTION_DETAILS => GET_TRANSACTION_DETAILS
757
+ }.freeze
758
+ end
759
+ end
760
+ end