feat(billing): add Stripe-style inbound webhook pipeline for subscrip… - #73
Merged
Conversation
…tions Replaces manual subscription toggling with a real webhook pipeline: HMAC-verified POST /api/v1/webhooks/billing, an idempotent BillingWebhookEvent store (unique eventId short-circuits replays and concurrent duplicate deliveries via the DB unique constraint), transactional subscription.activated/cancelled/payment.failed handling with a BillingCustomerMap side table to resolve external IDs, structured audit logging per transition, and a read-only admin listing endpoint. Unknown event types and downstream mutation failures are recorded and still return 200 rather than 500. Dev mode allows an unset webhook secret with a loud warning; production refuses to boot without one. Also fixes a pre-existing build break: gdpr.service.ts referenced AuditAction.GDPR_DATA_EXPORTED/USER_SELF_DELETED, which were never added to the enum.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
closes #59
this Pr Implemented a robust billing webhook pipeline to automate subscription lifecycle updates.
What Changed
Added POST /api/v1/webhooks/billing with raw body support and HMAC signature verification.
Implemented idempotent webhook event processing using a persistent BillingWebhookEvent store.
Added transactional handling for:
subscription.activated
subscription.cancelled
payment.failed
Gracefully ignored and recorded unsupported webhook events.
Added external billing ID mapping, structured audit logs, failure metadata, and processing latency tracking.
Enforced webhook security with payload size limits, environment-based secret validation, and isolated rate limiting.
Added comprehensive tests covering valid events, idempotency, invalid signatures, rollback behavior, concurrent deliveries, and missing ID mappings