In a Magento 2.1 store we programmatically add a discount to the order. Paypal, however, refuses the transaction with the message
PayPal gateway has rejected request. The totals of the cart item amounts do not match order amounts (#10413: Transaction refused because of an invalid argument. See additional error messages for details).
When adding a discount code manually in the frontend Paypal works fine. Looking at the database comparing the quotes with the programmatic discount and the discount code there is no difference.
Other payment gateways work correctly.
Looks like a Magento (Paypal?) bug. Any hints?