authorizenet 1.8.1 → 1.8.2

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