buckaroo-it / WooCommerce

Repository containing the WooCommerce Payment Plugin by Buckaroo
2 stars 3 forks source link

BP-3366 $orderAmount rounding issue #199

Closed ricklambrechts closed 2 months ago

ricklambrechts commented 7 months ago

Is it correct that this plugin does not update the order status to processing for example?

I see the $order->update_status() calls with failed, cancelled but I do not see processing. Only in the gateway-buckaroo-applepay.php file I see the processing update.

Buckaroo-Rene commented 7 months ago

@ricklambrechts ,

Thankyou for contacting Buckaroo. Please note that the order is updated upon a push message send from the Buckaroo Plaza. Therefore you'll also have to configure the website key settings in the Buckaroo Plaza. You can find the configuration constructions regarding the PUSH configuration for WooCommerce on: https://docs.buckaroo.io/docs/woocommerce-configuration

If you're having experiencing issues with the orders that are not updated to processing, perhaps there could be a server issue and the Buckaroo IP addresses need to be added to a allow list. The IP addresses and ports can be found here: https://docs.buckaroo.io/v1/docs/en/push-messages You can always also contact our technical support team, so they can take a look with you in the Buckaroo Plaza to see why the orders are not updated (support@buckaroo.nl).

Please let me know if this helped.

ricklambrechts commented 7 months ago

I opened the issue to fast.

Missed these lines: https://github.com/buckaroo-it/WooCommerce/blob/90ab2efc101900e99e7a2cde429bc53ae8a120c1/library/common.php#L1002-L1005

Will debug that because a client get the order note Received Buckaroo payment push notification. but orders stay on pending payment.

Buckaroo-Rene commented 7 months ago

@ricklambrechts,

Thank you for your quick reply. Please let us know if you need anything by creating a new ticket or contacting our technical support team (support@buckaroo.nl) if the issue persists.

ricklambrechts commented 7 months ago

I did some debugging and this is what I have discovered.

I have checked and compared these values for multiple orders.

https://github.com/buckaroo-it/WooCommerce/blob/90ab2efc101900e99e7a2cde429bc53ae8a120c1/library/common.php#L981-L982

The floats are having the following values:

orderAmount: 425.6728 totalPaid: 425.67

The isTotalPaid check returns false but the order is fully paid. Because of rounding issues this results in staying at the pending status and the order is cancelled automatically after X time.

orderAmount: 377.1999 totalPaid: 377.2

The isTotalPaid check returns true then. This results in an order that is set to processing through WooCommerce using the $order->payment_complete() function.

orderAmount: 400.026 totalPaid: 400.03

The isTotalPaid check returns true then. This results in an order that is set to processing through WooCommerce using the $order->payment_complete() function.

orderAmount: 195.2335 totalPaid: 195.23

The isTotalPaid check returns false but the order is fully paid. Because of rounding issues this results in staying at the pending status and the order is cancelled automatically after X time.

So the issue is that the $orderAmount is not rounded. I hope you can look in to this issue.

This is a possible workaround but maybe you have a better solution.

$orderAmount = (float) wc_format_decimal($order->get_total(), 2, false);
ricklambrechts commented 6 months ago

@Buckaroo-Rene can you look into this issue?

Buckaroo-Rene commented 6 months ago

@ricklambrechts , Thankyou for your research and excuse me for the late reply (I was on sick leave). I'll discuss it within the team and we'll let you know a.s.a.p.

ricklambrechts commented 6 months ago

Thanks and get well soon!

Buckaroo-Rene commented 6 months ago

Hi @ricklambrechts ,

We did some research for this issue that you're facing. Unfortunately we did not see the rounding issue occuring on our test environments. Could it be that you use a different setting for the number of decimals in the currency settings?

WooCommerce_Rounding_Decimals

And are you still having issues regarding the order status which is not set to processing?

I am looking forward to your reply.

Best Regards, René

ricklambrechts commented 6 months ago

Yes the decimals setting is set to 4. But this plugin should be able to handle it right?

Because prices are always round up for the payment but at the moment that the paid value is checked with the order value it is not rounded.

So at that the $orderAmount and $paidAmount check, the $orderAmount needs to be rounded the same as it is at the moment the payment request is created.

Else the client needs the possible workaround at every update.

Buckaroo-Rene commented 6 months ago

@ricklambrechts , Thank you for your quick reply and confirming the settings. Yes it should be and therefore our developers have created a fix that will be included in the next upcoming release.

ricklambrechts commented 6 months ago

Thank you. I have reviewed the change and i have left a comment.

https://github.com/buckaroo-it/WooCommerce/pull/201#issuecomment-1921505302