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,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
@@ -0,0 +1,162 @@
1
+ require 'test_helper'
2
+
3
+ class ModernPaymentsCimTest < Test::Unit::TestCase
4
+ def setup
5
+ Base.mode = :test
6
+
7
+ @gateway = ModernPaymentsCimGateway.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_create_customer
23
+ @gateway.expects(:ssl_post).returns(successful_create_customer_response)
24
+
25
+ assert response = @gateway.create_customer(@options)
26
+ assert_instance_of Response, response
27
+ assert response.test?
28
+ assert_success response
29
+ assert_equal "6677348", response.params["create_customer_result"]
30
+ end
31
+
32
+ def test_modify_customer_credit_card
33
+ @gateway.expects(:ssl_post).returns(successful_modify_customer_credit_card_response)
34
+
35
+ assert response = @gateway.modify_customer_credit_card("10001", @credit_card)
36
+ assert_instance_of Response, response
37
+ assert response.test?
38
+ assert_success response
39
+ assert_equal "6677757", response.params["modify_customer_credit_card_result"]
40
+ end
41
+
42
+ def test_successful_credit_card_authorization
43
+ @gateway.expects(:ssl_post).returns(successful_authorization_response)
44
+
45
+ assert response = @gateway.authorize_credit_card_payment("10001", @amount)
46
+ assert_instance_of Response, response
47
+ assert response.test?
48
+
49
+ assert_success response
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']
60
+ end
61
+
62
+ def test_unsuccessful_credit_card_authorization
63
+ @gateway.expects(:ssl_post).returns(unsuccessful_credit_card_authorization_response)
64
+
65
+ assert response = @gateway.authorize_credit_card_payment("10001", @amount)
66
+ assert_instance_of Response, response
67
+ assert response.test?
68
+ assert_failure response
69
+ assert_equal "999", response.authorization
70
+ assert_match /RESPONSECODE=D/, response.params["message_text"]
71
+ end
72
+
73
+ def test_soap_fault_response
74
+ @gateway.expects(:ssl_post).returns(soap_fault_response)
75
+
76
+ assert response = @gateway.create_customer(@options)
77
+ assert_instance_of Response, response
78
+ assert response.test?
79
+ assert_failure response
80
+ assert_equal "soap:Client", response.params["faultcode"]
81
+ end
82
+
83
+ private
84
+
85
+ def successful_create_customer_response
86
+ <<-XML
87
+ <?xml version="1.0" encoding="utf-8"?>
88
+ <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">
89
+ <soap:Body>
90
+ <CreateCustomerResponse xmlns="http://secure.modpay.com:81/ws/">
91
+ <CreateCustomerResult>6677348</CreateCustomerResult>
92
+ </CreateCustomerResponse>
93
+ </soap:Body>
94
+ </soap:Envelope>
95
+ XML
96
+ end
97
+
98
+ def successful_modify_customer_credit_card_response
99
+ <<-XML
100
+ <?xml version="1.0" encoding="utf-8"?>
101
+ <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">
102
+ <soap:Body>
103
+ <ModifyCustomerCreditCardResponse xmlns="http://secure.modpay.com:81/ws/">
104
+ <ModifyCustomerCreditCardResult>6677757</ModifyCustomerCreditCardResult>
105
+ </ModifyCustomerCreditCardResponse>
106
+ </soap:Body>
107
+ </soap:Envelope>
108
+ XML
109
+ end
110
+
111
+ def unsuccessful_credit_card_authorization_response
112
+ <<-XML
113
+ <?xml version="1.0" encoding="utf-8"?>
114
+ <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">
115
+ <soap:Body>
116
+ <AuthorizeCreditCardPaymentResponse xmlns="https://secure.modpay.com/netservices/test/">
117
+ <AuthorizeCreditCardPaymentResult>
118
+ <transId>999</transId>
119
+ <authCode/>
120
+ <avsCode/>
121
+ <transCode/>
122
+ <authString>RESPONSECODE=D,AUTHCODE=,DECLINEREASON.1.TAG=,DECLINEREASON.1.ERRORCLASS=card declined,DECLINEREASON.1.PARAM1=05:DECLINE,DECLINEREASON.1.PARAM2=The authorization is declined,DECLINEREASON.1.MESSAGE=Card was declined: The authorization is declined,AVSDATA</authString>
123
+ <messageText>RESPONSECODE=D,AUTHCODE=,DECLINEREASON.1.TAG=,DECLINEREASON.1.ERRORCLASS=card declined,DECLINEREASON.1.PARAM1=05:DECLINE,DECLINEREASON.1.PARAM2=The authorization is declined,DECLINEREASON.1.MESSAGE=Card was declined: The authorization is declined,AVSDATA</messageText>
124
+ <approved>false</approved>
125
+ </AuthorizeCreditCardPaymentResult>
126
+ </AuthorizeCreditCardPaymentResponse>
127
+ </soap:Body>
128
+ </soap:Envelope>
129
+ XML
130
+ end
131
+
132
+ def soap_fault_response
133
+ <<-XML
134
+ <?xml version="1.0" encoding="utf-8"?>
135
+ <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">
136
+ <soap:Body>
137
+ <soap:Fault>
138
+ <faultcode>soap:Client</faultcode>
139
+ <faultstring>System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: h heheheh http://secure.modpay.com:81/ws/CreateCustomer.
140
+ at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()
141
+ at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)
142
+ at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
143
+ at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean&amp; abortProcessing)</faultstring>
144
+ <detail/>
145
+ </soap:Fault>
146
+ </soap:Body>
147
+ </soap:Envelope>
148
+ XML
149
+ end
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
162
+ end
@@ -0,0 +1,158 @@
1
+ require 'test_helper'
2
+
3
+ class MonerisTest < Test::Unit::TestCase
4
+ def setup
5
+ Base.mode = :test
6
+
7
+ @gateway = MonerisGateway.new(
8
+ :login => 'store1',
9
+ :password => 'yesguy'
10
+ )
11
+
12
+ @amount = 100
13
+ @credit_card = credit_card('4242424242424242')
14
+ @options = { :order_id => '1', :billing_address => address }
15
+ end
16
+
17
+ def test_successful_purchase
18
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
19
+
20
+ assert response = @gateway.authorize(100, @credit_card, @options)
21
+ assert_success response
22
+ assert_equal '58-0_3;1026.1', response.authorization
23
+ end
24
+
25
+ def test_failed_purchase
26
+ @gateway.expects(:ssl_post).returns(failed_purchase_response)
27
+
28
+ assert response = @gateway.authorize(100, @credit_card, @options)
29
+ assert_failure response
30
+ end
31
+
32
+ def test_amount_style
33
+ assert_equal '10.34', @gateway.send(:amount, 1034)
34
+
35
+ assert_raise(ArgumentError) do
36
+ @gateway.send(:amount, '10.34')
37
+ end
38
+ end
39
+
40
+ def test_purchase_is_valid_xml
41
+
42
+ params = {
43
+ :order_id => "order1",
44
+ :amount => "1.01",
45
+ :pan => "4242424242424242",
46
+ :expdate => "0303",
47
+ :crypt_type => 7,
48
+ }
49
+
50
+ assert data = @gateway.send(:post_data, 'preauth', params)
51
+ assert REXML::Document.new(data)
52
+ assert_equal xml_capture_fixture.size, data.size
53
+ end
54
+
55
+ def test_purchase_is_valid_xml
56
+
57
+ params = {
58
+ :order_id => "order1",
59
+ :amount => "1.01",
60
+ :pan => "4242424242424242",
61
+ :expdate => "0303",
62
+ :crypt_type => 7,
63
+ }
64
+
65
+ assert data = @gateway.send(:post_data, 'purchase', params)
66
+ assert REXML::Document.new(data)
67
+ assert_equal xml_purchase_fixture.size, data.size
68
+ end
69
+
70
+ def test_capture_is_valid_xml
71
+
72
+ params = {
73
+ :order_id => "order1",
74
+ :amount => "1.01",
75
+ :pan => "4242424242424242",
76
+ :expdate => "0303",
77
+ :crypt_type => 7,
78
+ }
79
+
80
+ assert data = @gateway.send(:post_data, 'preauth', params)
81
+ assert REXML::Document.new(data)
82
+ assert_equal xml_capture_fixture.size, data.size
83
+ end
84
+
85
+ def test_supported_countries
86
+ assert_equal ['CA'], MonerisGateway.supported_countries
87
+ end
88
+
89
+ def test_supported_card_types
90
+ assert_equal [:visa, :master, :american_express], MonerisGateway.supported_cardtypes
91
+ end
92
+
93
+ def test_should_raise_error_if_transaction_param_empty_on_credit_request
94
+ [nil, '', '1234'].each do |invalid_transaction_param|
95
+ assert_raise(ArgumentError) { @gateway.void(invalid_transaction_param) }
96
+ end
97
+ end
98
+
99
+ private
100
+ def successful_purchase_response
101
+ <<-RESPONSE
102
+ <?xml version="1.0"?>
103
+ <response>
104
+ <receipt>
105
+ <ReceiptId>1026.1</ReceiptId>
106
+ <ReferenceNum>661221050010170010</ReferenceNum>
107
+ <ResponseCode>027</ResponseCode>
108
+ <ISO>01</ISO>
109
+ <AuthCode>013511</AuthCode>
110
+ <TransTime>18:41:13</TransTime>
111
+ <TransDate>2008-01-05</TransDate>
112
+ <TransType>00</TransType>
113
+ <Complete>true</Complete>
114
+ <Message>APPROVED * =</Message>
115
+ <TransAmount>1.00</TransAmount>
116
+ <CardType>V</CardType>
117
+ <TransID>58-0_3</TransID>
118
+ <TimedOut>false</TimedOut>
119
+ </receipt>
120
+ </response>
121
+
122
+ RESPONSE
123
+ end
124
+
125
+ def failed_purchase_response
126
+ <<-RESPONSE
127
+ <?xml version="1.0"?>
128
+ <response>
129
+ <receipt>
130
+ <ReceiptId>1026.1</ReceiptId>
131
+ <ReferenceNum>661221050010170010</ReferenceNum>
132
+ <ResponseCode>481</ResponseCode>
133
+ <ISO>01</ISO>
134
+ <AuthCode>013511</AuthCode>
135
+ <TransTime>18:41:13</TransTime>
136
+ <TransDate>2008-01-05</TransDate>
137
+ <TransType>00</TransType>
138
+ <Complete>true</Complete>
139
+ <Message>DECLINED * =</Message>
140
+ <TransAmount>1.00</TransAmount>
141
+ <CardType>V</CardType>
142
+ <TransID>97-2-0</TransID>
143
+ <TimedOut>false</TimedOut>
144
+ </receipt>
145
+ </response>
146
+
147
+ RESPONSE
148
+ end
149
+
150
+ def xml_purchase_fixture
151
+ '<request><store_id>store1</store_id><api_token>yesguy</api_token><purchase><amount>1.01</amount><pan>4242424242424242</pan><expdate>0303</expdate><crypt_type>7</crypt_type><order_id>order1</order_id></purchase></request>'
152
+ end
153
+
154
+ def xml_capture_fixture
155
+ '<request><store_id>store1</store_id><api_token>yesguy</api_token><preauth><amount>1.01</amount><pan>4242424242424242</pan><expdate>0303</expdate><crypt_type>7</crypt_type><order_id>order1</order_id></preauth></request>'
156
+ end
157
+
158
+ end