From 205ee0031edb7dbe27e7f403896479446cea3e27 Mon Sep 17 00:00:00 2001 From: Vasilica Olariu Date: Mon, 23 Jun 2025 14:37:15 +0300 Subject: [PATCH] Update revcipientverification event handling: do not process "phone" events --- .../recipient-verification.handler.ts | 8 ++++ .../handlers/recipient-verification.types.ts | 46 ++++++++++++++++--- 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/src/api/webhooks/trolley/handlers/recipient-verification.handler.ts b/src/api/webhooks/trolley/handlers/recipient-verification.handler.ts index 5738da9..48742d1 100644 --- a/src/api/webhooks/trolley/handlers/recipient-verification.handler.ts +++ b/src/api/webhooks/trolley/handlers/recipient-verification.handler.ts @@ -5,6 +5,7 @@ import { PaymentsService } from 'src/shared/payments'; import { Logger } from 'src/shared/global'; import { RecipientVerificationStatusUpdateEventData, + RecipientVerificationType, RecipientVerificationWebhookEvent, } from './recipient-verification.types'; import { Prisma, verification_status } from '@prisma/client'; @@ -26,6 +27,13 @@ export class RecipientVerificationHandler { where: { trolley_id: payload.recipientId }, }); + if (payload.type !== RecipientVerificationType.individual) { + this.logger.log( + `Handling only individual status updates, ignoring phone verification for recipient ${payload.recipientId}. Verification type: ${payload.type}.`, + ); + return; + } + if (!recipient) { this.logger.error( `Recipient with trolley_id ${payload.recipientId} not found.`, diff --git a/src/api/webhooks/trolley/handlers/recipient-verification.types.ts b/src/api/webhooks/trolley/handlers/recipient-verification.types.ts index a84a8a5..f53d21d 100644 --- a/src/api/webhooks/trolley/handlers/recipient-verification.types.ts +++ b/src/api/webhooks/trolley/handlers/recipient-verification.types.ts @@ -2,8 +2,45 @@ export enum RecipientVerificationWebhookEvent { statusUpdated = 'recipientVerification.status_updated', } +export enum RecipientVerificationType { + phone = 'phone', + individual = 'individual', +} + +interface VerifiedIdentityData { + dob: string; + reason: string | null; + address: { + city: string; + region: string; + country: string; + street1: string; + street2: string; + postalCode: string; + }; + lastName: string; + firstName: string; + documentType: string; + matchSignals: { + yobMatch: boolean; + countryMatch: boolean; + postalCodeMatch: boolean | null; + }; + ageWhenVerified: number; + documentValidFrom: string | null; + documentValidUntil: string | null; + documentIssuingCountry: string; +} + +interface VerifiedPhoneData { + phone: string; + channel: 'sms' | 'call'; + country: string; + phoneExtension: string | null; +} + export interface RecipientVerificationStatusUpdateEventData { - type: string; + type: RecipientVerificationType; recipientId: string; status: 'pending' | 'approved' | 'rejected'; createdAt: string; @@ -12,10 +49,5 @@ export interface RecipientVerificationStatusUpdateEventData { decisionAt: string | null; id: string; reasonType: string | null; - verifiedData: { - channel: 'sms' | 'email'; - phone: string; - phoneExtension: string | null; - country: string; - }; + verifiedData: VerifiedIdentityData | VerifiedPhoneData; }