forked from activemerchant/active_merchant
-
Notifications
You must be signed in to change notification settings - Fork 1
/
refund_void_updates_for_cim.diff
1794 lines (1741 loc) · 79.1 KB
/
refund_void_updates_for_cim.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
From 608a17bfb4f4f1abc0da8a153f2842e26240d1cc Mon Sep 17 00:00:00 2001
From: ben wiseley <[email protected]>
Date: Wed, 28 Oct 2009 16:32:01 -0700
Subject: [PATCH] Adding :refund, :void and :prior_auth_capture to authorize_net_cim
---
.../billing/gateways/authorize_net_cim.rb | 141 ++++++++++++-
.../gateways/remote_authorize_net_cim_test.rb | 165 +++++++++++++++
test/unit/gateways/authorize_net_cim_test.rb | 210 +++++++++++++++++++-
3 files changed, 504 insertions(+), 12 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/authorize_net_cim.rb b/lib/active_merchant/billing/gateways/authorize_net_cim.rb
index 6eb6f3e..6be4f1f 100644
--- a/lib/active_merchant/billing/gateways/authorize_net_cim.rb
+++ b/lib/active_merchant/billing/gateways/authorize_net_cim.rb
@@ -54,7 +54,10 @@ module ActiveMerchant #:nodoc:
CIM_TRANSACTION_TYPES = {
:auth_capture => 'profileTransAuthCapture',
:auth_only => 'profileTransAuthOnly',
- :capture_only => 'profileTransCaptureOnly'
+ :capture_only => 'profileTransCaptureOnly',
+ :prior_auth_capture => 'profileTransPriorAuthCapture',
+ :refund => 'profileTransRefund',
+ :void => 'profileTransVoid'
}
CIM_VALIDATION_MODES = {
@@ -309,14 +312,105 @@ module ActiveMerchant #:nodoc:
#
# ==== Transaction
#
- # * <tt>:type</tt> -- The type of transaction. Can be either <tt>:auth_only</tt>, <tt>:capture_only</tt>, or <tt>:auth_capture</tt>. (REQUIRED)
- # * <tt>:amount</tt> -- The amount for the tranaction. Formatted with a decimal. For example "4.95" (REQUIRED)
- # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer to use in this transaction. (REQUIRED)
- # * <tt>:customer_payment_profile_id</tt> -- The Customer Payment Profile ID of the Customer Payment Profile to use in this transaction. (REQUIRED)
+ # * <tt>:type</tt> -- The type of transaction. Can be either <tt>:auth_only</tt>, <tt>:capture_only</tt>, <tt>:auth_capture</tt>, <tt>:prior_auth_capture</tt>, <tt>:refund</tt> or <tt>:void</tt>. (REQUIRED)
+ # * <tt>:amount</tt> -- The amount for the tranaction. Formatted with a decimal. For example "4.95" (CONDITIONAL)
+ # - :type == :void (NOT USED)
+ # - :type == (:refund, :auth_only, :capture_only, :auth_capture, :prior_auth_capture) (REQUIRED)
+ #
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer to use in this transaction. (CONDITIONAL)
+ # - :type == (:void, :prior_auth_capture) (OPTIONAL)
+ # - :type == :refund (CONDITIONAL - required if masked information is not being submitted [see below])
+ # - :type == (:auth_only, :capture_only, :auth_capture) (REQUIRED)
+ #
+ # * <tt>:customer_payment_profile_id</tt> -- The Customer Payment Profile ID of the Customer Payment Profile to use in this transaction. (CONDITIONAL)
+ # - :type == (:void, :prior_auth_capture) (OPTIONAL)
+ # - :type == :refund (CONDITIONAL - required if masked information is not being submitted [see below])
+ # - :type == (:auth_only, :capture_only, :auth_capture) (REQUIRED)
+ #
+ # * <tt>:trans_id</tt> -- The payment gateway assigned transaction ID of the original transaction (CONDITIONAL):
+ # - :type = (:void, :refund, :prior_auth_capture) (REQUIRED)
+ # - :type = (:auth_only, :capture_only, :auth_capture) (NOT USED)
+ #
+ # * <tt>customer_shipping_address_id</tt> -- Payment gateway assigned ID associated with the customer shipping address (CONDITIONAL)
+ # - :type = (:void, :refund) (OPTIONAL)
+ # - :type = (:auth_only, :capture_only, :auth_capture) (NOT USED)
+ # - :type = (:prior_auth_capture) (OPTIONAL)
+ #
+ # ==== For :type == :refund only
+ # * <tt>:credit_card_number_masked</tt> -- (CONDITIONAL - requied for credit card refunds is :customer_profile_id AND :customer_payment_profile_id are missing)
+ # * <tt>:bank_routing_number_masked && :bank_account_number_masked</tt> -- (CONDITIONAL - requied for electronic check refunds is :customer_profile_id AND :customer_payment_profile_id are missing) (NOT ABLE TO TEST - I keep getting "ACH transactions are not accepted by this merchant." when trying to make a payment and, until that's possible I can't refund ([email protected]))
def create_customer_profile_transaction(options)
requires!(options, :transaction)
- requires!(options[:transaction], :type, :amount, :customer_profile_id, :customer_payment_profile_id)
+ requires!(options[:transaction], :type)
+ case options[:transaction][:type]
+ when :void
+ requires!(options[:transaction], :trans_id)
+ when :refund
+ requires!(options[:transaction], :trans_id) &&
+ (
+ (options[:transaction][:customer_profile_id] && options[:transaction][:customer_payment_profile_id]) ||
+ options[:transaction][:credit_card_number_masked] ||
+ (options[:transaction][:bank_routing_number_masked] && options[:transaction][:bank_account_number_masked])
+ )
+ when :prior_auth_capture
+ requires!(options[:transaction], :amount, :trans_id)
+ else
+ requires!(options[:transaction], :amount, :customer_profile_id, :customer_payment_profile_id)
+ end
+ request = build_request(:create_customer_profile_transaction, options)
+ commit(:create_customer_profile_transaction, request)
+ end
+
+ # Creates a new payment transaction for refund from an existing customer profile
+ #
+ # This is what is used to refund a transaction you have stored in a Customer Profile.
+ #
+ # Returns a Response object that contains the result of the transaction in <tt>params['direct_response']</tt>
+ #
+ # ==== Options
+ #
+ # * <tt>:transaction</tt> -- A hash containing information on the transaction that is being requested. (REQUIRED)
+ #
+ # ==== Transaction
+ #
+ # * <tt>:amount</tt> -- The total amount to be refunded (REQUIRED)
+ #
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer to use in this transaction. (CONDITIONAL :customer_payment_profile_id must be included if used)
+ # * <tt>:customer_payment_profile_id</tt> -- The Customer Payment Profile ID of the Customer Payment Profile to use in this transaction. (CONDITIONAL :customer_profile_id must be included if used)
+ #
+ # * <tt>:credit_card_number_masked</tt> -- Four Xs follwed by the last four digits of the credit card (CONDITIONAL - used if customer_profile_id and customer_payment_profile_id aren't given)
+ #
+ # * <tt>:bank_routing_number_masked</tt> -- The last four gidits of the routing number to be refunded (CONDITIONAL - must be used with :bank_account_number_masked)
+ # * <tt>:bank_account_number_masked</tt> -- The last four digis of the bank account number to be refunded, Ex. XXXX1234 (CONDITIONAL - must be used with :bank_routing_number_masked)
+ def create_customer_profile_transaction_for_refund(options)
+ requires!(options, :transaction)
+ options[:transaction][:type] = :refund
+ requires!(options[:transaction], :trans_id)
+ requires!(options[:transaction], :amount)
+ request = build_request(:create_customer_profile_transaction, options)
+ commit(:create_customer_profile_transaction, request)
+ end
+ # Creates a new payment transaction for void from an existing customer profile
+ #
+ # This is what is used to void a transaction you have stored in a Customer Profile.
+ #
+ # Returns a Response object that contains the result of the transaction in <tt>params['direct_response']</tt>
+ #
+ # ==== Options
+ #
+ # * <tt>:transaction</tt> -- A hash containing information on the transaction that is being requested. (REQUIRED)
+ #
+ # ==== Transaction
+ #
+ # * <tt>:trans_id</tt> -- The payment gateway assigned transaction id of the original transaction. (REQUIRED)
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer to use in this transaction.
+ # * <tt>:customer_payment_profile_id</tt> -- The Customer Payment Profile ID of the Customer Payment Profile to use in this transaction.
+ # * <tt>:customer_shipping_address_id</tt> -- Payment gateway assigned ID associated with the customer shipping address.
+ def create_customer_profile_transaction_for_void(options)
+ requires!(options, :transaction)
+ options[:transaction][:type] = :void
+ requires!(options[:transaction], :trans_id)
request = build_request(:create_customer_profile_transaction, options)
commit(:create_customer_profile_transaction, request)
end
@@ -502,10 +596,31 @@ module ActiveMerchant #:nodoc:
xml.tag!('transaction') do
xml.tag!(CIM_TRANSACTION_TYPES[transaction[:type]]) do
# The amount to be billed to the customer
- xml.tag!('amount', transaction[:amount])
- xml.tag!('customerProfileId', transaction[:customer_profile_id])
- xml.tag!('customerPaymentProfileId', transaction[:customer_payment_profile_id])
- xml.tag!('approvalCode', transaction[:approval_code]) if transaction[:type] == :capture_only
+ case transaction[:type]
+ when :void
+ tag_unless_blank(xml,'customerProfileId', transaction[:customer_profile_id])
+ tag_unless_blank(xml,'customerPaymentProfileId', transaction[:customer_payment_profile_id])
+ tag_unless_blank(xml,'customerShippingAddressId', transaction[:customer_shipping_address_id])
+ xml.tag!('transId', transaction[:trans_id])
+ when :refund
+ #TODO - add support for all the other options fields
+ xml.tag!('amount', transaction[:amount])
+ tag_unless_blank(xml, 'customerProfileId', transaction[:customer_profile_id])
+ tag_unless_blank(xml, 'customerPaymentProfileId', transaction[:customer_payment_profile_id])
+ tag_unless_blank(xml, 'customerShippingAddressId', transaction[:customer_shipping_address_id])
+ tag_unless_blank(xml, 'creditCardNumberMasked', transaction[:credit_card_number_masked])
+ tag_unless_blank(xml, 'bankRoutingNumberMasked', transaction[:bank_routing_number_masked])
+ tag_unless_blank(xml, 'bankAccountNumberMasked', transaction[:bank_account_number_masked])
+ xml.tag!('transId', transaction[:trans_id])
+ when :prior_auth_capture
+ xml.tag!('amount', transaction[:amount])
+ xml.tag!('transId', transaction[:trans_id])
+ else
+ xml.tag!('amount', transaction[:amount])
+ xml.tag!('customerProfileId', transaction[:customer_profile_id])
+ xml.tag!('customerPaymentProfileId', transaction[:customer_payment_profile_id])
+ xml.tag!('approvalCode', transaction[:approval_code]) if transaction[:type] == :capture_only
+ end
add_order(xml, transaction[:order]) if transaction[:order]
end
end
@@ -647,7 +762,11 @@ module ActiveMerchant #:nodoc:
response.params['direct_response'] = parse_direct_response(response) if response.params['direct_response']
response
end
-
+
+ def tag_unless_blank(xml, tag_name, data)
+ xml.tag!(tag_name, data) unless data.blank? || data.nil?
+ end
+
def parse_direct_response(response)
direct_response = {'raw' => response.params['direct_response']}
direct_response_fields = response.params['direct_response'].split(',')
diff --git a/test/remote/gateways/remote_authorize_net_cim_test.rb b/test/remote/gateways/remote_authorize_net_cim_test.rb
index 3ab9c39..eb7eb52 100644
--- a/test/remote/gateways/remote_authorize_net_cim_test.rb
+++ b/test/remote/gateways/remote_authorize_net_cim_test.rb
@@ -457,4 +457,169 @@ class AuthorizeNetCimTest < Test::Unit::TestCase
assert_nil response.authorization
assert_equal "This transaction has been approved.", response.params['direct_response']['message']
end
+
+ def test_should_create_customer_profile_transaction_auth_capture_and_then_void_request
+ response = get_and_validate_auth_capture_response
+
+ assert response = @gateway.create_customer_profile_transaction_for_void(
+ :transaction => {
+ :type => :void,
+ :trans_id => response.params['direct_response']['transaction_id']
+ }
+ )
+ assert_instance_of Response, response
+ assert_success response
+ assert_nil response.authorization
+ assert_equal 'This transaction has been approved.', response.params['direct_response']['message']
+ end
+
+ def test_should_create_customer_profile_transaction_auth_capture_and_then_refund_request
+ response = get_and_validate_auth_capture_response
+ assert response = @gateway.create_customer_profile_transaction_for_refund(
+ :transaction => {
+ :type => :refund,
+ :trans_id => response.params['direct_response']['transaction_id'],
+ :amount => "1.00",
+ :credit_card_number_masked => @credit_card_masked
+ }
+ )
+ assert_instance_of Response, response
+ assert_success response
+ assert_nil response.authorization
+ assert_equal 'This transaction has been approved.', response.params['direct_response']['message']
+ end
+
+ def test_should_create_customer_profile_transaction_auth_capture_and_then_refund_using_profile_ids_request
+ response = get_and_validate_auth_capture_response
+
+ assert response = @gateway.create_customer_profile_transaction(
+ :transaction => {
+ :type => :refund,
+ :amount => 1,
+ :customer_profile_id => @customer_profile_id,
+ :customer_payment_profile_id => @customer_payment_profile_id,
+ :trans_id => response.params['direct_response']['transaction_id']
+ }
+ )
+ assert_instance_of Response, response
+ # You can't test refunds in TEST MODE. If you authorize or capture
+ # a transaction, and the transaction is not yet settled by the payment
+ # gateway, you cannot issue a refund. You get an error message
+ # saying "The referenced transaction does not meet the criteria for issuing a credit.".
+ assert_failure response
+ assert_equal 'The referenced transaction does not meet the criteria for issuing a credit.', response.params['direct_response']['message']
+ end
+
+ def test_should_create_customer_profile_transaction_auth_capture_and_then_refund_using_masked_credit_card_request
+ response = get_and_validate_auth_capture_response
+
+ assert response = @gateway.create_customer_profile_transaction(
+ :transaction => {
+ :type => :refund,
+ :amount => 1,
+ :customer_profile_id => @customer_profile_id,
+ :customer_payment_profile_id => @customer_payment_profile_id,
+ :trans_id => response.params['direct_response']['transaction_id']
+ }
+ )
+ assert_instance_of Response, response
+ # You can't test refunds in TEST MODE. If you authorize or capture
+ # a transaction, and the transaction is not yet settled by the payment
+ # gateway, you cannot issue a refund. You get an error message
+ # saying "The referenced transaction does not meet the criteria for issuing a credit.".
+ assert_failure response
+ assert_equal 'The referenced transaction does not meet the criteria for issuing a credit.', response.params['direct_response']['message']
+ end
+
+ def test_should_create_customer_profile_transaction_auth_only_and_then_prior_auth_capture_request
+ response = get_and_validate_auth_only_response
+
+ assert response = @gateway.create_customer_profile_transaction(
+ :transaction => {
+ :type => :prior_auth_capture,
+ :trans_id => response.params['direct_response']['transaction_id'],
+ :amount => response.params['direct_response']['amount']
+ }
+ )
+ assert_instance_of Response, response
+ assert_success response
+ assert_nil response.authorization
+ assert_equal 'This transaction has been approved.', response.params['direct_response']['message']
+ return response
+ end
+
+ def get_and_validate_customer_payment_profile_request_with_bank_account_response
+ payment_profile = @options[:profile].delete(:payment_profiles)
+ assert response = @gateway.create_customer_profile(@options)
+ @customer_profile_id = response.authorization
+
+ assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
+ assert_nil response.params['profile']['payment_profiles']
+
+ assert response = @gateway.create_customer_payment_profile(
+ :customer_profile_id => @customer_profile_id,
+ :payment_profile => {
+ :customer_type => 'individual', # Optional
+ :bill_to => @address,
+ :payment => {
+ :bank_account => {
+ :account_type => :checking,
+ :name_on_account => 'John Doe',
+ :echeck_type => :ccd,
+ :bank_name => 'Bank of America',
+ :routing_number => '123456789',
+ :account_number => '12345678'
+ }
+ },
+ :drivers_license => {
+ :state => 'MD',
+ :number => '12345',
+ :date_of_birth => '1981-3-31'
+ },
+ :tax_id => '123456789'
+ }
+ )
+
+ assert response.test?
+ assert_success response
+ assert_nil response.authorization
+ assert @customer_payment_profile_id = response.params['customer_payment_profile_id']
+ assert @customer_payment_profile_id =~ /\d+/, "The customerPaymentProfileId should be numeric. It was #{@customer_payment_profile_id}"
+ return response
+ end
+
+ def get_and_validate_auth_capture_response
+ assert response = @gateway.create_customer_profile(@options)
+ @customer_profile_id = response.authorization
+
+ assert response = @gateway.get_customer_profile(:customer_profile_id => @customer_profile_id)
+ @customer_payment_profile_id = response.params['profile']['payment_profiles']['customer_payment_profile_id']
+
+ assert response = @gateway.create_customer_profile_transaction(
+ :transaction => {
+ :customer_profile_id => @customer_profile_id,
+ :customer_payment_profile_id => @customer_payment_profile_id,
+ :type => :auth_capture,
+ :order => {
+ :invoice_number => '1234',
+ :description => 'Test Order Description',
+ :purchase_order_number => '4321'
+ },
+ :amount => @amount
+ }
+ )
+
+ assert response.test?
+ assert_success response
+ assert_nil response.authorization
+ assert_equal "This transaction has been approved.", response.params['direct_response']['message']
+ assert response.params['direct_response']['approval_code'] =~ /\w{6}/
+ assert_equal "auth_capture", response.params['direct_response']['transaction_type']
+ assert_equal "100.00", response.params['direct_response']['amount']
+ assert_equal response.params['direct_response']['invoice_number'], '1234'
+ assert_equal response.params['direct_response']['order_description'], 'Test Order Description'
+ assert_equal response.params['direct_response']['purchase_order_number'], '4321'
+ return response
+ end
+
end
\ No newline at end of file
diff --git a/test/unit/gateways/authorize_net_cim_test.rb b/test/unit/gateways/authorize_net_cim_test.rb
index 911e33a..69ec147 100644
--- a/test/unit/gateways/authorize_net_cim_test.rb
+++ b/test/unit/gateways/authorize_net_cim_test.rb
@@ -325,7 +325,190 @@ class AuthorizeNetCimTest < Test::Unit::TestCase
assert_equal 'This transaction has been approved.', response.params['direct_response']['message']
end
+ def test_should_create_customer_profile_transaction_for_void_request
+ @gateway.expects(:ssl_post).returns(successful_create_customer_profile_transaction_response(:void))
+
+ assert response = @gateway.create_customer_profile_transaction_for_void(
+ :transaction => {
+ :trans_id => 1
+ }
+ )
+ assert_instance_of Response, response
+ assert_success response
+ assert_nil response.authorization
+ assert_equal 'This transaction has been approved.', response.params['direct_response']['message']
+ end
+
+ def test_should_create_customer_profile_transaction_for_refund_request
+ @gateway.expects(:ssl_post).returns(successful_create_customer_profile_transaction_response(:refund))
+
+ assert response = @gateway.create_customer_profile_transaction_for_refund(
+ :transaction => {
+ :trans_id => 1,
+ :amount => "1.00",
+ :credit_card_number_masked => "XXXX1234"
+ }
+ )
+ assert_instance_of Response, response
+ assert_success response
+ assert_nil response.authorization
+ assert_equal 'This transaction has been approved.', response.params['direct_response']['message']
+ end
+
+ def test_should_create_customer_profile_transaction_auth_capture_and_then_void_request
+ response = get_and_validate_auth_capture_response
+
+ @gateway.expects(:ssl_post).returns(successful_create_customer_profile_transaction_response(:void))
+ assert response = @gateway.create_customer_profile_transaction(
+ :transaction => {
+ :type => :void,
+ :trans_id => response.params['direct_response']['transaction_id']
+ }
+ )
+ assert_instance_of Response, response
+ assert_success response
+ assert_nil response.authorization
+ assert_equal 'This transaction has been approved.', response.params['direct_response']['message']
+ return response
+ end
+
+ def test_should_create_customer_profile_transaction_auth_capture_and_then_refund_using_profile_ids_request
+ response = get_and_validate_auth_capture_response
+
+ @gateway.expects(:ssl_post).returns(unsuccessful_create_customer_profile_transaction_response(:refund))
+ assert response = @gateway.create_customer_profile_transaction(
+ :transaction => {
+ :type => :refund,
+ :amount => 1,
+ :customer_profile_id => @customer_profile_id,
+ :customer_payment_profile_id => @customer_payment_profile_id,
+ :trans_id => response.params['direct_response']['transaction_id']
+ }
+ )
+ assert_instance_of Response, response
+ # You can't test refunds in TEST MODE. If you authorize or capture a transaction, and the transaction is not yet settled by the payment gateway, you cannot issue a refund. You get an error message saying "The referenced transaction does not meet the criteria for issuing a credit.".
+ # more on this http://help.ablecommerce.com/mergedProjects/ablecommerce7/orders/payments/entering_payments.htm and
+ # http://www.modernbill.com/support/manual/old/v4/adminhelp/english/Configuration/Payment_Settings/Gateway_API/AuthorizeNet/Module_Authorize.net.htm
+ assert_failure response
+ assert_equal 'The referenced transaction does not meet the criteria for issuing a credit.', response.params['direct_response']['message']
+ return response
+ end
+
+ def test_should_create_customer_profile_transaction_auth_capture_and_then_refund_using_masked_credit_card_request
+ response = get_and_validate_auth_capture_response
+
+ @gateway.expects(:ssl_post).returns(unsuccessful_create_customer_profile_transaction_response(:refund))
+ assert response = @gateway.create_customer_profile_transaction(
+ :transaction => {
+ :type => :refund,
+ :amount => 1,
+
+ :customer_profile_id => @customer_profile_id,
+ :customer_payment_profile_id => @customer_payment_profile_id,
+ :trans_id => response.params['direct_response']['transaction_id']
+ }
+ )
+ assert_instance_of Response, response
+ # You can't test refunds in TEST MODE. If you authorize or capture a transaction, and the transaction is not yet settled by the payment gateway, you cannot issue a refund. You get an error message saying "The referenced transaction does not meet the criteria for issuing a credit.".
+ # more on this http://help.ablecommerce.com/mergedProjects/ablecommerce7/orders/payments/entering_payments.htm and
+ # http://www.modernbill.com/support/manual/old/v4/adminhelp/english/Configuration/Payment_Settings/Gateway_API/AuthorizeNet/Module_Authorize.net.htm
+ assert_failure response
+ assert_equal 'The referenced transaction does not meet the criteria for issuing a credit.', response.params['direct_response']['message']
+ return response
+ end
+
+ # TODO - implement this
+ # def test_should_create_customer_profile_transaction_auth_capture_and_then_refund_using_masked_electronic_checking_info_request
+ # response = get_and_validate_auth_capture_response
+ #
+ # @gateway.expects(:ssl_post).returns(successful_create_customer_profile_transaction_response(:void))
+ # assert response = @gateway.create_customer_profile_transaction(
+ # :transaction => {
+ # :type => :void,
+ # :trans_id => response.params['direct_response']['transaction_id']
+ # }
+ # )
+ # assert_instance_of Response, response
+ # assert_success response
+ # assert_nil response.authorization
+ # assert_equal 'This transaction has been approved.', response.params['direct_response']['message']
+ # return response
+ # end
+
+ def test_should_create_customer_profile_transaction_for_void_request
+ @gateway.expects(:ssl_post).returns(successful_create_customer_profile_transaction_response(:void))
+
+ assert response = @gateway.create_customer_profile_transaction_for_void(
+ :transaction => {
+ :trans_id => 1
+ }
+ )
+ assert_instance_of Response, response
+ assert_success response
+ assert_nil response.authorization
+ assert_equal 'This transaction has been approved.', response.params['direct_response']['message']
+ end
+
+ def test_should_create_customer_profile_transaction_for_refund_request
+ @gateway.expects(:ssl_post).returns(successful_create_customer_profile_transaction_response(:refund))
+
+ assert response = @gateway.create_customer_profile_transaction_for_refund(
+ :transaction => {
+ :trans_id => 1,
+ :amount => "1.00",
+ :credit_card_number_masked => "XXXX1234"
+ }
+ )
+ assert_instance_of Response, response
+ assert_success response
+ assert_nil response.authorization
+ assert_equal 'This transaction has been approved.', response.params['direct_response']['message']
+ end
+
private
+
+ def get_auth_only_response
+ @gateway.expects(:ssl_post).returns(successful_create_customer_profile_transaction_response(:auth_only))
+
+ assert response = @gateway.create_customer_profile_transaction(
+ :transaction => {
+ :customer_profile_id => @customer_profile_id,
+ :customer_payment_profile_id => @customer_payment_profile_id,
+ :type => :auth_only,
+ :amount => @amount
+ }
+ )
+ assert_instance_of Response, response
+ assert_success response
+ assert_nil response.authorization
+ assert_equal 'This transaction has been approved.', response.params['direct_response']['message']
+ assert_equal 'auth_only', response.params['direct_response']['transaction_type']
+ assert_equal 'Gw4NGI', approval_code = response.params['direct_response']['approval_code']
+ return response
+ end
+
+ def get_and_validate_auth_capture_response
+ @gateway.expects(:ssl_post).returns(successful_create_customer_profile_transaction_response(:auth_capture))
+
+ assert response = @gateway.create_customer_profile_transaction(
+ :transaction => {
+ :customer_profile_id => @customer_profile_id,
+ :customer_payment_profile_id => @customer_payment_profile_id,
+ :type => :auth_capture,
+ :order => {
+ :invoice_number => '1234',
+ :description => 'Test Order Description',
+ :purchase_order_number => '4321'
+ },
+ :amount => @amount
+ }
+ )
+ assert_instance_of Response, response
+ assert_success response
+ assert_nil response.authorization
+ assert_equal 'This transaction has been approved.', response.params['direct_response']['message']
+ return response
+ end
def successful_create_customer_profile_response
<<-XML
@@ -630,7 +813,13 @@ class AuthorizeNetCimTest < Test::Unit::TestCase
SUCCESSFUL_DIRECT_RESPONSE = {
:auth_only => '1,1,1,This transaction has been approved.,Gw4NGI,Y,508223659,,,100.00,CC,auth_only,Up to 20 chars,,,,,,,,,,,Up to 255 Characters,,,,,,,,,,,,,,6E5334C13C78EA078173565FD67318E4,,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,',
:capture_only => '1,1,1,This transaction has been approved.,,Y,508223660,,,100.00,CC,capture_only,Up to 20 chars,,,,,,,,,,,Up to 255 Characters,,,,,,,,,,,,,,6E5334C13C78EA078173565FD67318E4,,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,',
- :auth_capture => '1,1,1,This transaction has been approved.,d1GENk,Y,508223661,32968c18334f16525227,Store purchase,1.00,CC,auth_capture,,Longbob,Longsen,,,,,,,,,,,,,,,,,,,,,,,269862C030129C1173727CC10B1935ED,P,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,'
+ :auth_capture => '1,1,1,This transaction has been approved.,d1GENk,Y,508223661,32968c18334f16525227,Store purchase,1.00,CC,auth_capture,,Longbob,Longsen,,,,,,,,,,,,,,,,,,,,,,,269862C030129C1173727CC10B1935ED,P,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,',
+ :void => '1,1,1,This transaction has been approved.,nnCMEx,P,2149222068,1245879759,,0.00,CC,void,1245879759,,,,,,,K1C2N6,,,,,,,,,,,,,,,,,,F240D65BB27ADCB8C80410B92342B22C,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,',
+ :refund => '1,1,1,This transaction has been approved.,nnCMEx,P,2149222068,1245879759,,0.00,CC,refund,1245879759,,,,,,,K1C2N6,,,,,,,,,,,,,,,,,,F240D65BB27ADCB8C80410B92342B22C,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,',
+ :prior_auth_capture => '1,1,1,This transaction has been approved.,VR0lrD,P,2149227870,1245958544,,1.00,CC,prior_auth_capture,1245958544,,,,,,,K1C2N6,,,,,,,,,,,,,,,,,,0B8BFE0A0DE6FDB69740ED20F79D04B0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,'
+ }
+ UNSUCCESSUL_DIRECT_RESPONSE = {
+ :refund => '3,2,54,The referenced transaction does not meet the criteria for issuing a credit.,,P,0,,,1.00,CC,credit,1245952682,,,Widgets Inc,1245952682 My Street,Ottawa,ON,K1C2N6,CA,,,[email protected],,,,,,,,,,,,,,207BCBBF78E85CF174C87AE286B472D2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,447250,406104'
}
def successful_create_customer_profile_transaction_response(transaction_type)
@@ -672,5 +861,24 @@ class AuthorizeNetCimTest < Test::Unit::TestCase
</validateCustomerPaymentProfileResponse>
XML
end
+
+ def unsuccessful_create_customer_profile_transaction_response(transaction_type)
+ <<-XML
+ <?xml version="1.0" encoding="utf-8"?>
+ <createCustomerProfileTransactionResponse
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd">
+ <messages>
+ <resultCode>Error</resultCode>
+ <message>
+ <code>E00027</code>
+ <text>The transaction was unsuccessful.</text>
+ </message>
+ </messages>
+ <directResponse>#{UNSUCCESSUL_DIRECT_RESPONSE[transaction_type]}</directResponse>
+ </createCustomerProfileTransactionResponse>
+ XML
+ end
end
--
1.6.0.4
From faf8d0302756584ac66cd1e0df1eb9d902a2e288 Mon Sep 17 00:00:00 2001
From: ben wiseley <[email protected]>
Date: Wed, 28 Oct 2009 18:14:33 -0700
Subject: [PATCH] removing trailing white space
---
.../billing/gateways/authorize_net_cim.rb | 150 ++++----
.../gateways/remote_authorize_net_cim_test.rb | 24 +-
test/unit/gateways/authorize_net_cim_test.rb | 410 ++++++++++----------
3 files changed, 292 insertions(+), 292 deletions(-)
diff --git a/lib/active_merchant/billing/gateways/authorize_net_cim.rb b/lib/active_merchant/billing/gateways/authorize_net_cim.rb
index 6be4f1f..08e1b59 100644
--- a/lib/active_merchant/billing/gateways/authorize_net_cim.rb
+++ b/lib/active_merchant/billing/gateways/authorize_net_cim.rb
@@ -1,23 +1,23 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
# ==== Customer Information Manager (CIM)
- #
+ #
# The Authorize.Net Customer Information Manager (CIM) is an optional additional service that allows you to store sensitive payment information on
- # Authorize.Net's servers, simplifying payments for returning customers and recurring transactions. It can also help with Payment Card Industry (PCI)
+ # Authorize.Net's servers, simplifying payments for returning customers and recurring transactions. It can also help with Payment Card Industry (PCI)
# Data Security Standard compliance, since customer data is no longer stored locally.
- #
+ #
# To use the AuthorizeNetCimGateway CIM must be enabled for your account.
- #
+ #
# Information about CIM is available on the {Authorize.Net website}[http://www.authorize.net/solutions/merchantsolutions/merchantservices/cim/].
# Information about the CIM API is available at the {Authorize.Net Integration Center}[http://developer.authorize.net/]
- #
+ #
# ==== Login and Password
- #
- # The login and password are not the username and password you use to
- # login to the Authorize.Net Merchant Interface. Instead, you will
- # use the API Login ID as the login and Transaction Key as the
+ #
+ # The login and password are not the username and password you use to
+ # login to the Authorize.Net Merchant Interface. Instead, you will
+ # use the API Login ID as the login and Transaction Key as the
# password.
- #
+ #
# ==== How to Get Your API Login ID and Transaction Key
#
# 1. Log into the Merchant Interface
@@ -26,12 +26,12 @@ module ActiveMerchant #:nodoc:
# 4. Type in the answer to the secret question configured on setup
# 5. Click Submit
class AuthorizeNetCimGateway < Gateway
-
+
class_inheritable_accessor :test_url, :live_url
self.test_url = 'https://apitest.authorize.net/xml/v1/request.api'
self.live_url = 'https://api.authorize.net/xml/v1/request.api'
-
+
AUTHORIZE_NET_CIM_NAMESPACE = 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'
CIM_ACTIONS = {
@@ -50,7 +50,7 @@ module ActiveMerchant #:nodoc:
:create_customer_profile_transaction => 'createCustomerProfileTransaction',
:validate_customer_payment_profile => 'validateCustomerPaymentProfile'
}
-
+
CIM_TRANSACTION_TYPES = {
:auth_capture => 'profileTransAuthCapture',
:auth_only => 'profileTransAuthOnly',
@@ -65,23 +65,23 @@ module ActiveMerchant #:nodoc:
:test => 'testMode',
:live => 'liveMode'
}
-
+
BANK_ACCOUNT_TYPES = {
:checking => 'checking',
:savings => 'savings',
:business_checking => 'businessChecking'
}
-
+
ECHECK_TYPES = {
:ccd => 'CCD',
:ppd => 'PPD'
}
-
+
self.homepage_url = 'http://www.authorize.net/'
self.display_name = 'Authorize.Net CIM'
self.supported_countries = ['US']
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
-
+
# Creates a new AuthorizeNetCimGateway
#
# The gateway requires that a valid API Login ID and Transaction Key be passed
@@ -91,7 +91,7 @@ module ActiveMerchant #:nodoc:
#
# * <tt>:login</tt> -- The Authorize.Net API Login ID (REQUIRED)
# * <tt>:password</tt> -- The Authorize.Net Transaction Key. (REQUIRED)
- # * <tt>:test</tt> -- +true+ or +false+. If true, perform transactions against the test server.
+ # * <tt>:test</tt> -- +true+ or +false+. If true, perform transactions against the test server.
# Otherwise, perform transactions against the production server.
def initialize(options = {})
requires!(options, :login, :password)
@@ -101,9 +101,9 @@ module ActiveMerchant #:nodoc:
# Creates a new customer profile along with any customer payment profiles and customer shipping addresses
# for the customer profile.
- #
- # Returns a Response with the Customer Profile ID of the new customer profile in the authorization field.
- # It is *CRITICAL* that you save this ID. There is no way to retrieve this through the API. You will not
+ #
+ # Returns a Response with the Customer Profile ID of the new customer profile in the authorization field.
+ # It is *CRITICAL* that you save this ID. There is no way to retrieve this through the API. You will not
# be able to create another Customer Profile with the same information.
#
# ==== Options
@@ -129,7 +129,7 @@ module ActiveMerchant #:nodoc:
requires!(options, :customer_profile_id)
requires!(options, :payment_profile)
requires!(options[:payment_profile], :payment)
-
+
request = build_request(:create_customer_payment_profile, options)
commit(:create_customer_payment_profile, request)
end
@@ -143,7 +143,7 @@ module ActiveMerchant #:nodoc:
def create_customer_shipping_address(options)
requires!(options, :customer_profile_id)
requires!(options, :address)
-
+
request = build_request(:create_customer_shipping_address, options)
commit(:create_customer_shipping_address, request)
end
@@ -204,9 +204,9 @@ module ActiveMerchant #:nodoc:
# Retrieve a customer payment profile for an existing customer profile.
#
- # Returns a Response whose params hash contains all the payment profile information. Sensitive information such as credit card
+ # Returns a Response whose params hash contains all the payment profile information. Sensitive information such as credit card
# numbers will be masked.
- #
+ #
# ==== Options
#
# * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer with the payment profile to be retrieved. (REQUIRED)
@@ -221,8 +221,8 @@ module ActiveMerchant #:nodoc:
# Retrieve a customer shipping address for an existing customer profile.
#
- # Returns a Response whose params hash contains all the shipping address information.
- #
+ # Returns a Response whose params hash contains all the shipping address information.
+ #
# ==== Options
#
# * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer with the payment profile to be retrieved. (REQUIRED)
@@ -235,16 +235,16 @@ module ActiveMerchant #:nodoc:
commit(:get_customer_shipping_address, request)
end
- # Updates an existing customer profile.
- #
- # Warning: if you do not provide a parameter in the <tt>:payment_profile</tt> hash, it is automatically set to nil at
- # Authorize.Net. You will most likely want to first get the profile hash using get_customer_profile and then only change the
+ # Updates an existing customer profile.
+ #
+ # Warning: if you do not provide a parameter in the <tt>:payment_profile</tt> hash, it is automatically set to nil at
+ # Authorize.Net. You will most likely want to first get the profile hash using get_customer_profile and then only change the
# elements you wish to change.
#
# ==== Options
#
# * <tt>:profile</tt> -- A hash containing the values the Customer Profile should be updated to. (REQUIRED)
- #
+ #
# ==== Profile
#
# * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer profile to update. (REQUIRED)
@@ -257,8 +257,8 @@ module ActiveMerchant #:nodoc:
end
# Updates a customer payment profile for an existing customer profile.
- #
- # Warning: if you do not provide a parameter in the <tt>:payment_profile</tt> hash, it is automatically set to nil at
+ #
+ # Warning: if you do not provide a parameter in the <tt>:payment_profile</tt> hash, it is automatically set to nil at
# Authorize.Net. You will most likely want to first get the profile hash using get_customer_payment_profile and then only
# change the elements you wish to change.
#
@@ -266,7 +266,7 @@ module ActiveMerchant #:nodoc:
#
# * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer with the payment profile to be updated. (REQUIRED)
# * <tt>:payment_profile</tt> -- A hash containing the values the Customer Payment Profile should be updated to. (REQUIRED)
- #
+ #
# ==== Payment Profile
#
# * <tt>:customer_payment_profile_id</tt> -- The Customer Payment Profile ID of the Customer Payment Profile to update. (REQUIRED)
@@ -279,8 +279,8 @@ module ActiveMerchant #:nodoc:
end
# Updates a customer shipping address for an existing customer profile.
- #
- # Warning: if you do not provide a parameter in the <tt>:address</tt> hash, it is automatically set to nil at
+ #
+ # Warning: if you do not provide a parameter in the <tt>:address</tt> hash, it is automatically set to nil at
# Authorize.Net. You will most likely want to first get the profile hash using get_customer_shipping_address and then only
# change the elements you wish to change.
#
@@ -288,7 +288,7 @@ module ActiveMerchant #:nodoc:
#
# * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer with the payment profile to be updated. (REQUIRED)
# * <tt>:address</tt> -- A hash containing the values the Customer Shipping Address should be updated to. (REQUIRED)
- #
+ #
# ==== Address
#
# * <tt>:customer_address_id</tt> -- The Customer Address ID of the Customer Payment Profile to update. (REQUIRED)
@@ -303,7 +303,7 @@ module ActiveMerchant #:nodoc:
# Creates a new payment transaction from an existing customer profile
#
# This is what is used to charge a customer whose information you have stored in a Customer Profile.
- #
+ #
# Returns a Response object that contains the result of the transaction in <tt>params['direct_response']</tt>
#
# ==== Options
@@ -394,7 +394,7 @@ module ActiveMerchant #:nodoc:
# Creates a new payment transaction for void from an existing customer profile
#
# This is what is used to void a transaction you have stored in a Customer Profile.
- #
+ #
# Returns a Response object that contains the result of the transaction in <tt>params['direct_response']</tt>
#
# ==== Options
@@ -404,7 +404,7 @@ module ActiveMerchant #:nodoc:
# ==== Transaction
#
# * <tt>:trans_id</tt> -- The payment gateway assigned transaction id of the original transaction. (REQUIRED)
- # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer to use in this transaction.
+ # * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer to use in this transaction.
# * <tt>:customer_payment_profile_id</tt> -- The Customer Payment Profile ID of the Customer Payment Profile to use in this transaction.
# * <tt>:customer_shipping_address_id</tt> -- Payment gateway assigned ID associated with the customer shipping address.
def create_customer_profile_transaction_for_void(options)
@@ -424,7 +424,7 @@ module ActiveMerchant #:nodoc:
# * <tt>:customer_profile_id</tt> -- The Customer Profile ID of the customer to use in this transaction. (REQUIRED)
# * <tt>:customer_payment_profile_id</tt> -- The Customer Payment Profile ID of the Customer Payment Profile to be verified. (REQUIRED)
# * <tt>:customer_address_id</tt> -- The Customer Address ID of the Customer Shipping Address to be verified.
- # * <tt>:validation_mode</tt> -- <tt>:live</tt> or <tt>:test</tt> In Test Mode, only field validation is performed.
+ # * <tt>:validation_mode</tt> -- <tt>:live</tt> or <tt>:test</tt> In Test Mode, only field validation is performed.
# In Live Mode, a transaction is generated and submitted to the processor with the amount of $0.01. If successful, the transaction is immediately voided. (REQUIRED)
def validate_customer_payment_profile(options)
requires!(options, :customer_profile_id, :customer_payment_profile_id, :validation_mode)
@@ -438,7 +438,7 @@ module ActiveMerchant #:nodoc:
def expdate(credit_card)
sprintf('%04d-%02d', credit_card.year, credit_card.month)
end
-
+
def build_request(action, options = {})
unless CIM_ACTIONS.include?(action)
raise StandardError, "Invalid Customer Information Manager Action: #{action}"
@@ -461,7 +461,7 @@ module ActiveMerchant #:nodoc:
xml.tag!('transactionKey', @options[:password])
end
end
-
+
def build_create_customer_profile_request(xml, options)
add_profile(xml, options[:profile])
@@ -470,23 +470,23 @@ module ActiveMerchant #:nodoc:
def build_create_customer_payment_profile_request(xml, options)
xml.tag!('customerProfileId', options[:customer_profile_id])
-
+
xml.tag!('paymentProfile') do
add_payment_profile(xml, options[:payment_profile])
end
-
+
xml.tag!('validationMode', CIM_VALIDATION_MODES[options[:validation_mode]]) if options[:validation_mode]
xml.target!
end
-
+
def build_create_customer_shipping_address_request(xml, options)
xml.tag!('customerProfileId', options[:customer_profile_id])
-
+
xml.tag!('address') do
add_address(xml, options[:address])
end
-
+
xml.target!
end
@@ -525,8 +525,8 @@ module ActiveMerchant #:nodoc:
end
def build_update_customer_profile_request(xml, options)
- add_profile(xml, options[:profile], true)
-
+ add_profile(xml, options[:profile], true)
+
xml.target!
end
@@ -534,7 +534,7 @@ module ActiveMerchant #:nodoc:
xml.tag!('customerProfileId', options[:customer_profile_id])
xml.tag!('paymentProfile') do
- add_payment_profile(xml, options[:payment_profile])
+ add_payment_profile(xml, options[:payment_profile])
end
xml.target!
@@ -544,7 +544,7 @@ module ActiveMerchant #:nodoc:
xml.tag!('customerProfileId', options[:customer_profile_id])
xml.tag!('address') do
- add_address(xml, options[:address])
+ add_address(xml, options[:address])
end
xml.target!
@@ -553,10 +553,10 @@ module ActiveMerchant #:nodoc:
def build_create_customer_profile_transaction_request(xml, options)
add_transaction(xml, options[:transaction])
xml.tag!('extraOptions', "x_test_request=TRUE") if @options[:test]
-
+
xml.target!
end
-
+
def build_validate_customer_payment_profile_request(xml, options)
xml.tag!('customerProfileId', options[:customer_profile_id])
xml.tag!('customerPaymentProfileId', options[:customer_payment_profile_id])
@@ -587,12 +587,12 @@ module ActiveMerchant #:nodoc:
end
end
end
-
+
def add_transaction(xml, transaction)
unless CIM_TRANSACTION_TYPES.include?(transaction[:type])
raise StandardError, "Invalid Customer Information Manager Transaction Type: #{transaction[:type]}"
end
-
+
xml.tag!('transaction') do
xml.tag!(CIM_TRANSACTION_TYPES[transaction[:type]]) do
# The amount to be billed to the customer
@@ -625,7 +625,7 @@ module ActiveMerchant #:nodoc:
end
end
end
-
+
def add_order(xml, order)
xml.tag!('order') do
xml.tag!('invoiceNumber', order[:invoice_number]) if order[:invoice_number]
@@ -633,7 +633,7 @@ module ActiveMerchant #:nodoc:
xml.tag!('purchaseOrderNumber', order[:purchase_order_number]) if order[:purchase_order_number]
end
end
-
+
def add_payment_profiles(xml, payment_profiles)
xml.tag!('paymentProfiles') do
add_payment_profile(xml, payment_profiles)
@@ -652,7 +652,7 @@ module ActiveMerchant #:nodoc:
add_address(xml, payment_profile[:bill_to])
end
end
-
+
if payment_profile[:payment]
xml.tag!('payment') do
add_credit_card(xml, payment_profile[:payment][:credit_card]) if payment_profile[:payment].has_key?(:credit_card)
@@ -663,7 +663,7 @@ module ActiveMerchant #:nodoc:
xml.tag!('taxId', payment_profile[:payment]) if payment_profile[:payment].has_key?(:tax_id)
end
end
-
+