Redsys Recieve Wrong Amount Format For Some Orders


I have version 4.9.3 and recently changed from PHP 7.0 to PHP 7.2 and now some orders do not send correct amount to Redsys payment processor. The redsys error SIS0019 => «Error de formato en Ds_Merchant_Amount»

I changed tax subtotal accuracy in fn.common to

$price = sprintf('%.' . $decimals . 'f', round((double) $price + 0.00000000001, 2));

but it did not help. Redys keeps receiving 0 total amount.

The weird thing is that it only happens with some products and orders.

How to fix it?


Is there some other place which controls round up of the prices?

I observed the following

My product price:

49.00 - 35% discount (promotion active) = 31.85 + Delivery 6.60 , total amount 38.45 as a result total amount send to Redsys is 0

Now when I changed delivery to 6.59, so the total amount is 38.44 everything works correct!

What is the issue?

Any idea what is the problem?

Someone knows if it is a bug or misconfiguration? The point is that if the error exists in one particular price amount means that it exists in some other price amounts as well.

It is required to check code of the redsys.php script

I checked redsys.php and it is same in 4.9 and 4.11 also it is strange that issue only happens after PHP 7.0 was changed to PHP 7.2

We never faced such issue and cannot answer you without code examination

Me neither. I spoke with Redsys and they told it is round up issue on the cart side.

Also I noticed that the problem occurs only when the total amount ends with xx.x5. (for example: 30.25, 54.15, 25.95, etc)

Is there any way to temporary bypass this issue?

as I know the round up is controlled by fn.common and

servired.php pass the amount as follows:

$amount = ($currency == '978') ? ($order_info['total'] * 100) : $order_info['total'];

How can I see the real total amount which are passed to redsys?

Well, I found the issue.

Looks like after PHP 7.0.33 there is a PHP bug

I think cs cart should update servired.php for php versions 7.033 and up, as follows to correct the bug with round up:

For those who have the same problem you need to change the following lines 70 and 124 in servired.php


$amount = ($currency == '978') ? ($order_info['total'] * 100) : $order_info['total'];


$amount = ($currency == '978') ? (int)($order_info['total'] * 100) : $order_info['total'];

Problem solved.

Thank you for keeping us updated