'PayPal Orders Create: Status 422, amount mismatch error despite matching values

I am receiving a 422 UNPROCESSABLE_ENTITY error from paypal, indicating that my amount->value and breakdown values don't match up, but as far as I can tell they aren't. The request body is as follows:

"amount": {
  "currency_code": "USD",
  "value": 5,
  "breakdown": {
    "item_total": {
      "value": 10,
      "currency_code": "USD",
      "discount": {
        "value": 5,
        "currency_code": "USD"
      }
    }
  }
}

The error message says about amount->value: Should equal item_total + tax_total + shipping + handling + insurance - shipping_discount - discount.

Since I don't have shipping/handling/insurance/etc, shouldn't it just be 5(amount) = 10(item_total) - 5(discount)? What am I missing here?

Also, just in case it matters, I have just a single item in the purchase unit:

"items": [
  {
    "name": "...",
    "unit_amount": {
      "value": 10,
      "currency_code": "USD"
    },
    "quantity": 1,
    "category": "DIGITAL_GOODS"
  }
]


Solution 1:[1]

For PHP that would be :

$request->body = [
        'intent' => 'CAPTURE',
        'purchase_units' => [
            [
                'invoice_id' => 'some-id',
                'amount' => [
                    'value' => 15,
                    'currency_code' => 'EUR',
                    'breakdown' => [
                        'shipping' => [
                            'value' => 5,
                            'currency_code' => 'EUR',
                        ],
                        'item_total' => [
                            'value' => 10,
                            'currency_code' => 'EUR',
                        ]
                    ],
                ],
            ],
        ],
        'application_context' => [
            'cancel_url' => $cancelUrl,
            'return_url' => $returnUrl,
        ],
    ];

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 max4ever