Skip to content

Commit

Permalink
Handle all successful SecurePay AU response codes
Browse files Browse the repository at this point in the history
  • Loading branch information
Cody Fauser committed May 27, 2008
1 parent 4b90e7c commit 5efe628
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
@@ -1,5 +1,6 @@
= ActiveMerchant CHANGELOG

* Handle all successful SecurePay AU response codes [cody]
* Get SageGateway working with real test account. Improve test suite. [cody]
* Unify TrustCommerce, Payment Express, and Braintree CC storage [benjamin.curtis]
* Update to use new Payflow Pro URLs [cody]
Expand Down
4 changes: 3 additions & 1 deletion lib/active_merchant/billing/gateways/secure_pay_au.rb
Expand Up @@ -36,6 +36,8 @@ class SecurePayAuGateway < Gateway
:credit => 4
}

SUCCESS_CODES = [ '00', '08', '11', '16', '77' ]

def initialize(options = {})
requires!(options, :login, :password)
@options = options
Expand Down Expand Up @@ -109,7 +111,7 @@ def commit(action, request)
end

def success?(response)
response[:response_code] == "00"
SUCCESS_CODES.include?(response[:response_code])
end

def authorization_from(response)
Expand Down
59 changes: 58 additions & 1 deletion test/unit/gateways/secure_pay_au_test.rb
Expand Up @@ -17,6 +17,17 @@ def setup
}
end

def test_successful_purchase_with_live_data
@gateway.expects(:ssl_post).returns(successful_live_purchase_response)

assert response = @gateway.purchase(@amount, @credit_card, @options)
assert_instance_of Response, response
assert_success response

assert_equal '000000', response.authorization
assert response.test?
end

def test_successful_purchase
@gateway.expects(:ssl_post).returns(successful_purchase_response)

Expand Down Expand Up @@ -97,7 +108,6 @@ def successful_purchase_response
</TxnList>
</Payment>
</SecurePayMessage>
XML
end

Expand Down Expand Up @@ -147,4 +157,51 @@ def failed_purchase_response
</SecurePayMessage>
XML
end

def successful_live_purchase_response
<<-XML
<?xml version="1.0" encoding="UTF-8"?>
<SecurePayMessage>
<MessageInfo>
<messageID>8af793f9af34bea0cf40f5fb5c630c</messageID>
<messageTimestamp>20080802041625665000+660</messageTimestamp>
<apiVersion>xml-4.2</apiVersion>
</MessageInfo>
<RequestType>Payment</RequestType>
<MerchantInfo>
<merchantID>XYZ0001</merchantID>
</MerchantInfo>
<Status>
<statusCode>000</statusCode>
<statusDescription>Normal</statusDescription>
</Status>
<Payment>
<TxnList count="1">
<Txn ID="1">
<txnType>0</txnType>
<txnSource>23</txnSource>
<amount>211700</amount>
<currency>AUD</currency>
<purchaseOrderNo>#1047.5</purchaseOrderNo>
<approved>Yes</approved>
<responseCode>77</responseCode>
<responseText>Approved</responseText>
<thinlinkResponseCode>100</thinlinkResponseCode>
<thinlinkResponseText>000</thinlinkResponseText>
<thinlinkEventStatusCode>000</thinlinkEventStatusCode>
<thinlinkEventStatusText>Normal</thinlinkEventStatusText>
<settlementDate>20080525</settlementDate>
<txnID>000000</txnID>
<CreditCardInfo>
<pan>424242...242</pan>
<expiryDate>07/11</expiryDate>
<cardType>6</cardType>
<cardDescription>Visa</cardDescription>
</CreditCardInfo>
</Txn>
</TxnList>
</Payment>
</SecurePayMessage>
XML
end
end

0 comments on commit 5efe628

Please sign in to comment.