Sermepa returns the quantity payed in a bad format and this way of managing it doesn't work well:

uc_payment_enter($order->order_id, 'lacaixa', $values['Ds_Amount'], 0, NULL, $comment);

The module solves this problem by passing the payment as the full payment, but this approach assumes that the payment is made full always and I'm not sure if there are cases that make a partial payment.

uc_payment_enter($order->order_id, 'lacaixa', $order->order_total, 0, NULL, $comment);

The sollution proposed for victorcoder is to format the returning amount from sermepa

    $amount_decimal = substr($values['Ds_Amount'], -2);
    $amount_integer = substr($values['Ds_Amount'], 0, -2);
    $amount = $amount_integer . "." . $amount_decimal;

Let's use this issue for applying the best option.

Comments

victorcoder’s picture

As pcambra said, formatting the value returned by sermepa will rely on them maintaining the same format over time.

I think, changing the format of returned values by sermepa is a major issue for their clients as they would have to adapt all existing software.

Given this, we should have time to adapt to the new format.

Somenone out there has a system where the ubercart user could pay only part of the total goods?

For instance I will continue using the module as is.

pcambra’s picture

I'm not sure of the formatting function, maybe the amount of decimals is not fixed always, do you know if sermepa returns this somehow in the $values array?

The ideal would be your version but with the amount of decimals that return sermepa, just in case. Maybe sometimes is 0

victorcoder’s picture

As specified in their service manual, the two last positions of the Ds_Amount field are considered as decimals for EUR always, but also is specified that if it's values will be the same of Ds_Merchant_Amount so maybe can we leave it as is?

pcambra’s picture

And what happens if the payment is made in a currency different from EUR? I think you can pay through sermepa in USD.

I've revised and I've found this other field: Ds_Merchant_SumTotal which specifies with the two last digits as decimals.

In the documentation it assumes this referring to Ds_Merchant_Amount:
El Importe vendrá multiplicado por 100, sin decimales y sin ceros a la izquierda.

Maybe another solution is possible, $order_total = Ds_Merchant_Amount/100, what do you think?

pcambra’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev
Status: Active » Fixed

I've applied the division by 100 in the 2.x version

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.