chore: prevent duplicate Lightning charges by adding durable invoice-level NWC payment guard #51
Reference in New Issue
Block a user
Delete Branch "userAdityaa/caravel:prevent-duplicate-lightning"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
This PR fixes a critical billing risk where Stripe webhook retries could trigger multiple NWC payment attempts for the same Stripe invoice. The fix introduces a durable invoice-level NWC payment state guard in SQLite and routes both invoice.created and outstanding-invoice NWC flows through it.
Problem
NWC payment was attempted first, then Stripe invoice was marked paid out-of-band. If Stripe marking failed, webhook handling failed and retries could re-enter payment logic without durable invoice-level protection.
Why this fixes the issue
Stripe retrying the same invoice can no longer create a second Lightning charge attempt for that invoice because the persisted guard blocks reattempts once the invoice is in pending or paid state, and paid state is reused for Stripe reconciliation.
closes #50