activemerchant 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +226 -0
  3. data/CONTRIBUTERS +52 -0
  4. data/README +34 -24
  5. data/Rakefile +152 -0
  6. data/gem-public_cert.pem +20 -0
  7. data/init.rb +3 -0
  8. data/lib/active_merchant.rb +3 -1
  9. data/lib/active_merchant/billing/credit_card.rb +21 -17
  10. data/lib/active_merchant/billing/credit_card_methods.rb +17 -19
  11. data/lib/active_merchant/billing/gateway.rb +160 -44
  12. data/lib/active_merchant/billing/gateways.rb +2 -15
  13. data/lib/active_merchant/billing/gateways/authorize_net.rb +21 -21
  14. data/lib/active_merchant/billing/gateways/bogus.rb +6 -6
  15. data/lib/active_merchant/billing/gateways/brain_tree.rb +191 -0
  16. data/lib/active_merchant/billing/gateways/card_stream.rb +207 -0
  17. data/lib/active_merchant/billing/gateways/cyber_source.rb +402 -0
  18. data/lib/active_merchant/billing/gateways/data_cash.rb +41 -97
  19. data/lib/active_merchant/billing/gateways/efsnet.rb +256 -0
  20. data/lib/active_merchant/billing/gateways/eway.rb +77 -29
  21. data/lib/active_merchant/billing/gateways/exact.rb +230 -0
  22. data/lib/active_merchant/billing/gateways/linkpoint.rb +6 -33
  23. data/lib/active_merchant/billing/gateways/moneris.rb +155 -125
  24. data/lib/active_merchant/billing/gateways/net_registry.rb +257 -0
  25. data/lib/active_merchant/billing/gateways/pay_junction.rb +407 -0
  26. data/lib/active_merchant/billing/gateways/payflow.rb +163 -25
  27. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +56 -38
  28. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +10 -1
  29. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +9 -0
  30. data/lib/active_merchant/billing/gateways/payflow_express.rb +36 -11
  31. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +6 -0
  32. data/lib/active_merchant/billing/gateways/payflow_uk.rb +7 -3
  33. data/lib/active_merchant/billing/gateways/payment_express.rb +261 -0
  34. data/lib/active_merchant/billing/gateways/paypal.rb +18 -4
  35. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +31 -15
  36. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +8 -0
  37. data/lib/active_merchant/billing/gateways/paypal_express.rb +33 -8
  38. data/lib/active_merchant/billing/gateways/plugnpay.rb +300 -0
  39. data/lib/active_merchant/billing/gateways/protx.rb +285 -0
  40. data/lib/active_merchant/billing/gateways/psigate.rb +13 -12
  41. data/lib/active_merchant/billing/gateways/psl_card.rb +297 -0
  42. data/lib/active_merchant/billing/gateways/quickpay.rb +197 -0
  43. data/lib/active_merchant/billing/gateways/realex.rb +212 -0
  44. data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
  45. data/lib/active_merchant/billing/gateways/trans_first.rb +136 -0
  46. data/lib/active_merchant/billing/gateways/trust_commerce.rb +43 -20
  47. data/lib/active_merchant/billing/gateways/usa_epay.rb +6 -5
  48. data/lib/active_merchant/billing/gateways/verifi.rb +235 -0
  49. data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
  50. data/lib/active_merchant/billing/integrations/gestpay/helper.rb +0 -2
  51. data/lib/active_merchant/billing/integrations/helper.rb +8 -1
  52. data/lib/active_merchant/billing/integrations/nochex.rb +62 -1
  53. data/lib/active_merchant/billing/integrations/nochex/notification.rb +9 -16
  54. data/lib/active_merchant/billing/integrations/notification.rb +1 -1
  55. data/lib/active_merchant/billing/integrations/paypal/helper.rb +59 -46
  56. data/lib/active_merchant/billing/integrations/paypal/notification.rb +14 -47
  57. data/lib/active_merchant/lib/error.rb +4 -0
  58. data/lib/active_merchant/lib/post_data.rb +22 -0
  59. data/lib/active_merchant/lib/posts_data.rb +23 -5
  60. data/lib/active_merchant/lib/requires_parameters.rb +2 -2
  61. data/lib/active_merchant/lib/validateable.rb +1 -1
  62. data/lib/support/gateway_support.rb +45 -0
  63. data/lib/tasks/cia.rb +1 -1
  64. data/script/generate +14 -0
  65. data/script/generator/base.rb +45 -0
  66. data/script/generator/generator.rb +24 -0
  67. data/script/generator/generators/gateway/gateway_generator.rb +14 -0
  68. data/script/generator/generators/gateway/templates/gateway.rb +73 -0
  69. data/script/generator/generators/gateway/templates/gateway_test.rb +41 -0
  70. data/script/generator/generators/gateway/templates/remote_gateway_test.rb +56 -0
  71. data/script/generator/generators/integration/integration_generator.rb +25 -0
  72. data/script/generator/generators/integration/templates/helper.rb +34 -0
  73. data/script/generator/generators/integration/templates/helper_test.rb +54 -0
  74. data/script/generator/generators/integration/templates/integration.rb +18 -0
  75. data/script/generator/generators/integration/templates/module_test.rb +9 -0
  76. data/script/generator/generators/integration/templates/notification.rb +100 -0
  77. data/script/generator/generators/integration/templates/notification_test.rb +41 -0
  78. data/script/generator/manifest.rb +20 -0
  79. data/test/extra/binding_of_caller.rb +80 -0
  80. data/test/extra/breakpoint.rb +547 -0
  81. data/test/fixtures.yml +251 -0
  82. data/test/remote_tests/remote_authorize_net_test.rb +113 -0
  83. data/test/remote_tests/remote_brain_tree_test.rb +78 -0
  84. data/test/remote_tests/remote_card_stream_test.rb +160 -0
  85. data/test/remote_tests/remote_cyber_source_test.rb +130 -0
  86. data/test/remote_tests/remote_data_cash_test.rb +155 -0
  87. data/test/remote_tests/remote_efsnet_test.rb +93 -0
  88. data/test/remote_tests/remote_eway_test.rb +71 -0
  89. data/test/remote_tests/remote_exact_test.rb +59 -0
  90. data/test/remote_tests/remote_gestpay_integration_test.rb +37 -0
  91. data/test/remote_tests/remote_linkpoint_test.rb +144 -0
  92. data/test/remote_tests/remote_moneris_test.rb +110 -0
  93. data/test/remote_tests/remote_net_registry_test.rb +120 -0
  94. data/test/remote_tests/remote_pay_junction_test.rb +162 -0
  95. data/test/remote_tests/remote_payflow_express_test.rb +50 -0
  96. data/test/remote_tests/remote_payflow_test.rb +241 -0
  97. data/test/remote_tests/remote_payflow_uk_test.rb +172 -0
  98. data/test/remote_tests/remote_payment_express_test.rb +136 -0
  99. data/test/remote_tests/remote_paypal_express_test.rb +49 -0
  100. data/test/remote_tests/remote_paypal_integration_test.rb +14 -0
  101. data/test/remote_tests/remote_paypal_test.rb +163 -0
  102. data/test/remote_tests/remote_plugnpay_test.rb +70 -0
  103. data/test/remote_tests/remote_protx_test.rb +184 -0
  104. data/test/remote_tests/remote_psigate_test.rb +87 -0
  105. data/test/remote_tests/remote_psl_card_test.rb +105 -0
  106. data/test/remote_tests/remote_quickpay_test.rb +182 -0
  107. data/test/remote_tests/remote_realex_test.rb +227 -0
  108. data/test/remote_tests/remote_secure_pay_test.rb +36 -0
  109. data/test/remote_tests/remote_trans_first_test.rb +37 -0
  110. data/test/remote_tests/remote_trust_commerce_test.rb +136 -0
  111. data/test/remote_tests/remote_usa_epay_test.rb +57 -0
  112. data/test/remote_tests/remote_verifi_test.rb +107 -0
  113. data/test/remote_tests/remote_viaklix_test.rb +53 -0
  114. data/test/test_helper.rb +132 -0
  115. data/test/unit/base_test.rb +61 -0
  116. data/test/unit/country_code_test.rb +33 -0
  117. data/test/unit/country_test.rb +64 -0
  118. data/test/unit/credit_card_formatting_test.rb +24 -0
  119. data/test/unit/credit_card_methods_test.rb +37 -0
  120. data/test/unit/credit_card_test.rb +365 -0
  121. data/test/unit/gateways/authorize_net_test.rb +140 -0
  122. data/test/unit/gateways/bogus_test.rb +43 -0
  123. data/test/unit/gateways/brain_tree_test.rb +77 -0
  124. data/test/unit/gateways/card_stream_test.rb +37 -0
  125. data/test/unit/gateways/cyber_source_test.rb +151 -0
  126. data/test/unit/gateways/data_cash_test.rb +23 -0
  127. data/test/unit/gateways/efsnet_test.rb +70 -0
  128. data/test/unit/gateways/eway_test.rb +105 -0
  129. data/test/unit/gateways/exact_test.rb +118 -0
  130. data/test/unit/gateways/gateway_test.rb +24 -0
  131. data/test/unit/gateways/linkpoint_test.rb +165 -0
  132. data/test/unit/gateways/moneris_test.rb +167 -0
  133. data/test/unit/gateways/net_registry_test.rb +478 -0
  134. data/test/unit/gateways/pay_junction_test.rb +61 -0
  135. data/test/unit/gateways/payflow_express_test.rb +165 -0
  136. data/test/unit/gateways/payflow_express_uk_test.rb +14 -0
  137. data/test/unit/gateways/payflow_test.rb +230 -0
  138. data/test/unit/gateways/payflow_uk_test.rb +68 -0
  139. data/test/unit/gateways/payment_express_test.rb +215 -0
  140. data/test/unit/gateways/paypal_express_test.rb +222 -0
  141. data/test/unit/gateways/paypal_test.rb +241 -0
  142. data/test/unit/gateways/plugnpay_test.rb +79 -0
  143. data/test/unit/gateways/protx_test.rb +110 -0
  144. data/test/unit/gateways/psigate_test.rb +110 -0
  145. data/test/unit/gateways/psl_card_test.rb +51 -0
  146. data/test/unit/gateways/quickpay_test.rb +125 -0
  147. data/test/unit/gateways/realex_test.rb +150 -0
  148. data/test/unit/gateways/secure_pay_test.rb +78 -0
  149. data/test/unit/gateways/trans_first_test.rb +125 -0
  150. data/test/unit/gateways/trust_commerce_test.rb +57 -0
  151. data/test/unit/gateways/usa_epay_test.rb +117 -0
  152. data/test/unit/gateways/verifi_test.rb +91 -0
  153. data/test/unit/gateways/viaklix_test.rb +72 -0
  154. data/test/unit/integrations/action_view_helper_test.rb +54 -0
  155. data/test/unit/integrations/bogus_module_test.rb +16 -0
  156. data/test/unit/integrations/chronopay_module_test.rb +9 -0
  157. data/test/unit/integrations/gestpay_module_test.rb +10 -0
  158. data/test/unit/integrations/helpers/bogus_helper_test.rb +28 -0
  159. data/test/unit/integrations/helpers/chronopay_helper_test.rb +67 -0
  160. data/test/unit/integrations/helpers/gestpay_helper_test.rb +100 -0
  161. data/test/unit/integrations/helpers/nochex_helper_test.rb +53 -0
  162. data/test/unit/integrations/helpers/paypal_helper_test.rb +162 -0
  163. data/test/unit/integrations/helpers/two_checkout_helper_test.rb +92 -0
  164. data/test/unit/integrations/nochex_module_test.rb +9 -0
  165. data/test/unit/integrations/notifications/chronopay_notification_test.rb +66 -0
  166. data/test/unit/integrations/notifications/gestpay_notification_test.rb +60 -0
  167. data/test/unit/integrations/notifications/nochex_notification_test.rb +51 -0
  168. data/test/unit/integrations/notifications/notification_test.rb +41 -0
  169. data/test/unit/integrations/notifications/paypal_notification_test.rb +85 -0
  170. data/test/unit/integrations/notifications/two_checkout_notification_test.rb +55 -0
  171. data/test/unit/integrations/paypal_module_test.rb +24 -0
  172. data/test/unit/integrations/two_checkout_module_test.rb +9 -0
  173. data/test/unit/post_data_test.rb +55 -0
  174. data/test/unit/response_test.rb +14 -0
  175. data/test/unit/validateable_test.rb +56 -0
  176. metadata +160 -7
  177. metadata.gz.sig +0 -0
  178. data/lib/active_merchant/billing/gateways/payflow/f73e89fd.0 +0 -17
@@ -0,0 +1,182 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class RemoteQuickpayTest < Test::Unit::TestCase
4
+
5
+ # 100 cents
6
+ AMOUNT = 100
7
+
8
+ def setup
9
+
10
+ @gateway = QuickpayGateway.new(fixtures(:quickpay))
11
+
12
+ @declined_visa = credit_card('4000300011112220')
13
+ @visa = credit_card('4000100011112224')
14
+ @dankort = credit_card('5019717010103742')
15
+ @visa_dankort = credit_card('4571100000000000')
16
+ @electron_dk = credit_card('4175001000000000')
17
+ @diners_club = credit_card('30401000000000')
18
+ @diners_club_dk = credit_card('36148010000000')
19
+ @maestro = credit_card('5020100000000000')
20
+ @maestro_dk = credit_card('6769271000000000')
21
+ @mastercard_dk = credit_card('5413031000000000')
22
+ @amex_dk = credit_card('3747100000000000')
23
+ @amex = credit_card('3700100000000000')
24
+
25
+ # forbrugsforeningen doesn't use a verification value
26
+ @forbrugsforeningen = credit_card('6007221000000000', :verification_value => nil)
27
+ end
28
+
29
+ def test_successful_purchase
30
+ assert response = @gateway.purchase(AMOUNT, @visa, :order_id => generate_order_id)
31
+ assert_equal 'OK', response.message
32
+ assert_equal 'DKK', response.params['currency']
33
+ assert_success response
34
+ assert !response.authorization.blank?
35
+ end
36
+
37
+ def test_successful_usd_purchase
38
+ assert response = @gateway.purchase(AMOUNT, @visa, :order_id => generate_order_id, :currency => 'USD')
39
+ assert_equal 'OK', response.message
40
+ assert_equal 'USD', response.params['currency']
41
+ assert_success response
42
+ assert !response.authorization.blank?
43
+ end
44
+
45
+ def test_dankort_authorization
46
+ assert response = @gateway.authorize(AMOUNT, @dankort, :order_id => generate_order_id)
47
+ assert_success response
48
+ assert !response.authorization.blank?
49
+ assert_equal 'Dankort', response.params['cardtype']
50
+ end
51
+
52
+ def test_visa_dankort_authorization
53
+ assert response = @gateway.authorize(AMOUNT, @visa_dankort, :order_id => generate_order_id)
54
+ assert_success response
55
+ assert !response.authorization.blank?
56
+ assert_equal 'Visa-Dankort', response.params['cardtype']
57
+ end
58
+
59
+ def test_visa_electron_authorization
60
+ assert response = @gateway.authorize(AMOUNT, @electron_dk, :order_id => generate_order_id)
61
+ assert_success response
62
+ assert !response.authorization.blank?
63
+ assert_equal 'Visa-Electron-DK', response.params['cardtype']
64
+ end
65
+
66
+ def test_diners_club_authorization
67
+ assert response = @gateway.authorize(AMOUNT, @diners_club, :order_id => generate_order_id)
68
+ assert_success response
69
+ assert !response.authorization.blank?
70
+ assert_equal 'Diners', response.params['cardtype']
71
+ end
72
+
73
+ def test_diners_club_dk_authorization
74
+ assert response = @gateway.authorize(AMOUNT, @diners_club_dk, :order_id => generate_order_id)
75
+ assert_success response
76
+ assert !response.authorization.blank?
77
+ assert_equal 'Diners', response.params['cardtype']
78
+ end
79
+
80
+ def test_maestro_authorization
81
+ assert response = @gateway.authorize(AMOUNT, @maestro, :order_id => generate_order_id)
82
+ assert_success response
83
+ assert !response.authorization.blank?
84
+ assert_equal 'Maestro', response.params['cardtype']
85
+ end
86
+
87
+ def test_maestro_dk_authorization
88
+ assert response = @gateway.authorize(AMOUNT, @maestro_dk, :order_id => generate_order_id)
89
+ assert_success response
90
+ assert !response.authorization.blank?
91
+ assert_equal 'Maestro', response.params['cardtype']
92
+ end
93
+
94
+ def test_mastercard_dk_authorization
95
+ assert response = @gateway.authorize(AMOUNT, @mastercard_dk, :order_id => generate_order_id)
96
+ assert_success response
97
+ assert !response.authorization.blank?
98
+ assert_equal 'MasterCard-DK', response.params['cardtype']
99
+ end
100
+
101
+ def test_american_express_dk_authorization
102
+ assert response = @gateway.authorize(AMOUNT, @amex_dk, :order_id => generate_order_id)
103
+ assert_success response
104
+ assert !response.authorization.blank?
105
+ assert_equal 'AmericanExpress-DK', response.params['cardtype']
106
+ end
107
+
108
+ def test_american_express_authorization
109
+ assert response = @gateway.authorize(AMOUNT, @amex, :order_id => generate_order_id)
110
+ assert_success response
111
+ assert !response.authorization.blank?
112
+ assert_equal 'AmericanExpress', response.params['cardtype']
113
+ end
114
+
115
+ def test_forbrugsforeningen_authorization
116
+ assert response = @gateway.authorize(AMOUNT, @forbrugsforeningen, :order_id => generate_order_id)
117
+ assert_success response
118
+ assert !response.authorization.blank?
119
+ assert_equal 'FBG-1886', response.params['cardtype']
120
+ end
121
+
122
+ def test_unsuccessful_purchase_with_missing_cvv2
123
+ assert response = @gateway.purchase(AMOUNT, @declined_visa, :order_id => generate_order_id)
124
+ assert_equal 'Missing/error in card verification data', response.message
125
+ assert_failure response
126
+ assert response.authorization.blank?
127
+ end
128
+
129
+ def test_authorize_and_capture
130
+ amount = AMOUNT
131
+ assert auth = @gateway.authorize(amount, @visa, :order_id => generate_order_id)
132
+ assert_success auth
133
+ assert_equal 'OK', auth.message
134
+ assert auth.authorization
135
+ assert capture = @gateway.capture(amount, auth.authorization)
136
+ assert_success capture
137
+ assert_equal 'OK', capture.message
138
+ end
139
+
140
+ def test_failed_capture
141
+ assert response = @gateway.capture(AMOUNT, '')
142
+ assert_failure response
143
+ assert_equal 'Missing/error in transaction number', response.message
144
+ end
145
+
146
+ def test_purchase_and_void
147
+ assert auth = @gateway.authorize(AMOUNT, @visa, :order_id => generate_order_id)
148
+ assert_success auth
149
+ assert_equal 'OK', auth.message
150
+ assert auth.authorization
151
+ assert void = @gateway.void(auth.authorization)
152
+ assert_success void
153
+ assert_equal 'OK', void.message
154
+ end
155
+
156
+ def test_authorization_capture_and_credit
157
+ assert auth = @gateway.authorize(AMOUNT, @visa, :order_id => generate_order_id)
158
+ assert_success auth
159
+ assert capture = @gateway.capture(AMOUNT, auth.authorization)
160
+ assert_success capture
161
+ assert credit = @gateway.credit(AMOUNT, auth.authorization)
162
+ assert_success credit
163
+ assert_equal 'OK', credit.message
164
+ end
165
+
166
+ def test_purchase_and_credit
167
+ assert purchase = @gateway.purchase(AMOUNT, @visa, :order_id => generate_order_id)
168
+ assert_success purchase
169
+ assert credit = @gateway.credit(AMOUNT, purchase.authorization)
170
+ assert_success credit
171
+ end
172
+
173
+ def test_invalid_login
174
+ gateway = QuickpayGateway.new(
175
+ :login => '',
176
+ :password => ''
177
+ )
178
+ assert response = gateway.purchase(AMOUNT, @visa, :order_id => generate_order_id)
179
+ assert_equal 'Missing/error in merchant', response.message
180
+ assert_failure response
181
+ end
182
+ end
@@ -0,0 +1,227 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class RemoteRealexTest < Test::Unit::TestCase
4
+ AMOUNT = 10000
5
+
6
+ def setup
7
+ @gateway = RealexGateway.new(fixtures(:realex))
8
+
9
+ @gateway_with_account = RealexGateway.new(fixtures(:realex_with_account))
10
+
11
+ # Replace the card numbers with the test account numbers from Realex
12
+ @visa = fixtures(:realex_visa)
13
+ @visa_declined = fixtures(:realex_visa_declined)
14
+ @visa_referral_b = fixtures(:realex_visa_referral_b)
15
+ @visa_referral_a = fixtures(:realex_visa_referral_a)
16
+ @visa_coms_error = fixtures(:realex_visa_coms_error)
17
+
18
+ @mastercard = fixtures(:realex_mastercard)
19
+ @mastercard_declined = fixtures(:realex_mastercard_declined)
20
+ @mastercard_referral_b = fixtures(:realex_mastercard_referral_b)
21
+ @mastercard_referral_a = fixtures(:realex_mastercard_referral_a)
22
+ @mastercard_coms_error = fixtures(:realex_mastercard_coms_error)
23
+ end
24
+
25
+ def test_nothing
26
+ assert true
27
+ end
28
+
29
+ def test_realex_purchase
30
+ [ @visa, @mastercard ].each do |card|
31
+
32
+ response = @gateway.purchase(AMOUNT, card,
33
+ :order_id => generate_order_id,
34
+ :description => 'Test Realex Purchase',
35
+ :billing_address => {
36
+ :zip => '90210',
37
+ :country => 'US'
38
+ }
39
+ )
40
+ assert_not_nil response
41
+ assert_success response
42
+ assert response.test?
43
+ assert response.authorization.length > 0
44
+ assert_equal 'Successful', response.message
45
+ end
46
+ end
47
+
48
+ def test_realex_purchase_with_invalid_login
49
+ gateway = RealexGateway.new(
50
+ :login => 'invalid',
51
+ :password => 'invalid'
52
+ )
53
+ response = gateway.purchase(AMOUNT, @visa,
54
+ :order_id => generate_order_id,
55
+ :description => 'Invalid login test'
56
+ )
57
+
58
+ assert_not_nil response
59
+ assert_failure response
60
+
61
+ assert_equal '504', response.params['result']
62
+ assert_equal "There is no such merchant id. Please contact realex payments if you continue to experience this problem.", response.params['message']
63
+ assert_equal RealexGateway::ERROR, response.message
64
+ end
65
+
66
+ def test_realex_purchase_with_invalid_account
67
+
68
+ response = @gateway_with_account.purchase(AMOUNT, @visa,
69
+ :order_id => generate_order_id,
70
+ :description => 'Test Realex purchase with invalid acocunt'
71
+ )
72
+
73
+ assert_not_nil response
74
+ assert_failure response
75
+
76
+ assert_equal '506', response.params['result']
77
+ assert_equal "There is no such merchant account. Please contact realex payments if you continue to experience this problem.", response.params['message']
78
+ assert_equal RealexGateway::ERROR, response.message
79
+ end
80
+
81
+ def test_realex_purchase_declined
82
+
83
+ [ @visa_declined, @mastercard_declined ].each do |card|
84
+
85
+ response = @gateway.purchase(AMOUNT, card,
86
+ :order_id => generate_order_id,
87
+ :description => 'Test Realex purchase declined'
88
+ )
89
+ assert_not_nil response
90
+ assert_failure response
91
+
92
+ assert_equal '101', response.params['result']
93
+ assert_equal response.params['message'], response.message
94
+ end
95
+
96
+ end
97
+
98
+ def test_realex_purchase_referral_b
99
+ [ @visa_referral_b, @mastercard_referral_b ].each do |card|
100
+
101
+ response = @gateway.purchase(AMOUNT, card,
102
+ :order_id => generate_order_id,
103
+ :description => 'Test Realex Referral B'
104
+ )
105
+ assert_not_nil response
106
+ assert_failure response
107
+ assert response.test?
108
+ assert_equal '102', response.params['result']
109
+ assert_equal RealexGateway::DECLINED, response.message
110
+ end
111
+ end
112
+
113
+ def test_realex_purchase_referral_a
114
+ [ @visa_referral_a, @mastercard_referral_a ].each do |card|
115
+
116
+ response = @gateway.purchase(AMOUNT, card,
117
+ :order_id => generate_order_id,
118
+ :description => 'Test Realex Rqeferral A'
119
+ )
120
+ assert_not_nil response
121
+ assert_failure response
122
+ assert_equal '103', response.params['result']
123
+ assert_equal RealexGateway::DECLINED, response.message
124
+ end
125
+
126
+ end
127
+
128
+ def test_realex_purchase_coms_error
129
+
130
+ [ @visa_coms_error, @mastercard_coms_error ].each do |card|
131
+
132
+ response = @gateway.purchase(AMOUNT, card,
133
+ :order_id => generate_order_id,
134
+ :description => 'Test Realex coms error'
135
+ )
136
+
137
+ assert_not_nil response
138
+ assert_failure response
139
+
140
+ assert_equal '205', response.params['result']
141
+ assert_equal RealexGateway::BANK_ERROR, response.message
142
+ end
143
+
144
+ end
145
+
146
+ def test_realex_ccn_error
147
+ @visa.number = 5
148
+
149
+ response = @gateway.purchase(AMOUNT, @visa,
150
+ :order_id => generate_order_id,
151
+ :description => 'Test Realex ccn error'
152
+ )
153
+ assert_not_nil response
154
+ assert_failure response
155
+
156
+ assert_equal '509', response.params['result']
157
+ assert_equal "Invalid credit card length", response.params['message']
158
+ assert_equal RealexGateway::ERROR, response.message
159
+ end
160
+
161
+ def test_realex_expiry_month_error
162
+ @visa.month = 13
163
+
164
+ response = @gateway.purchase(AMOUNT, @visa,
165
+ :order_id => generate_order_id,
166
+ :description => 'Test Realex expiry month error'
167
+ )
168
+ assert_not_nil response
169
+ assert_failure response
170
+
171
+ assert_equal '509', response.params['result']
172
+ assert_equal RealexGateway::ERROR, response.message
173
+ end
174
+
175
+
176
+ def test_realex_expiry_year_error
177
+ @visa.year = 2005
178
+
179
+ response = @gateway.purchase(AMOUNT, @visa,
180
+ :order_id => generate_order_id,
181
+ :description => 'Test Realex expiry year error'
182
+ )
183
+ assert_not_nil response
184
+ assert_failure response
185
+
186
+ assert_equal '509', response.params['result']
187
+ assert_equal RealexGateway::ERROR, response.message
188
+ end
189
+
190
+ def test_invalid_credit_card_name
191
+ @visa.first_name = ""
192
+ @visa.last_name = ""
193
+
194
+ response = @gateway.purchase(AMOUNT, @visa,
195
+ :order_id => generate_order_id,
196
+ :description => 'test_chname_error'
197
+ )
198
+ assert_not_nil response
199
+ assert_failure response
200
+
201
+ assert_equal '502', response.params['result']
202
+ assert_equal RealexGateway::ERROR, response.message
203
+ end
204
+
205
+ def test_cvn
206
+ @visa_cvn = @visa.clone
207
+ @visa_cvn.verification_value = "111"
208
+ response = @gateway.purchase(AMOUNT, @visa_cvn,
209
+ :order_id => generate_order_id,
210
+ :description => 'test_cvn'
211
+ )
212
+ assert_not_nil response
213
+ assert_success response
214
+ assert response.authorization.length > 0
215
+ end
216
+
217
+ def test_customer_number
218
+ response = @gateway.purchase(AMOUNT, @visa,
219
+ :order_id => generate_order_id,
220
+ :description => 'test_cust_num',
221
+ :customer => 'my customer id'
222
+ )
223
+ assert_not_nil response
224
+ assert_success response
225
+ assert response.authorization.length > 0
226
+ end
227
+ end
@@ -0,0 +1,36 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class RemoteSecurePayTest < Test::Unit::TestCase
4
+ include ActiveMerchant::Billing
5
+
6
+ AMOUNT = 100
7
+
8
+ def setup
9
+ @gateway = SecurePayGateway.new(fixtures(:secure_pay))
10
+
11
+ @creditcard = credit_card('4111111111111111',
12
+ :month => 7,
13
+ :year => 2007
14
+ )
15
+
16
+ @options = { :order_id => generate_order_id,
17
+ :description => 'Store purchase',
18
+ :billing_address => {
19
+ :address1 => '1234 My Street',
20
+ :address2 => 'Apartment 204',
21
+ :city => 'Beverly Hills',
22
+ :state => 'CA',
23
+ :country => 'US',
24
+ :zip => '90210'
25
+ }
26
+ }
27
+ end
28
+
29
+ def test_successful_purchase
30
+ assert response = @gateway.purchase(AMOUNT, @creditcard, @options)
31
+ assert response.success?
32
+ assert response.test?
33
+ assert_equal 'This transaction has been approved', response.message
34
+ assert response.authorization
35
+ end
36
+ end
@@ -0,0 +1,37 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class RemoteTransFirstTest < Test::Unit::TestCase
4
+ AMOUNT = 100
5
+
6
+ def setup
7
+ @gateway = TransFirstGateway.new(fixtures(:trans_first))
8
+
9
+ @creditcard = credit_card('4111111111111111')
10
+
11
+ @options = {
12
+ :order_id => generate_order_id,
13
+ :invoice => 'ActiveMerchant Sale',
14
+ :address => { :address1 => '1234 Shady Brook Lane',
15
+ :zip => '90210'
16
+ }
17
+ }
18
+ end
19
+
20
+ def test_successful_purchase
21
+ assert response = @gateway.purchase(AMOUNT, @creditcard, @options)
22
+ assert_equal 'test transaction', response.message
23
+ assert response.test?
24
+ assert_success response
25
+ assert !response.authorization.blank?
26
+ end
27
+
28
+ def test_invalid_login
29
+ gateway = TransFirstGateway.new(
30
+ :login => '',
31
+ :password => ''
32
+ )
33
+ assert response = gateway.purchase(AMOUNT, @creditcard, @options)
34
+ assert_equal 'invalid account', response.message
35
+ assert_failure response
36
+ end
37
+ end