From c5be57a05514b3a3dade6e70592afc4f1561f129 Mon Sep 17 00:00:00 2001 From: Nathan Lie Date: Thu, 12 Feb 2026 14:17:57 -0800 Subject: [PATCH 1/2] feat(backend): include tenantid in webhook data payload --- .../app/lib/webhooks.server.ts | 7 +++++++ packages/backend/src/webhook/service.ts | 1 + packages/mock-account-service-lib/src/types.ts | 1 + 3 files changed, 9 insertions(+) diff --git a/localenv/mock-account-servicing-entity/app/lib/webhooks.server.ts b/localenv/mock-account-servicing-entity/app/lib/webhooks.server.ts index 96f99ac5d5..5294bdccc4 100644 --- a/localenv/mock-account-servicing-entity/app/lib/webhooks.server.ts +++ b/localenv/mock-account-servicing-entity/app/lib/webhooks.server.ts @@ -40,6 +40,13 @@ export async function handleOutgoingPaymentCompletedFailed(wh: Webhook) { throw new Error('Invalid event type when handling outgoing payment webhook') } const payment = wh.data + // Don't handle webhook if it is referring to a tenant. + if ( + process.env.OPERATOR_TENANT_ID && + wh.tenantId !== process.env.OPERATOR_TENANT_ID + ) { + return + } const wa = payment['walletAddressId'] as string const acc = await mockAccounts.getByWalletAddressId(wa) diff --git a/packages/backend/src/webhook/service.ts b/packages/backend/src/webhook/service.ts index b1a54c2c8d..1144889016 100644 --- a/packages/backend/src/webhook/service.ts +++ b/packages/backend/src/webhook/service.ts @@ -206,6 +206,7 @@ async function sendWebhook( const body = { id: webhook.event.id, type: webhook.event.type, + tenantId: webhook.event.tenantId, data: webhook.event.data } diff --git a/packages/mock-account-service-lib/src/types.ts b/packages/mock-account-service-lib/src/types.ts index a81b20f327..6b6a4f4ad9 100644 --- a/packages/mock-account-service-lib/src/types.ts +++ b/packages/mock-account-service-lib/src/types.ts @@ -75,6 +75,7 @@ export interface Config { } export interface Webhook { id: string + tenantId: string type: WebhookEventType data: Record } From f23477ba0f9ef2b9909685bdc1da03019ea07bcc Mon Sep 17 00:00:00 2001 From: Nathan Lie Date: Thu, 12 Feb 2026 14:33:20 -0800 Subject: [PATCH 2/2] feat: ignore tenanted incoming payment webhooks in operator ase --- .../app/lib/webhooks.server.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/localenv/mock-account-servicing-entity/app/lib/webhooks.server.ts b/localenv/mock-account-servicing-entity/app/lib/webhooks.server.ts index 5294bdccc4..04c3cde29d 100644 --- a/localenv/mock-account-servicing-entity/app/lib/webhooks.server.ts +++ b/localenv/mock-account-servicing-entity/app/lib/webhooks.server.ts @@ -12,6 +12,10 @@ import { import { Webhook, WebhookEventType } from 'mock-account-service-lib' import { TenantOptions } from './types' +function cannotHandleWebhook(tenantId: string) { + return process.env.OPERATOR_TENANT_ID && tenantId !== process.env.OPERATOR_TENANT_ID +} + export interface AmountJSON { value: string assetCode: string @@ -42,11 +46,8 @@ export async function handleOutgoingPaymentCompletedFailed(wh: Webhook) { const payment = wh.data // Don't handle webhook if it is referring to a tenant. if ( - process.env.OPERATOR_TENANT_ID && - wh.tenantId !== process.env.OPERATOR_TENANT_ID - ) { - return - } + cannotHandleWebhook(wh.tenantId) + ) return const wa = payment['walletAddressId'] as string const acc = await mockAccounts.getByWalletAddressId(wa) @@ -151,6 +152,7 @@ export async function handleIncomingPaymentCompletedExpired( throw new Error('Invalid event type when handling incoming payment webhook') } + if (cannotHandleWebhook(wh.tenantId)) return const payment = wh.data const wa = payment['walletAddressId'] as string const acc = await mockAccounts.getByWalletAddressId(wa)