activemerchant 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +226 -0
  3. data/CONTRIBUTERS +52 -0
  4. data/README +34 -24
  5. data/Rakefile +152 -0
  6. data/gem-public_cert.pem +20 -0
  7. data/init.rb +3 -0
  8. data/lib/active_merchant.rb +3 -1
  9. data/lib/active_merchant/billing/credit_card.rb +21 -17
  10. data/lib/active_merchant/billing/credit_card_methods.rb +17 -19
  11. data/lib/active_merchant/billing/gateway.rb +160 -44
  12. data/lib/active_merchant/billing/gateways.rb +2 -15
  13. data/lib/active_merchant/billing/gateways/authorize_net.rb +21 -21
  14. data/lib/active_merchant/billing/gateways/bogus.rb +6 -6
  15. data/lib/active_merchant/billing/gateways/brain_tree.rb +191 -0
  16. data/lib/active_merchant/billing/gateways/card_stream.rb +207 -0
  17. data/lib/active_merchant/billing/gateways/cyber_source.rb +402 -0
  18. data/lib/active_merchant/billing/gateways/data_cash.rb +41 -97
  19. data/lib/active_merchant/billing/gateways/efsnet.rb +256 -0
  20. data/lib/active_merchant/billing/gateways/eway.rb +77 -29
  21. data/lib/active_merchant/billing/gateways/exact.rb +230 -0
  22. data/lib/active_merchant/billing/gateways/linkpoint.rb +6 -33
  23. data/lib/active_merchant/billing/gateways/moneris.rb +155 -125
  24. data/lib/active_merchant/billing/gateways/net_registry.rb +257 -0
  25. data/lib/active_merchant/billing/gateways/pay_junction.rb +407 -0
  26. data/lib/active_merchant/billing/gateways/payflow.rb +163 -25
  27. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +56 -38
  28. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +10 -1
  29. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +9 -0
  30. data/lib/active_merchant/billing/gateways/payflow_express.rb +36 -11
  31. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +6 -0
  32. data/lib/active_merchant/billing/gateways/payflow_uk.rb +7 -3
  33. data/lib/active_merchant/billing/gateways/payment_express.rb +261 -0
  34. data/lib/active_merchant/billing/gateways/paypal.rb +18 -4
  35. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +31 -15
  36. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +8 -0
  37. data/lib/active_merchant/billing/gateways/paypal_express.rb +33 -8
  38. data/lib/active_merchant/billing/gateways/plugnpay.rb +300 -0
  39. data/lib/active_merchant/billing/gateways/protx.rb +285 -0
  40. data/lib/active_merchant/billing/gateways/psigate.rb +13 -12
  41. data/lib/active_merchant/billing/gateways/psl_card.rb +297 -0
  42. data/lib/active_merchant/billing/gateways/quickpay.rb +197 -0
  43. data/lib/active_merchant/billing/gateways/realex.rb +212 -0
  44. data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
  45. data/lib/active_merchant/billing/gateways/trans_first.rb +136 -0
  46. data/lib/active_merchant/billing/gateways/trust_commerce.rb +43 -20
  47. data/lib/active_merchant/billing/gateways/usa_epay.rb +6 -5
  48. data/lib/active_merchant/billing/gateways/verifi.rb +235 -0
  49. data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
  50. data/lib/active_merchant/billing/integrations/gestpay/helper.rb +0 -2
  51. data/lib/active_merchant/billing/integrations/helper.rb +8 -1
  52. data/lib/active_merchant/billing/integrations/nochex.rb +62 -1
  53. data/lib/active_merchant/billing/integrations/nochex/notification.rb +9 -16
  54. data/lib/active_merchant/billing/integrations/notification.rb +1 -1
  55. data/lib/active_merchant/billing/integrations/paypal/helper.rb +59 -46
  56. data/lib/active_merchant/billing/integrations/paypal/notification.rb +14 -47
  57. data/lib/active_merchant/lib/error.rb +4 -0
  58. data/lib/active_merchant/lib/post_data.rb +22 -0
  59. data/lib/active_merchant/lib/posts_data.rb +23 -5
  60. data/lib/active_merchant/lib/requires_parameters.rb +2 -2
  61. data/lib/active_merchant/lib/validateable.rb +1 -1
  62. data/lib/support/gateway_support.rb +45 -0
  63. data/lib/tasks/cia.rb +1 -1
  64. data/script/generate +14 -0
  65. data/script/generator/base.rb +45 -0
  66. data/script/generator/generator.rb +24 -0
  67. data/script/generator/generators/gateway/gateway_generator.rb +14 -0
  68. data/script/generator/generators/gateway/templates/gateway.rb +73 -0
  69. data/script/generator/generators/gateway/templates/gateway_test.rb +41 -0
  70. data/script/generator/generators/gateway/templates/remote_gateway_test.rb +56 -0
  71. data/script/generator/generators/integration/integration_generator.rb +25 -0
  72. data/script/generator/generators/integration/templates/helper.rb +34 -0
  73. data/script/generator/generators/integration/templates/helper_test.rb +54 -0
  74. data/script/generator/generators/integration/templates/integration.rb +18 -0
  75. data/script/generator/generators/integration/templates/module_test.rb +9 -0
  76. data/script/generator/generators/integration/templates/notification.rb +100 -0
  77. data/script/generator/generators/integration/templates/notification_test.rb +41 -0
  78. data/script/generator/manifest.rb +20 -0
  79. data/test/extra/binding_of_caller.rb +80 -0
  80. data/test/extra/breakpoint.rb +547 -0
  81. data/test/fixtures.yml +251 -0
  82. data/test/remote_tests/remote_authorize_net_test.rb +113 -0
  83. data/test/remote_tests/remote_brain_tree_test.rb +78 -0
  84. data/test/remote_tests/remote_card_stream_test.rb +160 -0
  85. data/test/remote_tests/remote_cyber_source_test.rb +130 -0
  86. data/test/remote_tests/remote_data_cash_test.rb +155 -0
  87. data/test/remote_tests/remote_efsnet_test.rb +93 -0
  88. data/test/remote_tests/remote_eway_test.rb +71 -0
  89. data/test/remote_tests/remote_exact_test.rb +59 -0
  90. data/test/remote_tests/remote_gestpay_integration_test.rb +37 -0
  91. data/test/remote_tests/remote_linkpoint_test.rb +144 -0
  92. data/test/remote_tests/remote_moneris_test.rb +110 -0
  93. data/test/remote_tests/remote_net_registry_test.rb +120 -0
  94. data/test/remote_tests/remote_pay_junction_test.rb +162 -0
  95. data/test/remote_tests/remote_payflow_express_test.rb +50 -0
  96. data/test/remote_tests/remote_payflow_test.rb +241 -0
  97. data/test/remote_tests/remote_payflow_uk_test.rb +172 -0
  98. data/test/remote_tests/remote_payment_express_test.rb +136 -0
  99. data/test/remote_tests/remote_paypal_express_test.rb +49 -0
  100. data/test/remote_tests/remote_paypal_integration_test.rb +14 -0
  101. data/test/remote_tests/remote_paypal_test.rb +163 -0
  102. data/test/remote_tests/remote_plugnpay_test.rb +70 -0
  103. data/test/remote_tests/remote_protx_test.rb +184 -0
  104. data/test/remote_tests/remote_psigate_test.rb +87 -0
  105. data/test/remote_tests/remote_psl_card_test.rb +105 -0
  106. data/test/remote_tests/remote_quickpay_test.rb +182 -0
  107. data/test/remote_tests/remote_realex_test.rb +227 -0
  108. data/test/remote_tests/remote_secure_pay_test.rb +36 -0
  109. data/test/remote_tests/remote_trans_first_test.rb +37 -0
  110. data/test/remote_tests/remote_trust_commerce_test.rb +136 -0
  111. data/test/remote_tests/remote_usa_epay_test.rb +57 -0
  112. data/test/remote_tests/remote_verifi_test.rb +107 -0
  113. data/test/remote_tests/remote_viaklix_test.rb +53 -0
  114. data/test/test_helper.rb +132 -0
  115. data/test/unit/base_test.rb +61 -0
  116. data/test/unit/country_code_test.rb +33 -0
  117. data/test/unit/country_test.rb +64 -0
  118. data/test/unit/credit_card_formatting_test.rb +24 -0
  119. data/test/unit/credit_card_methods_test.rb +37 -0
  120. data/test/unit/credit_card_test.rb +365 -0
  121. data/test/unit/gateways/authorize_net_test.rb +140 -0
  122. data/test/unit/gateways/bogus_test.rb +43 -0
  123. data/test/unit/gateways/brain_tree_test.rb +77 -0
  124. data/test/unit/gateways/card_stream_test.rb +37 -0
  125. data/test/unit/gateways/cyber_source_test.rb +151 -0
  126. data/test/unit/gateways/data_cash_test.rb +23 -0
  127. data/test/unit/gateways/efsnet_test.rb +70 -0
  128. data/test/unit/gateways/eway_test.rb +105 -0
  129. data/test/unit/gateways/exact_test.rb +118 -0
  130. data/test/unit/gateways/gateway_test.rb +24 -0
  131. data/test/unit/gateways/linkpoint_test.rb +165 -0
  132. data/test/unit/gateways/moneris_test.rb +167 -0
  133. data/test/unit/gateways/net_registry_test.rb +478 -0
  134. data/test/unit/gateways/pay_junction_test.rb +61 -0
  135. data/test/unit/gateways/payflow_express_test.rb +165 -0
  136. data/test/unit/gateways/payflow_express_uk_test.rb +14 -0
  137. data/test/unit/gateways/payflow_test.rb +230 -0
  138. data/test/unit/gateways/payflow_uk_test.rb +68 -0
  139. data/test/unit/gateways/payment_express_test.rb +215 -0
  140. data/test/unit/gateways/paypal_express_test.rb +222 -0
  141. data/test/unit/gateways/paypal_test.rb +241 -0
  142. data/test/unit/gateways/plugnpay_test.rb +79 -0
  143. data/test/unit/gateways/protx_test.rb +110 -0
  144. data/test/unit/gateways/psigate_test.rb +110 -0
  145. data/test/unit/gateways/psl_card_test.rb +51 -0
  146. data/test/unit/gateways/quickpay_test.rb +125 -0
  147. data/test/unit/gateways/realex_test.rb +150 -0
  148. data/test/unit/gateways/secure_pay_test.rb +78 -0
  149. data/test/unit/gateways/trans_first_test.rb +125 -0
  150. data/test/unit/gateways/trust_commerce_test.rb +57 -0
  151. data/test/unit/gateways/usa_epay_test.rb +117 -0
  152. data/test/unit/gateways/verifi_test.rb +91 -0
  153. data/test/unit/gateways/viaklix_test.rb +72 -0
  154. data/test/unit/integrations/action_view_helper_test.rb +54 -0
  155. data/test/unit/integrations/bogus_module_test.rb +16 -0
  156. data/test/unit/integrations/chronopay_module_test.rb +9 -0
  157. data/test/unit/integrations/gestpay_module_test.rb +10 -0
  158. data/test/unit/integrations/helpers/bogus_helper_test.rb +28 -0
  159. data/test/unit/integrations/helpers/chronopay_helper_test.rb +67 -0
  160. data/test/unit/integrations/helpers/gestpay_helper_test.rb +100 -0
  161. data/test/unit/integrations/helpers/nochex_helper_test.rb +53 -0
  162. data/test/unit/integrations/helpers/paypal_helper_test.rb +162 -0
  163. data/test/unit/integrations/helpers/two_checkout_helper_test.rb +92 -0
  164. data/test/unit/integrations/nochex_module_test.rb +9 -0
  165. data/test/unit/integrations/notifications/chronopay_notification_test.rb +66 -0
  166. data/test/unit/integrations/notifications/gestpay_notification_test.rb +60 -0
  167. data/test/unit/integrations/notifications/nochex_notification_test.rb +51 -0
  168. data/test/unit/integrations/notifications/notification_test.rb +41 -0
  169. data/test/unit/integrations/notifications/paypal_notification_test.rb +85 -0
  170. data/test/unit/integrations/notifications/two_checkout_notification_test.rb +55 -0
  171. data/test/unit/integrations/paypal_module_test.rb +24 -0
  172. data/test/unit/integrations/two_checkout_module_test.rb +9 -0
  173. data/test/unit/post_data_test.rb +55 -0
  174. data/test/unit/response_test.rb +14 -0
  175. data/test/unit/validateable_test.rb +56 -0
  176. metadata +160 -7
  177. metadata.gz.sig +0 -0
  178. data/lib/active_merchant/billing/gateways/payflow/f73e89fd.0 +0 -17
@@ -0,0 +1,241 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class PaypalTest < Test::Unit::TestCase
4
+ def setup
5
+ @gateway = PaypalGateway.new(
6
+ :login => 'cody',
7
+ :password => 'test',
8
+ :pem => ''
9
+ )
10
+
11
+ @address = { :address1 => '1234 My Street',
12
+ :address2 => 'Apt 1',
13
+ :company => 'Widgets Inc',
14
+ :city => 'Ottawa',
15
+ :state => 'ON',
16
+ :zip => 'K1C2N6',
17
+ :country => 'Canada',
18
+ :phone => '(555)555-5555'
19
+ }
20
+
21
+ @creditcard = credit_card('4242424242424242')
22
+
23
+ Base.gateway_mode = :test
24
+ end
25
+
26
+ def teardown
27
+ Base.gateway_mode = :test
28
+ PaypalGateway.pem_file = nil
29
+ end
30
+
31
+ def test_no_ip_address
32
+ assert_raise(ArgumentError){ @gateway.purchase(100, @creditcard, :address => @address)}
33
+ end
34
+
35
+ def test_purchase_success
36
+ @creditcard.number = 1
37
+
38
+ assert response = @gateway.purchase(100, @creditcard, :address => @address, :ip => '127.0.0.1')
39
+ assert_equal Response, response.class
40
+ assert_equal '#0001', response.params['receiptid']
41
+ assert_equal true, response.success?
42
+ end
43
+
44
+ def test_purchase_error
45
+ @creditcard.number = 2
46
+
47
+ assert response = @gateway.purchase(100, @creditcard, :order_id => 1, :address => @address, :ip => '127.0.0.1')
48
+ assert_equal Response, response.class
49
+ assert_equal '#0001', response.params['receiptid']
50
+ assert_equal false, response.success?
51
+
52
+ end
53
+
54
+ def test_reauthorization
55
+ @gateway.expects(:ssl_post).returns(successful_reauthorization_response)
56
+ response = @gateway.reauthorize(1000, '32J876265E528623B')
57
+ assert response.success?
58
+ assert_equal('1TX27389GX108740X', response.authorization)
59
+ assert response.test?
60
+ end
61
+
62
+ def test_purchase_exceptions
63
+ @creditcard.number = 3
64
+
65
+ assert_raise(Error) do
66
+ assert response = @gateway.purchase(100, @creditcard, :order_id => 1, :address => @address, :ip => '127.0.0.1')
67
+ end
68
+ end
69
+
70
+ def test_amount_style
71
+ assert_equal '10.34', @gateway.send(:amount, 1034)
72
+
73
+ assert_raise(ArgumentError) do
74
+ @gateway.send(:amount, '10.34')
75
+ end
76
+ end
77
+
78
+ def test_paypal_timeout_error
79
+ @gateway.stubs(:ssl_post).returns(paypal_timeout_error_response)
80
+ response = @gateway.purchase(100, @creditcard, :order_id => 1, :address => @address, :ip => '127.0.0.1')
81
+ assert_equal "SOAP-ENV:Server", response.params['faultcode']
82
+ assert_equal "Internal error", response.params['faultstring']
83
+ assert_equal "Timeout processing request", response.params['detail']
84
+ assert_equal "SOAP-ENV:Server: Internal error - Timeout processing request", response.message
85
+ end
86
+
87
+ def test_pem_file_accessor
88
+ PaypalGateway.pem_file = '123456'
89
+ gateway = PaypalGateway.new(:login => 'test', :password => 'test')
90
+ assert_equal '123456', gateway.options[:pem]
91
+ end
92
+
93
+ def test_passed_in_pem_overrides_class_accessor
94
+ PaypalGateway.pem_file = '123456'
95
+ gateway = PaypalGateway.new(:login => 'test', :password => 'test', :pem => 'Clobber')
96
+ assert_equal 'Clobber', gateway.options[:pem]
97
+ end
98
+
99
+ def test_ensure_options_are_transferred_to_express_instance
100
+ PaypalGateway.pem_file = '123456'
101
+ gateway = PaypalGateway.new(:login => 'test', :password => 'password')
102
+ express = gateway.express
103
+ assert_instance_of PaypalExpressGateway, express
104
+ assert_equal 'test', express.options[:login]
105
+ assert_equal 'password', express.options[:password]
106
+ assert_equal '123456', express.options[:pem]
107
+ end
108
+
109
+ def test_successful_state_lookup
110
+ assert_equal 'AB', @gateway.send(:lookup_state, { :country => 'CA', :state => 'AB'})
111
+ end
112
+
113
+ def test_lookup_unknown_state
114
+ assert_equal '', @gateway.send(:lookup_state, { :country => 'XX', :state => 'NA'})
115
+ end
116
+
117
+ def test_lookup_uk_with_state
118
+ assert_equal 'Avon', @gateway.send(:lookup_state, { :country => 'United Kingdom', :state => 'Avon'})
119
+ end
120
+
121
+ def test_lookup_uk_with_no_state
122
+ assert_equal 'N/A', @gateway.send(:lookup_state, { :country => 'GB', :state => '' })
123
+ end
124
+
125
+ def test_lookup_australian_state
126
+ assert_equal 'Australian Capital Territory', @gateway.send(:lookup_state, { :country => 'AU', :state => 'ACT'} )
127
+ end
128
+
129
+ def test_supported_countries
130
+ assert_equal ['US'], PaypalGateway.supported_countries
131
+ end
132
+
133
+ def test_supported_card_types
134
+ assert_equal [:visa, :master, :american_express, :discover], PaypalGateway.supported_cardtypes
135
+ end
136
+
137
+ def test_button_source
138
+ PaypalGateway.application_id = 'ActiveMerchant_DC'
139
+
140
+ xml = REXML::Document.new(@gateway.send(:build_sale_or_authorization_request, 'Test', 100, @creditcard, {}))
141
+ assert_equal 'ActiveMerchant_DC', REXML::XPath.first(xml, '//n2:ButtonSource').text
142
+ end
143
+
144
+ def test_item_total_shipping_handling_and_tax_not_included_unless_all_are_present
145
+ xml = @gateway.send(:build_sale_or_authorization_request, 'Authorization', 100, @creditcard,
146
+ :tax => 100,
147
+ :shipping => 100,
148
+ :handling => 100
149
+ )
150
+
151
+ doc = REXML::Document.new(xml)
152
+ assert_nil REXML::XPath.first(doc, '//n2:PaymentDetails/n2:TaxTotal')
153
+ end
154
+
155
+ def test_item_total_shipping_handling_and_tax
156
+ xml = @gateway.send(:build_sale_or_authorization_request, 'Authorization', 100, @creditcard,
157
+ :tax => 100,
158
+ :shipping => 100,
159
+ :handling => 100,
160
+ :subtotal => 200
161
+ )
162
+
163
+ doc = REXML::Document.new(xml)
164
+ assert_equal '1.00', REXML::XPath.first(doc, '//n2:PaymentDetails/n2:TaxTotal').text
165
+ end
166
+
167
+ private
168
+ def paypal_timeout_error_response
169
+ <<-RESPONSE
170
+ <?xml version='1.0' encoding='UTF-8'?>
171
+ <SOAP-ENV:Envelope xmlns:cc='urn:ebay:apis:CoreComponentTypes' xmlns:sizeship='urn:ebay:api:PayPalAPI/sizeship.xsd' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/' xmlns:saml='urn:oasis:names:tc:SAML:1.0:assertion' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:wsu='http://schemas.xmlsoap.org/ws/2002/07/utility' xmlns:ebl='urn:ebay:apis:eBLBaseComponents' xmlns:ds='http://www.w3.org/2000/09/xmldsig#' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:ns='urn:ebay:api:PayPalAPI' xmlns:market='urn:ebay:apis:Market' xmlns:ship='urn:ebay:apis:ship' xmlns:auction='urn:ebay:apis:Auction' xmlns:wsse='http://schemas.xmlsoap.org/ws/2002/12/secext' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
172
+ <SOAP-ENV:Header>
173
+ <Security xsi:type='wsse:SecurityType' xmlns='http://schemas.xmlsoap.org/ws/2002/12/secext'/>
174
+ <RequesterCredentials xsi:type='ebl:CustomSecurityHeaderType' xmlns='urn:ebay:api:PayPalAPI'>
175
+ <Credentials xsi:type='ebl:UserIdPasswordType' xmlns='urn:ebay:apis:eBLBaseComponents'>
176
+ <Username xsi:type='xs:string'/>
177
+ <Password xsi:type='xs:string'/>
178
+ <Subject xsi:type='xs:string'/>
179
+ </Credentials>
180
+ </RequesterCredentials>
181
+ </SOAP-ENV:Header>
182
+ <SOAP-ENV:Body id='_0'>
183
+ <SOAP-ENV:Fault>
184
+ <faultcode>SOAP-ENV:Server</faultcode>
185
+ <faultstring>Internal error</faultstring>
186
+ <detail>Timeout processing request</detail>
187
+ </SOAP-ENV:Fault>
188
+ </SOAP-ENV:Body>
189
+ </SOAP-ENV:Envelope>
190
+ RESPONSE
191
+ end
192
+
193
+ def successful_reauthorization_response
194
+ <<-RESPONSE
195
+ <?xml version="1.0" encoding="UTF-8"?>
196
+ <SOAP-ENV:Envelope
197
+ xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
198
+ xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
199
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
200
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
201
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
202
+ xmlns:cc="urn:ebay:apis:CoreComponentTypes"
203
+ xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility"
204
+ xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
205
+ xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
206
+ xmlns:market="urn:ebay:apis:Market"
207
+ xmlns:auction="urn:ebay:apis:Auction"
208
+ xmlns:sizeship="urn:ebay:api:PayPalAPI/sizeship.xsd"
209
+ xmlns:ship="urn:ebay:apis:ship"
210
+ xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext"
211
+ xmlns:ebl="urn:ebay:apis:eBLBaseComponents"
212
+ xmlns:ns="urn:ebay:api:PayPalAPI">
213
+ <SOAP-ENV:Header>
214
+ <Security
215
+ xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext"
216
+ xsi:type="wsse:SecurityType">
217
+ </Security>
218
+ <RequesterCredentials xmlns="urn:ebay:api:PayPalAPI"
219
+ xsi:type="ebl:CustomSecurityHeaderType">
220
+ <Credentials xmlns="urn:ebay:apis:eBLBaseComponents"
221
+ xsi:type="ebl:UserIdPasswordType">
222
+ <Username xsi:type="xs:string"></Username>
223
+ <Password xsi:type="xs:string"></Password>
224
+ <Subject xsi:type="xs:string"></Subject>
225
+ </Credentials>
226
+ </RequesterCredentials>
227
+ </SOAP-ENV:Header>
228
+ <SOAP-ENV:Body id="_0">
229
+ <DoReauthorizationResponse xmlns="urn:ebay:api:PayPalAPI">
230
+ <Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">2007-03-04T23:34:42Z</Timestamp>
231
+ <Ack xmlns="urn:ebay:apis:eBLBaseComponents">Success</Ack>
232
+ <CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">e444ddb7b3ed9</CorrelationID>
233
+ <Version xmlns="urn:ebay:apis:eBLBaseComponents">2.000000</Version>
234
+ <Build xmlns="urn:ebay:apis:eBLBaseComponents">1.0006</Build>
235
+ <AuthorizationID xsi:type="ebl:AuthorizationId">1TX27389GX108740X</AuthorizationID>
236
+ </DoReauthorizationResponse>
237
+ </SOAP-ENV:Body>
238
+ </SOAP-ENV:Envelope>
239
+ RESPONSE
240
+ end
241
+ end
@@ -0,0 +1,79 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class PlugnpayTest < Test::Unit::TestCase
4
+ include ActiveMerchant::Billing
5
+
6
+ def setup
7
+ ActiveMerchant::Billing::Base.mode = :test
8
+
9
+ @login = 'X'
10
+ @password = 'Y'
11
+
12
+ @gateway = PlugnpayGateway.new(
13
+ :login => @login,
14
+ :password => @password,
15
+ :debug => true )
16
+
17
+ @creditcard = credit_card('4242424242424242')
18
+ end
19
+
20
+ def test_purchase_success
21
+ @creditcard.number = 1
22
+
23
+ assert response = @gateway.purchase(1000, @creditcard)
24
+ assert_equal Response, response.class
25
+ assert_equal true, response.success?
26
+ end
27
+
28
+ def test_purchase_error
29
+ @creditcard.number = 2
30
+
31
+ assert response = @gateway.purchase(1000, @creditcard)
32
+ assert_equal Response, response.class
33
+ assert_equal false, response.success?
34
+ end
35
+
36
+ def test_purchase_exceptions
37
+ @creditcard.number = 3
38
+
39
+ assert_raise(Error) do
40
+ assert response = @gateway.purchase(1000, @creditcard, :order_id => 1)
41
+ end
42
+ end
43
+
44
+ def test_amount_style
45
+ assert_equal '10.34', @gateway.send(:amount, Money.new(1034))
46
+ assert_equal '10.34', @gateway.send(:amount, 1034)
47
+
48
+ assert_raise(ArgumentError) do
49
+ @gateway.send(:amount, '10.34')
50
+ end
51
+ end
52
+
53
+ def test_add_address_outsite_north_america
54
+ result = PlugnpayGateway::PlugnpayPostData.new
55
+
56
+ @gateway.send(:add_addresses, result, :billing_address => {:address1 => '164 Waverley Street', :country => 'DE', :state => 'Dortmund'} )
57
+
58
+ assert_equal result[:state], 'ZZ'
59
+ assert_equal result[:province], 'Dortmund'
60
+
61
+ assert_equal result[:card_state], 'ZZ'
62
+ assert_equal result[:card_prov], 'Dortmund'
63
+
64
+ assert_equal result[:card_address1], '164 Waverley Street'
65
+ assert_equal result[:card_country], 'DE'
66
+
67
+ end
68
+
69
+ def test_add_address
70
+ result = PlugnpayGateway::PlugnpayPostData.new
71
+
72
+ @gateway.send(:add_addresses, result, :billing_address => {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'} )
73
+
74
+ assert_equal result[:card_state], 'CO'
75
+ assert_equal result[:card_address1], '164 Waverley Street'
76
+ assert_equal result[:card_country], 'US'
77
+
78
+ end
79
+ end
@@ -0,0 +1,110 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class ProtxTest < Test::Unit::TestCase
4
+ def setup
5
+ @gateway = ProtxGateway.new(
6
+ :login => 'X'
7
+ )
8
+
9
+ @creditcard = credit_card('4242424242424242', :type => 'visa')
10
+ end
11
+
12
+ def test_purchase_success
13
+ @creditcard.number = 1
14
+
15
+ assert response = @gateway.purchase(100, @creditcard, :order_id => 1)
16
+ assert_equal Response, response.class
17
+ assert_equal '#0001', response.params['receiptid']
18
+ assert_success response
19
+ end
20
+
21
+ def test_purchase_error
22
+ @creditcard.number = 2
23
+
24
+ assert response = @gateway.purchase(100, @creditcard, :order_id => 1)
25
+ assert_equal Response, response.class
26
+ assert_equal '#0001', response.params['receiptid']
27
+ assert_failure response
28
+ end
29
+
30
+ def test_purchase_exceptions
31
+ @creditcard.number = 3
32
+
33
+ assert_raise(Error) do
34
+ assert response = @gateway.purchase(100, @creditcard, :order_id => 1)
35
+ end
36
+ end
37
+
38
+ def test_authorization_format
39
+ @gateway.expects(:ssl_post).returns(successful_response)
40
+
41
+ assert response = @gateway.purchase(100, @creditcard, :order_id => 1)
42
+ assert_success response
43
+
44
+ assert_equal "1;{7307C8A9-766E-4BD1-AC41-3C34BB83F7E5};5559;WIUMDJS607", response.authorization
45
+ end
46
+
47
+ def test_purchase_url
48
+ assert_equal 'https://ukvpstest.protx.com/vspgateway/service/vspdirect-register.vsp', @gateway.send(:build_endpoint_url, :purchase)
49
+ end
50
+
51
+ def test_capture_url
52
+ assert_equal 'https://ukvpstest.protx.com/vspgateway/service/release.vsp', @gateway.send(:build_endpoint_url, :capture)
53
+ end
54
+
55
+ def test_electron_cards
56
+ # Visa range
57
+ assert_no_match ProtxGateway::ELECTRON, '4245180000000000'
58
+
59
+ # First electron range
60
+ assert_match ProtxGateway::ELECTRON, '4245190000000000'
61
+
62
+ # Second range
63
+ assert_match ProtxGateway::ELECTRON, '4249620000000000'
64
+ assert_match ProtxGateway::ELECTRON, '4249630000000000'
65
+
66
+ # Third
67
+ assert_match ProtxGateway::ELECTRON, '4508750000000000'
68
+
69
+ # Fourth
70
+ assert_match ProtxGateway::ELECTRON, '4844060000000000'
71
+ assert_match ProtxGateway::ELECTRON, '4844080000000000'
72
+
73
+ # Fifth
74
+ assert_match ProtxGateway::ELECTRON, '4844110000000000'
75
+ assert_match ProtxGateway::ELECTRON, '4844550000000000'
76
+
77
+ # Sixth
78
+ assert_match ProtxGateway::ELECTRON, '4917300000000000'
79
+ assert_match ProtxGateway::ELECTRON, '4917590000000000'
80
+
81
+ # Seventh
82
+ assert_match ProtxGateway::ELECTRON, '4918800000000000'
83
+
84
+ # Visa
85
+ assert_no_match ProtxGateway::ELECTRON, '4918810000000000'
86
+
87
+ # 19 PAN length
88
+ assert_match ProtxGateway::ELECTRON, '4249620000000000000'
89
+
90
+ # 20 PAN length
91
+ assert_no_match ProtxGateway::ELECTRON, '42496200000000000'
92
+ end
93
+
94
+ private
95
+
96
+ def successful_response
97
+ <<-RESP
98
+ VPSProtocol=2.22
99
+ Status=OK
100
+ StatusDetail=VSP Direct transaction from VSP Simulator.
101
+ VPSTxId={7307C8A9-766E-4BD1-AC41-3C34BB83F7E5}
102
+ SecurityKey=WIUMDJS607
103
+ TxAuthNo=5559
104
+ AVSCV2=NO DATA MATCHES
105
+ AddressResult=NOTMATCHED
106
+ PostCodeResult=MATCHED
107
+ CV2Result=NOTMATCHED
108
+ RESP
109
+ end
110
+ end
@@ -0,0 +1,110 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class PsigateTest < Test::Unit::TestCase
4
+ def setup
5
+ @gateway = PsigateGateway.new(
6
+ :login => 'teststore',
7
+ :password => 'psigate1234'
8
+ )
9
+
10
+ @creditcard = credit_card('4111111111111111')
11
+ end
12
+
13
+
14
+ def test_authorize_success
15
+ @creditcard.number = '1'
16
+
17
+ assert response = @gateway.authorize(2400, @creditcard, :order_id => 1)
18
+ assert_equal Response, response.class
19
+ assert_equal true, response.success?
20
+ end
21
+
22
+ def test_purchase_success
23
+ @creditcard.number = 1
24
+
25
+ assert response = @gateway.purchase(2400, @creditcard, :order_id => 1)
26
+ assert_equal Response, response.class
27
+ assert_equal '#0001', response.params['receiptid']
28
+ assert_equal true, response.success?
29
+ end
30
+
31
+
32
+ def test_purchase_error
33
+ @creditcard.number = 2
34
+
35
+ assert response = @gateway.purchase(2400, @creditcard, :order_id => 1)
36
+ assert_equal Response, response.class
37
+ assert_equal '#0001', response.params['receiptid']
38
+ assert_equal false, response.success?
39
+ end
40
+
41
+ def test_purchase_exceptions
42
+ @creditcard.number = 3
43
+
44
+ assert_raise(Error) do
45
+ assert response = @gateway.purchase(100, @creditcard, :order_id => 1)
46
+ end
47
+ end
48
+
49
+ def test_amount_style
50
+ assert_equal '10.34', @gateway.send(:amount, 1034)
51
+
52
+ assert_raise(ArgumentError) do
53
+ @gateway.send(:amount, '10.34')
54
+ end
55
+ end
56
+ end
57
+
58
+ class PsigateRequestTest < Test::Unit::TestCase
59
+ def setup
60
+ @gateway = PsigateGateway.new(
61
+ :login => 'teststore',
62
+ :password => 'psigate1234'
63
+ )
64
+
65
+ @creditcard = credit_card('4111111111111111')
66
+ end
67
+
68
+ def test_purchase_is_valid_xml
69
+ parameters = @gateway.send(:parameters, 2000, @creditcard, {:order_id => 1004,
70
+ :billing_address => {
71
+ :address1 => '123 fairweather Lane',
72
+ :address2 => 'Apt B',
73
+ :city => 'New York',
74
+ :state => 'NY',
75
+ :country => 'U.S.A.',
76
+ :zip => '10010'},
77
+ :email => 'jack@yahoo.com',
78
+ :CardAction => 0 } )
79
+ assert data = @gateway.send(:post_data, parameters)
80
+ assert_nothing_raised{ REXML::Document.new(data) }
81
+ end
82
+
83
+ def test_capture_is_valid_xml
84
+ parameters = @gateway.send(:parameters, 2000, CreditCard.new({}), {:order_id => 1004,
85
+ :CardAction => 2 } )
86
+
87
+ assert data = @gateway.send(:post_data, parameters)
88
+ assert REXML::Document.new(data)
89
+ assert_equal xml_capture_fixture.size, data.size
90
+ end
91
+
92
+ def test_supported_countries
93
+ assert_equal ['CA'], PsigateGateway.supported_countries
94
+ end
95
+
96
+ def test_supported_card_types
97
+ assert_equal [:visa, :master, :american_express], PsigateGateway.supported_cardtypes
98
+ end
99
+
100
+ private
101
+
102
+ def xml_purchase_fixture
103
+ %q{<?xml version='1.0'?><Order><Bcity>New York</Bcity><OrderID>1004</OrderID><Bcountry>U.S.A.</Bcountry><CardAction>0</CardAction><Baddress1>123 fairweather Lane</Baddress1><StoreID>teststore</StoreID><Bprovince>NY</Bprovince><CardNumber>4111111111111111</CardNumber><PaymentType>CC</PaymentType><SubTotal>20.00</SubTotal><Passphrase>psigate1234</Passphrase><CardExpMonth>08</CardExpMonth><Baddress2>Apt B</Baddress2><Bpostalcode>10010</Bpostalcode><Bname>Longbob Longsen</Bname><CardExpYear>07</CardExpYear><Email>jack@yahoo.com</Email></Order>}
104
+ end
105
+
106
+ def xml_capture_fixture
107
+ %q{<?xml version='1.0'?><Order><OrderID>1004</OrderID><CardAction>2</CardAction><StoreID>teststore</StoreID><PaymentType>CC</PaymentType><SubTotal>20.00</SubTotal><Passphrase>psigate1234</Passphrase></Order>}
108
+ end
109
+
110
+ end