chore: prevent duplicate Lightning charges by adding durable invoice-level NWC payment guard #51

Merged
hodlbod merged 2 commits from userAdityaa/caravel:prevent-duplicate-lightning into master 2026-04-25 13:02:56 +00:00
Contributor

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

### 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
userAdityaa added 1 commit 2026-04-25 11:23:25 +00:00
hodlbod added 1 commit 2026-04-25 13:02:49 +00:00
hodlbod merged commit 3ecd285290 into master 2026-04-25 13:02:56 +00:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: coracle/caravel#51