tomaj / omnipay-tatra

5 stars 12 forks source link

Handle comfortpay SoapFault #12

Open rootpd opened 3 years ago

rootpd commented 3 years ago

Based on the latest doc (2.0.4), Comfortpay can return SoapFault (exceptions) with error codes with the real meaning:

The error response can look like this:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope" xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:types="urn:tatrabanka:ibanking:Types" xmlns:teleplatba="urn:tatrabanka:ibanking:Teleplatba" xmlns:vposCommon="http://www.ri-rpc.sk/cmsdd/aim/common" xmlns:vposAuth="http://www.ri-rpc.sk/cmsdd/aim/vposAuth" xmlns:vposAuthFollow="http://www.ri-rpc.sk/cmsdd/aim/vposAuthFollow" xmlns:vposAuthResponse="http://www.ri-rpc.sk/cmsdd/aim/vposAuthResponse">
    <SOAP-ENV:Body>
        <SOAP-ENV:Fault>
            <SOAP-ENV:Code>
                <SOAP-ENV:Value>SOAP-ENV:Receiver</SOAP-ENV:Value>
            </SOAP-ENV:Code>
            <SOAP-ENV:Reason>
                <SOAP-ENV:Text xml:lang="en"></SOAP-ENV:Text>
            </SOAP-ENV:Reason>
            <SOAP-ENV:Detail>
                <types:ExceptionType>
                    <method>checkCard</method>
                    <file>ImplFile</file>
                    <line>2022</line>
                    <errorCode>50000</errorCode>
                    <subsystemId>19</subsystemId>
                    <subsystemErrorCode>0</subsystemErrorCode>
                    <message></message>
                </types:ExceptionType>
            </SOAP-ENV:Detail>
        </SOAP-ENV:Fault>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

To correctly handle these cases, library should probably catch SoapFault and extract errorCode from the response, same way as it extracts transactionStatus in successful payment.