Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BP-3366 $orderAmount rounding issue #199

Closed
ricklambrechts opened this issue Jan 23, 2024 · 11 comments
Closed

BP-3366 $orderAmount rounding issue #199

ricklambrechts opened this issue Jan 23, 2024 · 11 comments
Assignees
Labels
Priority: Normal This issue has a normal/medium priority. Status: Released A fix is included in a release already. 👏Thank You✨ Thank you for contributing!

Comments

@ricklambrechts
Copy link

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
Copy link
Contributor

@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.

@Buckaroo-Rene Buckaroo-Rene self-assigned this Jan 24, 2024
@Buckaroo-Rene Buckaroo-Rene added Status: Waiting for info We are waiting for more information regarding this issue. Priority: Minor This issue has a minor priority. labels Jan 24, 2024
@ricklambrechts
Copy link
Author

I opened the issue to fast.

Missed these lines:

WooCommerce/library/common.php

Lines 1002 to 1005 in 90ab2ef

// order is completely paid
if ($totalPaid >= $orderAmount) {
$order->payment_complete($transaction);
}

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

@Buckaroo-Rene
Copy link
Contributor

@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.

@Buckaroo-Rene Buckaroo-Rene removed Status: Waiting for info We are waiting for more information regarding this issue. Priority: Minor This issue has a minor priority. labels Jan 24, 2024
@ricklambrechts
Copy link
Author

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

I have checked and compared these values for multiple orders.

$orderAmount = (float) $order->get_total();
$paidAmount = (float) $response->amount;

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
Copy link
Author

@Buckaroo-Rene can you look into this issue?

@Buckaroo-Rene
Copy link
Contributor

@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
Copy link
Author

Thanks and get well soon!

@Buckaroo-Rene Buckaroo-Rene changed the title Update WooCommerce order status to processing BP-3366 $orderAmount rounding issue Jan 30, 2024
@Buckaroo-Rene Buckaroo-Rene added Status: Researching We are researching this issue. Priority: Normal This issue has a normal/medium priority. 👏Thank You✨ Thank you for contributing! labels Jan 30, 2024
@Buckaroo-Rene
Copy link
Contributor

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
Copy link
Author

ricklambrechts commented Feb 1, 2024

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
Copy link
Contributor

@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.

@Buckaroo-Rene Buckaroo-Rene added Status: Waiting for release This issue has been solved, but is not released yet. and removed Status: Researching We are researching this issue. labels Feb 1, 2024
@ricklambrechts
Copy link
Author

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

#201 (comment)

@Buckaroo-Rene Buckaroo-Rene added Status: Released A fix is included in a release already. and removed Status: Waiting for release This issue has been solved, but is not released yet. labels Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Normal This issue has a normal/medium priority. Status: Released A fix is included in a release already. 👏Thank You✨ Thank you for contributing!
Projects
None yet
Development

No branches or pull requests

2 participants