From a3d18bd755595ba78b897237a116bafc464bed55 Mon Sep 17 00:00:00 2001 From: Cody Fauser Date: Thu, 8 Oct 2009 10:20:42 -0300 Subject: [PATCH] Use basic SkipJack host for all non-authorization transactions. Fix status method --- CHANGELOG | 1 + .../billing/gateways/skip_jack.rb | 6 +- test/unit/gateways/skip_jack_test.rb | 56 +++++++++++++++++++ 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 4cd649209b1..1f0d4bc5427 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ = ActiveMerchant CHANGELOG +* Use basic SkipJack host for all non-authorization transactions. Fix status method [cody] * Strip non alpha numeric chars out of MerchantWare order number [cody] * Parse complete response of Authorize.net CIM gateway [Patrick Joyce] * Update to PayPal Sandbox URL for testing Payflow Pro Express Checkout. See Express Checkout for Payflow Pro guide [cody] diff --git a/lib/active_merchant/billing/gateways/skip_jack.rb b/lib/active_merchant/billing/gateways/skip_jack.rb index 2fc41d16220..d26ba60a8f9 100644 --- a/lib/active_merchant/billing/gateways/skip_jack.rb +++ b/lib/active_merchant/billing/gateways/skip_jack.rb @@ -245,9 +245,7 @@ def credit(money, identification, options = {}) end def status(order_id) - post = { } - post[:szOrderNumber] = :order_id - commit(:get_status, nil, post) + commit(:get_status, nil, :szOrderNumber => order_id) end private @@ -278,7 +276,7 @@ def commit(action, money, parameters) def url_for(action) result = test? ? TEST_HOST : LIVE_HOST - result += advanced? ? ADVANCED_PATH : BASIC_PATH + result += advanced? && action == :authorization ? ADVANCED_PATH : BASIC_PATH result += "?#{ACTIONS[action]}" end diff --git a/test/unit/gateways/skip_jack_test.rb b/test/unit/gateways/skip_jack_test.rb index 115cf68426a..ced0ff05a0f 100644 --- a/test/unit/gateways/skip_jack_test.rb +++ b/test/unit/gateways/skip_jack_test.rb @@ -116,24 +116,65 @@ def test_basic_test_url assert_equal "https://developer.skipjackic.com/scripts/evolvcc.dll?AuthorizeAPI", @gateway.send(:url_for, :authorization) end + def test_basic_test_url_non_authorization + @gateway.stubs(:test?).returns(true) + @gateway.stubs(:advanced?).returns(false) + assert_equal "https://developer.skipjackic.com/scripts/evolvcc.dll?SJAPI_TransactionChangeStatusRequest", @gateway.send(:url_for, :change_status) + end + def test_advanced_test_url @gateway.stubs(:test?).returns(true) @gateway.stubs(:advanced?).returns(true) assert_equal "https://developer.skipjackic.com/evolvcc/evolvcc.aspx?AuthorizeAPI", @gateway.send(:url_for, :authorization) end + def test_advanced_test_url_non_authorization + @gateway.stubs(:test?).returns(true) + @gateway.stubs(:advanced?).returns(true) + assert_equal "https://developer.skipjackic.com/scripts/evolvcc.dll?SJAPI_TransactionChangeStatusRequest", @gateway.send(:url_for, :change_status) + end + def test_basic_live_url @gateway.stubs(:test?).returns(false) @gateway.stubs(:advanced?).returns(false) assert_equal "https://www.skipjackic.com/scripts/evolvcc.dll?AuthorizeAPI", @gateway.send(:url_for, :authorization) end + def test_basic_live_url_non_authorization + @gateway.stubs(:test?).returns(false) + @gateway.stubs(:advanced?).returns(false) + assert_equal "https://www.skipjackic.com/scripts/evolvcc.dll?SJAPI_TransactionChangeStatusRequest", @gateway.send(:url_for, :change_status) + end + def test_advanced_live_url @gateway.stubs(:test?).returns(false) @gateway.stubs(:advanced?).returns(true) assert_equal "https://www.skipjackic.com/evolvcc/evolvcc.aspx?AuthorizeAPI", @gateway.send(:url_for, :authorization) end + def test_advanced_live_url_non_authorization + @gateway.stubs(:test?).returns(false) + @gateway.stubs(:advanced?).returns(true) + assert_equal "https://www.skipjackic.com/scripts/evolvcc.dll?SJAPI_TransactionChangeStatusRequest", @gateway.send(:url_for, :change_status) + end + + def test_paymentech_authorization_success + @gateway.expects(:ssl_post).returns(successful_paymentech_authorization_response) + + assert response = @gateway.authorize(@amount, @credit_card, @options) + assert_instance_of Response, response + assert_success response + assert_equal '40000024585892.109', response.authorization + end + + def test_paymentech_authorization_failure + @gateway.expects(:ssl_post).returns(unsuccessful_paymentech_authorization_response) + + assert response = @gateway.authorize(@amount, @credit_card, @options) + assert_instance_of Response, response + assert_failure response + end + private def successful_authorization_response <<-CSV @@ -154,4 +195,19 @@ def unsuccessful_authorization_response "AUTHCODE","szSerialNumber","szTransactionAmount","szAuthorizationDeclinedMessage","szAVSResponseCode","szAVSResponseMessage","szOrderNumber","szAuthorizationResponseCode","szIsApproved","szCVV2ResponseCode","szCVV2ResponseMessage","szReturnCode","szTransactionFileName","szCAVVResponseCode"\r\n"EMPTY","000386891209","100","","","","b1eec256d0182f29375e0cbae685092d","","0","","","-35","","" CSV end + + def unsuccessful_paymentech_authorization_response + <<-CSV +"AUTHCODE","szSerialNumber","szTransactionAmount","szAuthorizationDeclinedMessage","szAVSResponseCode","szAVSResponseMessage","szOrderNumber","szAuthorizationResponseCode","szIsApproved","szCVV2ResponseCode","szCVV2ResponseMessage","szReturnCode","szTransactionFileName","szCAVVResponseCode", +"EMPTY","000000000000","1.00","","","","43985b7953199d1f02c3017f948e9f13","","0","","","-83","","", + CSV + end + + def successful_paymentech_authorization_response + <<-CSV +"AUTHCODE","szSerialNumber","szTransactionAmount","szAuthorizationDeclinedMessage","szAVSResponseCode","szAVSResponseMessage","szOrderNumber","szAuthorizationResponseCode","szIsApproved","szCVV2ResponseCode","szCVV2ResponseMessage","szReturnCode","szTransactionFileName","szCAVVResponseCode", +"093223","000000000000","1.00","","Y","Card authorized, exact address match with 5 digit zip code.","5ac0f04e737baea5a5370037afe827f6","093223","1","M","Match","1","40000024585892.109","", + CSV + end end +