Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix up response message for Modern payments

  • Loading branch information...
commit 052915af2d4e388a13fc020478e584a67220b92c 1 parent aa74045
Cody Fauser authored
View
2  lib/active_merchant/billing/gateways/modern_payments_cim.rb
@@ -211,7 +211,7 @@ def parse_element(response, node)
if node.has_elements?
node.elements.each{|e| parse_element(response, e) }
else
- response[node.name.underscore.to_sym] = node.text
+ response[node.name.underscore.to_sym] = node.text.to_s.strip
end
end
end
View
1  test/remote/gateways/remote_modern_payments_test.rb
@@ -53,4 +53,5 @@ def test_invalid_login
gateway.purchase(@amount, @credit_card, @options)
end
end
+
end
View
53 test/unit/gateways/modern_payments_cim_test.rb
@@ -40,22 +40,23 @@ def test_modify_customer_credit_card
end
def test_successful_credit_card_authorization
- @gateway.expects(:ssl_post).returns(successful_credit_card_authorization_response)
+ @gateway.expects(:ssl_post).returns(successful_authorization_response)
assert response = @gateway.authorize_credit_card_payment("10001", @amount)
assert_instance_of Response, response
assert response.test?
assert_success response
- assert_equal "999", response.params["trans_id"]
- assert_equal "RESPONSECODE=A,AUTHCODE=XXXXXX,DECLINEREASON=,AVSDATA=NYZ,TRANSID=C00 TESTXXXXXXX", response.params["auth_string"]
- assert_equal "RESPONSECODE=A,AUTHCODE=XXXXXX,DECLINEREASON=,AVSDATA=NYZ,TRANSID=C00 TESTXXXXXXX", response.params["message_text"]
+ assert_equal "18713505", response.params["trans_id"]
+ assert_equal "RESPONSECODE=A\nAUTHCODE=020411\nDECLINEREASON=\nAVSDATA=Z\nTRANSID=C00 17093294", response.params["auth_string"]
+ assert_equal "Approved", response.params["message_text"]
assert_equal "true", response.params["approved"]
- assert_equal nil, response.params["avs_code"]
- assert_equal nil, response.params["auth_code"]
- assert_equal nil, response.params["trans_code"]
- assert_equal "999", response.authorization
- assert_match /RESPONSECODE=A/, response.params["message_text"]
+ assert_equal "Z", response.params["avs_code"]
+ assert_equal "020411", response.params["auth_code"]
+ assert_equal "C00 17093294", response.params["trans_code"]
+ assert_equal "18713505", response.authorization
+ assert_equal ModernPaymentsCimGateway::SUCCESS_MESSAGE, response.message
+ assert_equal 'Z', response.avs_result['code']
end
def test_unsuccessful_credit_card_authorization
@@ -107,27 +108,6 @@ def successful_modify_customer_credit_card_response
XML
end
- def successful_credit_card_authorization_response
- <<-XML
-<?xml version="1.0" encoding="utf-8"?>
-<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <soap:Body>
- <AuthorizeCreditCardPaymentResponse xmlns="https://secure.modpay.com/netservices/test/">
- <AuthorizeCreditCardPaymentResult>
- <transId>999</transId>
- <authCode/>
- <avsCode/>
- <transCode/>
- <authString>RESPONSECODE=A,AUTHCODE=XXXXXX,DECLINEREASON=,AVSDATA=NYZ,TRANSID=C00 TESTXXXXXXX</authString>
- <messageText>RESPONSECODE=A,AUTHCODE=XXXXXX,DECLINEREASON=,AVSDATA=NYZ,TRANSID=C00 TESTXXXXXXX</messageText>
- <approved>true</approved>
- </AuthorizeCreditCardPaymentResult>
- </AuthorizeCreditCardPaymentResponse>
- </soap:Body>
-</soap:Envelope>
- XML
- end
-
def unsuccessful_credit_card_authorization_response
<<-XML
<?xml version="1.0" encoding="utf-8"?>
@@ -167,5 +147,16 @@ def soap_fault_response
</soap:Envelope>
XML
end
-
+
+ def successful_authorization_response
+ <<-XML
+<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><AuthorizeCreditCardPaymentResponse xmlns="https://secure.modpay.com/ws/"><AuthorizeCreditCardPaymentResult><transId>18713505</transId><authCode>020411</authCode><avsCode>Z</avsCode><transCode>C00 17093294
+</transCode><authString>RESPONSECODE=A
+AUTHCODE=020411
+DECLINEREASON=
+AVSDATA=Z
+TRANSID=C00 17093294
+</authString><messageText>Approved</messageText><approved>true</approved></AuthorizeCreditCardPaymentResult></AuthorizeCreditCardPaymentResponse></soap:Body></soap:Envelope>
+ XML
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.