Skip to content

Commit

Permalink
Use basic SkipJack host for all non-authorization transactions. Fix s…
Browse files Browse the repository at this point in the history
…tatus method
  • Loading branch information
Cody Fauser committed Oct 8, 2009
1 parent 2dc4fb2 commit a3d18bd
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 4 deletions.
1 change: 1 addition & 0 deletions 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]
Expand Down
6 changes: 2 additions & 4 deletions lib/active_merchant/billing/gateways/skip_jack.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
56 changes: 56 additions & 0 deletions test/unit/gateways/skip_jack_test.rb
Expand Up @@ -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
Expand All @@ -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

0 comments on commit a3d18bd

Please sign in to comment.