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

Rounding error in payment controller results in "Partial payment not allowed." error #2222

Closed
joostwaaijer opened this issue Jun 23, 2021 · 3 comments
Assignees
Labels

Comments

@joostwaaijer
Copy link
Contributor

Description
We are experiencing some issues in a shop where we have setup various currencies for customers to pay with.
We have setup the USD as primary currency and AUD, CAD, EUR and GBP as secondary currencies. When a customer tries to pay in a secondary currency, we sometimes get rounding issues in the pay action, and then receiving the error that the payment the customer is trying to do, is a partial payment, which is not allowed. After some debugging we found out that the amount the customer wants to pay is 94.2399999 while the outstanding balance is 94.24.

I've found that the following check is blocking our customers from going to the selected payment gateway.
https://github.com/craftcms/commerce/blob/develop/src/controllers/PaymentsController.php#L430

To Reproduce
How, and what happened?

  1. Add USD as primary currency with a rate of 1.0
  2. Add any secondary currency with a rate of 0.718
  3. Get a cart with a total cost of $94.24 and set the currency to the secondary one.
  4. Select a gateway and perform the pay action

Expected behavior
The $paymentAmountInPrimaryCurrency should be correctly rounded of to two decimals to be the same amount as $order->getOutstandingBalance()

Additional info

  • Craft version: Craft Pro 3.6.17
  • Commerce version: 3.3.4.1
  • PHP version:8.0.7
  • Database driver & version: PostgreSQL 12.6
@lukeholder
Copy link
Member

Fixed with #2226

@joostwaaijer
Copy link
Contributor Author

Thanks!

@brandonkelly
Copy link
Member

Commerce 3.3.5 is out now with the fix for this. Thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants