Skip to content

feat(payments): payment + webhook flow#183

Merged
chitrank2050 merged 4 commits into
mainfrom
feat/131-payments-create-payment-intent-on-invoice-finalize
May 22, 2026
Merged

feat(payments): payment + webhook flow#183
chitrank2050 merged 4 commits into
mainfrom
feat/131-payments-create-payment-intent-on-invoice-finalize

Conversation

@chitrank2050
Copy link
Copy Markdown
Owner

@chitrank2050 chitrank2050 commented May 22, 2026

🚀 Features

  • payments: Payment intent service + webhook receiver with handlers (7141c03)
  • payments: Auto-create payment intent on invoice finalize (5b67895)
  • payments: Payment success handler — verified full webhook flow (ec97f29)
  • Add Swagger tags for payments & webhooks, introduce response DTOs for payment & webhook events (9f6906f)

- PaymentIntentService: creates payment intents, schedules retries with backoff
- WebhookController: POST /webhooks/stripe + /webhooks/fake endpoints
- WebhookProcessingService: signature validation, deduplication, event routing
- PaymentSuccessHandler: marks invoice PAID, creates ledger PAYMENT, advances period
- PaymentFailureHandler: records failure, schedules retry, PAST_DUE after max retries
- Webhook deduplication via UNIQUE provider_event_id constraint
- Raw body parser enabled for Stripe signature validation
- Schema: payment_attempts + webhook_events tables with indexes
- Tested: success flow, failure flow, dedup — all passing
- InvoicesController.finalize() triggers PaymentIntentService after finalize
- Fire-and-forget: response returns immediately, payment created async
- Fixed duplicate finalize call bug (was calling finalize twice)
- Tested: generate → finalize → payment auto-created with SUCCEEDED status
- Webhook → find attempt → update SUCCEEDED → markPaid → advancePeriod
- Tested: INV-2026-0008 FINALIZED → PAID via webhook, ledger PAYMENT created
- Tested: subscription period advanced Jul 20 → Aug 20
- Tested: idempotent — duplicate webhook skipped, no double-payment
- advancePeriod wrapped in try/catch (non-critical, cron catches failures)
@chitrank2050 chitrank2050 merged commit 8481842 into main May 22, 2026
8 of 9 checks passed
@chitrank2050 chitrank2050 deleted the feat/131-payments-create-payment-intent-on-invoice-finalize branch May 22, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment