Skip to content

0.2.0

Choose a tag to compare

@AlexanderBuzz AlexanderBuzz released this 03 Sep 17:59
· 64 commits to master since this release
da5b0bf

0.2.0 — Settlement policy

The decision whether a delivered amount pays for a quote now lives in the core, so every
LedgerDirect plugin calls an order paid under exactly the same conditions. Until now each
plugin decided on its own (Shopware in its payment handlers, Magento in a local AmountCheck).

Added

  • Core\Payment\SettlementPolicy
    • isSettled(PaymentIntent): bool
      • Native asset (XRP): amount_paid >= amount_requested × (1 − tolerance). Default tolerance
        0.0015 (0.15 %) — the quote is a float rounded to five places and wallets may shave
        rounding on their side. Platforms may pass their own tolerance.
      • Issued currency (RLUSD, USDC, merchant tokens): currency and issuer must equal the
        quoted ones and value >= requested value, compared as exact decimals, no tolerance.
        A same-named token from another issuer never settles the order.
      • Overpayment settles; a PaymentIntent without amount_paid never does.
    • shortfall(PaymentIntent): ?string — what is still due as a plain decimal string: null
      once settled, the full amount while nothing has arrived, and the full amount for a payment
      in the wrong token (it does not count against the request). Meant for "X of Y received"
      on a payment page.
  • PaymentIntent::amountRequestedValue() / amountPaidValue() — the plain decimal behind
    either amount shape (float for the native asset, IssuedCurrencyAmount otherwise), without
    trailing zeros or exponent notation.
  • INVARIANTS.md, section "Settlement" — the rules above, and the line between the core
    (the decision) and the platform adapter (invoice, order status, emails).

Notes

  • Additive only; no existing behaviour changed.
  • Decimal rendering deliberately avoids BigDecimal::stripTrailingZeros(): brick/math renamed
    it to strippedOfTrailingZeros() within the range this package supports (^0.12 … ^0.20).
  • CI: PHP 8.2 / 8.3 / 8.4 and the lowest-dependencies job (brick/math 0.12) — green.

Upgrading

No changes required.