activemerchant 1.4.2 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +78 -0
  3. data/{CONTRIBUTERS → CONTRIBUTORS} +44 -0
  4. data/{README → README.rdoc} +4 -1
  5. data/Rakefile +7 -13
  6. data/lib/active_merchant.rb +11 -21
  7. data/lib/active_merchant/billing/avs_result.rb +13 -10
  8. data/lib/active_merchant/billing/base.rb +2 -2
  9. data/lib/active_merchant/billing/check.rb +1 -1
  10. data/lib/active_merchant/billing/credit_card_methods.rb +2 -2
  11. data/lib/active_merchant/billing/expiry_date.rb +10 -4
  12. data/lib/active_merchant/billing/gateway.rb +7 -6
  13. data/lib/active_merchant/billing/gateways.rb +18 -3
  14. data/lib/active_merchant/billing/gateways/authorize_net.rb +20 -12
  15. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +40 -6
  16. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb.orig +736 -0
  17. data/lib/active_merchant/billing/gateways/braintree.rb +6 -211
  18. data/lib/active_merchant/billing/gateways/data_cash.rb +5 -7
  19. data/lib/active_merchant/billing/gateways/elavon.rb +134 -0
  20. data/lib/active_merchant/billing/gateways/eway.rb +7 -2
  21. data/lib/active_merchant/billing/gateways/first_pay.rb +172 -0
  22. data/lib/active_merchant/billing/gateways/instapay.rb +164 -0
  23. data/lib/active_merchant/billing/gateways/jetpay.rb +270 -0
  24. data/lib/active_merchant/billing/gateways/linkpoint.rb +65 -12
  25. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +154 -0
  26. data/lib/active_merchant/billing/gateways/merchant_ware.rb +283 -0
  27. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +12 -6
  28. data/lib/active_merchant/billing/gateways/ogone.rb +279 -0
  29. data/lib/active_merchant/billing/gateways/pay_secure.rb +1 -1
  30. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -1
  31. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +1 -1
  32. data/lib/active_merchant/billing/gateways/payflow_express.rb +1 -1
  33. data/lib/active_merchant/billing/gateways/payment_express.rb +20 -32
  34. data/lib/active_merchant/billing/gateways/paypal.rb +22 -9
  35. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +2 -1
  36. data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
  37. data/lib/active_merchant/billing/gateways/psl_card.rb +4 -6
  38. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +7 -1
  39. data/lib/active_merchant/billing/gateways/{protx.rb → sage_pay.rb} +60 -35
  40. data/lib/active_merchant/billing/gateways/sallie_mae.rb +144 -0
  41. data/lib/active_merchant/billing/gateways/secure_pay.rb +1 -1
  42. data/lib/active_merchant/billing/gateways/skip_jack.rb +23 -10
  43. data/lib/active_merchant/billing/gateways/smart_ps.rb +265 -0
  44. data/lib/active_merchant/billing/gateways/transax.rb +25 -0
  45. data/lib/active_merchant/billing/gateways/viaklix.rb +38 -14
  46. data/lib/active_merchant/billing/gateways/wirecard.rb +15 -2
  47. data/lib/active_merchant/billing/integrations.rb +18 -11
  48. data/lib/active_merchant/billing/integrations/bogus.rb +4 -3
  49. data/lib/active_merchant/billing/integrations/chronopay.rb +4 -3
  50. data/lib/active_merchant/billing/integrations/chronopay/notification.rb +3 -1
  51. data/lib/active_merchant/billing/integrations/gestpay.rb +4 -5
  52. data/lib/active_merchant/billing/integrations/gestpay/notification.rb +3 -1
  53. data/lib/active_merchant/billing/integrations/hi_trust.rb +4 -3
  54. data/lib/active_merchant/billing/integrations/nochex.rb +4 -3
  55. data/lib/active_merchant/billing/integrations/nochex/notification.rb +1 -1
  56. data/lib/active_merchant/billing/integrations/paypal.rb +3 -4
  57. data/lib/active_merchant/billing/integrations/paypal/helper.rb +9 -8
  58. data/lib/active_merchant/billing/integrations/quickpay.rb +2 -3
  59. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +1 -1
  60. data/lib/active_merchant/billing/integrations/two_checkout.rb +3 -3
  61. data/lib/active_merchant/lib/connection.rb +170 -0
  62. data/lib/active_merchant/lib/country.rb +4 -1
  63. data/lib/active_merchant/lib/posts_data.rb +22 -84
  64. data/test/fixtures.yml +39 -1
  65. data/test/remote/gateways/remote_authorize_net_cim_test.rb +2 -1
  66. data/test/remote/gateways/remote_authorize_net_test.rb +1 -1
  67. data/test/remote/gateways/remote_beanstream_interac_test.rb +1 -1
  68. data/test/remote/gateways/remote_beanstream_test.rb +1 -1
  69. data/test/remote/gateways/remote_braintree_test.rb +2 -9
  70. data/test/remote/gateways/remote_card_stream_test.rb +1 -1
  71. data/test/remote/gateways/remote_cyber_source_test.rb +1 -1
  72. data/test/remote/gateways/remote_data_cash_test.rb +1 -2
  73. data/test/remote/gateways/remote_efsnet_test.rb +1 -1
  74. data/test/remote/gateways/remote_elavon_test.rb +66 -0
  75. data/test/remote/gateways/remote_eway_test.rb +1 -1
  76. data/test/remote/gateways/remote_exact_test.rb +1 -1
  77. data/test/remote/gateways/remote_first_pay_test.rb +87 -0
  78. data/test/remote/gateways/remote_instapay_test.rb +61 -0
  79. data/test/remote/gateways/remote_jetpay_test.rb +103 -0
  80. data/test/remote/gateways/remote_linkpoint_test.rb +11 -2
  81. data/test/remote/gateways/remote_merchant_e_solutions_test.rb +173 -0
  82. data/test/remote/gateways/remote_merchant_ware_test.rb +113 -0
  83. data/test/remote/gateways/remote_modern_payments_cim_test.rb +1 -1
  84. data/test/remote/gateways/remote_modern_payments_test.rb +23 -9
  85. data/test/remote/gateways/remote_moneris_test.rb +1 -1
  86. data/test/remote/gateways/remote_net_registry_test.rb +1 -1
  87. data/test/remote/gateways/remote_netbilling_test.rb +1 -1
  88. data/test/remote/gateways/remote_ogone_test.rb +115 -0
  89. data/test/remote/gateways/remote_pay_junction_test.rb +1 -1
  90. data/test/remote/gateways/remote_pay_secure_test.rb +1 -1
  91. data/test/remote/gateways/remote_payflow_express_test.rb +1 -1
  92. data/test/remote/gateways/remote_payflow_test.rb +1 -1
  93. data/test/remote/gateways/remote_payflow_uk_test.rb +1 -1
  94. data/test/remote/gateways/remote_payment_express_test.rb +17 -7
  95. data/test/remote/gateways/remote_paypal_express_test.rb +1 -1
  96. data/test/remote/gateways/remote_paypal_test.rb +26 -2
  97. data/test/remote/gateways/remote_plugnpay_test.rb +1 -1
  98. data/test/remote/gateways/remote_psigate_test.rb +1 -1
  99. data/test/remote/gateways/remote_psl_card_test.rb +1 -3
  100. data/test/remote/gateways/remote_quickpay_test.rb +1 -1
  101. data/test/remote/gateways/remote_realex_test.rb +1 -1
  102. data/test/remote/gateways/remote_sage_bankcard_test.rb +1 -1
  103. data/test/remote/gateways/remote_sage_pay_test.rb +219 -0
  104. data/test/remote/gateways/remote_sage_test.rb +1 -1
  105. data/test/remote/gateways/remote_sage_virtual_check_test.rb +1 -1
  106. data/test/remote/gateways/remote_sallie_mae_test.rb +51 -0
  107. data/test/remote/gateways/remote_secure_pay_au_test.rb +1 -1
  108. data/test/remote/gateways/remote_secure_pay_tech_test.rb +1 -1
  109. data/test/remote/gateways/remote_secure_pay_test.rb +2 -2
  110. data/test/remote/gateways/remote_skipjack_test.rb +1 -1
  111. data/test/remote/gateways/remote_trans_first_test.rb +1 -1
  112. data/test/remote/gateways/remote_transax_test.rb +112 -0
  113. data/test/remote/gateways/remote_trust_commerce_test.rb +1 -1
  114. data/test/remote/gateways/remote_usa_epay_test.rb +1 -1
  115. data/test/remote/gateways/remote_verifi_test.rb +1 -1
  116. data/test/remote/gateways/remote_viaklix_test.rb +1 -1
  117. data/test/remote/gateways/remote_wirecard_test.rb +34 -0
  118. data/test/remote/integrations/remote_gestpay_integration_test.rb +1 -1
  119. data/test/remote/integrations/remote_paypal_integration_test.rb +1 -1
  120. data/test/test_helper.rb +81 -89
  121. data/test/unit/avs_result_test.rb +1 -1
  122. data/test/unit/base_test.rb +1 -2
  123. data/test/unit/check_test.rb +1 -1
  124. data/test/unit/connection_test.rb +129 -0
  125. data/test/unit/country_code_test.rb +1 -1
  126. data/test/unit/country_test.rb +1 -1
  127. data/test/unit/credit_card_formatting_test.rb +1 -1
  128. data/test/unit/credit_card_methods_test.rb +10 -1
  129. data/test/unit/credit_card_test.rb +1 -1
  130. data/test/unit/cvv_result_test.rb +1 -1
  131. data/test/unit/expiry_date_test.rb +13 -2
  132. data/test/unit/gateways/authorize_net_cim_test.rb +39 -1
  133. data/test/unit/gateways/authorize_net_test.rb +1 -1
  134. data/test/unit/gateways/beanstream_interac_test.rb +1 -1
  135. data/test/unit/gateways/beanstream_test.rb +1 -1
  136. data/test/unit/gateways/bogus_test.rb +1 -1
  137. data/test/unit/gateways/braintree_test.rb +16 -14
  138. data/test/unit/gateways/card_stream_test.rb +1 -1
  139. data/test/unit/gateways/cyber_source_test.rb +1 -1
  140. data/test/unit/gateways/data_cash_test.rb +2 -1
  141. data/test/unit/gateways/efsnet_test.rb +1 -1
  142. data/test/unit/gateways/elavon_test.rb +139 -0
  143. data/test/unit/gateways/eway_test.rb +1 -1
  144. data/test/unit/gateways/exact_test.rb +1 -1
  145. data/test/unit/gateways/first_pay_test.rb +125 -0
  146. data/test/unit/gateways/gateway_test.rb +1 -1
  147. data/test/unit/gateways/instapay_test.rb +102 -0
  148. data/test/unit/gateways/jetpay_test.rb +185 -0
  149. data/test/unit/gateways/linkpoint_test.rb +37 -7
  150. data/test/unit/gateways/merchant_e_solutions_test.rb +169 -0
  151. data/test/unit/gateways/merchant_ware_test.rb +188 -0
  152. data/test/unit/gateways/modern_payments_cim_test.rb +25 -34
  153. data/test/unit/gateways/moneris_test.rb +1 -1
  154. data/test/unit/gateways/net_registry_test.rb +1 -1
  155. data/test/unit/gateways/netbilling_test.rb +1 -1
  156. data/test/unit/gateways/ogone_test.rb +319 -0
  157. data/test/unit/gateways/pay_junction_test.rb +1 -1
  158. data/test/unit/gateways/pay_secure_test.rb +1 -1
  159. data/test/unit/gateways/payflow_express_test.rb +2 -2
  160. data/test/unit/gateways/payflow_express_uk_test.rb +73 -1
  161. data/test/unit/gateways/payflow_test.rb +1 -1
  162. data/test/unit/gateways/payflow_uk_test.rb +1 -1
  163. data/test/unit/gateways/payment_express_test.rb +3 -3
  164. data/test/unit/gateways/paypal_express_test.rb +1 -1
  165. data/test/unit/gateways/paypal_test.rb +50 -1
  166. data/test/unit/gateways/plugnpay_test.rb +1 -1
  167. data/test/unit/gateways/psigate_test.rb +1 -1
  168. data/test/unit/gateways/psl_card_test.rb +1 -1
  169. data/test/unit/gateways/quickpay_test.rb +1 -1
  170. data/test/unit/gateways/realex_test.rb +1 -1
  171. data/test/unit/gateways/sage_bankcard_test.rb +36 -2
  172. data/test/unit/gateways/{protx_test.rb → sage_pay_test.rb} +49 -32
  173. data/test/unit/gateways/sage_virtual_check_test.rb +1 -1
  174. data/test/unit/gateways/sallie_mae_test.rb +53 -0
  175. data/test/unit/gateways/secure_pay_au_test.rb +1 -1
  176. data/test/unit/gateways/secure_pay_tech_test.rb +1 -1
  177. data/test/unit/gateways/secure_pay_test.rb +24 -10
  178. data/test/unit/gateways/skip_jack_test.rb +81 -1
  179. data/test/unit/gateways/trans_first_test.rb +1 -1
  180. data/test/unit/gateways/trust_commerce_test.rb +1 -1
  181. data/test/unit/gateways/usa_epay_test.rb +1 -1
  182. data/test/unit/gateways/verifi_test.rb +1 -1
  183. data/test/unit/gateways/viaklix_test.rb +1 -1
  184. data/test/unit/gateways/wirecard_test.rb +19 -1
  185. data/test/unit/generators/test_generator_helper.rb +1 -1
  186. data/test/unit/integrations/action_view_helper_test.rb +1 -1
  187. data/test/unit/integrations/bogus_module_test.rb +1 -1
  188. data/test/unit/integrations/chronopay_module_test.rb +1 -1
  189. data/test/unit/integrations/gestpay_module_test.rb +1 -1
  190. data/test/unit/integrations/helpers/bogus_helper_test.rb +1 -1
  191. data/test/unit/integrations/helpers/chronopay_helper_test.rb +1 -1
  192. data/test/unit/integrations/helpers/gestpay_helper_test.rb +1 -1
  193. data/test/unit/integrations/helpers/hi_trust_helper_test.rb +1 -1
  194. data/test/unit/integrations/helpers/nochex_helper_test.rb +1 -1
  195. data/test/unit/integrations/helpers/paypal_helper_test.rb +11 -2
  196. data/test/unit/integrations/helpers/quickpay_helper_test.rb +1 -1
  197. data/test/unit/integrations/helpers/two_checkout_helper_test.rb +1 -1
  198. data/test/unit/integrations/hi_trust_module_test.rb +1 -1
  199. data/test/unit/integrations/nochex_module_test.rb +1 -1
  200. data/test/unit/integrations/notifications/chronopay_notification_test.rb +1 -1
  201. data/test/unit/integrations/notifications/gestpay_notification_test.rb +1 -1
  202. data/test/unit/integrations/notifications/hi_trust_notification_test.rb +1 -1
  203. data/test/unit/integrations/notifications/nochex_notification_test.rb +2 -2
  204. data/test/unit/integrations/notifications/notification_test.rb +1 -1
  205. data/test/unit/integrations/notifications/paypal_notification_test.rb +1 -1
  206. data/test/unit/integrations/notifications/quickpay_notification_test.rb +1 -1
  207. data/test/unit/integrations/notifications/two_checkout_notification_test.rb +1 -1
  208. data/test/unit/integrations/paypal_module_test.rb +1 -1
  209. data/test/unit/integrations/quickpay_module_test.rb +1 -1
  210. data/test/unit/integrations/returns/chronopay_return_test.rb +1 -1
  211. data/test/unit/integrations/returns/gestpay_return_test.rb +1 -1
  212. data/test/unit/integrations/returns/hi_trust_return_test.rb +1 -1
  213. data/test/unit/integrations/returns/nochex_return_test.rb +1 -1
  214. data/test/unit/integrations/returns/paypal_return_test.rb +1 -1
  215. data/test/unit/integrations/returns/return_test.rb +1 -1
  216. data/test/unit/integrations/returns/two_checkout_return_test.rb +1 -1
  217. data/test/unit/integrations/two_checkout_module_test.rb +1 -1
  218. data/test/unit/post_data_test.rb +1 -1
  219. data/test/unit/posts_data_test.rb +14 -66
  220. data/test/unit/response_test.rb +1 -1
  221. data/test/unit/utils_test.rb +1 -1
  222. data/test/unit/validateable_test.rb +1 -1
  223. metadata +41 -45
  224. metadata.gz.sig +0 -0
  225. data/test/extra/binding_of_caller.rb +0 -80
  226. data/test/extra/breakpoint.rb +0 -547
  227. data/test/remote/gateways/remote_protx_test.rb +0 -184
@@ -0,0 +1,169 @@
1
+ require 'test_helper'
2
+
3
+ class MerchantESolutionsTest < Test::Unit::TestCase
4
+ def setup
5
+ Base.gateway_mode = :test
6
+
7
+ @gateway = MerchantESolutionsGateway.new(
8
+ :login => 'login',
9
+ :password => 'password'
10
+ )
11
+
12
+ @credit_card = credit_card
13
+ @amount = 100
14
+
15
+ @options = {
16
+ :order_id => '1',
17
+ :billing_address => address,
18
+ :description => 'Store Purchase'
19
+ }
20
+ end
21
+
22
+ def test_successful_purchase
23
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
24
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
25
+ assert_instance_of Response, response
26
+ assert_success response
27
+ assert_equal '5547cc97dae23ea6ad1a4abd33445c91', response.authorization
28
+ assert response.test?
29
+ end
30
+
31
+ def test_unsuccessful_purchase
32
+ @gateway.expects(:ssl_post).returns(failed_purchase_response)
33
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
34
+ assert_failure response
35
+ assert response.test?
36
+ end
37
+
38
+ def test_authorization
39
+ @gateway.expects(:ssl_post).returns(successful_authorization_response)
40
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
41
+ assert response.success?
42
+ assert_equal '42e52603e4c83a55890fbbcfb92b8de1', response.authorization
43
+ assert response.test?
44
+ end
45
+
46
+ def test_capture
47
+ @gateway.expects(:ssl_post).returns(successful_capture_response)
48
+ assert response = @gateway.capture(@amount, '42e52603e4c83a55890fbbcfb92b8de1', @options)
49
+ assert response.success?
50
+ assert_equal '42e52603e4c83a55890fbbcfb92b8de1', response.authorization
51
+ assert response.test?
52
+ end
53
+
54
+ def test_credit
55
+ @gateway.expects(:ssl_post).returns(successful_credit_response)
56
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
57
+ assert response.success?
58
+ assert_equal '0a5ca4662ac034a59595acb61e8da025', response.authorization
59
+ assert response.test?
60
+ end
61
+
62
+ def test_void
63
+ @gateway.expects(:ssl_post).returns(successful_void_response)
64
+ assert response = @gateway.void('42e52603e4c83a55890fbbcfb92b8de1')
65
+ assert response.success?
66
+ assert_equal '1b08845c6dee3fa1a73fee2a009d33a7', response.authorization
67
+ assert response.test?
68
+ end
69
+
70
+ def test_store
71
+ @gateway.expects(:ssl_post).returns(successful_store_response)
72
+ assert response = @gateway.store(@credit_card)
73
+ assert response.success?
74
+ assert_equal 'ae641b57b19b3bb89faab44191479872', response.authorization
75
+ assert response.test?
76
+ end
77
+
78
+ def test_unstore
79
+ @gateway.expects(:ssl_post).returns(successful_unstore_response)
80
+ assert response = @gateway.unstore('ae641b57b19b3bb89faab44191479872')
81
+ assert response.success?
82
+ assert_equal 'd79410c91b4b31ba99f5a90558565df9', response.authorization
83
+ assert response.test?
84
+ end
85
+
86
+ def test_successful_avs_check
87
+ @gateway.expects(:ssl_post).returns(successful_purchase_response + '&avs_result=Y')
88
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
89
+ assert_equal response.avs_result['code'], "Y"
90
+ assert_equal response.avs_result['message'], "Street address and 5-digit postal code match."
91
+ assert_equal response.avs_result['street_match'], "Y"
92
+ assert_equal response.avs_result['postal_match'], "Y"
93
+ end
94
+
95
+ def test_unsuccessful_avs_check_with_bad_street_address
96
+ @gateway.expects(:ssl_post).returns(successful_purchase_response + '&avs_result=Z')
97
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
98
+ assert_equal response.avs_result['code'], "Z"
99
+ assert_equal response.avs_result['message'], "Street address does not match, but 5-digit postal code matches."
100
+ assert_equal response.avs_result['street_match'], "N"
101
+ assert_equal response.avs_result['postal_match'], "Y"
102
+ end
103
+
104
+ def test_unsuccessful_avs_check_with_bad_zip
105
+ @gateway.expects(:ssl_post).returns(successful_purchase_response + '&avs_result=A')
106
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
107
+ assert_equal response.avs_result['code'], "A"
108
+ assert_equal response.avs_result['message'], "Street address matches, but 5-digit and 9-digit postal code do not match."
109
+ assert_equal response.avs_result['street_match'], "Y"
110
+ assert_equal response.avs_result['postal_match'], "N"
111
+ end
112
+
113
+ def test_successful_cvv_check
114
+ @gateway.expects(:ssl_post).returns(successful_purchase_response + '&cvv2_result=M')
115
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
116
+ assert_equal response.cvv_result['code'], "M"
117
+ assert_equal response.cvv_result['message'], "Match"
118
+ end
119
+
120
+ def test_unsuccessful_cvv_check
121
+ @gateway.expects(:ssl_post).returns(failed_purchase_response + '&cvv2_result=N')
122
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
123
+ assert_equal response.cvv_result['code'], "N"
124
+ assert_equal response.cvv_result['message'], "No Match"
125
+ end
126
+
127
+ def test_supported_countries
128
+ assert_equal ['US'], MerchantESolutionsGateway.supported_countries
129
+ end
130
+
131
+ def test_supported_card_types
132
+ assert_equal [:visa, :master, :american_express, :discover, :jcb], MerchantESolutionsGateway.supported_cardtypes
133
+ end
134
+
135
+ private
136
+
137
+ def successful_purchase_response
138
+ 'transaction_id=5547cc97dae23ea6ad1a4abd33445c91&error_code=000&auth_response_text=Exact Match&auth_code=12345A'
139
+ end
140
+
141
+ def successful_authorization_response
142
+ 'transaction_id=42e52603e4c83a55890fbbcfb92b8de1&error_code=000&auth_response_text=Exact Match&auth_code=12345A'
143
+ end
144
+
145
+ def successful_credit_response
146
+ 'transaction_id=0a5ca4662ac034a59595acb61e8da025&error_code=000&auth_response_text=Credit Approved'
147
+ end
148
+
149
+ def successful_void_response
150
+ 'transaction_id=1b08845c6dee3fa1a73fee2a009d33a7&error_code=000&auth_response_text=Void Request Accepted'
151
+ end
152
+
153
+ def successful_capture_response
154
+ 'transaction_id=42e52603e4c83a55890fbbcfb92b8de1&error_code=000&auth_response_text=Settle Request Accepted'
155
+ end
156
+
157
+ def successful_store_response
158
+ 'transaction_id=ae641b57b19b3bb89faab44191479872&error_code=000&auth_response_text=Card Data Stored'
159
+ end
160
+
161
+ def successful_unstore_response
162
+ 'transaction_id=d79410c91b4b31ba99f5a90558565df9&error_code=000&auth_response_text=Stored Card Data Deleted'
163
+ end
164
+
165
+ def failed_purchase_response
166
+ 'transaction_id=error&error_code=101&auth_response_text=Invalid%20I%20or%20Key%20Incomplete%20Request'
167
+ end
168
+
169
+ end
@@ -0,0 +1,188 @@
1
+ require 'test_helper'
2
+
3
+ class MerchantWareTest < Test::Unit::TestCase
4
+ def setup
5
+ @gateway = MerchantWareGateway.new(
6
+ :login => 'login',
7
+ :password => 'password',
8
+ :name => 'name'
9
+ )
10
+
11
+ @credit_card = credit_card
12
+ @amount = 100
13
+
14
+ @options = {
15
+ :order_id => '1',
16
+ :billing_address => address
17
+ }
18
+ end
19
+
20
+ def test_successful_authorization
21
+ @gateway.expects(:ssl_post).returns(successful_authorization_response)
22
+
23
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
24
+ assert_instance_of Response, response
25
+ assert_success response
26
+
27
+ assert_equal '4706382;1', response.authorization
28
+ assert_equal "APPROVED", response.message
29
+ assert response.test?
30
+ end
31
+
32
+ def test_soap_fault_during_authorization
33
+ response_500 = stub(:code => "500", :message => "Internal Server Error", :body => fault_authorization_response)
34
+ @gateway.expects(:ssl_post).raises(ActiveMerchant::ResponseError.new(response_500))
35
+
36
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
37
+ assert_instance_of Response, response
38
+ assert_failure response
39
+ assert response.test?
40
+
41
+ assert_nil response.authorization
42
+ assert_equal "Server was unable to process request. ---> strPAN should be at least 13 to at most 19 characters in size. Parameter name: strPAN", response.message
43
+ assert_equal response_500.code, response.params["http_code"]
44
+ assert_equal response_500.message, response.params["http_message"]
45
+ end
46
+
47
+ def test_failed_authorization
48
+ @gateway.expects(:ssl_post).returns(failed_authorization_response)
49
+
50
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
51
+ assert_instance_of Response, response
52
+ assert_failure response
53
+ assert response.test?
54
+
55
+ assert_nil response.authorization
56
+ assert_equal "transaction type not supported by version", response.message
57
+ assert_equal "FAILED", response.params["status"]
58
+ assert_equal "1014", response.params["failure_code"]
59
+ end
60
+
61
+ def test_failed_void
62
+ @gateway.expects(:ssl_post).returns(failed_void_response)
63
+
64
+ assert response = @gateway.void("1")
65
+ assert_instance_of Response, response
66
+ assert_failure response
67
+ assert response.test?
68
+
69
+ assert_nil response.authorization
70
+ assert_equal "decline", response.message
71
+ assert_equal "DECLINED", response.params["status"]
72
+ assert_equal "1012", response.params["failure_code"]
73
+ end
74
+
75
+ def test_avs_result
76
+ @gateway.expects(:ssl_post).returns(successful_authorization_response)
77
+
78
+ response = @gateway.authorize(@amount, @credit_card, @options)
79
+ assert_equal 'N', response.avs_result['code']
80
+ end
81
+
82
+ def test_cvv_result
83
+ @gateway.expects(:ssl_post).returns(successful_authorization_response)
84
+
85
+ response = @gateway.authorize(@amount, @credit_card, @options)
86
+ assert_equal 'M', response.cvv_result['code']
87
+ end
88
+
89
+ private
90
+
91
+ def successful_authorization_response
92
+ <<-XML
93
+ <?xml version="1.0" encoding="utf-8"?>
94
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
95
+ <soap:Body>
96
+ <IssueKeyedPreAuthResponse xmlns="http://merchantwarehouse.com/MerchantWARE/Client/TransactionRetail">
97
+ <IssueKeyedPreAuthResult>
98
+ <ReferenceID>4706382</ReferenceID>
99
+ <OrderNumber>1</OrderNumber>
100
+ <TXDate>7/3/2009 2:05:04 AM</TXDate>
101
+ <ApprovalStatus>APPROVED</ApprovalStatus>
102
+ <AuthCode>VI0100</AuthCode>
103
+ <CardHolder>Longbob Longsen</CardHolder>
104
+ <Amount>1.00</Amount>
105
+ <Type>5</Type>
106
+ <CardNumber>************4242</CardNumber>
107
+ <CardType>0</CardType>
108
+ <AVSResponse>N</AVSResponse>
109
+ <CVResponse>M</CVResponse>
110
+ <POSEntryType>1</POSEntryType>
111
+ </IssueKeyedPreAuthResult>
112
+ </IssueKeyedPreAuthResponse>
113
+ </soap:Body>
114
+ </soap:Envelope>
115
+ XML
116
+ end
117
+
118
+ def fault_authorization_response
119
+ <<-XML
120
+ <?xml version="1.0" encoding="utf-8"?>
121
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
122
+ <soap:Body>
123
+ <soap:Fault>
124
+ <faultcode>soap:Server</faultcode>
125
+ <faultstring>Server was unable to process request. ---&gt; strPAN should be at least 13 to at most 19 characters in size.
126
+ Parameter name: strPAN</faultstring>
127
+ <detail/>
128
+ </soap:Fault>
129
+ </soap:Body>
130
+ </soap:Envelope>
131
+ XML
132
+ end
133
+
134
+ def failed_authorization_response
135
+ <<-XML
136
+ <?xml version="1.0" encoding="utf-8"?>
137
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
138
+ <soap:Body>
139
+ <IssueKeyedPreAuthResponse xmlns="http://merchantwarehouse.com/MerchantWARE/Client/TransactionRetail">
140
+ <IssueKeyedPreAuthResult>
141
+ <ReferenceID/>
142
+ <OrderNumber>1</OrderNumber>
143
+ <TXDate>7/3/2009 3:04:33 AM</TXDate>
144
+ <ApprovalStatus>FAILED;1014;transaction type not supported by version</ApprovalStatus>
145
+ <AuthCode/>
146
+ <CardHolder>Longbob Longsen</CardHolder>
147
+ <Amount>1.00</Amount>
148
+ <Type>5</Type>
149
+ <CardNumber>*********0123</CardNumber>
150
+ <CardType>0</CardType>
151
+ <AVSResponse/>
152
+ <CVResponse/>
153
+ <POSEntryType>1</POSEntryType>
154
+ </IssueKeyedPreAuthResult>
155
+ </IssueKeyedPreAuthResponse>
156
+ </soap:Body>
157
+ </soap:Envelope>
158
+ XML
159
+ end
160
+
161
+ def failed_void_response
162
+ <<-XML
163
+ <?xml version="1.0" encoding="utf-8"?>
164
+ <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
165
+ <soap:Body>
166
+ <IssueVoidResponse xmlns="http://merchantwarehouse.com/MerchantWARE/Client/TransactionRetail">
167
+ <IssueVoidResult>
168
+ <ReferenceID>4707277</ReferenceID>
169
+ <OrderNumber/>
170
+ <TXDate>7/3/2009 3:28:38 AM</TXDate>
171
+ <ApprovalStatus>DECLINED;1012;decline</ApprovalStatus>
172
+ <AuthCode/>
173
+ <CardHolder/>
174
+ <Amount/>
175
+ <Type>3</Type>
176
+ <CardNumber/>
177
+ <CardType>0</CardType>
178
+ <AVSResponse/>
179
+ <CVResponse/>
180
+ <POSEntryType>0</POSEntryType>
181
+ </IssueVoidResult>
182
+ </IssueVoidResponse>
183
+ </soap:Body>
184
+ </soap:Envelope>
185
+ XML
186
+ end
187
+
188
+ end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
1
+ require 'test_helper'
2
2
 
3
3
  class ModernPaymentsCimTest < Test::Unit::TestCase
4
4
  def setup
@@ -40,22 +40,23 @@ class ModernPaymentsCimTest < Test::Unit::TestCase
40
40
  end
41
41
 
42
42
  def test_successful_credit_card_authorization
43
- @gateway.expects(:ssl_post).returns(successful_credit_card_authorization_response)
43
+ @gateway.expects(:ssl_post).returns(successful_authorization_response)
44
44
 
45
45
  assert response = @gateway.authorize_credit_card_payment("10001", @amount)
46
46
  assert_instance_of Response, response
47
47
  assert response.test?
48
48
 
49
49
  assert_success response
50
- assert_equal "999", response.params["trans_id"]
51
- assert_equal "RESPONSECODE=A,AUTHCODE=XXXXXX,DECLINEREASON=,AVSDATA=NYZ,TRANSID=C00 TESTXXXXXXX", response.params["auth_string"]
52
- assert_equal "RESPONSECODE=A,AUTHCODE=XXXXXX,DECLINEREASON=,AVSDATA=NYZ,TRANSID=C00 TESTXXXXXXX", response.params["message_text"]
53
- assert_equal "false", response.params["approved"]
54
- assert_equal nil, response.params["avs_code"]
55
- assert_equal nil, response.params["auth_code"]
56
- assert_equal nil, response.params["trans_code"]
57
- assert_equal "999", response.authorization
58
- assert_match /RESPONSECODE=A/, response.params["message_text"]
50
+ assert_equal "18713505", response.params["trans_id"]
51
+ assert_equal "RESPONSECODE=A\nAUTHCODE=020411\nDECLINEREASON=\nAVSDATA=Z\nTRANSID=C00 17093294", response.params["auth_string"]
52
+ assert_equal "Approved", response.params["message_text"]
53
+ assert_equal "true", response.params["approved"]
54
+ assert_equal "Z", response.params["avs_code"]
55
+ assert_equal "020411", response.params["auth_code"]
56
+ assert_equal "C00 17093294", response.params["trans_code"]
57
+ assert_equal "18713505", response.authorization
58
+ assert_equal ModernPaymentsCimGateway::SUCCESS_MESSAGE, response.message
59
+ assert_equal 'Z', response.avs_result['code']
59
60
  end
60
61
 
61
62
  def test_unsuccessful_credit_card_authorization
@@ -64,7 +65,7 @@ class ModernPaymentsCimTest < Test::Unit::TestCase
64
65
  assert response = @gateway.authorize_credit_card_payment("10001", @amount)
65
66
  assert_instance_of Response, response
66
67
  assert response.test?
67
- assert_success response
68
+ assert_failure response
68
69
  assert_equal "999", response.authorization
69
70
  assert_match /RESPONSECODE=D/, response.params["message_text"]
70
71
  end
@@ -107,27 +108,6 @@ class ModernPaymentsCimTest < Test::Unit::TestCase
107
108
  XML
108
109
  end
109
110
 
110
- def successful_credit_card_authorization_response
111
- <<-XML
112
- <?xml version="1.0" encoding="utf-8"?>
113
- <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
114
- <soap:Body>
115
- <AuthorizeCreditCardPaymentResponse xmlns="https://secure.modpay.com/netservices/test/">
116
- <AuthorizeCreditCardPaymentResult>
117
- <transId>999</transId>
118
- <authCode/>
119
- <avsCode/>
120
- <transCode/>
121
- <authString>RESPONSECODE=A,AUTHCODE=XXXXXX,DECLINEREASON=,AVSDATA=NYZ,TRANSID=C00 TESTXXXXXXX</authString>
122
- <messageText>RESPONSECODE=A,AUTHCODE=XXXXXX,DECLINEREASON=,AVSDATA=NYZ,TRANSID=C00 TESTXXXXXXX</messageText>
123
- <approved>false</approved>
124
- </AuthorizeCreditCardPaymentResult>
125
- </AuthorizeCreditCardPaymentResponse>
126
- </soap:Body>
127
- </soap:Envelope>
128
- XML
129
- end
130
-
131
111
  def unsuccessful_credit_card_authorization_response
132
112
  <<-XML
133
113
  <?xml version="1.0" encoding="utf-8"?>
@@ -167,5 +147,16 @@ class ModernPaymentsCimTest < Test::Unit::TestCase
167
147
  </soap:Envelope>
168
148
  XML
169
149
  end
170
-
150
+
151
+ def successful_authorization_response
152
+ <<-XML
153
+ <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><AuthorizeCreditCardPaymentResponse xmlns="https://secure.modpay.com/ws/"><AuthorizeCreditCardPaymentResult><transId>18713505</transId><authCode>020411</authCode><avsCode>Z</avsCode><transCode>C00 17093294
154
+ </transCode><authString>RESPONSECODE=A
155
+ AUTHCODE=020411
156
+ DECLINEREASON=
157
+ AVSDATA=Z
158
+ TRANSID=C00 17093294
159
+ </authString><messageText>Approved</messageText><approved>true</approved></AuthorizeCreditCardPaymentResult></AuthorizeCreditCardPaymentResponse></soap:Body></soap:Envelope>
160
+ XML
161
+ end
171
162
  end