Commerce: Payment does not get completed I am having trouble getting a payment completed (SaferPay, offsite gateway). After coming back from the payment provider I get redirected to the unchanged payment page again with the following error message: Payment Error: , the error code (?) is 0.

I have found this in the logs:

$_GET=array (
'commerceTransactionId' =&gt; '87'
'commerceTransactionHash' =&gt; 'f4dcff157345d68b54934791fe7b0522'
)
$_POST=array (
'DATA' =&gt; '&lt;IDP MSGTYPE="PayConfirm" TOKEN="(unused)" VTVERIFY="(obsolete)" KEYID="1-0" ID="Oh7p4zbhSnWOUAzjGE5bAS4rSnAb" ACCOUNTID="401860-17795278" PROVIDERID="1395" PROVIDERNAME="PayPal Saferpay Test" PAYMENTMETHOD="16" ORDERID="2435" AMOUNT="3071" CURRENCY="EUR" IP="84.141.245.197" IPCOUNTRY="DE" /&gt;'
'SIGNATURE' =&gt; '3eec17d64cd2f4e9e57402e3efb1d91d79af35cf462f1f971ad2aa79ceda5e6814d7fb4d82cf2bfe044c791cbc38ea3007598d4d0ac6ba16db08e1abb2dc0b61'
)
$_SESSION=array (
'1c4d338641dbdf309e6ed655daae834eYii.CWebUser.flash.error' =&gt; 'Payment Error: '
'1c4d338641dbdf309e6ed655daae834eYii.CWebUser.flashcounters' =&gt;
array (
'error' =&gt; 0
)
)


The QUERY_STRING cuts after the transaction hash:   

'commerceTransactionId=87&amp;commerceTransactionHash=f4dcff157345d68b54934791fe7b0522'


Strangeley enough it is working locally, where the log says the following:

$_GET=array (
'commerceTransactionId' =&gt; '56'
'commerceTransactionHash' =&gt; '2db11e4c56020b3adad7565478f2bc56'
'DATA' =&gt; '&lt;IDP MSGTYPE="PayConfirm" TOKEN="(unused)" VTVERIFY="(obsolete)" KEYID="1-0" ID="GCzE6MbphEYrSAUYhlA9bnvY6Y7b" ACCOUNTID="401860-17795278" PROVIDERID="1395" PROVIDERNAME="PayPal Saferpay Test" PAYMENTMETHOD="16" ORDERID="2435" AMOUNT="20430" CURRENCY="EUR" IP="84.141.245.197" IPCOUNTRY="DE" /&gt;'
'SIGNATURE' =&gt; '0378583461a09e40efe22a39cc5c7ca4c3bbe4e7f89c041154b00bcd1b65604309d219bad395ee2fefabc8726e9afd2364b769baa08ac927317698a9ab795e8b'
)


Remotely it lives on a sub domain. What could be the problem?
Not an answer to the specific issue as such, but perhaps handy for future folks looking to debug issues in this area - you can dump the gateway request data with something like this in your business logic plugin:

(see hook docs here: https://craftcommerce.com/docs/hooks-reference#commerce_modifygatewayrequestdata)

    public function commerce_modifyGatewayRequestData($data,$type,$transaction)
{

        BusinessLogicPlugin::log("commerce_modifyGatewayRequestData"); 
        BusinessLogicPlugin::log("data");
        BusinessLogicPlugin::log($data);
        BusinessLogicPlugin::log("type");
        BusinessLogicPlugin::log($type);
        BusinessLogicPlugin::log("transaction");
        BusinessLogicPlugin::log($transaction);
 }


(assuming you have a log function in there that accepts strings and if not a string does a var_dump)

That at least gives you a full look at the data you're sending.

You can also modify the $data in there, and return $data at the end if you need to massage any of the data before submissin.  E.g. with eWay you should truncate some fields if they are too long or you will get errors...

E.g.

        if(isset($data['Customer']['Street1']))
        $data['Customer']['Street1'] = substr($data['Customer']['Street1'], 0, 49);

        ...etc

        return $data;


Similarly, after a transaction, you can log the response etc using this event: https://craftcommerce.com/docs/events-reference#commerce_transactions.onsavetransaction

(See what you can log at https://craftcommerce.com/docs/transaction-model)

craft()-&gt;on('commerce_transactions.onSaveTransaction', function ($event){

    $transaction = $event-&gt;params['transaction'];
    BusinessLogicPlugin::log($transaction-&gt;response);

});