feat: add bank account webhook receiver (#487)#503
Open
numdinkushi wants to merge 1 commit into
Open
Conversation
Introduce Paystack and Stripe webhook handling to update linked bank account status, with signature verification, schema migration, and tests. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Someone is attempting to deploy a commit to the vestroll's projects Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
@numdinkushi PR should point to dev branch not main branch |
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.
Summary
Adds a secure webhook receiver so Paystack and Stripe can push bank-connection status updates into VestRoll. The endpoint verifies each provider’s signature, maps webhook events to internal account states (
pending→verified/disconnected), and persists changes on the newbank_accountstable.Approach
POST /api/v1/finance/webhooks/bank— reads the raw body for signature verification, resolves the provider from headers or?provider=, and returns structured success/error responses.x-paystack-signature); Stripe signed payload with replay protection (stripe-signature).provider_account_id; setsverified_at/disconnected_atwhen applicable; skips no-op updates.0001_add_bank_accountsforbank_accountsand related enums.Type of Change
Linked Issues
Fixes #487
Key Changes
src/app/api/v1/finance/webhooks/bank/route.ts— webhook entrypointbank-webhook.service.ts— signature check, event parsing, DB updatesbank-webhook-signature.utils.ts— Paystack & Stripe verificationbank-webhook.utils.ts— provider resolution, payload parsing, account ID extractionbank-webhook.constants.ts— signature headers, event → status maps, env keysbank_accountstable, enums (bank_account_status,bank_connection_provider), migration0001_add_bank_accounts.env.example—PAYSTACK_WEBHOOK_SECRET,STRIPE_WEBHOOK_SECRETSupported events (high level)
customeridentification.*,dedicatedaccount.assign.*,transfer.*financial_connections.account.*,account.application.deauthorizedTest Plan
pnpm db:migrateand confirmbank_accountsexistsx-paystack-signature→ status updates for a seeded rowstripe-signature→ status updates for a seeded rowstatusUpdated: false(no 500)pnpm run test— bank webhook specs passDeployment Notes
PAYSTACK_WEBHOOK_SECRETand/orSTRIPE_WEBHOOK_SECRETin the target environment.POST /api/v1/finance/webhooks/bank?provider=paystack(orstripe)Checklist
Screenshots / Recordings
N/A — backend API only.