mattbauer-activemerchant 1.4.2
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.
- data/CHANGELOG +459 -0
- data/CONTRIBUTERS +118 -0
- data/MIT-LICENSE +20 -0
- data/README +134 -0
- data/Rakefile +153 -0
- data/gem-public_cert.pem +20 -0
- data/init.rb +3 -0
- data/lib/active_merchant.rb +60 -0
- data/lib/active_merchant/billing/avs_result.rb +98 -0
- data/lib/active_merchant/billing/base.rb +57 -0
- data/lib/active_merchant/billing/check.rb +68 -0
- data/lib/active_merchant/billing/credit_card.rb +159 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +21 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +125 -0
- data/lib/active_merchant/billing/cvv_result.rb +38 -0
- data/lib/active_merchant/billing/expiry_date.rb +34 -0
- data/lib/active_merchant/billing/gateway.rb +158 -0
- data/lib/active_merchant/billing/gateways.rb +3 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +657 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +703 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +102 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +233 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +98 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +17 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +230 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +406 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +595 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +229 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +106 -0
- data/lib/active_merchant/billing/gateways/eway.rb +277 -0
- data/lib/active_merchant/billing/gateways/exact.rb +222 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +172 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +164 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +396 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +154 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +283 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +36 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +214 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +295 -0
- data/lib/active_merchant/billing/gateways/moneris_usa.rb +258 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +189 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +168 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +259 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +392 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +236 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +207 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +39 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +138 -0
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +15 -0
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +21 -0
- data/lib/active_merchant/billing/gateways/payment_express.rb +230 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +121 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +325 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +38 -0
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +130 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +20 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +292 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +214 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +306 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +213 -0
- data/lib/active_merchant/billing/gateways/realex.rb +200 -0
- data/lib/active_merchant/billing/gateways/sage.rb +146 -0
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +88 -0
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +110 -0
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +308 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +157 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +442 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +254 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +127 -0
- data/lib/active_merchant/billing/gateways/transax.rb +26 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +418 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +194 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +228 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +189 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +318 -0
- data/lib/active_merchant/billing/integrations.rb +22 -0
- data/lib/active_merchant/billing/integrations/action_view_helper.rb +79 -0
- data/lib/active_merchant/billing/integrations/bogus.rb +22 -0
- data/lib/active_merchant/billing/integrations/bogus/helper.rb +17 -0
- data/lib/active_merchant/billing/integrations/bogus/notification.rb +11 -0
- data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/chronopay.rb +22 -0
- data/lib/active_merchant/billing/integrations/chronopay/helper.rb +81 -0
- data/lib/active_merchant/billing/integrations/chronopay/notification.rb +156 -0
- data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/gestpay.rb +26 -0
- data/lib/active_merchant/billing/integrations/gestpay/common.rb +42 -0
- data/lib/active_merchant/billing/integrations/gestpay/helper.rb +70 -0
- data/lib/active_merchant/billing/integrations/gestpay/notification.rb +83 -0
- data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/helper.rb +93 -0
- data/lib/active_merchant/billing/integrations/hi_trust.rb +26 -0
- data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
- data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +59 -0
- data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
- data/lib/active_merchant/billing/integrations/nochex.rb +87 -0
- data/lib/active_merchant/billing/integrations/nochex/helper.rb +68 -0
- data/lib/active_merchant/billing/integrations/nochex/notification.rb +94 -0
- data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/notification.rb +62 -0
- data/lib/active_merchant/billing/integrations/paypal.rb +40 -0
- data/lib/active_merchant/billing/integrations/paypal/helper.rb +119 -0
- data/lib/active_merchant/billing/integrations/paypal/notification.rb +154 -0
- data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/quickpay.rb +18 -0
- data/lib/active_merchant/billing/integrations/quickpay/helper.rb +72 -0
- data/lib/active_merchant/billing/integrations/quickpay/notification.rb +74 -0
- data/lib/active_merchant/billing/integrations/return.rb +35 -0
- data/lib/active_merchant/billing/integrations/two_checkout.rb +23 -0
- data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +59 -0
- data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +114 -0
- data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
- data/lib/active_merchant/billing/response.rb +32 -0
- data/lib/active_merchant/lib/connection.rb +170 -0
- data/lib/active_merchant/lib/country.rb +319 -0
- data/lib/active_merchant/lib/error.rb +4 -0
- data/lib/active_merchant/lib/post_data.rb +22 -0
- data/lib/active_merchant/lib/posts_data.rb +47 -0
- data/lib/active_merchant/lib/requires_parameters.rb +16 -0
- data/lib/active_merchant/lib/utils.rb +18 -0
- data/lib/active_merchant/lib/validateable.rb +76 -0
- data/lib/certs/cacert.pem +7815 -0
- data/lib/support/gateway_support.rb +58 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/test/fixtures.yml +353 -0
- data/test/remote/gateways/remote_authorize_net_cim_test.rb +459 -0
- data/test/remote/gateways/remote_authorize_net_test.rb +145 -0
- data/test/remote/gateways/remote_beanstream_interac_test.rb +53 -0
- data/test/remote/gateways/remote_beanstream_test.rb +150 -0
- data/test/remote/gateways/remote_braintree_test.rb +154 -0
- data/test/remote/gateways/remote_card_stream_test.rb +148 -0
- data/test/remote/gateways/remote_cyber_source_test.rb +144 -0
- data/test/remote/gateways/remote_data_cash_test.rb +357 -0
- data/test/remote/gateways/remote_efsnet_test.rb +81 -0
- data/test/remote/gateways/remote_elavon_test.rb +66 -0
- data/test/remote/gateways/remote_eway_test.rb +74 -0
- data/test/remote/gateways/remote_exact_test.rb +60 -0
- data/test/remote/gateways/remote_first_pay_test.rb +87 -0
- data/test/remote/gateways/remote_instapay_test.rb +61 -0
- data/test/remote/gateways/remote_linkpoint_test.rb +112 -0
- data/test/remote/gateways/remote_merchant_e_solutions_test.rb +173 -0
- data/test/remote/gateways/remote_merchant_ware_test.rb +113 -0
- data/test/remote/gateways/remote_modern_payments_cim_test.rb +58 -0
- data/test/remote/gateways/remote_modern_payments_test.rb +43 -0
- data/test/remote/gateways/remote_moneris_test.rb +118 -0
- data/test/remote/gateways/remote_moneris_usa_test.rb +115 -0
- data/test/remote/gateways/remote_net_registry_test.rb +85 -0
- data/test/remote/gateways/remote_netbilling_test.rb +70 -0
- data/test/remote/gateways/remote_ogone_test.rb +108 -0
- data/test/remote/gateways/remote_pay_junction_test.rb +143 -0
- data/test/remote/gateways/remote_pay_secure_test.rb +39 -0
- data/test/remote/gateways/remote_payflow_express_test.rb +50 -0
- data/test/remote/gateways/remote_payflow_test.rb +237 -0
- data/test/remote/gateways/remote_payflow_uk_test.rb +173 -0
- data/test/remote/gateways/remote_payment_express_test.rb +136 -0
- data/test/remote/gateways/remote_paypal_express_test.rb +49 -0
- data/test/remote/gateways/remote_paypal_test.rb +178 -0
- data/test/remote/gateways/remote_plugnpay_test.rb +72 -0
- data/test/remote/gateways/remote_psigate_test.rb +50 -0
- data/test/remote/gateways/remote_psl_card_test.rb +125 -0
- data/test/remote/gateways/remote_quickpay_test.rb +190 -0
- data/test/remote/gateways/remote_realex_test.rb +224 -0
- data/test/remote/gateways/remote_sage_bankcard_test.rb +109 -0
- data/test/remote/gateways/remote_sage_pay_test.rb +219 -0
- data/test/remote/gateways/remote_sage_test.rb +87 -0
- data/test/remote/gateways/remote_sage_virtual_check_test.rb +62 -0
- data/test/remote/gateways/remote_secure_pay_au_test.rb +40 -0
- data/test/remote/gateways/remote_secure_pay_tech_test.rb +37 -0
- data/test/remote/gateways/remote_secure_pay_test.rb +28 -0
- data/test/remote/gateways/remote_skipjack_test.rb +105 -0
- data/test/remote/gateways/remote_trans_first_test.rb +34 -0
- data/test/remote/gateways/remote_transax_test.rb +112 -0
- data/test/remote/gateways/remote_trust_commerce_test.rb +152 -0
- data/test/remote/gateways/remote_usa_epay_test.rb +46 -0
- data/test/remote/gateways/remote_verifi_test.rb +107 -0
- data/test/remote/gateways/remote_viaklix_test.rb +43 -0
- data/test/remote/gateways/remote_wirecard_test.rb +111 -0
- data/test/remote/integrations/remote_gestpay_integration_test.rb +37 -0
- data/test/remote/integrations/remote_paypal_integration_test.rb +26 -0
- data/test/test_helper.rb +182 -0
- data/test/unit/avs_result_test.rb +59 -0
- data/test/unit/base_test.rb +55 -0
- data/test/unit/check_test.rb +88 -0
- data/test/unit/connection_test.rb +129 -0
- data/test/unit/country_code_test.rb +33 -0
- data/test/unit/country_test.rb +64 -0
- data/test/unit/credit_card_formatting_test.rb +19 -0
- data/test/unit/credit_card_methods_test.rb +179 -0
- data/test/unit/credit_card_test.rb +318 -0
- data/test/unit/cvv_result_test.rb +33 -0
- data/test/unit/expiry_date_test.rb +32 -0
- data/test/unit/gateways/authorize_net_cim_test.rb +638 -0
- data/test/unit/gateways/authorize_net_test.rb +290 -0
- data/test/unit/gateways/beanstream_interac_test.rb +51 -0
- data/test/unit/gateways/beanstream_test.rb +108 -0
- data/test/unit/gateways/bogus_test.rb +46 -0
- data/test/unit/gateways/braintree_test.rb +126 -0
- data/test/unit/gateways/card_stream_test.rb +90 -0
- data/test/unit/gateways/cyber_source_test.rb +188 -0
- data/test/unit/gateways/data_cash_test.rb +133 -0
- data/test/unit/gateways/efsnet_test.rb +123 -0
- data/test/unit/gateways/elavon_test.rb +139 -0
- data/test/unit/gateways/eway_test.rb +118 -0
- data/test/unit/gateways/exact_test.rb +156 -0
- data/test/unit/gateways/first_pay_test.rb +125 -0
- data/test/unit/gateways/gateway_test.rb +48 -0
- data/test/unit/gateways/instapay_test.rb +102 -0
- data/test/unit/gateways/linkpoint_test.rb +167 -0
- data/test/unit/gateways/merchant_e_solutions_test.rb +169 -0
- data/test/unit/gateways/merchant_ware_test.rb +188 -0
- data/test/unit/gateways/modern_payments_cim_test.rb +171 -0
- data/test/unit/gateways/moneris_test.rb +185 -0
- data/test/unit/gateways/moneris_usa_test.rb +183 -0
- data/test/unit/gateways/net_registry_test.rb +416 -0
- data/test/unit/gateways/netbilling_test.rb +54 -0
- data/test/unit/gateways/ogone_test.rb +256 -0
- data/test/unit/gateways/pay_junction_test.rb +123 -0
- data/test/unit/gateways/pay_secure_test.rb +71 -0
- data/test/unit/gateways/payflow_express_test.rb +173 -0
- data/test/unit/gateways/payflow_express_uk_test.rb +86 -0
- data/test/unit/gateways/payflow_test.rb +305 -0
- data/test/unit/gateways/payflow_uk_test.rb +30 -0
- data/test/unit/gateways/payment_express_test.rb +195 -0
- data/test/unit/gateways/paypal_express_test.rb +382 -0
- data/test/unit/gateways/paypal_test.rb +569 -0
- data/test/unit/gateways/plugnpay_test.rb +86 -0
- data/test/unit/gateways/psigate_test.rb +169 -0
- data/test/unit/gateways/psl_card_test.rb +64 -0
- data/test/unit/gateways/quickpay_test.rb +112 -0
- data/test/unit/gateways/realex_test.rb +151 -0
- data/test/unit/gateways/sage_bankcard_test.rb +162 -0
- data/test/unit/gateways/sage_pay_test.rb +139 -0
- data/test/unit/gateways/sage_virtual_check_test.rb +71 -0
- data/test/unit/gateways/secure_pay_au_test.rb +207 -0
- data/test/unit/gateways/secure_pay_tech_test.rb +44 -0
- data/test/unit/gateways/secure_pay_test.rb +87 -0
- data/test/unit/gateways/skip_jack_test.rb +133 -0
- data/test/unit/gateways/trans_first_test.rb +112 -0
- data/test/unit/gateways/trust_commerce_test.rb +90 -0
- data/test/unit/gateways/usa_epay_test.rb +128 -0
- data/test/unit/gateways/verifi_test.rb +96 -0
- data/test/unit/gateways/viaklix_test.rb +78 -0
- data/test/unit/gateways/wirecard_test.rb +250 -0
- data/test/unit/generators/test_gateway_generator.rb +46 -0
- data/test/unit/generators/test_generator_helper.rb +20 -0
- data/test/unit/generators/test_integration_generator.rb +53 -0
- data/test/unit/integrations/action_view_helper_test.rb +50 -0
- data/test/unit/integrations/bogus_module_test.rb +20 -0
- data/test/unit/integrations/chronopay_module_test.rb +13 -0
- data/test/unit/integrations/gestpay_module_test.rb +14 -0
- data/test/unit/integrations/helpers/bogus_helper_test.rb +28 -0
- data/test/unit/integrations/helpers/chronopay_helper_test.rb +67 -0
- data/test/unit/integrations/helpers/gestpay_helper_test.rb +100 -0
- data/test/unit/integrations/helpers/hi_trust_helper_test.rb +16 -0
- data/test/unit/integrations/helpers/nochex_helper_test.rb +53 -0
- data/test/unit/integrations/helpers/paypal_helper_test.rb +171 -0
- data/test/unit/integrations/helpers/quickpay_helper_test.rb +40 -0
- data/test/unit/integrations/helpers/two_checkout_helper_test.rb +92 -0
- data/test/unit/integrations/hi_trust_module_test.rb +13 -0
- data/test/unit/integrations/nochex_module_test.rb +13 -0
- data/test/unit/integrations/notifications/chronopay_notification_test.rb +66 -0
- data/test/unit/integrations/notifications/gestpay_notification_test.rb +60 -0
- data/test/unit/integrations/notifications/hi_trust_notification_test.rb +59 -0
- data/test/unit/integrations/notifications/nochex_notification_test.rb +51 -0
- data/test/unit/integrations/notifications/notification_test.rb +54 -0
- data/test/unit/integrations/notifications/paypal_notification_test.rb +85 -0
- data/test/unit/integrations/notifications/quickpay_notification_test.rb +69 -0
- data/test/unit/integrations/notifications/two_checkout_notification_test.rb +55 -0
- data/test/unit/integrations/paypal_module_test.rb +28 -0
- data/test/unit/integrations/quickpay_module_test.rb +9 -0
- data/test/unit/integrations/returns/chronopay_return_test.rb +11 -0
- data/test/unit/integrations/returns/gestpay_return_test.rb +10 -0
- data/test/unit/integrations/returns/hi_trust_return_test.rb +24 -0
- data/test/unit/integrations/returns/nochex_return_test.rb +10 -0
- data/test/unit/integrations/returns/paypal_return_test.rb +10 -0
- data/test/unit/integrations/returns/return_test.rb +11 -0
- data/test/unit/integrations/returns/two_checkout_return_test.rb +24 -0
- data/test/unit/integrations/two_checkout_module_test.rb +13 -0
- data/test/unit/post_data_test.rb +55 -0
- data/test/unit/posts_data_test.rb +48 -0
- data/test/unit/response_test.rb +28 -0
- data/test/unit/utils_test.rb +7 -0
- data/test/unit/validateable_test.rb +60 -0
- metadata +396 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class PlugnpayTest < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
def setup
|
|
6
|
+
Base.gateway_mode = :test
|
|
7
|
+
|
|
8
|
+
@gateway = PlugnpayGateway.new(
|
|
9
|
+
:login => 'X',
|
|
10
|
+
:password => 'Y'
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
@credit_card = credit_card
|
|
14
|
+
@options = {
|
|
15
|
+
:billing_address => address,
|
|
16
|
+
:description => 'Store purchase'
|
|
17
|
+
}
|
|
18
|
+
@amount = 100
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_purchase_success
|
|
22
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
23
|
+
|
|
24
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
25
|
+
assert_equal Response, response.class
|
|
26
|
+
assert_success response
|
|
27
|
+
assert_equal '2008012522252119738', response.authorization
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def test_purchase_error
|
|
31
|
+
@gateway.expects(:ssl_post).returns(unsuccessful_purchase_response)
|
|
32
|
+
|
|
33
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
34
|
+
assert_equal Response, response.class
|
|
35
|
+
assert_failure response
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_add_address_outsite_north_america
|
|
39
|
+
result = PlugnpayGateway::PlugnpayPostData.new
|
|
40
|
+
|
|
41
|
+
@gateway.send(:add_addresses, result, :billing_address => {:address1 => '164 Waverley Street', :country => 'DE', :state => 'Dortmund'} )
|
|
42
|
+
|
|
43
|
+
assert_equal result[:state], 'ZZ'
|
|
44
|
+
assert_equal result[:province], 'Dortmund'
|
|
45
|
+
|
|
46
|
+
assert_equal result[:card_state], 'ZZ'
|
|
47
|
+
assert_equal result[:card_prov], 'Dortmund'
|
|
48
|
+
|
|
49
|
+
assert_equal result[:card_address1], '164 Waverley Street'
|
|
50
|
+
assert_equal result[:card_country], 'DE'
|
|
51
|
+
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def test_add_address
|
|
55
|
+
result = PlugnpayGateway::PlugnpayPostData.new
|
|
56
|
+
|
|
57
|
+
@gateway.send(:add_addresses, result, :billing_address => {:address1 => '164 Waverley Street', :country => 'US', :state => 'CO'} )
|
|
58
|
+
|
|
59
|
+
assert_equal result[:card_state], 'CO'
|
|
60
|
+
assert_equal result[:card_address1], '164 Waverley Street'
|
|
61
|
+
assert_equal result[:card_country], 'US'
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def test_avs_result
|
|
65
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
66
|
+
|
|
67
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
68
|
+
assert_equal 'X', response.avs_result['code']
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def test_cvv_result
|
|
72
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
73
|
+
|
|
74
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
75
|
+
assert_equal 'M', response.cvv_result['code']
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
private
|
|
79
|
+
def successful_purchase_response
|
|
80
|
+
"FinalStatus=success&IPaddress=72%2e138%2e32%2e216&MStatus=success&User_Agent=&acct_code3=newcard&address1=1234%20My%20Street&address2=Apt%201&app_level=5&auth_code=TSTAUT&auth_date=20080125&auth_msg=%20&authtype=authpostauth&avs_code=X&card_address1=1234%20My%20Street&card_amount=1%2e00&card_city=Ottawa&card_country=CA&card_name=Longbob%20Longsen&card_state=ON&card_type=VISA&card_zip=K1C2N6&city=Ottawa&convert=underscores&country=CA¤cy=usd&cvvresp=M&dontsndmail=yes&easycart=0&merchant=pnpdemo2&merchfraudlev=&mode=auth&orderID=2008012522252119738&phone=555%2d555%2d5555&publisher_email=trash%40plugnpay%2ecom&publisher_name=pnpdemo2&publisher_password=pnpdemo222&resp_code=00&shipinfo=0&shipname=Jim%20Smith&sresp=A&state=ON&success=yes&zip=K1C2N6&a=b\n"
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def unsuccessful_purchase_response
|
|
84
|
+
"FinalStatus=fraud&IPaddress=72%2e138%2e32%2e216&MStatus=badcard&User_Agent=&address1=1234%20My%20Street&address2=Apt%201&app_level=5&auth_code=&auth_date=20080125&auth_msg=%20Invalid%20Credit%20Card%20Number%2e%7c&authtype=authonly&card_address1=1234%20My%20Street&card_amount=1%2e00&card_city=Ottawa&card_country=CA&card_name=Longbob%20Longsen&card_state=ON&card_type=failure&card_zip=K1C2N6&city=Ottawa&convert=underscores&country=CA¤cy=usd&dontsndmail=yes&easycart=0&errdetails=card%2dnumber%7cCard%20Number%20fails%20LUHN%20%2d%2010%20check%2e%7c&errlevel=1&merchant=pnpdemo2&mode=auth&orderID=2008012522275901541&phone=555%2d555%2d5555&publisher_email=trash%40plugnpay%2ecom&publisher_name=pnpdemo2&publisher_password=pnpdemo222&resp_code=P55&shipinfo=0&shipname=Jim%20Smith&sresp=E&state=ON&success=no&zip=K1C2N6&MErrMsg=Invalid%20Credit%20Card%20Number%2e%7c&a=b\n"
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
require '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
|
+
@amount = 100
|
|
11
|
+
@credit_card = credit_card('4111111111111111')
|
|
12
|
+
@options = { :order_id => 1, :billing_address => address }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_successful_authorization
|
|
16
|
+
@gateway.expects(:ssl_post).returns(successful_authorization_response)
|
|
17
|
+
|
|
18
|
+
assert response = @gateway.authorize(@amount, @credit_card, @options)
|
|
19
|
+
assert_instance_of Response, response
|
|
20
|
+
assert_success response
|
|
21
|
+
assert_equal '1000', response.authorization
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_successful_purchase
|
|
25
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
26
|
+
|
|
27
|
+
assert response = @gateway.authorize(@amount, @credit_card, @options)
|
|
28
|
+
assert_instance_of Response, response
|
|
29
|
+
assert_success response
|
|
30
|
+
assert_equal '1000', response.authorization
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_failed_purchase
|
|
34
|
+
@gateway.expects(:ssl_post).returns(failed_purchase_response)
|
|
35
|
+
|
|
36
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
37
|
+
assert_failure response
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def test_amount_style
|
|
41
|
+
assert_equal '10.34', @gateway.send(:amount, 1034)
|
|
42
|
+
|
|
43
|
+
assert_raise(ArgumentError) do
|
|
44
|
+
@gateway.send(:amount, '10.34')
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def test_supported_countries
|
|
49
|
+
assert_equal ['CA'], PsigateGateway.supported_countries
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def test_supported_card_types
|
|
53
|
+
assert_equal [:visa, :master, :american_express], PsigateGateway.supported_cardtypes
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_avs_result
|
|
57
|
+
@gateway.expects(:ssl_post).returns(successful_authorization_response)
|
|
58
|
+
|
|
59
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
60
|
+
assert_equal 'X', response.avs_result['code']
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_cvv_result
|
|
64
|
+
@gateway.expects(:ssl_post).returns(successful_authorization_response)
|
|
65
|
+
|
|
66
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
67
|
+
assert_equal 'M', response.cvv_result['code']
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
private
|
|
71
|
+
|
|
72
|
+
def successful_authorization_response
|
|
73
|
+
<<-RESPONSE
|
|
74
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
75
|
+
<Result>
|
|
76
|
+
<TransTime>Sun Jan 06 23:10:53 EST 2008</TransTime>
|
|
77
|
+
<OrderID>1000</OrderID>
|
|
78
|
+
<TransactionType>PREAUTH</TransactionType>
|
|
79
|
+
<Approved>APPROVED</Approved>
|
|
80
|
+
<ReturnCode>Y:123456:0abcdef:M:X:NNN</ReturnCode>
|
|
81
|
+
<ErrMsg/>
|
|
82
|
+
<TaxTotal>0.00</TaxTotal>
|
|
83
|
+
<ShipTotal>0.00</ShipTotal>
|
|
84
|
+
<SubTotal>24.00</SubTotal>
|
|
85
|
+
<FullTotal>24.00</FullTotal>
|
|
86
|
+
<PaymentType>CC</PaymentType>
|
|
87
|
+
<CardNumber>......4242</CardNumber>
|
|
88
|
+
<TransRefNumber>1bdde305d7658367</TransRefNumber>
|
|
89
|
+
<CardIDResult>M</CardIDResult>
|
|
90
|
+
<AVSResult>X</AVSResult>
|
|
91
|
+
<CardAuthNumber>123456</CardAuthNumber>
|
|
92
|
+
<CardRefNumber>0abcdef</CardRefNumber>
|
|
93
|
+
<CardType>VISA</CardType>
|
|
94
|
+
<IPResult>NNN</IPResult>
|
|
95
|
+
<IPCountry>UN</IPCountry>
|
|
96
|
+
<IPRegion>UNKNOWN</IPRegion>
|
|
97
|
+
<IPCity>UNKNOWN</IPCity>
|
|
98
|
+
</Result>
|
|
99
|
+
RESPONSE
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def successful_purchase_response
|
|
103
|
+
<<-RESPONSE
|
|
104
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
105
|
+
<Result>
|
|
106
|
+
<TransTime>Sun Jan 06 23:15:30 EST 2008</TransTime>
|
|
107
|
+
<OrderID>1000</OrderID>
|
|
108
|
+
<TransactionType>SALE</TransactionType>
|
|
109
|
+
<Approved>APPROVED</Approved>
|
|
110
|
+
<ReturnCode>Y:123456:0abcdef:M:X:NNN</ReturnCode>
|
|
111
|
+
<ErrMsg/>
|
|
112
|
+
<TaxTotal>0.00</TaxTotal>
|
|
113
|
+
<ShipTotal>0.00</ShipTotal>
|
|
114
|
+
<SubTotal>24.00</SubTotal>
|
|
115
|
+
<FullTotal>24.00</FullTotal>
|
|
116
|
+
<PaymentType>CC</PaymentType>
|
|
117
|
+
<CardNumber>......4242</CardNumber>
|
|
118
|
+
<TransRefNumber>1bdde305da3ee234</TransRefNumber>
|
|
119
|
+
<CardIDResult>M</CardIDResult>
|
|
120
|
+
<AVSResult>X</AVSResult>
|
|
121
|
+
<CardAuthNumber>123456</CardAuthNumber>
|
|
122
|
+
<CardRefNumber>0abcdef</CardRefNumber>
|
|
123
|
+
<CardType>VISA</CardType>
|
|
124
|
+
<IPResult>NNN</IPResult>
|
|
125
|
+
<IPCountry>UN</IPCountry>
|
|
126
|
+
<IPRegion>UNKNOWN</IPRegion>
|
|
127
|
+
<IPCity>UNKNOWN</IPCity>
|
|
128
|
+
</Result>
|
|
129
|
+
RESPONSE
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def failed_purchase_response
|
|
133
|
+
<<-RESPONSE
|
|
134
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
135
|
+
<Result>
|
|
136
|
+
<TransTime>Sun Jan 06 23:24:29 EST 2008</TransTime>
|
|
137
|
+
<OrderID>b3dca49e3ec77e42ab80a0f0f590fff0</OrderID>
|
|
138
|
+
<TransactionType>SALE</TransactionType>
|
|
139
|
+
<Approved>DECLINED</Approved>
|
|
140
|
+
<ReturnCode>N:TESTDECLINE</ReturnCode>
|
|
141
|
+
<ErrMsg/>
|
|
142
|
+
<TaxTotal>0.00</TaxTotal>
|
|
143
|
+
<ShipTotal>0.00</ShipTotal>
|
|
144
|
+
<SubTotal>24.00</SubTotal>
|
|
145
|
+
<FullTotal>24.00</FullTotal>
|
|
146
|
+
<PaymentType>CC</PaymentType>
|
|
147
|
+
<CardNumber>......4242</CardNumber>
|
|
148
|
+
<TransRefNumber>1bdde305df991f89</TransRefNumber>
|
|
149
|
+
<CardIDResult>M</CardIDResult>
|
|
150
|
+
<AVSResult>X</AVSResult>
|
|
151
|
+
<CardAuthNumber>TEST</CardAuthNumber>
|
|
152
|
+
<CardRefNumber>TESTTRANS</CardRefNumber>
|
|
153
|
+
<CardType>VISA</CardType>
|
|
154
|
+
<IPResult>NNN</IPResult>
|
|
155
|
+
<IPCountry>UN</IPCountry>
|
|
156
|
+
<IPRegion>UNKNOWN</IPRegion>
|
|
157
|
+
<IPCity>UNKNOWN</IPCity>
|
|
158
|
+
</Result>
|
|
159
|
+
RESPONSE
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def xml_purchase_fixture
|
|
163
|
+
'<?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>'
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def xml_capture_fixture
|
|
167
|
+
'<?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>'
|
|
168
|
+
end
|
|
169
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class PslCardTest < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
def setup
|
|
6
|
+
@gateway = PslCardGateway.new(
|
|
7
|
+
:login => 'LOGIN',
|
|
8
|
+
:password => 'PASSWORD'
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
@credit_card = credit_card
|
|
12
|
+
@options = {
|
|
13
|
+
:billing_address => address,
|
|
14
|
+
:description => 'Store purchase'
|
|
15
|
+
}
|
|
16
|
+
@amount = 100
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_successful_authorization
|
|
20
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
21
|
+
assert response = @gateway.authorize(@amount, @credit_card, @options)
|
|
22
|
+
assert_success response
|
|
23
|
+
assert_equal '08012522454901256086', response.authorization
|
|
24
|
+
assert response.test?
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_unsuccessful_request
|
|
28
|
+
@gateway.expects(:ssl_post).returns(unsuccessful_purchase_response)
|
|
29
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
30
|
+
assert_failure response
|
|
31
|
+
assert response.test?
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_supported_countries
|
|
35
|
+
assert_equal ['GB'], PslCardGateway.supported_countries
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def test_supported_card_types
|
|
39
|
+
assert_equal [ :visa, :master, :american_express, :diners_club, :jcb, :switch, :solo, :maestro ], PslCardGateway.supported_cardtypes
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_avs_result
|
|
43
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
44
|
+
|
|
45
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
46
|
+
assert_equal 'Y', response.avs_result['code']
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_cvv_result
|
|
50
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
51
|
+
|
|
52
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
53
|
+
assert_equal 'M', response.cvv_result['code']
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
private
|
|
57
|
+
def successful_purchase_response
|
|
58
|
+
"ResponseCode=00&Message=AUTHCODE:01256&CrossReference=08012522454901256086&First4=4543&Last4=9982&ExpMonth=12&ExpYear=2010&AVSCV2Check=ALL MATCH&Amount=1000&QAAddress=76 Roseby Avenue Manchester&QAPostcode=M63X 7TH&MerchantName=Merchant Name&QAName=John Smith"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def unsuccessful_purchase_response
|
|
62
|
+
"ResponseCode=05&Message=CARD DECLINED&QAAddress=The Parkway Larches Approach Hull North Humberside&QAPostcode=HU7 9OP&MerchantName=Merchant Name&QAName="
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class QuickpayTest < Test::Unit::TestCase
|
|
4
|
+
def setup
|
|
5
|
+
@gateway = QuickpayGateway.new(
|
|
6
|
+
:login => 'LOGIN',
|
|
7
|
+
:password => 'PASSWORD'
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
@credit_card = credit_card('4242424242424242')
|
|
11
|
+
@amount = 100
|
|
12
|
+
@options = { :order_id => '1', :billing_address => address }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_successful_purchase
|
|
16
|
+
@gateway.expects(:ssl_post).returns(successful_authorization_response, successful_capture_response)
|
|
17
|
+
|
|
18
|
+
assert response = @gateway.purchase(@amount, @credit_card, @options)
|
|
19
|
+
assert_success response
|
|
20
|
+
assert_equal '2865261', response.authorization
|
|
21
|
+
assert response.test?
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def test_successful_authorization
|
|
25
|
+
@gateway.expects(:ssl_post).returns(successful_authorization_response)
|
|
26
|
+
|
|
27
|
+
assert response = @gateway.authorize(@amount, @credit_card, @options)
|
|
28
|
+
assert_success response
|
|
29
|
+
assert_equal '2865261', response.authorization
|
|
30
|
+
assert response.test?
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_failed_authorization
|
|
34
|
+
@gateway.expects(:ssl_post).returns(failed_authorization_response)
|
|
35
|
+
|
|
36
|
+
assert response = @gateway.authorize(@amount, @credit_card, @options)
|
|
37
|
+
assert_failure response
|
|
38
|
+
assert_equal 'Missing/error in card verification data', response.message
|
|
39
|
+
assert response.test?
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_parsing_response_with_errors
|
|
43
|
+
@gateway.expects(:ssl_post).returns(error_response)
|
|
44
|
+
|
|
45
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
46
|
+
assert_failure response
|
|
47
|
+
assert_equal '008', response.params['qpstat']
|
|
48
|
+
assert_equal 'Missing/error in cardnumber, Missing/error in expirationdate, Missing/error in card verification data, Missing/error in amount, Missing/error in ordernum, Missing/error in currency', response.params['qpstatmsg']
|
|
49
|
+
assert_equal 'Missing/error in cardnumber, Missing/error in expirationdate, Missing/error in card verification data, Missing/error in amount, Missing/error in ordernum, Missing/error in currency', response.message
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def test_merchant_error
|
|
53
|
+
@gateway.expects(:ssl_post).returns(merchant_error)
|
|
54
|
+
|
|
55
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
56
|
+
assert_failure response
|
|
57
|
+
assert_equal response.message, 'Missing/error in merchant'
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def test_parsing_successful_response
|
|
61
|
+
@gateway.expects(:ssl_post).returns(successful_authorization_response)
|
|
62
|
+
|
|
63
|
+
response = @gateway.authorize(@amount, @credit_card, @options)
|
|
64
|
+
|
|
65
|
+
assert_success response
|
|
66
|
+
assert_equal 'OK', response.message
|
|
67
|
+
|
|
68
|
+
assert_equal '2865261', response.authorization
|
|
69
|
+
assert_equal '000', response.params['qpstat']
|
|
70
|
+
assert_equal '000', response.params['pbsstat']
|
|
71
|
+
assert_equal '2865261', response.params['transaction']
|
|
72
|
+
assert_equal '070425223705', response.params['time']
|
|
73
|
+
assert_equal '104680', response.params['ordernum']
|
|
74
|
+
assert_equal 'cody@example.com', response.params['merchantemail']
|
|
75
|
+
assert_equal 'Visa', response.params['cardtype']
|
|
76
|
+
assert_equal @amount.to_s, response.params['amount']
|
|
77
|
+
assert_equal 'OK', response.params['qpstatmsg']
|
|
78
|
+
assert_equal 'Shopify', response.params['merchant']
|
|
79
|
+
assert_equal '1110', response.params['msgtype']
|
|
80
|
+
assert_equal 'USD', response.params['currency']
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def test_supported_countries
|
|
84
|
+
assert_equal ['DK'], QuickpayGateway.supported_countries
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def test_supported_card_types
|
|
88
|
+
assert_equal [ :dankort, :forbrugsforeningen, :visa, :master, :american_express, :diners_club, :jcb, :maestro ], QuickpayGateway.supported_cardtypes
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
private
|
|
92
|
+
|
|
93
|
+
def error_response
|
|
94
|
+
"<?xml version='1.0' encoding='ISO-8859-1'?><response><qpstat>008</qpstat><qpstatmsg>Missing/error in cardnumber, Missing/error in expirationdate, Missing/error in card verification data, Missing/error in amount, Missing/error in ordernum, Missing/error in currency</qpstatmsg></response>"
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def merchant_error
|
|
98
|
+
"<?xml version='1.0' encoding='ISO-8859-1'?><response><qpstat>008</qpstat><qpstatmsg>Missing/error in merchant</qpstatmsg></response>"
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def successful_authorization_response
|
|
102
|
+
"<?xml version='1.0' encoding='ISO-8859-1'?><response><qpstat>000</qpstat><transaction>2865261</transaction><time>070425223705</time><ordernum>104680</ordernum><merchantemail>cody@example.com</merchantemail><pbsstat>000</pbsstat><cardtype>Visa</cardtype><amount>100</amount><qpstatmsg>OK</qpstatmsg><merchant>Shopify</merchant><msgtype>1110</msgtype><currency>USD</currency></response>"
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def successful_capture_response
|
|
106
|
+
'<?xml version="1.0" encoding="ISO-8859-1"?><response><msgtype>1230</msgtype><amount>100</amount><time>080107061755</time><pbsstat>000</pbsstat><qpstat>000</qpstat><qpstatmsg>OK</qpstatmsg><currency>DKK</currency><ordernum>4820346075804536193</ordernum><transaction>2865261</transaction><merchant>Shopify</merchant><merchantemail>pixels@jadedpixel.com</merchantemail></response>'
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def failed_authorization_response
|
|
110
|
+
'<?xml version="1.0" encoding="ISO-8859-1"?><response><qpstat>008</qpstat><qpstatmsg>Missing/error in card verification data</qpstatmsg></response>'
|
|
111
|
+
end
|
|
112
|
+
end
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
require 'digest/sha1'
|
|
3
|
+
|
|
4
|
+
class RealexTest < Test::Unit::TestCase
|
|
5
|
+
|
|
6
|
+
def setup
|
|
7
|
+
@login = 'your_merchant_id'
|
|
8
|
+
@password = 'your_secret'
|
|
9
|
+
|
|
10
|
+
@gateway = RealexGateway.new(
|
|
11
|
+
:login => @merchant_id,
|
|
12
|
+
:password => @secret,
|
|
13
|
+
:account => ''
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
@gateway_with_account = RealexGateway.new(
|
|
17
|
+
:login => @merchant_id,
|
|
18
|
+
:password => @secret,
|
|
19
|
+
:account => 'bill_web_cengal'
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
@credit_card = CreditCard.new(
|
|
23
|
+
:number => '4263971921001307',
|
|
24
|
+
:month => 8,
|
|
25
|
+
:year => 2008,
|
|
26
|
+
:first_name => 'Longbob',
|
|
27
|
+
:last_name => 'Longsen',
|
|
28
|
+
:type => 'visa'
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
@options = {
|
|
32
|
+
:order_id => '1'
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@amount = 100
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def test_in_test
|
|
40
|
+
assert_equal :test, ActiveMerchant::Billing::Base.gateway_mode
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_hash
|
|
44
|
+
result = Digest::SHA1.hexdigest("20061213105925.your_merchant_id.1.400.EUR.4263971921001307")
|
|
45
|
+
assert_equal "6bbce4d13f8e830401db4ee530eecb060bc50f64", result
|
|
46
|
+
|
|
47
|
+
#add the secret to the end
|
|
48
|
+
result = Digest::SHA1.hexdigest(result + "." + @password)
|
|
49
|
+
assert_equal "06a8b619cbd76024676401e5a83e7e5453521af3", result
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def test_successful_purchase
|
|
53
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
54
|
+
|
|
55
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
56
|
+
assert_instance_of Response, response
|
|
57
|
+
assert_success response
|
|
58
|
+
assert response.test?
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_unsuccessful_purchase
|
|
62
|
+
@gateway.expects(:ssl_post).returns(unsuccessful_purchase_response)
|
|
63
|
+
|
|
64
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
65
|
+
assert_instance_of Response, response
|
|
66
|
+
assert_failure response
|
|
67
|
+
assert response.test?
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def test_supported_countries
|
|
71
|
+
assert_equal ['IE', 'GB'], RealexGateway.supported_countries
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def test_supported_card_types
|
|
75
|
+
assert_equal [ :visa, :master, :american_express, :diners_club, :switch, :solo, :laser ], RealexGateway.supported_cardtypes
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def test_avs_result_not_supported
|
|
79
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
80
|
+
|
|
81
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
82
|
+
assert_nil response.avs_result['code']
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def test_cvv_result
|
|
86
|
+
@gateway.expects(:ssl_post).returns(successful_purchase_response)
|
|
87
|
+
|
|
88
|
+
response = @gateway.purchase(@amount, @credit_card, @options)
|
|
89
|
+
assert_equal 'M', response.cvv_result['code']
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
private
|
|
93
|
+
|
|
94
|
+
def successful_purchase_response
|
|
95
|
+
<<-RESPONSE
|
|
96
|
+
<response timestamp='20010427043422'>
|
|
97
|
+
<merchantid>your merchant id</merchantid>
|
|
98
|
+
<account>account to use</account>
|
|
99
|
+
<orderid>order id from request</orderid>
|
|
100
|
+
<authcode>authcode received</authcode>
|
|
101
|
+
<result>00</result>
|
|
102
|
+
<message>[ test system ] message returned from system</message>
|
|
103
|
+
<pasref> realex payments reference</pasref>
|
|
104
|
+
<cvnresult>M</cvnresult>
|
|
105
|
+
<batchid>batch id for this transaction (if any)</batchid>
|
|
106
|
+
<cardissuer>
|
|
107
|
+
<bank>Issuing Bank Name</bank>
|
|
108
|
+
<country>Issuing Bank Country</country>
|
|
109
|
+
<countrycode>Issuing Bank Country Code</countrycode>
|
|
110
|
+
<region>Issuing Bank Region</region>
|
|
111
|
+
</cardissuer>
|
|
112
|
+
<tss>
|
|
113
|
+
<result>89</result>
|
|
114
|
+
<check id="1000">9</check>
|
|
115
|
+
<check id="1001">9</check>
|
|
116
|
+
</tss>
|
|
117
|
+
<sha1hash>7384ae67....ac7d7d</sha1hash>
|
|
118
|
+
<md5hash>34e7....a77d</md5hash>
|
|
119
|
+
</response>"
|
|
120
|
+
RESPONSE
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def unsuccessful_purchase_response
|
|
124
|
+
<<-RESPONSE
|
|
125
|
+
<response timestamp='20010427043422'>
|
|
126
|
+
<merchantid>your merchant id</merchantid>
|
|
127
|
+
<account>account to use</account>
|
|
128
|
+
<orderid>order id from request</orderid>
|
|
129
|
+
<authcode>authcode received</authcode>
|
|
130
|
+
<result>01</result>
|
|
131
|
+
<message>[ test system ] message returned from system</message>
|
|
132
|
+
<pasref> realex payments reference</pasref>
|
|
133
|
+
<cvnresult>M</cvnresult>
|
|
134
|
+
<batchid>batch id for this transaction (if any)</batchid>
|
|
135
|
+
<cardissuer>
|
|
136
|
+
<bank>Issuing Bank Name</bank>
|
|
137
|
+
<country>Issuing Bank Country</country>
|
|
138
|
+
<countrycode>Issuing Bank Country Code</countrycode>
|
|
139
|
+
<region>Issuing Bank Region</region>
|
|
140
|
+
</cardissuer>
|
|
141
|
+
<tss>
|
|
142
|
+
<result>89</result>
|
|
143
|
+
<check id="1000">9</check>
|
|
144
|
+
<check id="1001">9</check>
|
|
145
|
+
</tss>
|
|
146
|
+
<sha1hash>7384ae67....ac7d7d</sha1hash>
|
|
147
|
+
<md5hash>34e7....a77d</md5hash>
|
|
148
|
+
</response>"
|
|
149
|
+
RESPONSE
|
|
150
|
+
end
|
|
151
|
+
end
|