We reported this against core a while back (https://lab.civicrm.org/dev/financial/-/issues/174) but the actual fix needs to happen here in the IPN handler.
The scenario is:
- contribution total is 155
- an initial payment of 55 is made some other way, contribution becomes Partially Paid, balance 100
- the remaining 100 is paid via Mollie (iDeal), which comes back through handlePaymentNotification()
- contribution correctly ends up Completed
- but the payment transaction gets recorded as the full 155 instead of the 100 that was actually paid this time
Dug into it — handlePaymentNotification() always calls completetransaction when the response is successful, which assumes this is the first/only payment and just marks the whole thing as paid for the original amount. That doesn't hold up if the contribution already had a balance from an earlier payment (or is Pending from a pay-later flow).
Put together a fix: check the contribution status first, keep using completetransaction for the normal case, but if it's already Partially Paid or Pending, go through Payment::create with the amount the processor actually reports instead. Opened a PR for it here: #302
We mostly only use Mollie so I can't easily test other gateways, but the completetransaction call itself isn't gateway-specific so I'd expect this to hit anyone using instalments / pay-later / split payments through this extension. Curious if others have run into the same thing.
We reported this against core a while back (https://lab.civicrm.org/dev/financial/-/issues/174) but the actual fix needs to happen here in the IPN handler.
The scenario is:
Dug into it —
handlePaymentNotification()always callscompletetransactionwhen the response is successful, which assumes this is the first/only payment and just marks the whole thing as paid for the original amount. That doesn't hold up if the contribution already had a balance from an earlier payment (or is Pending from a pay-later flow).Put together a fix: check the contribution status first, keep using
completetransactionfor the normal case, but if it's already Partially Paid or Pending, go throughPayment::createwith the amount the processor actually reports instead. Opened a PR for it here: #302We mostly only use Mollie so I can't easily test other gateways, but the
completetransactioncall itself isn't gateway-specific so I'd expect this to hit anyone using instalments / pay-later / split payments through this extension. Curious if others have run into the same thing.