paypalpaypal-rest-sdk

PayPal ITEM_TOTAL_MISMATCH issue


I am facing "ITEM_TOTAL_MISMATCH" issue in PayPal api. I am calling "v2/checkout/orders" api. Quantity is 105 and amount is $115. Unit amount is $1.095238095238095 but PayPal api accept only up to 2 decimals so round off is $1.10. I also tried $1.09 but both time getting error "ITEM_TOTAL_MISMATCH". Please help me to fix this issue.

Below is my PayPal request data:

{
  "intent": "CAPTURE",
  "purchase_units": [
    {
      "items": [
        {
          "name": "AI Music",
          "description": "",
          "quantity": "105",
          "unit_amount": {
            "currency_code": "USD",
            "value": "1.10"
          },
          "tax": null
        }
      ],
      "amount": {
        "currency_code": "USD",
        "value": "115.00",
        "breakdown": {
          "item_total": {
            "currency_code": "USD",
            "value": "115.00"
          },
          "discount": null,
          "tax_total": null,
          "shipping": null
        }
      }
    }
  ],
  "payment_source": {
    "card": {
      "name": "Test ",
      "number": "4111111111111111",
      "security_code": "251",
      "expiry": "2028-05"
    }
  }
}

Thanks


Solution

  • This is a math issue: 105 * 1.10 = 115.50, not 115.00, hence the correct API error. Total must be 115.50 with those values.

    If you want the total to be exactly 115.00 with a quantity x 105 of $1.10 items, you will need to add a rounding discount or adjustment as a separate entry.


    Apart from simply rounding the unit price to 1.10 and going with that corresponding total, the simpler solution is to set "name": "AI Music x105" with quantity 1.