laravel-shop/tests/Feature/Ledger
Fabian @ Blax Software 1849f55558 feat(ledger): real-time balance-transaction upsert for webhook sync
Adds the primitives a host webhook needs to keep the ledger current in
real time, so the importer is a backstop rather than the only path:

- ledgerRowFromBalanceTransaction(): the canonical row builder (the
  import command now delegates to it), with refund→charge buyer fallback.
- recordBalanceTransaction(): idempotent upsert on the txn_ id that never
  downgrades a known customer_id/email to null (so a webhook's resolved
  buyer isn't clobbered by a later importer pass that couldn't resolve it).
- syncLedgerForCharge(): retrieves a charge + its refunds and upserts their
  balance transactions, user-independent, never throws (logs + returns 0).

Facade @methods + 3 LedgerMetricsTest cases (upsert idempotency, no-downgrade,
non-charge-id guard). Full suite 1461 green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-09-15 09:36:40 +02:00
..
LedgerMetricsTest.php feat(ledger): real-time balance-transaction upsert for webhook sync 2026-09-15 09:36:40 +02:00