So what happens when the amount paid for a lightning invoice is not the same as the amount invoiced? Does the transaction go through or fail?
Even if you overpay a Lightning invoice, which should never happen under normal circumstances since invoices encode the amount, the receiving node should accept up to twice the expected amount.
The reason for this is that both parties to a channel need to agree on the proposed new channel balance and the specific new channel balance amount needs to be known in advance.
When a payment is being routed, intermediary nodes do not know the final destination and the final amount anyway. The routing path is constructed by the payer. If the payee doesn't like the final amount, they can simply fail the payment.
To put it in other words, intermediary nodes calculate the amount they need to forward based on the information provided by the sender, and not included in the invoice, which they never see anyway.