feat(gateway): multi-merchant support — sub-accounts under a single publishable key#49
Merged
aguilar1x merged 12 commits intoJul 19, 2026
Conversation
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 multi-merchant support to the Connect Gateway: a single platform
pk_/sk_pair can host many isolated sub-merchants, each with isolated escrow settlement and webhook delivery, plus an admin listing of sub-merchants and their settled volume.All new columns are nullable and all new tables additive, so existing single-merchant integrations are unchanged.
What's included
Merchant(sub-account owned by a platformApiKey) andMerchantSettlement(idempotent per-escrow ledger) models, plus a nullablemerchantIdonCheckoutSession,WebhookEndpoint,WebhookEvent, andSubscription, with a single additive migration.POST /v1/sessionaccepts an optionalmerchantId, validated to be anactivesub-merchant owned by the authenticated key (unknown/disabled/foreign →400).merchantId; on release the amount/asset are recorded against that sub-merchant's settled volume (idempotent onescrowId, fire-once across both release paths).merchantId = Mreaches only endpoints scoped toM; a platform event reaches only platform (null) endpoints. Endpoints can be registered with amerchantId; inbound webhooks and subscription events carry/inherit it.POST/GET /admin/keys/:keyId/merchants(create / list with per-asset settled volume) andPOST /admin/merchants/:id/disable.MULTI_MERCHANT.mdandmerchantIdadditions toWEBHOOKS.md.Acceptance criteria
merchantIdroutes settlement to that sub-merchant only.Testing
tsc --noEmitclean, Biome clean.Closes #44