Skip to content

Commit aa1190c

Browse files
authored
Merge pull request #78 from topcoder-platform/fix-recipientverification-event-handling
Update revcipientverification event handling
2 parents bb3f230 + 205ee00 commit aa1190c

File tree

2 files changed

+47
-7
lines changed

2 files changed

+47
-7
lines changed

src/api/webhooks/trolley/handlers/recipient-verification.handler.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { PaymentsService } from 'src/shared/payments';
55
import { Logger } from 'src/shared/global';
66
import {
77
RecipientVerificationStatusUpdateEventData,
8+
RecipientVerificationType,
89
RecipientVerificationWebhookEvent,
910
} from './recipient-verification.types';
1011
import { Prisma, verification_status } from '@prisma/client';
@@ -26,6 +27,13 @@ export class RecipientVerificationHandler {
2627
where: { trolley_id: payload.recipientId },
2728
});
2829

30+
if (payload.type !== RecipientVerificationType.individual) {
31+
this.logger.log(
32+
`Handling only individual status updates, ignoring phone verification for recipient ${payload.recipientId}. Verification type: ${payload.type}.`,
33+
);
34+
return;
35+
}
36+
2937
if (!recipient) {
3038
this.logger.error(
3139
`Recipient with trolley_id ${payload.recipientId} not found.`,

src/api/webhooks/trolley/handlers/recipient-verification.types.ts

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,45 @@ export enum RecipientVerificationWebhookEvent {
22
statusUpdated = 'recipientVerification.status_updated',
33
}
44

5+
export enum RecipientVerificationType {
6+
phone = 'phone',
7+
individual = 'individual',
8+
}
9+
10+
interface VerifiedIdentityData {
11+
dob: string;
12+
reason: string | null;
13+
address: {
14+
city: string;
15+
region: string;
16+
country: string;
17+
street1: string;
18+
street2: string;
19+
postalCode: string;
20+
};
21+
lastName: string;
22+
firstName: string;
23+
documentType: string;
24+
matchSignals: {
25+
yobMatch: boolean;
26+
countryMatch: boolean;
27+
postalCodeMatch: boolean | null;
28+
};
29+
ageWhenVerified: number;
30+
documentValidFrom: string | null;
31+
documentValidUntil: string | null;
32+
documentIssuingCountry: string;
33+
}
34+
35+
interface VerifiedPhoneData {
36+
phone: string;
37+
channel: 'sms' | 'call';
38+
country: string;
39+
phoneExtension: string | null;
40+
}
41+
542
export interface RecipientVerificationStatusUpdateEventData {
6-
type: string;
43+
type: RecipientVerificationType;
744
recipientId: string;
845
status: 'pending' | 'approved' | 'rejected';
946
createdAt: string;
@@ -12,10 +49,5 @@ export interface RecipientVerificationStatusUpdateEventData {
1249
decisionAt: string | null;
1350
id: string;
1451
reasonType: string | null;
15-
verifiedData: {
16-
channel: 'sms' | 'email';
17-
phone: string;
18-
phoneExtension: string | null;
19-
country: string;
20-
};
52+
verifiedData: VerifiedIdentityData | VerifiedPhoneData;
2153
}

0 commit comments

Comments
 (0)