Skip to content

feat: account credit closes #145 - #423

Merged
v0l merged 2 commits into
masterfrom
feat/account-credit
Oct 20, 2026
Merged

v0l merged 2 commits into
masterfrom
feat/account-credit

Conversation

@v0l

@v0l v0l commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Fixes #145

A balance a customer tops up and spends against purchases, renewals and
upgrades, in the same flow as NWC.

  • POST /api/v1/account/credit/topup issues a Lightning invoice; on
    settlement the balance rises and a topup ledger row is written.
  • GET/PATCH /api/v1/account/credit return and toggle the balance and
    the auto_apply opt-in.
  • With auto_apply on, every quote applies min(balance, bill) and the
    external invoice is for the remainder. A bill fully covered by credit
    settles immediately with no invoice to pay.
  • Auto-renewal draws on credit before saved payment methods, so a
    wallet-free account renews itself while the balance lasts.
  • Admin GET/PATCH /api/admin/v1/users/{id}/credit and the ledger
    endpoint, gated by the new account_credit RBAC resource.

Credit covers net + tax, never the provider processing fee, and a balance
never goes negative: account_credit_event records every movement
(topup/spend/refund/admin) and the balance is the sum of the ledger.
Debits are written unsettled at invoice time and settled in
apply_payment next to discount redemptions, so every settlement path
records them exactly once.

Tests: 10 subscription unit tests, 11 mock DB tests, 5 e2e scenarios
(passing against the docker stack).

Comment thread lnvps_api/src/payments/invoice.rs Dismissed
Comment thread lnvps_api/src/payments/invoice.rs Dismissed
Comment thread lnvps_api/src/subscription/mod.rs Fixed
Comment thread lnvps_api/src/subscription/mod.rs Fixed
Comment thread lnvps_api/src/subscription/mod.rs Fixed
Comment thread lnvps_api/src/subscription/mod.rs Fixed
@v0l
v0l force-pushed the feat/account-credit branch from d15d5a6 to 37c6cf9 Compare October 16, 2026 10:49
Comment thread lnvps_api/src/subscription/mod.rs Dismissed
Comment thread lnvps_api/src/subscription/mod.rs Dismissed
Comment thread lnvps_api/src/subscription/mod.rs Dismissed
Comment thread lnvps_api/src/subscription/mod.rs Dismissed
@v0l
v0l merged commit 4860ded into master Oct 20, 2026
10 checks passed
@v0l
v0l deleted the feat/account-credit branch October 20, 2026 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Account Credit

2 participants