1

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' => '87'
'commerceTransactionHash' => 'f4dcff157345d68b54934791fe7b0522'
)
$_POST=array (
'DATA' => '<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" />'
'SIGNATURE' => '3eec17d64cd2f4e9e57402e3efb1d91d79af35cf462f1f971ad2aa79ceda5e6814d7fb4d82cf2bfe044c791cbc38ea3007598d4d0ac6ba16db08e1abb2dc0b61'
)
$_SESSION=array (
'1c4d338641dbdf309e6ed655daae834eYii.CWebUser.flash.error' => 'Payment Error: '
'1c4d338641dbdf309e6ed655daae834eYii.CWebUser.flashcounters' =>
array (
'error' => 0
)
)

The QUERY_STRING cuts after the transaction hash:

'commerceTransactionId=87&commerceTransactionHash=f4dcff157345d68b54934791fe7b0522'

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

$_GET=array (
'commerceTransactionId' => '56'
'commerceTransactionHash' => '2db11e4c56020b3adad7565478f2bc56'
'DATA' => '<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" />'
'SIGNATURE' => '0378583461a09e40efe22a39cc5c7ca4c3bbe4e7f89c041154b00bcd1b65604309d219bad395ee2fefabc8726e9afd2364b769baa08ac927317698a9ab795e8b'
)

Remotely it lives on a sub domain. What could be the problem?

  • Which gateway driver are you using? – Luke Holder May 18 '17 at 13:10
  • SaferPay by Six Payment Solutions. I had to make a plugin. I have just resolved the problem: a function collected the wrong data. Apparently the universe decided asking for help a required step to solving stuff on your own. – Marcus Scheller May 18 '17 at 13:13
  • But a different problem arised: Now I have a Error Message: DATA Atribute missing although it is clearly there. If I catch the URL and use that a second time it works. What could that be? – Marcus Scheller May 18 '17 at 13:14
  • Again, works locally. – Marcus Scheller May 18 '17 at 13:18
  • Can you add an answer for the solution that worked for this question? If you have a new question, you can post it separately. – Brad Bell May 18 '17 at 21:34
2

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()->on('commerce_transactions.onSaveTransaction', function ($event){

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

});
|improve this answer|||||
  • Thanks Jeremy. This is great! My issues have been resolved. I am adding my findings in an answer. – Marcus Scheller May 19 '17 at 7:32
1

The Complete Function of the SaferPay gateway had the wrong arguments which I didn’t catch first thus creating a malformed request, I guess. Fixing that solved the problem.

As for the second issue (Missing DATA attribute): turned out that I didn’t have CSRF protection enabled which I was sure that I had. But this Craft installation is from around 2014 and I only picked up working on it again this month. So I missed that also. Enabling it (as suggested in the docs) resolved that too so everything is working as expected now.

I have no idea about the inner workings of this so if anyone could enlighten me on that I would be very grateful. My knowledge of PHP is pretty much non existing and I am merely glueing stuff together and see what works.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.