Skip to content

IPN records full contribution amount instead of remaining balance on a Partially Paid / Pending contribution #303

Description

@magnolia61

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:

  1. contribution total is 155
  2. an initial payment of 55 is made some other way, contribution becomes Partially Paid, balance 100
  3. the remaining 100 is paid via Mollie (iDeal), which comes back through handlePaymentNotification()
  4. contribution correctly ends up Completed
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions