Skip to content

Commit

Permalink
Merge pull request #1889 from DFXswiss/develop
Browse files Browse the repository at this point in the history
[DEV-3439] Add pending if type init (#1887)
  • Loading branch information
Kolibri1990 authored Jan 7, 2025
2 parents 24c54ad + f94e4d8 commit eadbd78
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/subdomains/generic/kyc/dto/ident-result.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export enum IdentShortResult {
REVIEW = 'Review',
SUCCESS = 'Success',
FAIL = 'Fail',
PENDING = 'Pending',
}

export enum IdentItemStatus {
Expand Down
20 changes: 15 additions & 5 deletions src/subdomains/generic/kyc/dto/sum-sub.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -269,6 +273,7 @@ const SumSubReasonMap: Record<SumSubRejectionLabels, string> = {
};

export function getSumsubResult(dto: SumSubWebhookResult): IdentShortResult {
if (dto.reviewStatus === ReviewStatus.INIT) IdentShortResult.PENDING;
switch (dto.type) {
case SumSubWebhookType.APPLICANT_PENDING:
return IdentShortResult.REVIEW;
Expand All @@ -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;
Expand Down
11 changes: 11 additions & 0 deletions src/subdomains/generic/kyc/entities/kyc-step.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,17 @@ export class KycStep extends IEntity {
return [this.id, update];
}

inProgress(result?: KycStepResult): UpdateResult<KycStep> {
const update: Partial<KycStep> = {
status: KycStepStatus.IN_PROGRESS,
result: this.setResult(result),
};

Object.assign(this, update);

return [this.id, update];
}

ignored(comment: string): UpdateResult<KycStep> {
const update: Partial<KycStep> = {
status: KycStepStatus.IGNORED,
Expand Down
5 changes: 5 additions & 0 deletions src/subdomains/generic/kyc/services/kyc.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit eadbd78

Please sign in to comment.