diff --git a/src/subdomains/generic/kyc/dto/ident-result.dto.ts b/src/subdomains/generic/kyc/dto/ident-result.dto.ts index 13185cbd3..b5a27220f 100644 --- a/src/subdomains/generic/kyc/dto/ident-result.dto.ts +++ b/src/subdomains/generic/kyc/dto/ident-result.dto.ts @@ -59,6 +59,7 @@ export enum IdentShortResult { REVIEW = 'Review', SUCCESS = 'Success', FAIL = 'Fail', + PENDING = 'Pending', } export enum IdentItemStatus { diff --git a/src/subdomains/generic/kyc/dto/sum-sub.dto.ts b/src/subdomains/generic/kyc/dto/sum-sub.dto.ts index 537095dba..abcefb9ee 100644 --- a/src/subdomains/generic/kyc/dto/sum-sub.dto.ts +++ b/src/subdomains/generic/kyc/dto/sum-sub.dto.ts @@ -25,8 +25,8 @@ export interface SumSubWebhookResult { reviewRejectType?: ReviewRejectType; buttonIds?: string[]; }; - reviewStatus?: string; - videoIdentReviewStatus?: string; + reviewStatus?: ReviewStatus; + videoIdentReviewStatus?: ReviewStatus; createdAt: Date; createdAtMs?: Date; sandboxMode?: boolean; @@ -95,9 +95,13 @@ export enum ReviewRejectType { RETRY = 'RETRY', } -export enum VideoIdentStatus { +export enum ReviewStatus { + INIT = 'init', PENDING = 'pending', + PRE_CHECKED = 'prechecked', + QUEUED = 'queued', COMPLETED = 'completed', + ON_HOLD = 'onHold', } export enum SumSubWebhookType { @@ -269,6 +273,7 @@ const SumSubReasonMap: Record = { }; export function getSumsubResult(dto: SumSubWebhookResult): IdentShortResult { + if (dto.reviewStatus === ReviewStatus.INIT) IdentShortResult.PENDING; switch (dto.type) { case SumSubWebhookType.APPLICANT_PENDING: return IdentShortResult.REVIEW; @@ -277,10 +282,15 @@ export function getSumsubResult(dto: SumSubWebhookResult): IdentShortResult { return dto.reviewResult.reviewAnswer === ReviewAnswer.GREEN ? IdentShortResult.SUCCESS : IdentShortResult.FAIL; case SumSubWebhookType.VIDEO_IDENT_STATUS_CHANGED: - if (dto.videoIdentReviewStatus === VideoIdentStatus.PENDING) { + if (dto.videoIdentReviewStatus === ReviewStatus.INIT) { + return IdentShortResult.PENDING; + } + + if (dto.videoIdentReviewStatus === ReviewStatus.PENDING) { return IdentShortResult.REVIEW; } - if (dto.videoIdentReviewStatus === VideoIdentStatus.COMPLETED) { + + if (dto.videoIdentReviewStatus === ReviewStatus.COMPLETED) { return dto.reviewResult.reviewAnswer === ReviewAnswer.GREEN ? IdentShortResult.SUCCESS : IdentShortResult.FAIL; } break; diff --git a/src/subdomains/generic/kyc/entities/kyc-step.entity.ts b/src/subdomains/generic/kyc/entities/kyc-step.entity.ts index 15baeefdf..4de92aa44 100644 --- a/src/subdomains/generic/kyc/entities/kyc-step.entity.ts +++ b/src/subdomains/generic/kyc/entities/kyc-step.entity.ts @@ -212,6 +212,17 @@ export class KycStep extends IEntity { return [this.id, update]; } + inProgress(result?: KycStepResult): UpdateResult { + const update: Partial = { + status: KycStepStatus.IN_PROGRESS, + result: this.setResult(result), + }; + + Object.assign(this, update); + + return [this.id, update]; + } + ignored(comment: string): UpdateResult { const update: Partial = { status: KycStepStatus.IGNORED, diff --git a/src/subdomains/generic/kyc/services/kyc.service.ts b/src/subdomains/generic/kyc/services/kyc.service.ts index ccfd7a79b..b10d39838 100644 --- a/src/subdomains/generic/kyc/services/kyc.service.ts +++ b/src/subdomains/generic/kyc/services/kyc.service.ts @@ -518,6 +518,11 @@ export class KycService { await this.kycStepRepo.update(...kycStep.pause(dto)); break; + case IdentShortResult.PENDING: + if ([KycStepStatus.EXTERNAL_REVIEW].includes(kycStep.status)) + await this.kycStepRepo.update(...kycStep.inProgress(dto)); + break; + case IdentShortResult.REVIEW: if (![KycStepStatus.INTERNAL_REVIEW, KycStepStatus.MANUAL_REVIEW].includes(kycStep.status)) await this.kycStepRepo.update(...kycStep.externalReview(dto));