Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/integration/sift/dto/sift.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,7 @@ export const SiftAmlDeclineMap: { [method in AmlReason]: DeclineCategory } = {
[AmlReason.INTERMEDIARY_WITHOUT_SENDER]: DeclineCategory.RISKY,
[AmlReason.NAME_TOO_SHORT]: DeclineCategory.OTHER,
[AmlReason.ASSET_INPUT_NOT_ALLOWED]: DeclineCategory.INVALID,
[AmlReason.MANUAL_CHECK_SPECIAL_EXTERNAL_PHONE]: DeclineCategory.RISKY,
};

export interface ScoreRsponse {
Expand Down
4 changes: 2 additions & 2 deletions src/subdomains/core/aml/enums/aml-error.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,12 @@ export const AmlErrorResult: {
[AmlError.BIC_PHONE_VERIFICATION_NEEDED]: {
type: AmlErrorType.CRUCIAL,
amlCheck: CheckStatus.PENDING,
amlReason: AmlReason.MANUAL_CHECK_PHONE,
amlReason: AmlReason.MANUAL_CHECK_SPECIAL_EXTERNAL_PHONE,
},
[AmlError.IBAN_PHONE_VERIFICATION_NEEDED]: {
type: AmlErrorType.CRUCIAL,
amlCheck: CheckStatus.PENDING,
amlReason: AmlReason.MANUAL_CHECK_PHONE,
amlReason: AmlReason.MANUAL_CHECK_SPECIAL_EXTERNAL_PHONE,
},
[AmlError.BANK_RELEASE_DATE_MISSING]: {
type: AmlErrorType.SINGLE,
Expand Down
1 change: 1 addition & 0 deletions src/subdomains/core/aml/enums/aml-reason.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export enum AmlReason {
INTERMEDIARY_WITHOUT_SENDER = 'IntermediaryWithoutSender',
NAME_TOO_SHORT = 'NameTooShort',
ASSET_INPUT_NOT_ALLOWED = 'AssetInputNotAllowed',
MANUAL_CHECK_SPECIAL_EXTERNAL_PHONE = 'ManualCheckSpecialExternalPhone',
}

export const KycAmlReasons = [
Expand Down
6 changes: 4 additions & 2 deletions src/subdomains/core/aml/services/aml-helper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,17 @@ export class AmlHelperService {
errors.push(AmlError.IBAN_BLACKLISTED);

if (
!entity.userData.phoneCallCheckDate &&
(!entity.userData.phoneCallSpecialExternalCheckDate ||
!entity.userData.phoneCallSpecialExternalCheckValuesObject?.includes(entity.bankTx.bic)) &&
entity.userData.isPersonalAccount &&
phoneCallList.some((b) =>
b.matches([SpecialExternalAccountType.AML_PHONE_CALL_NEEDED_BIC_BUY], entity.bankTx.bic),
)
)
errors.push(AmlError.BIC_PHONE_VERIFICATION_NEEDED);
if (
!entity.userData.phoneCallCheckDate &&
(!entity.userData.phoneCallSpecialExternalCheckDate ||
!entity.userData.phoneCallSpecialExternalCheckValuesObject?.includes(entity.bankTx.iban)) &&
entity.userData.isPersonalAccount &&
phoneCallList.some(
(b) =>
Expand Down
26 changes: 20 additions & 6 deletions src/subdomains/core/aml/services/aml.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { CountryService } from 'src/shared/models/country/country.service';
import { IpLogService } from 'src/shared/models/ip-log/ip-log.service';
import { DfxLogger } from 'src/shared/services/dfx-logger';
import { Util } from 'src/shared/utils/util';
import { KycLogType } from 'src/subdomains/generic/kyc/enums/kyc.enum';
import { KycLogService } from 'src/subdomains/generic/kyc/services/kyc-log.service';
import { KycService } from 'src/subdomains/generic/kyc/services/kyc.service';
import { NameCheckService } from 'src/subdomains/generic/kyc/services/name-check.service';
import { AccountMergeService } from 'src/subdomains/generic/user/models/account-merge/account-merge.service';
Expand Down Expand Up @@ -43,16 +45,28 @@ export class AmlService {
private readonly transactionService: TransactionService,
private readonly ipLogService: IpLogService,
private readonly kycService: KycService,
private readonly kycLogService: KycLogService,
) {}

async postProcessing(entity: BuyFiat | BuyCrypto, last30dVolume: number | undefined): Promise<void> {
async postProcessing(
entity: BuyFiat | BuyCrypto,
last30dVolume: number | undefined,
isFirstRun = false,
): Promise<void> {
if (entity.cryptoInput) await this.payInService.updatePayInAction(entity.cryptoInput.id, entity.amlCheck);

if (
[CheckStatus.PENDING, CheckStatus.GSHEET].includes(entity.amlCheck) &&
entity.amlReason === AmlReason.VIDEO_IDENT_NEEDED
)
await this.userDataService.checkOrTriggerVideoIdent(entity.userData);
if ([CheckStatus.PENDING, CheckStatus.GSHEET].includes(entity.amlCheck)) {
if (entity.amlReason === AmlReason.VIDEO_IDENT_NEEDED)
await this.userDataService.checkOrTriggerVideoIdent(entity.userData);
if (isFirstRun && entity.amlReason === AmlReason.MANUAL_CHECK_SPECIAL_EXTERNAL_PHONE) {
await this.kycLogService.createLogInternal(
entity.userData,
KycLogType.KYC,
`Reset phoneCallSpecialExternalCheckDate ${entity.userData.phoneCallSpecialExternalCheckDate}`,
);
await this.userDataService.updateUserDataInternal(entity.userData, { phoneCallSpecialExternalCheckDate: null });
}
}

if (entity.amlCheck === CheckStatus.PASS) {
if (entity.user.status === UserStatus.NA) await this.userService.activateUser(entity.user, entity.userData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export class BuyCryptoPreparationService {
if (entity.cryptoInput && !entity.cryptoInput.isConfirmed) continue;

const amlCheckBefore = entity.amlCheck;
const isFirstRun = entity.amlCheck == null;

const inputCurrency = entity.cryptoInput?.asset ?? (await this.fiatService.getFiatByName(entity.inputAsset));
const inputReferenceCurrency =
Expand Down Expand Up @@ -192,7 +193,7 @@ export class BuyCryptoPreparationService {
),
);

await this.amlService.postProcessing(entity, last30dVolume);
await this.amlService.postProcessing(entity, last30dVolume, isFirstRun);

if (amlCheckBefore !== entity.amlCheck) await this.buyCryptoWebhookService.triggerWebhook(entity);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,4 +328,13 @@ export class UpdateUserDataDto {
@IsOptional()
@IsEnum(PhoneCallStatus)
phoneCallStatus?: PhoneCallStatus;

@IsOptional()
@IsDate()
@Type(() => Date)
phoneCallSpecialExternalCheckDate?: Date;

@IsOptional()
@IsString()
phoneCallSpecialExternalCheckValue?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ export class UserData extends IEntity {
@Column({ type: 'datetime2', nullable: true })
phoneCallIpCountryCheckDate?: Date;

@Column({ type: 'datetime2', nullable: true })
phoneCallSpecialExternalCheckDate?: Date;

@Column({ length: 256, nullable: true })
phoneCallSpecialExternalCheckValues?: string; // already checked semicolon separated iban's, bic's and blz's

@Column({ length: 256, nullable: true })
phoneCallTimes: string; // PhoneCallPreferredTimes array

Expand Down Expand Up @@ -526,6 +532,19 @@ export class UserData extends IEntity {
return this.phoneCallTimes ? (this.phoneCallTimes?.split(';') as PhoneCallPreferredTime[]) : [];
}

get phoneCallSpecialExternalCheckValuesObject(): string[] {
return this.phoneCallSpecialExternalCheckValues?.split(';');
}

addPhoneCallSpecialExternalCheckValue(specialAccountValue: string): void {
const existing = this.phoneCallSpecialExternalCheckValuesObject;
if (existing?.includes(specialAccountValue)) return;

this.phoneCallSpecialExternalCheckValues = existing
? `${this.phoneCallSpecialExternalCheckValues};${specialAccountValue}`
: specialAccountValue;
}

get hasValidNameCheckDate(): boolean {
return this.lastNameCheckDate && Util.daysDiff(this.lastNameCheckDate) <= Config.amlCheckLastNameCheckValidity;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,9 @@ export class UserDataService {

dto = await this.loadRelationsAndVerify({ id: userData.id, ...dto }, dto);

if (dto.phoneCallSpecialExternalCheckValue)
userData.addPhoneCallSpecialExternalCheckValue(dto.phoneCallSpecialExternalCheckValue);

if (dto.bankTransactionVerification === CheckStatus.PASS) {
// cancel a pending video ident, if ident is completed
const identCompleted = userData.hasCompletedStep(KycStepName.IDENT);
Expand Down
1 change: 1 addition & 0 deletions src/subdomains/supporting/payment/dto/transaction.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export const TransactionReasonMapper: {
[AmlReason.INTERMEDIARY_WITHOUT_SENDER]: TransactionReason.BANK_NOT_ALLOWED,
[AmlReason.NAME_TOO_SHORT]: TransactionReason.KYC_DATA_NEEDED,
[AmlReason.ASSET_INPUT_NOT_ALLOWED]: TransactionReason.ASSET_NOT_AVAILABLE,
[AmlReason.MANUAL_CHECK_SPECIAL_EXTERNAL_PHONE]: TransactionReason.PHONE_VERIFICATION_NEEDED,
};

export class UnassignedTransactionDto {
Expand Down
Loading