magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.48k stars 9.29k forks source link

Paypal Order total mismatch - Price rounding issue #24233

Open Priya-V-Panchal opened 5 years ago

Priya-V-Panchal commented 5 years ago

Preconditions (*)

  1. Magento 2.3.1 EE
  2. Paypal Express checkout enabled
  3. Tax Enabled

Steps to reproduce (*)

  1. Admin - Stores - Settings - Configuration - General - Currency Setup - Set the currency options to Japanese Yen and Save
  2. Add a new product with price 11.5120
  3. Add to cart that product from the front
  4. Go to checkout and fill up address details including Country, State and Postal code So that tax would be applied (In my case, tax amount is 1.0935 and shipping amount is 7.95)
  5. Place order with PayPal express checkout

Expected result (*)

  1. The order should be placed

Actual result (*)

  1. Below Error message is getting displayed on UI with 400 Status Code:

image image

Note: User is able to place Order using "Check/Money Order" but difference in Grand Total is observed in Checkout page and Order Information page image

image

m2-assistant[bot] commented 5 years ago

Hi @Priya-V-Panchal. Thank you for your report. To help us process this issue please make sure that you provided the following information:

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@Priya-V-Panchal do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?


m2-assistant[bot] commented 5 years ago

Hi @engcom-Charlie. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Charlie commented 5 years ago

Hello @Priya-V-Panchal I can't reproduce this issue on fresh Magento 2.3-develop & 2.3.2.

Manual testing scenario:

  1. Add a new product with price 11.5120
  2. Add to cart that product from the front
  3. Go to checkout and fill up address details including Country, State and Postal code So that tax would be applied (In my case, tax amount is 0.95 and shipping amount is 5.00) image <-- There is good calculation
  4. Place order with PayPal express checkout

Actualt result: Order placed.

So i have to close it. If you can reproduce this issue on 2.3-develop branch please inform me. Thanks for you report!

Priya-V-Panchal commented 5 years ago

Hi @engcom-Charlie ,

Thanks for looking into it. As per my comment, to reproduce this issue can you please check with the exact amount which I specified in the question?

You will replicate the issue.

This issue is related to price rounding and it gives minor difference in total like 0.01 so it would only occur with summation of some specified float price.

engcom-Charlie commented 5 years ago

@Priya-V-Panchal can you provide your Tax rate percent? Mine: image

Priya-V-Panchal commented 5 years ago

HI @engcom-Charlie ,

My rate percent is 9.5000 & Tax Amount is 1.0935

engcom-Charlie commented 5 years ago

@Priya-V-Panchal Good calculation again: image

Priya-V-Panchal commented 5 years ago

@engcom-Charlie , Could you please give me your quote item details from quote_item table?

engcom-Charlie commented 5 years ago

@Priya-V-Panchal ofc: image

Priya-V-Panchal commented 5 years ago

Hi @engcom-Charlie

Please check my quote item detail. In my case, Tax amount and row total both are slightly different which causes the issue.

Screenshot from 2019-08-26 14-26-05

engcom-Charlie commented 5 years ago

@Priya-V-Panchal Row total both and tax amount are different because when we create a product in Magento 2.3-develop, the price is validated by js-validator to 11.51: image

Priya-V-Panchal commented 5 years ago

In my case, it is taking value up to 4 decimals trailing without zero. Like row total 11.5120 and tax is 1.0935 I am using Magento Enterprice version, does it make any difference in getting this type of float value?

engcom-Charlie commented 5 years ago

@Priya-V-Panchal okay, i will try on EE version.

Priya-V-Panchal commented 5 years ago

Thanks @engcom-Charlie Let me know about your findings

m2-assistant[bot] commented 5 years ago

Hi @sdzhepa. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

sdzhepa commented 5 years ago

Hello @Priya-V-Panchal

Thank you for reporting and collaboration!

Unfortunately, we are not able to reproduce this issue by provided steps either on Open Sorce(CE) or Commerce(EE) versions of Magento.

I am closing this issue, but I would strongly recommend report this problem to the Support portal associated with your Commerce account.

Current repository and issue tracker aimed at Magento Open Source version only and the main focus is community contribution/collaboration. It described in Issue reporting guidelines and it is a part of the issue report template:

Verify, that the issue you are about to report does not relate to the Magento Commerce. GitHub is intended for Magento Open Source users to report on issues related to Open Source only. There are no account management services associated with GitHub. You can report Commerce-related issues in one of two ways:

  • You can use the Support portal associated with your account
  • If you are a Partner reporting on behalf of a merchant, use the Partner portal.
ArchanaMohan1 commented 4 years ago

@engcom-Charlie - We are facing the above issue as well.Below are the details.Do look into this.

Preconditions

Magento 2.3.1 CE Paypal Express checkout enabled Tax Enabled

Steps to reproduce

Add a fews products to the cart from the frontend. Go to checkout and fill up address details including Country, State and Postal code So that tax would be applied. Place order with PayPal express checkout

Expected result The order should be placed

Actual result It gives "The totals of the cart item amounts do not match order amounts." error. PayPal is considering rounded price value of Subtotal and tax in its API. As you understand, this does not match the Magento rounding method.

Please look into this.

charleskj commented 4 years ago

The issue still there in 2.3.1 version

'SHIPPINGAMT' => '8.33',
 'ITEMAMT' => '44.17',
 'TAXAMT' => '12.49',
'AMT' => '65.00',

SHIPPINGAMT + ITEMAMT + TAXAMT = AMT 8.33 + 44.17 + 12.49 = 65 64.99 = 65.00

Paypal Debug Log

[2019-11-19 10:31:02] main.DEBUG: array (
  'url' => 'https://api-3t.paypal.com/nvp',
  'DoExpressCheckoutPayment' => 
  array (
    'TOKEN' => '*********',
    'PAYERID' => '**************',
    'PAYMENTACTION' => 'Sale',
    'AMT' => '65.00',
    'CURRENCYCODE' => 'EUR',
    'BUTTONSOURCE' => 'Magento_Cart_Community',
    'NOTIFYURL' => 'https://www.flowerbx.com/de/paypal/ipn',
    'RETURNFMFDETAILS' => 1,
    'SHIPPINGAMT' => '8.33',
    'ITEMAMT' => '44.17',
    'TAXAMT' => '12.49',
    'BUSINESS' => 'Frau',
    'EMAIL' => '**************,
    'FIRSTNAME' => '*****',
    'LASTNAME' => '******',
    'MIDDLENAME' => NULL,
    'SALUTATION' => NULL,
    'SUFFIX' => NULL,
    'COUNTRYCODE' => 'DE',
    'STATE' => '***',
    'CITY' => '*******',
    'STREET' => '*******',
    'ZIP' => '******',
    'PHONENUM' => '*******',
    'SHIPTOCOUNTRYCODE' => 'DE',
    'SHIPTOSTATE' => '****',
    'SHIPTOCITY' => '******',
    'SHIPTOSTREET' => '*******',
    'SHIPTOZIP' => '*******',
    'SHIPTOPHONENUM' => '********',
    'SHIPTOSTREET2' => '',
    'STREET2' => '',
    'SHIPTONAME' => '*********',
    'ADDROVERRIDE' => 1,
    'METHOD' => 'DoExpressCheckoutPayment',
    'VERSION' => '72.0',
    'USER' => '****',
    'PWD' => '****',
    'SIGNATURE' => '****',
  ),
  'response' => 
  array (
    'TOKEN' => '********',
    'SUCCESSPAGEREDIRECTREQUESTED' => 'false',
    'TIMESTAMP' => '*******',
    'CORRELATIONID' => '*******',
    'ACK' => 'Failure',
    'VERSION' => '72.0',
    'BUILD' => '******',
    'L_ERRORCODE0' => '10413',
    'L_SHORTMESSAGE0' => 'Transaction refused because of an invalid argument. See additional error messages for details.',
    'L_LONGMESSAGE0' => 'The totals of the cart item amounts do not match order amounts.',
    'L_SEVERITYCODE0' => 'Error',
  ),
edroberts commented 4 years ago

@ sdzhepa - this has been replicated on Open Source and should be reopened - please see above

matthewhaworth commented 4 years ago

I've raised this with Magento themselves. They're currently saying it's due to the Bronto module.

edroberts commented 4 years ago

Seeing this problem without using Bronto

TonyRutherford1 commented 4 years ago

This is still an issue and should have not been closed! @sdzhepa

Fifciu commented 4 years ago

I have the same problem on Magento 2.3.4 Open Source. If I try Magento's frontend it works. However, I am using Magento2 only via Rest API as the backend for my PWA

slimmen commented 3 years ago

@sdzhepa this seems still to be an issue, we're losing a lot of orders and money because of this rounding error. Is there anyone that has a fix for this?

m2-assistant[bot] commented 3 years ago

Hi @engcom-Delta. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

m2-assistant[bot] commented 3 years ago

Hi @engcom-Alfa. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

sdzhepa commented 3 years ago

@engcom-Delta @engcom-Alfa @engcom-Bravo

Could you please re-check this issue on the latest 2.4-develop branch?

engcom-Delta commented 3 years ago

HI @slimmen @Fifciu @TonyRutherford1 Unfortunately I'm not able to reproduce issue by steps on clean 2.4-develop( both CE and EE) Manual testing scenario:

Result: :heavy_check_mark: Order amount is correct - 20.55 (11.51 +7.95 +1.09 = 20.55) image image image

Could you take a look and add more details if something is missed, like product and rate creation?

ghost commented 3 years ago

@engcom-Dash
To reproduce this issue please set the currency to JPY (japanese currency) instead of US dollar. Japanese currency doesn't support the decimal, hence all the payment gateways fail not just paypal.

m2-assistant[bot] commented 3 years ago

Hi @engcom-November. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-November commented 3 years ago

Verified the issue on Magento 2.4-develop branch and the issue is reproducible with Japanese Currency setup. Steps to reproduce:

  1. Admin - Stores - Settings - Configuration - General - Currency Setup - Set the currency options to Japanese Yen and Save
  2. Stores - Tax zones and Rates - Create Tax rate of 9.5%
  3. Stores - Tax Rules - Add New Tax Rule - Apply tax rate and Save
  4. Create a Simple Product from Admin with Price Ex: 11.5120 (any Decimal value) and Save
  5. Reindex and Clear Cache
  6. Front-end - Login as Customer - Add this product to cart and proceed to Checkout
  7. Make Payment using PayPal Express Checkout Issue: Payment is failing with 400 Status code and below error message is getting displayed on UI
24233-1 24233-2

Exception log: [2021-08-19 11:14:52] main.CRITICAL: PayPal gateway has rejected request. Currency does not support decimal precision (#10004: Transaction refused because of an invalid argument. See additional error messages for details). {"exception":"[object] (Magento\Framework\Exception\LocalizedException(code: 0): PayPal gateway has rejected request. Currency does not support decimal precision (#10004: Transaction refused because of an invalid argument. See additional error messages for details). at /var/www/html/magento2.4/magento2/lib/internal/Magento/Framework/ObjectManager/Factory/AbstractFactory.php:121)"} []

Note: User is able to place Order using "Check/Money Order" but difference in Grand Total is observed in Checkout page and Order Information page

24233-3 24233-4
github-jira-sync-bot commented 3 years ago

Unfortunately, not enough information was provided to create a Jira ticket. Please make sure you added the following label(s): Reproduced on 2.4.x, ^Area:.*

Once all required labels are present, please add Issue: Confirmed label again.

github-jira-sync-bot commented 3 years ago

:white_check_mark: Jira issue https://jira.corp.magento.com/browse/AC-687 is successfully created for this GitHub issue.

m2-assistant[bot] commented 3 years ago

:white_check_mark: Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

ansonliam commented 3 years ago

There is another situation that creating the bug where a coupon code is placed.

Preconditions (*)

Magento 2.4.1 CE Paypal Express checkout enabled Tax Enabled

Steps to reproduce (*)

  1. Admin - Stores - Settings - Configuration - General - Currency Setup - Set the currency options to Australian and Save
  2. Tax is 10%
  3. Add a new product with price 549
  4. Add a new product with price 119
  5. Add a new product with price 677
  6. Create a shipping item of 49.
  7. Create a Cart Price Rule of 5% for the whole cart.
  8. Add to cart of three items above from the frontend,
  9. Go to checkout and fill up address details including Country, State and Postal code So that tax would be applied (In my case, The cart total before tax is $1326.75. Discount amount is $-67.25. shipping amount is $49 and Tax amount is $120.61)
  10. Place order with PayPal express checkout

Expected result (*)

The order should be placed

Actual result (*)

Below Error message is getting displayed on UI. The request amount is $1326.75 but the total of Shipping ($44.54), items ($1155.48) and tax ($126.72) is $1326.74 which has 1 cent difference

image

(
  'url' => 'https://api-3t.sandbox.paypal.com/nvp',
  'SetExpressCheckout' => 
  array (
    'PAYMENTACTION' => 'Sale',
    'AMT' => '1326.75',
    'CURRENCYCODE' => 'AUD',
    'RETURNURL' => 'https://example-domain.com.au/paypal/express/return/',
    'CANCELURL' => 'https://example-domain.com.au/paypal/express/cancel/',
    'INVNUM' => '000013320',
    'SOLUTIONTYPE' => 'Sole',
    'GIROPAYCANCELURL' => 'https://example-domain.com.au/paypal/express/cancel/',
    'GIROPAYSUCCESSURL' => 'https://example-domain.com.au/checkout/onepage/success/',
    'BANKTXNPENDINGURL' => 'https://example-domain.com.au/checkout/onepage/success/',
    'SHIPPINGAMT' => '44.54',
    'ITEMAMT' => '1155.48',
    'TAXAMT' => '126.72',
    'BUSINESS' => NULL,
    'NOTETEXT' => NULL,
    'EMAIL' => 'xxx@xxx.com',
    'FIRSTNAME' => 'xxx',
    'LASTNAME' => 'xxx',
    'MIDDLENAME' => NULL,
    'SALUTATION' => NULL,
    'SUFFIX' => NULL,
    'COUNTRYCODE' => 'AU',
    'STATE' => 'VIC',
    'CITY' => '123',
    'STREET' => '123',
    'ZIP' => '3000',
    'PHONENUM' => '0123123123',
    'SHIPTOCOUNTRYCODE' => 'AU',
    'SHIPTOSTATE' => 'VIC',
    'SHIPTOCITY' => '123',
    'SHIPTOSTREET' => '123',
    'SHIPTOZIP' => '3000',
    'SHIPTOPHONENUM' => '0123123123',
    'SHIPTOSTREET2' => '',
    'STREET2' => '',
    'SHIPTONAME' => 'xxxx',
    'ADDROVERRIDE' => 1,
    'METHOD' => 'SetExpressCheckout',
    'VERSION' => '72.0',
    'USER' => '****',
    'PWD' => '****',
    'SIGNATURE' => '****',
    'BUTTONSOURCE' => 'Magento_2_Community',
  )
ansonliam commented 3 years ago

same issue of https://github.com/magento/magento2/issues/33651