Re-implement Trustly refund tracker on top of the ledger
authorMagnus Hagander <magnus@hagander.net>
Fri, 10 Oct 2025 11:33:52 +0000 (13:33 +0200)
committerMagnus Hagander <magnus@hagander.net>
Fri, 10 Oct 2025 11:36:09 +0000 (13:36 +0200)
commita03baf562438718146d9e4a492185f17856a749f
treedd90d1e9c64eb77886a80622fa57c1861c7febaf
parent4f87c2cc310ee9de32b474de3fe222874e85af0b
Re-implement Trustly refund tracker on top of the ledger

Previously we explicitly called the API about the withdrawal entry, but
that API is now restricted. And we don't *really* need it -- refunds
show up on the ledger, so just use that.

The only case this doesn't work is refunds in a different currency, and
in that case we just estimate the fees and send a notice to hope for the
best :) It's not a common scenario, and not worth spending too much on
(in production it has never happened outside of testing).

To do this, we now track refund transactions int he TrustlyWithdrawals
table, and also store the orderid on them if we have them.

This removes the separate job to match trustly refunds, and handles it
all from the fetch withdrawals job.

Not fully tested since it needs production data, so expect some
follow-up commits..
postgresqleu/trustlypayment/management/commands/trustly_fetch_withdrawals.py
postgresqleu/trustlypayment/management/commands/trustly_match_refunds.py [deleted file]
postgresqleu/trustlypayment/migrations/0005_refund_matching_on_withdrawals.py [new file with mode: 0644]
postgresqleu/trustlypayment/models.py