activemerchant 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,70 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class PlugnpayTest < Test::Unit::TestCase
4
+ include ActiveMerchant::Billing
5
+
6
+ def setup
7
+ @gateway = PlugnpayGateway.new(fixtures(:plugnpay))
8
+ @good_creditcard = credit_card('4242424242424242')
9
+ @bad_creditcard = credit_card('1234123412341234')
10
+ end
11
+
12
+ def test_bad_credit_card
13
+ assert response = @gateway.authorize(1000, @bad_creditcard)
14
+ assert_failure response
15
+ assert_equal 'Invalid Credit Card No.', response.message
16
+ end
17
+
18
+ def test_good_credit_card
19
+ assert response = @gateway.authorize(1000, @good_creditcard)
20
+ assert_success response
21
+ assert !response.authorization.blank?
22
+ assert_equal 'Success', response.message
23
+ end
24
+
25
+ def test_purchase_transaction
26
+ assert response = @gateway.purchase(1000, @good_creditcard)
27
+ assert_success response
28
+ assert !response.authorization.blank?
29
+ assert_equal 'Success', response.message
30
+ end
31
+
32
+ # Capture, and Void require that you Whitelist your IP address.
33
+ # In the gateway admin tool, you must add your IP address to the allowed addresses and uncheck "Remote client" under the
34
+ # "Auth Transactions" section of the "Security Requirements" area in the test account Security Administration Area.
35
+ def test_authorization_and_capture
36
+ assert authorization = @gateway.authorize(100, @good_creditcard)
37
+ assert_success authorization
38
+
39
+ assert capture = @gateway.capture(100, authorization.authorization)
40
+ assert_success capture
41
+ assert_equal 'Success', capture.message
42
+ end
43
+
44
+ def test_authorization_and_void
45
+ assert authorization = @gateway.authorize(100, @good_creditcard)
46
+ assert_success authorization
47
+
48
+ assert void = @gateway.void(authorization.authorization)
49
+ assert_success void
50
+ assert_equal 'Success', void.message
51
+ end
52
+
53
+ def test_purchase_and_credit
54
+ amount = 100
55
+
56
+ assert purchase = @gateway.purchase(amount, @good_creditcard)
57
+ assert_success purchase
58
+
59
+ assert credit = @gateway.credit(amount, purchase.authorization)
60
+ assert_success credit
61
+ assert_equal 'Success', credit.message
62
+ end
63
+
64
+ def test_credit_with_no_previous_transaction
65
+ assert credit = @gateway.credit(100, @good_creditcard)
66
+
67
+ assert_success credit
68
+ assert_equal 'Success', credit.message
69
+ end
70
+ end
@@ -0,0 +1,184 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ # Some of the standard tests have been removed at Protx test
4
+ # server is pants and accepts anything and says Status=OK. (shift)
5
+ class RemoteProtxTest < Test::Unit::TestCase
6
+ include ActiveMerchant::Billing
7
+
8
+ # Run the tests in the simulated environment
9
+ # set to false to run the tests in the test environment
10
+ ProtxGateway.simulate = true
11
+
12
+ AMOUNT = 100
13
+
14
+ def setup
15
+ @gateway = ProtxGateway.new(fixtures(:protx))
16
+
17
+ @amex = CreditCard.new(
18
+ :number => '374245455400001',
19
+ :month => 12,
20
+ :year => 2009,
21
+ :verification_value => 4887,
22
+ :first_name => 'Longbob',
23
+ :last_name => 'Longsen',
24
+ :type => :american_express
25
+ )
26
+
27
+ @maestro = CreditCard.new(
28
+ :number => '6759016800000120097',
29
+ :month => 6,
30
+ :year => 2009,
31
+ :issue_number => 1,
32
+ :verification_value => 701,
33
+ :first_name => 'Longbob',
34
+ :last_name => 'Longsen',
35
+ :type => :maestro
36
+ )
37
+
38
+ @solo = CreditCard.new(
39
+ :number => '6334960300099354',
40
+ :month => 6,
41
+ :year => 2008,
42
+ :issue_number => 1,
43
+ :verification_value => 227,
44
+ :first_name => 'Longbob',
45
+ :last_name => 'Longsen',
46
+ :type => :solo
47
+ )
48
+
49
+ @mastercard = CreditCard.new(
50
+ :number => '5301250070000191',
51
+ :month => 12,
52
+ :year => 2009,
53
+ :verification_value => 419,
54
+ :first_name => 'Longbob',
55
+ :last_name => 'Longsen',
56
+ :type => :master
57
+ )
58
+
59
+ @declined_card = CreditCard.new(
60
+ :number => '4000300011112220',
61
+ :month => 9,
62
+ :year => 2009,
63
+ :first_name => 'Longbob',
64
+ :last_name => 'Longsen'
65
+ )
66
+
67
+ @electron = credit_card('4917300000000008',
68
+ :type => 'electron',
69
+ :verification_value => '123'
70
+ )
71
+
72
+ @mastercard_options = {
73
+ :address => { :address1 => '25 The Larches',
74
+ :city => "Narborough",
75
+ :state => "Leicester",
76
+ :zip => 'LE10 2RT'
77
+ },
78
+ :order_id => generate_order_id,
79
+ :description => 'Store purchase'
80
+ }
81
+
82
+ @maestro_options = {
83
+ :address => { :address1 => 'The Parkway',
84
+ :address2 => "Larches Approach",
85
+ :city => "Hull",
86
+ :state => "North Humberside",
87
+ :zip => 'HU7 9OP'
88
+ },
89
+ :order_id => generate_order_id,
90
+ :description => 'Store purchase'
91
+ }
92
+
93
+ @solo_options = {
94
+ :address => {
95
+ :address1 => '5 Zigzag Road',
96
+ :city => 'Isleworth',
97
+ :state => 'Middlesex',
98
+ :zip => 'TW7 8FF'
99
+ },
100
+ :order_id => generate_order_id,
101
+ :description => 'Store purchase'
102
+ }
103
+ end
104
+
105
+ def test_successful_mastercard_purchase
106
+ assert response = @gateway.purchase(AMOUNT, @mastercard, @mastercard_options)
107
+ assert_success response
108
+ assert response.test?
109
+ assert !response.authorization.blank?
110
+ end
111
+
112
+ def test_successful_authorization_and_capture
113
+ assert auth = @gateway.authorize(AMOUNT, @mastercard, @mastercard_options)
114
+ assert_success auth
115
+
116
+ assert capture = @gateway.capture(AMOUNT, auth.authorization)
117
+ assert_success capture
118
+ end
119
+
120
+ def test_successful_authorization_and_void
121
+ assert auth = @gateway.authorize(AMOUNT, @mastercard, @mastercard_options)
122
+ assert_success auth
123
+
124
+ assert void = @gateway.void(auth.authorization)
125
+ assert_success void
126
+ end
127
+
128
+ def test_successful_purchase_and_void
129
+ assert purchase = @gateway.purchase(AMOUNT, @mastercard, @mastercard_options)
130
+ assert_success purchase
131
+
132
+ assert void = @gateway.void(purchase.authorization)
133
+ assert_success void
134
+ end
135
+
136
+ def test_successful_purchase_and_credit
137
+ assert purchase = @gateway.purchase(AMOUNT, @mastercard, @mastercard_options)
138
+ assert_success purchase
139
+
140
+ assert credit = @gateway.credit(AMOUNT, purchase.authorization,
141
+ :description => 'Crediting trx',
142
+ :order_id => generate_order_id
143
+ )
144
+
145
+ assert_success credit
146
+ end
147
+
148
+ def test_successful_maestro_purchase
149
+ assert response = @gateway.purchase(AMOUNT, @maestro, @maestro_options)
150
+ assert_success response
151
+ end
152
+
153
+ def test_successful_solo_purchase
154
+ assert response = @gateway.purchase(AMOUNT, @solo, @solo_options)
155
+ assert_success response
156
+ assert response.test?
157
+ assert !response.authorization.blank?
158
+ end
159
+
160
+ def test_successful_amex_purchase
161
+ assert response = @gateway.purchase(AMOUNT, @amex, :order_id => generate_order_id)
162
+ assert_success response
163
+ assert response.test?
164
+ assert !response.authorization.blank?
165
+ end
166
+
167
+ def test_successful_electron_purchase
168
+ assert response = @gateway.purchase(AMOUNT, @electron, :order_id => generate_order_id)
169
+ assert_success response
170
+ assert response.test?
171
+ assert !response.authorization.blank?
172
+ end
173
+
174
+ def test_invalid_login
175
+ message = ProtxGateway.simulate ? 'VSP Simulator cannot find your vendor name. Ensure you have have supplied a Vendor field with your VSP Vendor name assigned to it.' : '3034 : The Vendor or VendorName value is required.'
176
+
177
+ gateway = ProtxGateway.new(
178
+ :login => ''
179
+ )
180
+ assert response = gateway.purchase(AMOUNT, @mastercard, @mastercard_options)
181
+ assert_equal message, response.message
182
+ assert_failure response
183
+ end
184
+ end
@@ -0,0 +1,87 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class PsigateRemoteTest < Test::Unit::TestCase
4
+ # set up order numbers as contants because even a test credit must match an
5
+ # existing purchase in psigate's test system
6
+ ORDER_NUM1 = Time.now.to_i.to_s
7
+ ORDER_NUM2 = (Time.now.to_i + 1).to_s
8
+ ORDER_NUM3 = (Time.now.to_i + 2).to_s
9
+
10
+ def setup
11
+ Base.gateway_mode = :test
12
+ @gateway = PsigateGateway.new(fixtures(:psigate))
13
+
14
+ @creditcard = credit_card('4242424242424242')
15
+ end
16
+
17
+ def test_remote_authorize
18
+ assert response = @gateway.authorize(2400, @creditcard,
19
+ :order_id => ORDER_NUM1,
20
+ :billing_address => {
21
+ :address1 => '123 fairweather Lane',
22
+ :address2 => 'Apt B',
23
+ :city => 'New York',
24
+ :state => 'NY',
25
+ :country => 'U.S.A.',
26
+ :zip => '10010'},
27
+ :email => 'jack@yahoo.com'
28
+ )
29
+ assert_equal Response, response.class
30
+ assert_equal true, response.success?
31
+ assert_equal "APPROVED", response.params["approved"]
32
+ assert_equal ORDER_NUM1, response.authorization
33
+ end
34
+
35
+ def test_remote_capture
36
+ assert response = @gateway.capture(2400, ORDER_NUM1 )
37
+ assert_equal Response, response.class
38
+ assert_equal true, response.success?
39
+ assert_equal "APPROVED", response.params["approved"]
40
+ assert_equal "APPROVED", response.params["approved"]
41
+ end
42
+
43
+
44
+ # named test_remote_apurchase (with an a) so that it executes prior to the
45
+ # test_remote_credit method. Otherwise the credit won't reference an existing
46
+ # purchase and the test will fail
47
+ def test_remote_apurchase
48
+ assert response = @gateway.purchase(2400, @creditcard, {:order_id => ORDER_NUM2,
49
+ :billing_address => {
50
+ :address1 => '123 fairweather Lane',
51
+ :address2 => 'Apt B',
52
+ :city => 'New York',
53
+ :state => 'NY',
54
+ :country => 'U.S.A.',
55
+ :zip => '10010'},
56
+ :email => 'jack@yahoo.com'
57
+ })
58
+ assert_equal Response, response.class
59
+ assert_equal true, response.success?
60
+ assert_equal "APPROVED", response.params["approved"]
61
+ end
62
+
63
+ def test_remote_credit
64
+ assert response = @gateway.credit(2400, ORDER_NUM2)
65
+ assert_equal Response, response.class
66
+ assert_equal true, response.success?
67
+ assert_equal "APPROVED", response.params["approved"]
68
+ end
69
+
70
+ def test_remote_decline
71
+ assert response = @gateway.purchase(2400, @creditcard, {:order_id => ORDER_NUM3,
72
+ :billing_address => {
73
+ :address1 => '123 fairweather Lane',
74
+ :address2 => 'Apt B',
75
+ :city => 'New York',
76
+ :state => 'NY',
77
+ :country => 'U.S.A.',
78
+ :zip => '10010'},
79
+ :email => 'jack@yahoo.com',
80
+ :test_result => 'D'
81
+ })
82
+ assert_equal Response, response.class
83
+ assert_equal false, response.success?
84
+ assert_equal "DECLINED", response.params["approved"]
85
+ end
86
+
87
+ end
@@ -0,0 +1,105 @@
1
+ # Author:: MoneySpyder, http://moneyspyder.co.uk
2
+
3
+ require File.dirname(__FILE__) + '/../test_helper'
4
+
5
+ class RemotePslCardTest < Test::Unit::TestCase
6
+ # The test results are determined by the amount of the transaction
7
+ ACCEPT_AMOUNT = 1000
8
+ REFERRED_AMOUNT = 6000
9
+ DECLINED_AMOUNT = 11000
10
+ KEEP_CARD_AMOUNT = 15000
11
+
12
+ def setup
13
+ @gateway = PslCardGateway.new(fixtures(:psl_card))
14
+
15
+ @uk_maestro = CreditCard.new(fixtures(:psl_maestro))
16
+ @uk_maestro_address = fixtures(:psl_maestro_address)
17
+
18
+ @solo = CreditCard.new(fixtures(:psl_solo))
19
+ @solo_address = fixtures(:psl_solo_address)
20
+
21
+ @visa = CreditCard.new(fixtures(:psl_visa))
22
+ @visa_address = fixtures(:psl_visa_address)
23
+ end
24
+
25
+ def test_successful_visa_purchase
26
+ response = @gateway.purchase(ACCEPT_AMOUNT, @visa,
27
+ :address => @visa_address
28
+ )
29
+ assert_success response
30
+ assert response.test?
31
+ end
32
+
33
+ def test_successful_visa_purchase_specifying_currency
34
+ response = @gateway.purchase(ACCEPT_AMOUNT, @visa,
35
+ :address => @visa_address,
36
+ :currency => 'GBP'
37
+ )
38
+ assert_success response
39
+ assert response.test?
40
+ end
41
+
42
+ def test_successful_solo_purchase
43
+ response = @gateway.purchase(ACCEPT_AMOUNT, @solo,
44
+ :address => @solo_address
45
+ )
46
+ assert_success response
47
+ assert response.test?
48
+ end
49
+
50
+ def test_referred_purchase
51
+ response = @gateway.purchase(REFERRED_AMOUNT, @uk_maestro,
52
+ :address => @uk_maestro_address
53
+ )
54
+ assert_failure response
55
+ assert response.test?
56
+ end
57
+
58
+ def test_declined_purchase
59
+ response = @gateway.purchase(DECLINED_AMOUNT, @uk_maestro,
60
+ :address => @uk_maestro_address
61
+ )
62
+ assert_failure response
63
+ assert response.test?
64
+ end
65
+
66
+ def test_declined_keep_card_purchase
67
+ response = @gateway.purchase(KEEP_CARD_AMOUNT, @uk_maestro,
68
+ :address => @uk_maestro_address
69
+ )
70
+ assert_failure response
71
+ assert response.test?
72
+ end
73
+
74
+ def test_successful_authorization
75
+ response = @gateway.authorize(ACCEPT_AMOUNT, @uk_maestro,
76
+ :address => @uk_maestro_address
77
+ )
78
+ assert_success response
79
+ assert response.test?
80
+ end
81
+
82
+ def test_no_login
83
+ @gateway = PslCardGateway.new(
84
+ :login => ''
85
+ )
86
+ response = @gateway.authorize(ACCEPT_AMOUNT, @uk_maestro,
87
+ :address => @uk_maestro_address
88
+ )
89
+ assert_failure response
90
+ assert response.test?
91
+ end
92
+
93
+ def test_successful_authorization_and_capture
94
+ authorization = @gateway.authorize(ACCEPT_AMOUNT, @uk_maestro,
95
+ :address => @uk_maestro_address
96
+ )
97
+ assert_success authorization
98
+ assert authorization.test?
99
+
100
+ capture = @gateway.capture(ACCEPT_AMOUNT, authorization.authorization)
101
+
102
+ assert_success capture
103
+ assert capture.test?
104
+ end
105
+ end