News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Paypal Error - TAX_TOTAL_MISMATCH

Started by audiorock, May 13, 2024, 19:49:15 PM

Previous topic - Next topic

audiorock

Hi,

Joomla 4.4.4, VirtueMart 4.2.10 11010, PHP 8.1.27


I'm having a problem with PayPal payment. Confirming the payment the following error is released in FRONTEND (this active debugging on the front-end side is terrible for the customer who purchases!!!)
1 vmdebug createOrder no OrderId Var0:
stdClass Object
(
    [name] => UNPROCESSABLE_ENTITY
    [details] => Array
        (
            [0] => stdClass Object
                (
                    [field] => /purchase_units/@reference_id=='default'/amount/breakdown/tax_total/value
                    [value] => 69.78
                    [issue] => TAX_TOTAL_MISMATCH
                    [description] => Should equal sum of (tax * quantity) across all items for a given purchase_unit
                )

        )

    [message] => The requested action could not be performed, semantically incorrect, or failed business validation.
    [debug_id] => a2cd68df1e418
    [links] => Array
        (
            [0] => stdClass Object
                (
                    [href] => https://developer.paypal.com/docs/api/orders/v2/#error-TAX_TOTAL_MISMATCH
                    [rel] => information_link
                    [method] => GET
                )

        )

)
2 vmdebug Created order here
4 vmdebug vmInfo: Checkout blocked by Payment plugin
5 vmdebug Confirmed order returned false
7 vmdebug findCorrectItemidBySQL use as like en-GB `link` like "index.php?option=com_virtuemart&view=cart%"

Incorrect data has been entered


Can you help me, please?

audiorock


AH

Get the latest version of VM and the plugins - released a few days ago
Regards
A

Joomla 4.4.5
php 8.1

audiorock

#3
I have already installed the latest version of the VM plugin (4.2.10 11010) and the problem persists!

the problem only occurs when I add multiples of the same item to my cart.



Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

audiorock

Hi,

we use VAT set at 22% (operator VATtax +%) and discounts in some products (operator DBTax -%)


audiorock

Hi,
if it can be useful, with parameter "with Breakdown" in OFF, the problem not appears!


carlos88

#7
Hello, 
I am experiencing the exact same issue. 
I'm posting it here, but I'm not sure if it's better to open a ticket in my VirtueMart members area.

Joomla 5.1.4 + VM 4.2.18 11050

It seems that by setting "With Breakdown" to No, the issue is apparently resolved, but I don't think this is the optimal solution. Also, I haven't received any new orders with PayPal payments yet, so I'm not entirely sure that it's working properly now. 
The underlying problem is an error in VAT calculation. 
I'm attaching a screenshot of a customer order that couldn't be paid:

The VAT amount shown in the screenshot is €27.65. 
That amount matches what is sent to PayPal in the request, but according to my calculations, that amount is incorrect; it should be €27.47.

{
  "reference_id": "default",
  "amount": {
    "currency_code": "EUR",
    "value": "154.49",
    "breakdown": {
      "shipping": {
        "currency_code": "EUR",
        "value": "0"
      },
      "item_total": {
        "currency_code": "EUR",
        "value": "131.83"
      },
      "discount": {
        "currency_code": "EUR",
        "value": "4.81"
      },
      "tax_total": {
        "currency_code": "EUR",
        "value": "27.65"
      }
    }
  }
}

The order details sent to PayPal in the request are:

"purchase_units": [
  {
    "reference_id": "default",
    "amount": {
      "currency_code": "EUR",
      "value": "154.49",
      "breakdown": {
        "shipping": {
          "currency_code": "EUR",
          "value": "0"
        },
        "item_total": {
          "currency_code": "EUR",
          "value": "131.83"
        },
        "discount": {
          "currency_code": "EUR",
          "value": "4.81"
        },
        "tax_total": {
          "currency_code": "EUR",
          "value": "27.65"
        }
      }
    },
    "description": "G2MB08277 jaltor.com",
    "custom_id": "G2MB08277",
    "items": [
      {
        "name": "HEBILLA 50X15 PLATEADA",
        "description": "0079",
        "quantity": 102,
        "unit_amount": {
          "currency_code": "EUR",
          "value": "0.5"
        },
        "tax": {
          "currency_code": "EUR",
          "value": "0.1"
        }
      },
      {
        "name": "HEBILLA 50X20 PLATEADA",
        "description": "0195",
        "quantity": 51,
        "unit_amount": {
          "currency_code": "EUR",
          "value": "0.41"
        },
        "tax": {
          "currency_code": "EUR",
          "value": "0.09"
        }
      },
      {
        "name": "PIQUETE 50-4.5 PLATEADO SOLDADO",
        "description": "0301",
        "quantity": 51,
        "unit_amount": {
          "currency_code": "EUR",
          "value": "0.58"
        },
        "tax": {
          "currency_code": "EUR",
          "value": "0.12"
        }
      },
      {
        "name": "CINTA 50MM POLIPROPILENO BLANCA ANIBAL",
        "description": "0184",
        "quantity": 41,
        "unit_amount": {
          "currency_code": "EUR",
          "value": "0.74"
        },
        "tax": {
          "currency_code": "EUR",
          "value": "0.16"
        }
      }
    ]
  }
]

And PayPal's response includes the following:

"body": {
  "name": "UNPROCESSABLE_ENTITY",
  "details": [
    {
      "field": "/purchase_units/@reference_id=='default'/amount/breakdown/tax_total/value",
      "value": "xxxxxx",
      "issue": "TAX_TOTAL_MISMATCH",
      "description": "Should equal sum of (tax * quantity) across all items for a given purchase_unit"
    }
  ],
  "message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
  "debug_id": "",
  "links": [
    {
      "href": "https://developer.paypal.com/docs/api/orders/v2/#error-TAX_TOTAL_MISMATCH",
      "rel": "information_link",
      "method": "GET"
    }
  ]
}