smulube-activemerchant 1.5.1.1 → 1.5.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. data/.gitignore +6 -0
  2. data/Rakefile +85 -0
  3. data/generators/gateway/USAGE +5 -0
  4. data/generators/gateway/gateway_generator.rb +61 -0
  5. data/generators/gateway/templates/gateway.rb +77 -0
  6. data/generators/gateway/templates/gateway_test.rb +49 -0
  7. data/generators/gateway/templates/remote_gateway_test.rb +57 -0
  8. data/generators/integration/USAGE +5 -0
  9. data/generators/integration/integration_generator.rb +68 -0
  10. data/generators/integration/templates/helper.rb +34 -0
  11. data/generators/integration/templates/helper_test.rb +54 -0
  12. data/generators/integration/templates/integration.rb +18 -0
  13. data/generators/integration/templates/module_test.rb +9 -0
  14. data/generators/integration/templates/notification.rb +100 -0
  15. data/generators/integration/templates/notification_test.rb +41 -0
  16. data/init.rb +3 -0
  17. data/lib/active_merchant/billing/gateways/payflow_nvp_uk.rb +18 -11
  18. data/lib/active_merchant/version.rb +3 -0
  19. data/lib/active_merchant.rb +1 -0
  20. data/script/destroy +14 -0
  21. data/script/generate +14 -0
  22. data/test/fixtures.yml +355 -0
  23. data/test/remote/gateways/remote_authorize_net_cim_test.rb +460 -0
  24. data/test/remote/gateways/remote_authorize_net_test.rb +145 -0
  25. data/test/remote/gateways/remote_beanstream_interac_test.rb +53 -0
  26. data/test/remote/gateways/remote_beanstream_test.rb +150 -0
  27. data/test/remote/gateways/remote_braintree_test.rb +147 -0
  28. data/test/remote/gateways/remote_card_stream_test.rb +148 -0
  29. data/test/remote/gateways/remote_cyber_source_test.rb +144 -0
  30. data/test/remote/gateways/remote_data_cash_test.rb +356 -0
  31. data/test/remote/gateways/remote_efsnet_test.rb +81 -0
  32. data/test/remote/gateways/remote_elavon_test.rb +66 -0
  33. data/test/remote/gateways/remote_eway_test.rb +74 -0
  34. data/test/remote/gateways/remote_exact_test.rb +60 -0
  35. data/test/remote/gateways/remote_first_pay_test.rb +87 -0
  36. data/test/remote/gateways/remote_instapay_test.rb +61 -0
  37. data/test/remote/gateways/remote_jetpay_test.rb +103 -0
  38. data/test/remote/gateways/remote_linkpoint_test.rb +121 -0
  39. data/test/remote/gateways/remote_merchant_e_solutions_test.rb +173 -0
  40. data/test/remote/gateways/remote_merchant_ware_test.rb +113 -0
  41. data/test/remote/gateways/remote_modern_payments_cim_test.rb +58 -0
  42. data/test/remote/gateways/remote_modern_payments_test.rb +57 -0
  43. data/test/remote/gateways/remote_moneris_test.rb +82 -0
  44. data/test/remote/gateways/remote_net_registry_test.rb +85 -0
  45. data/test/remote/gateways/remote_netbilling_test.rb +70 -0
  46. data/test/remote/gateways/remote_ogone_test.rb +115 -0
  47. data/test/remote/gateways/remote_pay_junction_test.rb +143 -0
  48. data/test/remote/gateways/remote_pay_secure_test.rb +39 -0
  49. data/test/remote/gateways/remote_payflow_express_test.rb +50 -0
  50. data/test/remote/gateways/remote_payflow_nvp_uk_test.rb +57 -0
  51. data/test/remote/gateways/remote_payflow_test.rb +237 -0
  52. data/test/remote/gateways/remote_payflow_uk_test.rb +173 -0
  53. data/test/remote/gateways/remote_payment_express_test.rb +136 -0
  54. data/test/remote/gateways/remote_paypal_express_test.rb +49 -0
  55. data/test/remote/gateways/remote_paypal_test.rb +191 -0
  56. data/test/remote/gateways/remote_plugnpay_test.rb +72 -0
  57. data/test/remote/gateways/remote_psigate_test.rb +50 -0
  58. data/test/remote/gateways/remote_psl_card_test.rb +123 -0
  59. data/test/remote/gateways/remote_quickpay_test.rb +190 -0
  60. data/test/remote/gateways/remote_realex_test.rb +224 -0
  61. data/test/remote/gateways/remote_sage_bankcard_test.rb +109 -0
  62. data/test/remote/gateways/remote_sage_pay_test.rb +219 -0
  63. data/test/remote/gateways/remote_sage_test.rb +87 -0
  64. data/test/remote/gateways/remote_sage_virtual_check_test.rb +62 -0
  65. data/test/remote/gateways/remote_sallie_mae_test.rb +51 -0
  66. data/test/remote/gateways/remote_secure_pay_au_test.rb +40 -0
  67. data/test/remote/gateways/remote_secure_pay_tech_test.rb +37 -0
  68. data/test/remote/gateways/remote_secure_pay_test.rb +28 -0
  69. data/test/remote/gateways/remote_skipjack_test.rb +105 -0
  70. data/test/remote/gateways/remote_trans_first_test.rb +34 -0
  71. data/test/remote/gateways/remote_transax_test.rb +112 -0
  72. data/test/remote/gateways/remote_trust_commerce_test.rb +152 -0
  73. data/test/remote/gateways/remote_usa_epay_test.rb +46 -0
  74. data/test/remote/gateways/remote_verifi_test.rb +107 -0
  75. data/test/remote/gateways/remote_viaklix_test.rb +43 -0
  76. data/test/remote/gateways/remote_wirecard_test.rb +111 -0
  77. data/test/remote/integrations/remote_gestpay_integration_test.rb +37 -0
  78. data/test/remote/integrations/remote_paypal_integration_test.rb +26 -0
  79. data/test/test_helper.rb +184 -0
  80. data/test/unit/avs_result_test.rb +59 -0
  81. data/test/unit/base_test.rb +54 -0
  82. data/test/unit/check_test.rb +88 -0
  83. data/test/unit/connection_test.rb +129 -0
  84. data/test/unit/country_code_test.rb +33 -0
  85. data/test/unit/country_test.rb +64 -0
  86. data/test/unit/credit_card_formatting_test.rb +19 -0
  87. data/test/unit/credit_card_methods_test.rb +179 -0
  88. data/test/unit/credit_card_test.rb +318 -0
  89. data/test/unit/cvv_result_test.rb +33 -0
  90. data/test/unit/expiry_date_test.rb +32 -0
  91. data/test/unit/gateways/authorize_net_cim_test.rb +676 -0
  92. data/test/unit/gateways/authorize_net_test.rb +290 -0
  93. data/test/unit/gateways/beanstream_interac_test.rb +51 -0
  94. data/test/unit/gateways/beanstream_test.rb +144 -0
  95. data/test/unit/gateways/bogus_test.rb +58 -0
  96. data/test/unit/gateways/braintree_test.rb +118 -0
  97. data/test/unit/gateways/card_stream_test.rb +90 -0
  98. data/test/unit/gateways/cyber_source_test.rb +188 -0
  99. data/test/unit/gateways/data_cash_test.rb +133 -0
  100. data/test/unit/gateways/efsnet_test.rb +123 -0
  101. data/test/unit/gateways/elavon_test.rb +139 -0
  102. data/test/unit/gateways/eway_test.rb +118 -0
  103. data/test/unit/gateways/exact_test.rb +156 -0
  104. data/test/unit/gateways/first_pay_test.rb +125 -0
  105. data/test/unit/gateways/gateway_test.rb +48 -0
  106. data/test/unit/gateways/instapay_test.rb +102 -0
  107. data/test/unit/gateways/jetpay_test.rb +185 -0
  108. data/test/unit/gateways/linkpoint_test.rb +197 -0
  109. data/test/unit/gateways/merchant_e_solutions_test.rb +169 -0
  110. data/test/unit/gateways/merchant_ware_test.rb +188 -0
  111. data/test/unit/gateways/modern_payments_cim_test.rb +162 -0
  112. data/test/unit/gateways/moneris_test.rb +158 -0
  113. data/test/unit/gateways/net_registry_test.rb +416 -0
  114. data/test/unit/gateways/netbilling_test.rb +54 -0
  115. data/test/unit/gateways/ogone_test.rb +319 -0
  116. data/test/unit/gateways/pay_junction_test.rb +123 -0
  117. data/test/unit/gateways/pay_secure_test.rb +71 -0
  118. data/test/unit/gateways/payflow_express_test.rb +173 -0
  119. data/test/unit/gateways/payflow_express_uk_test.rb +86 -0
  120. data/test/unit/gateways/payflow_nvp_uk_test.rb +201 -0
  121. data/test/unit/gateways/payflow_test.rb +305 -0
  122. data/test/unit/gateways/payflow_uk_test.rb +30 -0
  123. data/test/unit/gateways/payment_express_test.rb +195 -0
  124. data/test/unit/gateways/paypal_express_test.rb +382 -0
  125. data/test/unit/gateways/paypal_test.rb +569 -0
  126. data/test/unit/gateways/plugnpay_test.rb +86 -0
  127. data/test/unit/gateways/psigate_test.rb +169 -0
  128. data/test/unit/gateways/psl_card_test.rb +64 -0
  129. data/test/unit/gateways/quickpay_test.rb +112 -0
  130. data/test/unit/gateways/realex_test.rb +151 -0
  131. data/test/unit/gateways/sage_bankcard_test.rb +196 -0
  132. data/test/unit/gateways/sage_pay_test.rb +139 -0
  133. data/test/unit/gateways/sage_virtual_check_test.rb +71 -0
  134. data/test/unit/gateways/sallie_mae_test.rb +53 -0
  135. data/test/unit/gateways/secure_pay_au_test.rb +207 -0
  136. data/test/unit/gateways/secure_pay_tech_test.rb +44 -0
  137. data/test/unit/gateways/secure_pay_test.rb +101 -0
  138. data/test/unit/gateways/skip_jack_test.rb +228 -0
  139. data/test/unit/gateways/trans_first_test.rb +112 -0
  140. data/test/unit/gateways/trust_commerce_test.rb +90 -0
  141. data/test/unit/gateways/usa_epay_test.rb +128 -0
  142. data/test/unit/gateways/verifi_test.rb +96 -0
  143. data/test/unit/gateways/viaklix_test.rb +78 -0
  144. data/test/unit/gateways/wirecard_test.rb +250 -0
  145. data/test/unit/generators/test_gateway_generator.rb +46 -0
  146. data/test/unit/generators/test_generator_helper.rb +20 -0
  147. data/test/unit/generators/test_integration_generator.rb +53 -0
  148. data/test/unit/integrations/action_view_helper_test.rb +50 -0
  149. data/test/unit/integrations/bogus_module_test.rb +20 -0
  150. data/test/unit/integrations/chronopay_module_test.rb +13 -0
  151. data/test/unit/integrations/gestpay_module_test.rb +14 -0
  152. data/test/unit/integrations/helpers/bogus_helper_test.rb +28 -0
  153. data/test/unit/integrations/helpers/chronopay_helper_test.rb +110 -0
  154. data/test/unit/integrations/helpers/gestpay_helper_test.rb +100 -0
  155. data/test/unit/integrations/helpers/hi_trust_helper_test.rb +16 -0
  156. data/test/unit/integrations/helpers/nochex_helper_test.rb +53 -0
  157. data/test/unit/integrations/helpers/paypal_helper_test.rb +171 -0
  158. data/test/unit/integrations/helpers/quickpay_helper_test.rb +40 -0
  159. data/test/unit/integrations/helpers/two_checkout_helper_test.rb +92 -0
  160. data/test/unit/integrations/hi_trust_module_test.rb +13 -0
  161. data/test/unit/integrations/nochex_module_test.rb +13 -0
  162. data/test/unit/integrations/notifications/chronopay_notification_test.rb +66 -0
  163. data/test/unit/integrations/notifications/gestpay_notification_test.rb +60 -0
  164. data/test/unit/integrations/notifications/hi_trust_notification_test.rb +59 -0
  165. data/test/unit/integrations/notifications/nochex_notification_test.rb +51 -0
  166. data/test/unit/integrations/notifications/notification_test.rb +54 -0
  167. data/test/unit/integrations/notifications/paypal_notification_test.rb +85 -0
  168. data/test/unit/integrations/notifications/quickpay_notification_test.rb +69 -0
  169. data/test/unit/integrations/notifications/two_checkout_notification_test.rb +55 -0
  170. data/test/unit/integrations/paypal_module_test.rb +28 -0
  171. data/test/unit/integrations/quickpay_module_test.rb +9 -0
  172. data/test/unit/integrations/returns/chronopay_return_test.rb +11 -0
  173. data/test/unit/integrations/returns/gestpay_return_test.rb +10 -0
  174. data/test/unit/integrations/returns/hi_trust_return_test.rb +24 -0
  175. data/test/unit/integrations/returns/nochex_return_test.rb +10 -0
  176. data/test/unit/integrations/returns/paypal_return_test.rb +10 -0
  177. data/test/unit/integrations/returns/return_test.rb +11 -0
  178. data/test/unit/integrations/returns/two_checkout_return_test.rb +24 -0
  179. data/test/unit/integrations/two_checkout_module_test.rb +13 -0
  180. data/test/unit/post_data_test.rb +55 -0
  181. data/test/unit/posts_data_test.rb +48 -0
  182. data/test/unit/response_test.rb +28 -0
  183. data/test/unit/utils_test.rb +7 -0
  184. data/test/unit/validateable_test.rb +60 -0
  185. data.tar.gz.sig +0 -0
  186. metadata +453 -107
  187. metadata.gz.sig +0 -0
@@ -0,0 +1,185 @@
1
+ require 'test_helper'
2
+
3
+ class JetpayTest < Test::Unit::TestCase
4
+ include ActiveMerchant::Billing
5
+
6
+ def setup
7
+ Base.gateway_mode = :test
8
+
9
+ @gateway = JetpayGateway.new(:login => 'login')
10
+
11
+ @credit_card = credit_card
12
+ @amount = 100
13
+
14
+ @options = {
15
+ :order_id => '1',
16
+ :billing_address => address(:country => 'US'),
17
+ :shipping_address => address(:country => 'US'),
18
+ :email => 'test@test.com',
19
+ :ip => '127.0.0.1',
20
+ :order_id => '12345',
21
+ :tax => 7
22
+ }
23
+ end
24
+
25
+ def test_successful_purchase
26
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
27
+
28
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
29
+ assert_success response
30
+
31
+ assert_equal '707a4f1750d8dc03bd;TEST47;100', response.authorization
32
+ assert_equal('TEST47', response.params["approval"])
33
+ assert response.test?
34
+ end
35
+
36
+ def test_unsuccessful_request
37
+ @gateway.expects(:ssl_post).returns(failed_purchase_response)
38
+
39
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
40
+ assert_failure response
41
+ assert_equal('7605f7c5d6e8f74deb;;100', response.authorization)
42
+ assert response.test?
43
+ end
44
+
45
+ def test_successful_authorize
46
+ @gateway.expects(:ssl_post).returns(successful_authorize_response)
47
+
48
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
49
+ assert_success response
50
+
51
+ assert_equal('010327153017T10018;502F6B;100', response.authorization)
52
+ assert_equal('502F6B', response.params["approval"])
53
+ assert response.test?
54
+ end
55
+
56
+ def test_successful_capture
57
+ @gateway.expects(:ssl_post).returns(successful_capture_response)
58
+
59
+ assert response = @gateway.capture(1111, "010327153017T10018;502F7B;1111")
60
+ assert_success response
61
+
62
+ assert_equal('010327153017T10018;502F6B;1111', response.authorization)
63
+ assert_equal('502F6B', response.params["approval"])
64
+ assert response.test?
65
+ end
66
+
67
+ def test_successful_void
68
+ # no need for csv
69
+ card = credit_card('4242424242424242', :verification_value => nil)
70
+
71
+ @gateway.expects(:ssl_post).returns(successful_void_response)
72
+
73
+ assert response = @gateway.void('010327153x17T10418;502F7B;500')
74
+ assert_success response
75
+
76
+ assert_equal('010327153x17T10418;502F7B;500', response.authorization)
77
+ assert_equal('502F7B', response.params["approval"])
78
+ assert response.test?
79
+ end
80
+
81
+ def test_successful_credit
82
+ # no need for csv
83
+ card = credit_card('4242424242424242', :verification_value => nil)
84
+
85
+ @gateway.expects(:ssl_post).returns(successful_credit_response)
86
+
87
+ # linked credit
88
+ assert response = @gateway.credit(9900, '010327153017T10017')
89
+ assert_success response
90
+
91
+ assert_equal('010327153017T10017;002F6B;9900', response.authorization)
92
+ assert_equal('002F6B', response.params['approval'])
93
+ assert response.test?
94
+
95
+ # unlinked credit
96
+ @gateway.expects(:ssl_post).returns(successful_credit_response)
97
+
98
+ assert response = @gateway.credit(9900, card)
99
+ assert_success response
100
+ end
101
+
102
+ def test_avs_result
103
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
104
+
105
+ response = @gateway.purchase(@amount, @credit_card)
106
+ assert_equal 'Y', response.avs_result['code']
107
+ end
108
+
109
+ def test_cvv_result
110
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
111
+
112
+ response = @gateway.purchase(@amount, @credit_card)
113
+ assert_equal 'P', response.cvv_result['code']
114
+ end
115
+
116
+
117
+ private
118
+ def successful_purchase_response
119
+ <<-EOF
120
+ <JetPayResponse><TransactionID>707a4f1750d8dc03bd</TransactionID>
121
+ <ActionCode>000</ActionCode>
122
+ <Approval>TEST47</Approval>
123
+ <CVV2>P</CVV2>
124
+ <ResponseText>APPROVED</ResponseText>
125
+ <AddressMatch>Y</AddressMatch>
126
+ <ZipMatch>Y</ZipMatch>
127
+ <AVS>Y</AVS>
128
+ </JetPayResponse>
129
+ EOF
130
+ end
131
+
132
+ def failed_purchase_response
133
+ <<-EOF
134
+ <JetPayResponse>
135
+ <TransactionID>7605f7c5d6e8f74deb</TransactionID>
136
+ <ActionCode>005</ActionCode>
137
+ <ResponseText>DECLINED</ResponseText>
138
+ </JetPayResponse>
139
+ EOF
140
+ end
141
+
142
+ def successful_authorize_response
143
+ <<-EOF
144
+ <JetPayResponse>
145
+ <TransactionID>010327153017T10018</TransactionID>
146
+ <ActionCode>000</ActionCode>
147
+ <Approval>502F6B</Approval>
148
+ <ResponseText>APPROVED</ResponseText>
149
+ </JetPayResponse>
150
+ EOF
151
+ end
152
+
153
+ def successful_capture_response
154
+ <<-EOF
155
+ <JetPayResponse>
156
+ <TransactionID>010327153017T10018</TransactionID>
157
+ <ActionCode>000</ActionCode>
158
+ <Approval>502F6B</Approval>
159
+ <ResponseText>APPROVED</ResponseText>
160
+ </JetPayResponse>
161
+ EOF
162
+ end
163
+
164
+ def successful_void_response
165
+ <<-EOF
166
+ <JetPayResponse>
167
+ <TransactionID>010327153x17T10418</TransactionID>
168
+ <ActionCode>000</ActionCode>
169
+ <Approval>502F7B</Approval>
170
+ <ResponseText>VOID PROCESSED</ResponseText>
171
+ </JetPayResponse>
172
+ EOF
173
+ end
174
+
175
+ def successful_credit_response
176
+ <<-EOF
177
+ <JetPayResponse>
178
+ <TransactionID>010327153017T10017</TransactionID>
179
+ <ActionCode>000</ActionCode>
180
+ <Approval>002F6B</Approval>
181
+ <ResponseText>APPROVED</ResponseText>
182
+ </JetPayResponse>
183
+ EOF
184
+ end
185
+ end
@@ -0,0 +1,197 @@
1
+ require 'test_helper'
2
+
3
+ class LinkpointTest < Test::Unit::TestCase
4
+ def setup
5
+ Base.mode = :test
6
+
7
+ @gateway = LinkpointGateway.new(
8
+ :login => 123123,
9
+ :pem => 'PEM'
10
+ )
11
+
12
+ @credit_card = credit_card('4111111111111111')
13
+ @options = { :order_id => 1000, :billing_address => address }
14
+ end
15
+
16
+ def test_credit_card_formatting
17
+ assert_equal '04', @gateway.send(:format_creditcard_expiry_year, 2004)
18
+ assert_equal '04', @gateway.send(:format_creditcard_expiry_year, '2004')
19
+ assert_equal '04', @gateway.send(:format_creditcard_expiry_year, 4)
20
+ assert_equal '04', @gateway.send(:format_creditcard_expiry_year, '04')
21
+ end
22
+
23
+ def test_successful_authorization
24
+ @gateway.expects(:ssl_post).returns(successful_authorization_response)
25
+
26
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
27
+ assert_instance_of Response, response
28
+ assert_success response
29
+ assert_equal '1000', response.authorization
30
+ end
31
+
32
+ def test_successful_capture
33
+ @gateway.expects(:ssl_post).returns(successful_capture_response)
34
+
35
+ assert response = @gateway.capture(@email, '1000', @options)
36
+ assert_instance_of Response, response
37
+ assert_success response
38
+ assert_equal '1000', response.authorization
39
+ end
40
+
41
+ def test_successful_purchase
42
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
43
+
44
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
45
+ assert_instance_of Response, response
46
+ assert_success response
47
+ assert_equal '1000', response.authorization
48
+ end
49
+
50
+ def test_failed_purchase
51
+ @gateway.expects(:ssl_post).returns(failed_purchase_response)
52
+
53
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
54
+ assert_failure response
55
+ end
56
+
57
+ def test_recurring
58
+ @gateway.expects(:ssl_post).returns(successful_recurring_response)
59
+
60
+ assert response = @gateway.recurring(2400, @credit_card, :order_id => 1003, :installments => 12, :startdate => "immediate", :periodicity => :monthly)
61
+ assert_success response
62
+ end
63
+
64
+ def test_amount_style
65
+ assert_equal '10.34', @gateway.send(:amount, 1034)
66
+
67
+ assert_raise(ArgumentError) do
68
+ @gateway.send(:amount, '10.34')
69
+ end
70
+ end
71
+
72
+ def test_purchase_is_valid_xml
73
+ parameters = @gateway.send(:parameters, 1000, @credit_card, :ordertype => "SALE", :order_id => 1004,
74
+ :billing_address => {
75
+ :address1 => '1313 lucky lane',
76
+ :city => 'Lost Angeles',
77
+ :state => 'CA',
78
+ :zip => '90210'
79
+ }
80
+ )
81
+
82
+ assert data = @gateway.send(:post_data, @amount, @credit_card, @options)
83
+ assert REXML::Document.new(data)
84
+ end
85
+
86
+ def test_recurring_is_valid_xml
87
+ parameters = @gateway.send(:parameters, 1000, @credit_card, :ordertype => "SALE", :action => "SUBMIT", :installments => 12, :startdate => "immediate", :periodicity => "monthly", :order_id => 1006,
88
+ :billing_address => {
89
+ :address1 => '1313 lucky lane',
90
+ :city => 'Lost Angeles',
91
+ :state => 'CA',
92
+ :zip => '90210'
93
+ }
94
+ )
95
+ assert data = @gateway.send(:post_data, @amount, @credit_card, @options)
96
+ assert REXML::Document.new(data)
97
+ end
98
+
99
+ def test_line_items_are_valid_xml
100
+ options = {:ordertype => "SALE", :action => "SUBMIT", :installments => 12, :startdate => "immediate", :periodicity => "monthly", :order_id => 1006,
101
+ :billing_address => {
102
+ :address1 => '1313 lucky lane',
103
+ :city => 'Lost Angeles',
104
+ :state => 'CA',
105
+ :zip => '90210'
106
+ },
107
+ :line_items => [{:id => '123456', :description => "Logo T-Shirt", :price =>
108
+ "12.00", :quantity => '1', :options => [{:name => "Color", :value =>
109
+ "Red"}, {:name => "Size", :value => "XL"}]},{:id => '111', :description => "keychain", :price => "3.00", :quantity => '1'}]}
110
+
111
+
112
+ assert data = @gateway.send(:post_data, @amount, @credit_card, options)
113
+ assert REXML::Document.new(data)
114
+ end
115
+
116
+ def test_declined_purchase_is_valid_xml
117
+ @gateway = LinkpointGateway.new(:login => 123123, :pem => 'PEM')
118
+
119
+ parameters = @gateway.send(:parameters, 1000, @credit_card, :ordertype => "SALE", :order_id => 1005,
120
+ :billing_address => {
121
+ :address1 => '1313 lucky lane',
122
+ :city => 'Lost Angeles',
123
+ :state => 'CA',
124
+ :zip => '90210'
125
+ }
126
+ )
127
+
128
+ assert data = @gateway.send(:post_data, @amount, @credit_card, @options)
129
+ assert REXML::Document.new(data)
130
+ end
131
+
132
+ def test_overriding_test_mode
133
+ Base.gateway_mode = :production
134
+
135
+ gateway = LinkpointGateway.new(
136
+ :login => 'LOGIN',
137
+ :pem => 'PEM',
138
+ :test => true
139
+ )
140
+
141
+ assert gateway.test?
142
+ end
143
+
144
+ def test_using_production_mode
145
+ Base.gateway_mode = :production
146
+
147
+ gateway = LinkpointGateway.new(
148
+ :login => 'LOGIN',
149
+ :pem => 'PEM'
150
+ )
151
+
152
+ assert !gateway.test?
153
+ end
154
+
155
+ def test_supported_countries
156
+ assert_equal ['US'], LinkpointGateway.supported_countries
157
+ end
158
+
159
+ def test_supported_card_types
160
+ assert_equal [:visa, :master, :american_express, :discover, :jcb, :diners_club], LinkpointGateway.supported_cardtypes
161
+ end
162
+
163
+ def test_avs_result
164
+ @gateway.expects(:ssl_post).returns(successful_authorization_response)
165
+
166
+ response = @gateway.purchase(@amount, @credit_card, @options)
167
+ assert_equal 'N', response.avs_result['code']
168
+ end
169
+
170
+ def test_cvv_result
171
+ @gateway.expects(:ssl_post).returns(successful_authorization_response)
172
+
173
+ response = @gateway.purchase(@amount, @credit_card, @options)
174
+ assert_equal 'M', response.cvv_result['code']
175
+ end
176
+
177
+ private
178
+ def successful_authorization_response
179
+ '<r_csp>CSI</r_csp><r_time>Sun Jan 6 21:41:31 2008</r_time><r_ref>0004486182</r_ref><r_error/><r_ordernum>1000</r_ordernum><r_message>APPROVED</r_message><r_code>1234560004486182:NNNM:100018312899:</r_code><r_tdate>1199680890</r_tdate><r_score/><r_authresponse/><r_approved>APPROVED</r_approved><r_avs>NNNM</r_avs>'
180
+ end
181
+
182
+ def successful_capture_response
183
+ '<r_csp>CSI</r_csp><r_time>Wed Dec 2 13:57:19 2009</r_time><r_ref>0009554566</r_ref><r_error></r_error><r_ordernum>1000</r_ordernum><r_message>ACCEPTED</r_message><r_code>0000000009554566: :9554566:</r_code><r_tdate>1259780240</r_tdate><r_score></r_score><r_authresponse></r_authresponse><r_approved>APPROVED</r_approved><r_avs> </r_avs>'
184
+ end
185
+
186
+ def successful_purchase_response
187
+ '<r_csp>CSI</r_csp><r_time>Sun Jan 6 21:45:22 2008</r_time><r_ref>0004486195</r_ref><r_error></r_error><r_ordernum>1000</r_ordernum><r_message>APPROVED</r_message><r_code>1234560004486195:NNNM:100018312912:</r_code><r_tdate>1199681121</r_tdate><r_score></r_score><r_authresponse></r_authresponse><r_approved>APPROVED</r_approved><r_avs>NNNM</r_avs>'
188
+ end
189
+
190
+ def failed_purchase_response
191
+ '<r_csp></r_csp><r_time>Sun Jan 6 21:50:51 2008</r_time><r_ref></r_ref><r_error>SGS-002300: Invalid credit card type.</r_error><r_ordernum>2aec6babe076111deb2c94c21181d9fe</r_ordernum><r_message></r_message><r_code></r_code><r_tdate></r_tdate><r_score></r_score><r_authresponse></r_authresponse><r_approved>DECLINED</r_approved><r_avs></r_avs>'
192
+ end
193
+
194
+ def successful_recurring_response
195
+ '<r_csp>CSI</r_csp><r_time>Sun Jan 6 21:49:00 2008</r_time><r_ref>0004486198</r_ref><r_error></r_error><r_ordernum>2206b7c9a31de5fb077913134011059d</r_ordernum><r_message>APPROVED</r_message><r_code>1234560004486198:NNNM:100018312915:</r_code><r_tdate>1199681339</r_tdate><r_score></r_score><r_authresponse></r_authresponse><r_approved>APPROVED</r_approved><r_avs>NNN</r_avs>'
196
+ end
197
+ end
@@ -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