Compare commits

...

10 Commits

50 changed files with 7169 additions and 2631 deletions

9003
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,7 @@ import { LoggerModule } from 'nestjs-pino';
import { DataSource } from 'typeorm';
import { addTransactionalDataSource } from 'typeorm-transactional';
import { AuthModule } from './auth/auth.module';
import { CardModule } from './card/card.module';
import { CacheModule } from './common/modules/cache/cache.module';
import { LookupModule } from './common/modules/lookup/lookup.module';
import { NeoLeapModule } from './common/modules/neoleap/neoleap.module';
@ -26,7 +27,7 @@ import { GuardianModule } from './guardian/guardian.module';
import { HealthModule } from './health/health.module';
import { JuniorModule } from './junior/junior.module';
import { UserModule } from './user/user.module';
import { CardModule } from './card/card.module';
import { WebhookModule } from './webhook/webhook.module';
@Module({
controllers: [],
@ -61,6 +62,7 @@ import { CardModule } from './card/card.module';
CustomerModule,
JuniorModule,
GuardianModule,
CardModule,
NotificationModule,
OtpModule,
@ -71,7 +73,7 @@ import { CardModule } from './card/card.module';
CronModule,
NeoLeapModule,
CardModule,
WebhookModule,
],
providers: [
// Global Pipes

View File

@ -9,9 +9,11 @@ import {
ChangePasswordRequestDto,
CreateUnverifiedUserRequestDto,
ForgetPasswordRequestDto,
JuniorLoginRequestDto,
LoginRequestDto,
RefreshTokenRequestDto,
SendForgetPasswordOtpRequestDto,
setJuniorPasswordRequestDto,
VerifyForgetPasswordOtpRequestDto,
VerifyUserRequestDto,
} from '../dtos/request';
@ -69,10 +71,26 @@ export class AuthController {
@Post('change-password')
@HttpCode(HttpStatus.NO_CONTENT)
@UseGuards(AccessTokenGuard)
async changePassword(@AuthenticatedUser() { sub }: IJwtPayload, @Body() forgetPasswordDto: ChangePasswordRequestDto) {
changePassword(@AuthenticatedUser() { sub }: IJwtPayload, @Body() forgetPasswordDto: ChangePasswordRequestDto) {
return this.authService.changePassword(sub, forgetPasswordDto);
}
@Post('junior/set-password')
@HttpCode(HttpStatus.NO_CONTENT)
@Public()
setJuniorPasscode(@Body() setPassworddto: setJuniorPasswordRequestDto) {
return this.authService.setJuniorPassword(setPassworddto);
}
@Post('junior/login')
@HttpCode(HttpStatus.OK)
@ApiDataResponse(LoginResponseDto)
async juniorLogin(@Body() juniorLoginDto: JuniorLoginRequestDto) {
const [res, user] = await this.authService.juniorLogin(juniorLoginDto);
return ResponseFactory.data(new LoginResponseDto(res, user));
}
@Post('refresh-token')
@Public()
async refreshToken(@Body() { refreshToken }: RefreshTokenRequestDto) {

View File

@ -1,11 +1,11 @@
export * from './change-password.request.dto';
export * from './create-unverified-user.request.dto';
export * from './forget-password.request.dto';
export * from './junior-login.request.dto';
export * from './login.request.dto';
export * from './refresh-token.request.dto';
export * from './send-forget-password-otp.request.dto';
export * from './set-junior-password.request.dto';
export * from './set-passcode.request.dto';
export * from './verify-forget-password-otp.request.dto';
export * from './verify-otp.request.dto';
export * from './verify-user.request.dto';

View File

@ -0,0 +1,12 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsEmail, IsString } from 'class-validator';
import { i18nValidationMessage as i18n } from 'nestjs-i18n';
export class JuniorLoginRequestDto {
@ApiProperty({ example: 'test@junior.com' })
@IsEmail({}, { message: i18n('validation.IsEmail', { path: 'general', property: 'auth.email' }) })
email!: string;
@ApiProperty({ example: 'Abcd1234@' })
@IsString({ message: i18n('validation.IsString', { path: 'general', property: 'auth.password' }) })
password!: string;
}

View File

@ -1,8 +1,11 @@
import { ApiProperty } from '@nestjs/swagger';
import { ApiProperty, PickType } from '@nestjs/swagger';
import { IsNotEmpty, IsString } from 'class-validator';
import { i18nValidationMessage as i18n } from 'nestjs-i18n';
import { SetPasscodeRequestDto } from './set-passcode.request.dto';
export class setJuniorPasswordRequestDto extends SetPasscodeRequestDto {
import { ChangePasswordRequestDto } from './change-password.request.dto';
export class setJuniorPasswordRequestDto extends PickType(ChangePasswordRequestDto, [
'newPassword',
'confirmNewPassword',
]) {
@ApiProperty()
@IsString({ message: i18n('validation.IsNumberString', { path: 'general', property: 'auth.qrToken' }) })
@IsNotEmpty({ message: i18n('validation.IsNotEmpty', { path: 'general', property: 'auth.qrToken' }) })

View File

@ -1,15 +0,0 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsNumberString, MaxLength, MinLength } from 'class-validator';
import { i18nValidationMessage as i18n } from 'nestjs-i18n';
const PASSCODE_LENGTH = 6;
export class SetPasscodeRequestDto {
@ApiProperty({ example: '123456' })
@IsNumberString(
{ no_symbols: true },
{ message: i18n('validation.IsNumberString', { path: 'general', property: 'auth.passcode' }) },
)
@MinLength(PASSCODE_LENGTH, { message: i18n('validation.MinLength', { path: 'general', property: 'auth.passcode' }) })
@MaxLength(PASSCODE_LENGTH, { message: i18n('validation.MaxLength', { path: 'general', property: 'auth.passcode' }) })
passcode!: string;
}

View File

@ -14,6 +14,7 @@ import {
ChangePasswordRequestDto,
CreateUnverifiedUserRequestDto,
ForgetPasswordRequestDto,
JuniorLoginRequestDto,
LoginRequestDto,
SendForgetPasswordOtpRequestDto,
setJuniorPasswordRequestDto,
@ -196,11 +197,14 @@ export class AuthService {
this.logger.log(`Password changed successfully for user with id ${userId}`);
}
async setJuniorPasscode(body: setJuniorPasswordRequestDto) {
async setJuniorPassword(body: setJuniorPasswordRequestDto) {
this.logger.log(`Setting passcode for junior with qrToken ${body.qrToken}`);
if (body.newPassword != body.confirmNewPassword) {
throw new BadRequestException('AUTH.PASSWORD_MISMATCH');
}
const juniorId = await this.userTokenService.validateToken(body.qrToken, UserType.JUNIOR);
const salt = bcrypt.genSaltSync(SALT_ROUNDS);
const hashedPasscode = bcrypt.hashSync(body.passcode, salt);
const hashedPasscode = bcrypt.hashSync(body.newPassword, salt);
await this.userService.setPassword(juniorId!, hashedPasscode, salt);
await this.userTokenService.invalidateToken(body.qrToken);
this.logger.log(`Passcode set successfully for junior with id ${juniorId}`);
@ -278,6 +282,26 @@ export class AuthService {
return [tokens, user];
}
async juniorLogin(juniorLoginDto: JuniorLoginRequestDto): Promise<[ILoginResponse, User]> {
const user = await this.userService.findUser({ email: juniorLoginDto.email });
if (!user || !user.roles.includes(Roles.JUNIOR)) {
throw new UnauthorizedException('AUTH.INVALID_CREDENTIALS');
}
this.logger.log(`validating password for user with email ${juniorLoginDto.email}`);
const isPasswordValid = bcrypt.compareSync(juniorLoginDto.password, user.password);
if (!isPasswordValid) {
this.logger.error(`Invalid password for user with email ${juniorLoginDto.email}`);
throw new UnauthorizedException('AUTH.INVALID_CREDENTIALS');
}
const tokens = await this.generateAuthToken(user);
this.logger.log(`Password validated successfully for user`);
return [tokens, user];
}
private async generateAuthToken(user: User) {
this.logger.log(`Generating auth token for user with id ${user.id}`);
const [accessToken, refreshToken] = await Promise.all([

View File

@ -1,5 +1,8 @@
import { Module } from '@nestjs/common';
import { forwardRef, Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { NeoLeapModule } from '~/common/modules/neoleap/neoleap.module';
import { CustomerModule } from '~/customer/customer.module';
import { CardsController } from './controllers';
import { Card } from './entities';
import { Account } from './entities/account.entity';
import { Transaction } from './entities/transaction.entity';
@ -11,7 +14,11 @@ import { AccountService } from './services/account.service';
import { TransactionService } from './services/transaction.service';
@Module({
imports: [TypeOrmModule.forFeature([Card, Account, Transaction])],
imports: [
TypeOrmModule.forFeature([Card, Account, Transaction]),
forwardRef(() => NeoLeapModule),
forwardRef(() => CustomerModule), // <-- add forwardRef here
],
providers: [
CardService,
CardRepository,
@ -21,5 +28,6 @@ import { TransactionService } from './services/transaction.service';
AccountRepository,
],
exports: [CardService, TransactionService],
controllers: [CardsController],
})
export class CardModule {}

View File

@ -0,0 +1,39 @@
import { Controller, Get, Post, UseGuards } from '@nestjs/common';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { IJwtPayload } from '~/auth/interfaces';
import { AuthenticatedUser } from '~/common/decorators';
import { AccessTokenGuard } from '~/common/guards';
import { CardEmbossingDetailsResponseDto } from '~/common/modules/neoleap/dtos/response';
import { ApiDataResponse } from '~/core/decorators';
import { ResponseFactory } from '~/core/utils';
import { CardResponseDto } from '../dtos/responses';
import { CardService } from '../services';
@Controller('cards')
@ApiBearerAuth()
@ApiTags('Cards')
@UseGuards(AccessTokenGuard)
export class CardsController {
constructor(private readonly cardService: CardService) {}
@Post()
@ApiDataResponse(CardResponseDto)
async createCard(@AuthenticatedUser() { sub }: IJwtPayload) {
const card = await this.cardService.createCard(sub);
return ResponseFactory.data(new CardResponseDto(card));
}
@Get('current')
@ApiDataResponse(CardResponseDto)
async getCurrentCard(@AuthenticatedUser() { sub }: IJwtPayload) {
const card = await this.cardService.getCardByCustomerId(sub);
return ResponseFactory.data(new CardResponseDto(card));
}
@Get('embossing-details')
@ApiDataResponse(CardEmbossingDetailsResponseDto)
async getCardById(@AuthenticatedUser() { sub }: IJwtPayload) {
const res = await this.cardService.getEmbossingInformation(sub);
return ResponseFactory.data(res);
}
}

View File

@ -0,0 +1 @@
export * from './cards.controller';

View File

@ -0,0 +1,56 @@
import { ApiProperty } from '@nestjs/swagger';
import { Card } from '~/card/entities';
import { CardScheme, CardStatus, CustomerType } from '~/card/enums';
import { CardStatusDescriptionMapper } from '~/card/mappers/card-status-description.mapper';
import { UserLocale } from '~/core/enums';
export class CardResponseDto {
@ApiProperty({
example: 'b34df8c2-5d3e-4b1a-9c2f-7e3b1a2d3f4e',
})
id!: string;
@ApiProperty({
example: '123456',
description: 'The first six digits of the card number.',
})
firstSixDigits!: string;
@ApiProperty({ example: '7890', description: 'The last four digits of the card number.' })
lastFourDigits!: string;
@ApiProperty({
enum: CardScheme,
description: 'The card scheme (e.g., VISA, MASTERCARD).',
})
scheme!: CardScheme;
@ApiProperty({
enum: CardStatus,
description: 'The current status of the card (e.g., ACTIVE, PENDING).',
})
status!: CardStatus;
@ApiProperty({
example: 'The card is active',
description: 'A description of the card status.',
})
statusDescription!: string;
@ApiProperty({
example: 2000.0,
description: 'The credit limit of the card.',
})
balance!: number;
constructor(card: Card) {
this.id = card.id;
this.firstSixDigits = card.firstSixDigits;
this.lastFourDigits = card.lastFourDigits;
this.scheme = card.scheme;
this.status = card.status;
this.statusDescription = CardStatusDescriptionMapper[card.statusDescription][UserLocale.ENGLISH].description;
this.balance =
card.customerType === CustomerType.CHILD ? Math.min(card.limit, card.account.balance) : card.account.balance;
}
}

View File

@ -0,0 +1 @@
export * from './card.response.dto';

View File

@ -39,7 +39,7 @@ export class Card {
@Column({ type: 'varchar', nullable: false, name: 'customer_type' })
customerType!: CustomerType;
@Column({ type: 'varchar', nullable: false, default: CardColors.BLUE })
@Column({ type: 'varchar', nullable: false, default: CardColors.DEEP_MAGENTA })
color!: CardColors;
@Column({ type: 'varchar', nullable: false, default: CardStatus.PENDING })

View File

@ -1,4 +1,13 @@
export enum CardColors {
RED = 'RED',
BLUE = 'BLUE',
RAINBOW_PASTEL = 'RAINBOW_PASTEL',
DEEP_MAGENTA = 'DEEP_MAGENTA',
GREEN_TEAL = 'GREEN_TEAL',
BLUE_GREEN = 'BLUE_GREEN',
TEAL_NAVY = 'TEAL_NAVY',
PURPLE_PINK = 'PURPLE_PINK',
GOLD_BLUE = 'GOLD_BLUE',
OCEAN_BLUE = 'OCEAN_BLUE',
BROWN_RUST = 'BROWN_RUST',
}

View File

@ -1,7 +1,10 @@
import { UserLocale } from '~/core/enums';
import { CardStatusDescription } from '../enums';
export const CardStatusMapper: Record<CardStatusDescription, { [key in UserLocale]: { description: string } }> = {
export const CardStatusDescriptionMapper: Record<
CardStatusDescription,
{ [key in UserLocale]: { description: string } }
> = {
[CardStatusDescription.NORMAL]: {
[UserLocale.ENGLISH]: { description: 'The card is active' },
[UserLocale.ARABIC]: { description: 'البطاقة نشطة' },

View File

@ -9,7 +9,12 @@ import { CardColors, CardIssuers, CardScheme, CardStatus, CardStatusDescription,
export class CardRepository {
constructor(@InjectRepository(Card) private readonly cardRepository: Repository<Card>) {}
createCard(customerId: string, accountId: string, card: CreateApplicationResponse): Promise<Card> {
createCard(
customerId: string,
accountId: string,
card: CreateApplicationResponse,
cardColor?: CardColors,
): Promise<Card> {
return this.cardRepository.save(
this.cardRepository.create({
customerId: customerId,
@ -18,7 +23,7 @@ export class CardRepository {
customerType: CustomerType.PARENT,
firstSixDigits: card.firstSixDigits,
lastFourDigits: card.lastFourDigits,
color: CardColors.BLUE,
color: cardColor ? cardColor : CardColors.DEEP_MAGENTA,
scheme: CardScheme.VISA,
issuer: CardIssuers.NEOLEAP,
accountId: accountId,
@ -28,7 +33,7 @@ export class CardRepository {
}
getCardById(id: string): Promise<Card | null> {
return this.cardRepository.findOne({ where: { id } });
return this.cardRepository.findOne({ where: { id }, relations: ['account'] });
}
getCardByReferenceNumber(referenceNumber: string): Promise<Card | null> {
@ -42,9 +47,10 @@ export class CardRepository {
});
}
getActiveCardForCustomer(customerId: string): Promise<Card | null> {
getCardByCustomerId(customerId: string): Promise<Card | null> {
return this.cardRepository.findOne({
where: { customerId, status: CardStatus.ACTIVE },
where: { customerId },
relations: ['account'],
});
}

View File

@ -1,22 +1,55 @@
import { BadRequestException, Injectable } from '@nestjs/common';
import { BadRequestException, forwardRef, Inject, Injectable } from '@nestjs/common';
import { Transactional } from 'typeorm-transactional';
import { AccountCardStatusChangedWebhookRequest } from '~/common/modules/neoleap/dtos/requests';
import { CreateApplicationResponse } from '~/common/modules/neoleap/dtos/response';
import { NeoLeapService } from '~/common/modules/neoleap/services';
import { Customer } from '~/customer/entities';
import { KycStatus } from '~/customer/enums';
import { CustomerService } from '~/customer/services';
import { Card } from '../entities';
import { CardColors } from '../enums';
import { CardStatusMapper } from '../mappers/card-status.mapper';
import { CardRepository } from '../repositories';
import { AccountService } from './account.service';
@Injectable()
export class CardService {
constructor(private readonly cardRepository: CardRepository, private readonly accountService: AccountService) {}
constructor(
private readonly cardRepository: CardRepository,
private readonly accountService: AccountService,
@Inject(forwardRef(() => NeoLeapService)) private readonly neoleapService: NeoLeapService,
@Inject(forwardRef(() => CustomerService)) private readonly customerService: CustomerService,
) {}
@Transactional()
async createCard(customerId: string, cardData: CreateApplicationResponse): Promise<Card> {
const account = await this.accountService.createAccount(cardData);
return this.cardRepository.createCard(customerId, account.id, cardData);
async createCard(customerId: string): Promise<Card> {
const customer = await this.customerService.findCustomerById(customerId);
if (customer.kycStatus !== KycStatus.APPROVED) {
throw new BadRequestException('CUSTOMER.KYC_NOT_APPROVED');
}
if (customer.cards.length > 0) {
throw new BadRequestException('CUSTOMER.ALREADY_HAS_CARD');
}
const data = await this.neoleapService.createApplication(customer);
const account = await this.accountService.createAccount(data);
const createdCard = await this.cardRepository.createCard(customerId, account.id, data);
return this.getCardById(createdCard.id);
}
async createCardForChild(parentCustomer: Customer, childCustomer: Customer, cardColor: CardColors, cardPin: string) {
const data = await this.neoleapService.createChildCard(parentCustomer, childCustomer, cardPin);
const createdCard = await this.cardRepository.createCard(
childCustomer.id,
parentCustomer.cards[0].account.id,
data,
cardColor,
);
return this.getCardById(createdCard.id);
}
async getCardById(id: string): Promise<Card> {
const card = await this.cardRepository.getCardById(id);
@ -46,8 +79,8 @@ export class CardService {
return card;
}
async getActiveCardForCustomer(customerId: string): Promise<Card> {
const card = await this.cardRepository.getActiveCardForCustomer(customerId);
async getCardByCustomerId(customerId: string): Promise<Card> {
const card = await this.cardRepository.getCardByCustomerId(customerId);
if (!card) {
throw new BadRequestException('CARD.NOT_FOUND');
}
@ -60,4 +93,10 @@ export class CardService {
return this.cardRepository.updateCardStatus(card.id, status, description);
}
async getEmbossingInformation(customerId: string) {
const card = await this.getCardByCustomerId(customerId);
return this.neoleapService.getEmbossingInformation(card);
}
}

View File

@ -14,8 +14,8 @@ import { CardService } from './card.service';
export class TransactionService {
constructor(
private readonly transactionRepository: TransactionRepository,
private readonly cardService: CardService,
private readonly accountService: AccountService,
private readonly cardService: CardService,
) {}
@Transactional()

View File

@ -0,0 +1,38 @@
export const CARD_EMBOSSING_DETAILS_MOCK = {
ResponseHeader: {
Version: '1.0.0',
MsgUid: 'adaa1893-9f95-48a8-b7a1-0422bcf629b5',
Source: 'ZOD',
ServiceId: 'GetEmbossingInformation',
ReqDateTime: '2025-06-11T07:32:16.304Z',
RspDateTime: '2025-08-14T10:01:14.205',
ResponseCode: '000',
ResponseType: 'Success',
ProcessingTime: 67,
EncryptionKey: null,
ResponseDescription: 'Operation Successful',
LocalizedResponseDescription: null,
CustomerSpecificResponseDescriptionList: null,
HeaderUserDataList: null,
},
GetEmbossingInformationResponseDetails: {
icvv: '259',
Track1: '%B4017786818471184^AMMAR/QAFFAF^31102261029800997000000?',
Track2: ';4017786818471184=31102261029899700?',
Track3: null,
EmvTrack1: '1029800259000000',
EmvTrack2: '4017786818471184D31102261029825900',
ClearPan: '4017786818471184',
PinBlock: '663B1A71D8112D97',
Cvv: '997',
Cvv2: '834',
iCvv: '259',
Pvv: '0298',
EmbossingName: 'AMMAR QAFFAF',
ExpiryDate: '20311031',
OldPlasticExpiryDate: null,
CardStatus: '30',
OldPlasticCardStatus: ' ',
EmbossingRecord: null,
},
};

View File

@ -1,3 +1,11 @@
function getRandomWithDigits(digits: number): string {
const min = Math.pow(10, digits - 1); // e.g. 1000 for 4 digits
const max = Math.pow(10, digits) - 1; // e.g. 9999 for 4 digits
const result = Math.floor(Math.random() * (max - min + 1)) + min;
return result.toString();
}
export const CREATE_APPLICATION_MOCK = {
ResponseHeader: {
Version: '1.0.0',
@ -673,9 +681,9 @@ export const CREATE_APPLICATION_MOCK = {
},
AccountDetailsList: [
{
Id: 21017,
Id: getRandomWithDigits(5),
InstitutionCode: '1100',
AccountNumber: '6899999999999999',
AccountNumber: getRandomWithDigits(16),
Currency: {
CurrCode: '682',
AlphaCode: 'SAR',
@ -704,10 +712,10 @@ export const CREATE_APPLICATION_MOCK = {
{
pvv: null,
ResponseCardIdentifier: {
Id: 28595,
Id: getRandomWithDigits(5),
Pan: 'DDDDDDDDDDDDDDDDDDD',
MaskedPan: '999999_9999',
VPan: '1100000000000000',
VPan: getRandomWithDigits(16),
Seqno: 0,
},
ExpiryDate: '2031-09-30',

View File

@ -1,3 +1,4 @@
export * from './card-embossing-details.mock';
export * from './create-application.mock';
export * from './initiate-kyc.mock';
export * from './inquire-application.mock';

View File

@ -19,5 +19,11 @@ export const getKycCallbackMock = (nationalId: string) => {
professionTitle: 'Software Engineer',
professionType: 'Full-Time',
isPep: 'N',
country: '682',
region: 'Mecca',
city: 'At-Taif',
neighborhood: 'Al-Hamra',
street: 'Al-Masjid Al-Haram',
building: '123',
};
};

View File

@ -1,62 +0,0 @@
import { Body, Controller, Post, UseGuards } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { IJwtPayload } from '~/auth/interfaces';
import { CardService } from '~/card/services';
import { AuthenticatedUser } from '~/common/decorators';
import { AccessTokenGuard } from '~/common/guards';
import { ApiDataResponse } from '~/core/decorators';
import { ResponseFactory } from '~/core/utils';
import { CustomerResponseDto } from '~/customer/dtos/response';
import { CustomerService } from '~/customer/services';
import { UpdateCardControlsRequestDto } from '../dtos/requests';
import { CreateApplicationResponse, InquireApplicationResponse } from '../dtos/response';
import { NeoLeapService } from '../services/neoleap.service';
@Controller('neotest')
@ApiTags('Neoleap Test API , for testing purposes only, will be removed in production')
@UseGuards(AccessTokenGuard)
@ApiBearerAuth()
export class NeoTestController {
constructor(
private readonly neoleapService: NeoLeapService,
private readonly customerService: CustomerService,
private readonly cardService: CardService,
private readonly configService: ConfigService,
) {}
@Post('update-kys')
@ApiDataResponse(CustomerResponseDto)
async updateKys(@AuthenticatedUser() user: IJwtPayload) {
const customer = await this.customerService.updateKyc(user.sub);
return ResponseFactory.data(new CustomerResponseDto(customer));
}
@Post('inquire-application')
@ApiDataResponse(InquireApplicationResponse)
async inquireApplication(@AuthenticatedUser() user: IJwtPayload) {
const customer = await this.customerService.findCustomerById(user.sub);
const data = await this.neoleapService.inquireApplication(customer.applicationNumber.toString());
return ResponseFactory.data(data);
}
@Post('create-application')
@ApiDataResponse(CreateApplicationResponse)
async createApplication(@AuthenticatedUser() user: IJwtPayload) {
const customer = await this.customerService.findCustomerById(user.sub);
const data = await this.neoleapService.createApplication(customer);
await this.cardService.createCard(customer.id, data);
return ResponseFactory.data(data);
}
@Post('update-card-controls')
async updateCardControls(
@AuthenticatedUser() user: IJwtPayload,
@Body() { amount, count }: UpdateCardControlsRequestDto,
) {
const card = await this.cardService.getActiveCardForCustomer(user.sub);
await this.neoleapService.updateCardControl(card.cardReference, amount, count);
return ResponseFactory.data({ message: 'Card controls updated successfully' });
}
}

View File

@ -96,4 +96,34 @@ export class KycWebhookRequest {
@IsString()
@ApiProperty({ example: 'N' })
isPep!: string;
@Expose()
@IsString()
@ApiProperty({ example: '682' })
country!: string;
@Expose()
@IsString()
@ApiProperty({ example: 'Mecca' })
region!: string;
@Expose()
@IsString()
@ApiProperty({ example: 'At-Taif' })
city!: string;
@Expose()
@IsString()
@ApiProperty({ example: 'Al-Hamra' })
neighborhood!: string;
@Expose()
@IsString()
@ApiProperty({ example: 'Al-Masjid Al-Haram' })
street!: string;
@Expose()
@IsString()
@ApiProperty({ example: '123' })
building!: string;
}

View File

@ -0,0 +1,26 @@
import { ApiProperty } from '@nestjs/swagger';
import { Expose } from 'class-transformer';
export class CardEmbossingDetailsResponseDto {
@ApiProperty({
example: '997',
})
@Expose({ name: 'Cvv' })
cvv!: string;
@ApiProperty({ example: '4017786818471184' })
@Expose({ name: 'ClearPan' })
cardNumber!: string;
@ApiProperty({
example: '20311031',
})
@Expose({ name: 'ExpiryDate' })
expiryDate!: string;
@ApiProperty({
example: 'AMMAR QAFFAF',
})
@Expose({ name: 'EmbossingName' })
cardHolderName!: string;
}

View File

@ -1,3 +1,4 @@
export * from './card-embossing-details.response.dto';
export * from './create-application.response.dto';
export * from './initiate-kyc.response.dto';
export * from './inquire-application.response';

View File

@ -1,16 +1,11 @@
import { HttpModule } from '@nestjs/axios';
import { forwardRef, Module } from '@nestjs/common';
import { CardModule } from '~/card/card.module';
import { CustomerModule } from '~/customer/customer.module';
import { NeoLeapWebhooksController } from './controllers/neoleap-webhooks.controller';
import { NeoTestController } from './controllers/neotest.controller';
import { NeoLeapWebhookService } from './services';
import { Module } from '@nestjs/common';
import { NeoLeapService } from './services/neoleap.service';
@Module({
imports: [HttpModule, CardModule, forwardRef(() => CustomerModule)],
controllers: [NeoTestController, NeoLeapWebhooksController],
providers: [NeoLeapService, NeoLeapWebhookService],
imports: [HttpModule],
controllers: [],
providers: [NeoLeapService],
exports: [NeoLeapService],
})
export class NeoLeapModule {}

View File

@ -1,2 +1,2 @@
export * from './neoleap-webook.service';
export * from '../../../../webhook/services/neoleap-webook.service';
export * from './neoleap.service';

View File

@ -4,13 +4,20 @@ import { ConfigService } from '@nestjs/config';
import { ClassConstructor, plainToInstance } from 'class-transformer';
import moment from 'moment';
import { v4 as uuid } from 'uuid';
import { Card } from '~/card/entities';
import { CountriesNumericISO } from '~/common/constants';
import { InitiateKycRequestDto } from '~/customer/dtos/request';
import { Customer } from '~/customer/entities';
import { Gender, KycStatus } from '~/customer/enums';
import { CREATE_APPLICATION_MOCK, INITIATE_KYC_MOCK, INQUIRE_APPLICATION_MOCK } from '../__mocks__/';
import { Gender } from '~/customer/enums';
import {
CARD_EMBOSSING_DETAILS_MOCK,
CREATE_APPLICATION_MOCK,
INITIATE_KYC_MOCK,
INQUIRE_APPLICATION_MOCK,
} from '../__mocks__/';
import { getKycCallbackMock } from '../__mocks__/kyc-callback.mock';
import {
CardEmbossingDetailsResponseDto,
CreateApplicationResponse,
InitiateKycResponseDto,
InquireApplicationResponse,
@ -29,6 +36,7 @@ export class NeoLeapService {
private readonly zodApiUrl: string;
private readonly apiKey: string;
private readonly useGateway: boolean;
private readonly useKycMock: boolean;
private readonly institutionCode = '1100';
useLocalCert: boolean;
constructor(private readonly httpService: HttpService, private readonly configService: ConfigService) {
@ -37,12 +45,13 @@ export class NeoLeapService {
this.useGateway = [true, 'true'].includes(this.configService.get<boolean>('USE_GATEWAY', false));
this.useLocalCert = this.configService.get<boolean>('USE_LOCAL_CERT', false);
this.zodApiUrl = this.configService.getOrThrow<string>('ZOD_API_URL');
this.useKycMock = [true, 'true'].includes(this.configService.get<boolean>('USE_KYC_MOCK', true));
}
async initiateKyc(customerId: string, body: InitiateKycRequestDto) {
initiateKyc(customerId: string, body: InitiateKycRequestDto) {
const responseKey = 'InitiateKycResponseDetails';
if (!this.useGateway) {
if (this.useKycMock) {
const responseDto = plainToInstance(InitiateKycResponseDto, INITIATE_KYC_MOCK[responseKey], {
excludeExtraneousValues: true,
});
@ -82,17 +91,9 @@ export class NeoLeapService {
);
}
async createApplication(customer: Customer) {
createApplication(customer: Customer) {
const responseKey = 'CreateNewApplicationResponseDetails';
if (customer.kycStatus !== KycStatus.APPROVED) {
throw new BadRequestException('CUSTOMER.KYC_NOT_APPROVED');
}
if (customer.cards.length > 0) {
throw new BadRequestException('CUSTOMER.ALREADY_HAS_CARD');
}
if (!this.useGateway) {
return plainToInstance(CreateApplicationResponse, CREATE_APPLICATION_MOCK[responseKey], {
excludeExtraneousValues: true,
@ -164,7 +165,82 @@ export class NeoLeapService {
);
}
async inquireApplication(externalApplicationNumber: string) {
createChildCard(parent: Customer, child: Customer, cardPin: string) {
const responseKey = 'CreateNewApplicationResponseDetails';
if (!this.useGateway) {
return plainToInstance(CreateApplicationResponse, CREATE_APPLICATION_MOCK[responseKey], {
excludeExtraneousValues: true,
});
}
const payload: ICreateApplicationRequest = {
CreateNewApplicationRequestDetails: {
ApplicationRequestDetails: {
InstitutionCode: this.institutionCode,
ExternalApplicationNumber: child.applicationNumber.toString(),
ApplicationType: '01',
Product: '1101',
ApplicationDate: moment().format('YYYY-MM-DD'),
BranchCode: '000',
ApplicationSource: 'O',
DeliveryMethod: 'V',
},
ApplicationProcessingDetails: {
SuggestedLimit: 0,
RequestedLimit: 0,
AssignedLimit: 0,
ProcessControl: 'STND',
},
ApplicationFinancialInformation: {
Currency: {
AlphaCode: 'SAR',
},
BillingCycle: 'C1',
},
ApplicationOtherInfo: {
ParentAccountNumber: parent.cards[0].account.accountNumber,
},
ApplicationCustomerDetails: {
FirstName: parent.firstName,
LastName: parent.lastName,
FullName: parent.fullName,
DateOfBirth: moment(parent.dateOfBirth).format('YYYY-MM-DD'),
EmbossName: child.fullName.toUpperCase(), // TODO Enter Emboss Name
IdType: '01',
IdNumber: parent.nationalId,
IdExpiryDate: moment(parent.nationalIdExpiry).format('YYYY-MM-DD'),
Title: parent.gender === Gender.MALE ? 'Mr' : 'Ms',
Gender: parent.gender === Gender.MALE ? 'M' : 'F',
LocalizedDateOfBirth: moment(parent.dateOfBirth).format('YYYY-MM-DD'),
Nationality: CountriesNumericISO[parent.countryOfResidence],
},
ApplicationAddress: {
City: parent.city,
Country: CountriesNumericISO[parent.country],
Region: parent.region,
AddressLine1: `${parent.street} ${parent.building}`,
AddressLine2: parent.neighborhood,
AddressRole: 0,
Email: child.user.email,
Phone1: child.user.phoneNumber,
CountryDetails: {
DefaultCurrency: {},
Description: [],
},
},
},
RequestHeader: this.prepareHeaders('CreateNewApplication'),
};
return this.sendRequestToNeoLeap<ICreateApplicationRequest, CreateApplicationResponse>(
'application/CreateNewApplication',
payload,
responseKey,
CreateApplicationResponse,
);
}
inquireApplication(externalApplicationNumber: string) {
const responseKey = 'InquireApplicationResponseDetails';
if (!this.useGateway) {
return plainToInstance(InquireApplicationResponse, INQUIRE_APPLICATION_MOCK[responseKey], {
@ -196,7 +272,7 @@ export class NeoLeapService {
);
}
async updateCardControl(cardId: string, amount: number, count?: number) {
updateCardControl(cardId: string, amount: number, count?: number) {
const responseKey = 'UpdateCardControlResponseDetails';
if (!this.useGateway) {
return;
@ -225,6 +301,33 @@ export class NeoLeapService {
);
}
getEmbossingInformation(card: Card) {
const responseKey = 'GetEmbossingInformationResponseDetails';
if (!this.useGateway) {
return plainToInstance(CardEmbossingDetailsResponseDto, CARD_EMBOSSING_DETAILS_MOCK[responseKey], {
excludeExtraneousValues: true,
});
}
const payload = {
GetEmbossingInformationRequestDetails: {
InstitutionCode: this.institutionCode,
CardIdentifier: {
InstitutionCode: this.institutionCode,
Id: card.cardReference,
},
},
RequestHeader: this.prepareHeaders('GetEmbossingInformation'),
};
return this.sendRequestToNeoLeap<typeof payload, CardEmbossingDetailsResponseDto>(
'issuance/GetEmbossingInformation',
payload,
responseKey,
CardEmbossingDetailsResponseDto,
);
}
private prepareHeaders(serviceName: string): INeoleapHeaderRequest['RequestHeader'] {
return {
Version: '1.0.0',

View File

@ -21,7 +21,7 @@ export class NotificationCreatedListener {
/**
* Handles the NOTIFICATION_CREATED event by calling the appropriate channel logic.
*/
async handle(event: IEventInterface) {
handle(event: IEventInterface) {
this.logger.log(
`Handling ${EventType.NOTIFICATION_CREATED} event for notification ${event.id} (channel: ${event.channel})`,
);

View File

@ -68,7 +68,6 @@ export class NotificationsService {
});
this.logger.log(`emitting ${EventType.NOTIFICATION_CREATED} event`);
return this.redisPubSubService.publishEvent(EventType.NOTIFICATION_CREATED, {
...notification,
data: { otp },

View File

@ -19,7 +19,6 @@ export class OtpService {
async generateAndSendOtp(sendOtpRequest: ISendOtp): Promise<string> {
this.logger.log(`invalidate OTP for ${sendOtpRequest.recipient} and ${sendOtpRequest.otpType}`);
await this.otpRepository.invalidateOtp(sendOtpRequest);
this.logger.log(`Generating OTP for ${sendOtpRequest.recipient}`);
const otp = this.useMock ? DEFAULT_OTP_DIGIT.repeat(DEFAULT_OTP_LENGTH) : generateRandomOtp(DEFAULT_OTP_LENGTH);

View File

@ -9,12 +9,7 @@ import { CustomerRepository } from './repositories/customer.repository';
import { CustomerService } from './services';
@Module({
imports: [
TypeOrmModule.forFeature([Customer]),
forwardRef(() => UserModule),
GuardianModule,
forwardRef(() => NeoLeapModule),
],
imports: [TypeOrmModule.forFeature([Customer]), GuardianModule, forwardRef(() => UserModule), NeoLeapModule],
controllers: [CustomerController],
providers: [CustomerService, CustomerRepository],
exports: [CustomerService],

View File

@ -14,8 +14,7 @@ export class CustomerRepository {
findOne(where: FindOptionsWhere<Customer>) {
return this.customerRepository.findOne({
where,
relations: ['user', 'cards'],
relations: ['user', 'cards', 'cards.account'],
});
}
@ -30,6 +29,7 @@ export class CustomerRepository {
lastName: body.lastName,
dateOfBirth: body.dateOfBirth,
countryOfResidence: body.countryOfResidence,
gender: body.gender,
}),
);
}

View File

@ -33,7 +33,10 @@ export class CustomerService {
async createJuniorCustomer(guardianId: string, juniorId: string, body: CreateJuniorRequestDto) {
this.logger.log(`Creating junior customer for user ${juniorId}`);
return this.customerRepository.createCustomer(juniorId, body, false);
await this.customerRepository.createCustomer(juniorId, body, false);
this.logger.log(`Junior customer created for user ${juniorId} successfully`);
return this.customerRepository.findOne({ id: juniorId });
}
async findCustomerById(id: string) {
@ -104,13 +107,18 @@ export class CustomerService {
dateOfBirth: moment(body.dob, 'YYYYMMDD').toDate(),
nationalId: body.nationalId,
nationalIdExpiry: moment(body.nationalIdExpiry, 'YYYYMMDD').toDate(),
countryOfResidence: NumericToCountryIso[body.nationality],
country: NumericToCountryIso[body.nationality],
countryOfResidence: NumericToCountryIso[body.country],
country: NumericToCountryIso[body.country],
gender: body.gender === 'M' ? Gender.MALE : Gender.FEMALE,
sourceOfIncome: body.incomeSource,
profession: body.professionTitle,
professionType: body.professionType,
isPep: body.isPep === 'Y',
city: body.city,
region: body.region,
neighborhood: body.neighborhood,
street: body.street,
building: body.building,
});
}

View File

@ -50,7 +50,9 @@
"CUSTOMER": {
"NOT_FOUND": "لم يتم العثور على العميل.",
"ALREADY_EXISTS": "العميل موجود بالفعل.",
"KYC_NOT_APPROVED": "لم يتم الموافقة على هوية العميل بعد."
"KYC_NOT_APPROVED": "لم يتم الموافقة على هوية العميل بعد.",
"ALREADY_HAS_CARD": "العميل لديه بطاقة بالفعل.",
"DOES_NOT_HAVE_CARD": "العميل لا يملك بطاقة."
},
"GIFT": {

View File

@ -49,7 +49,9 @@
"CUSTOMER": {
"NOT_FOUND": "The customer was not found.",
"ALREADY_EXISTS": "The customer already exists.",
"KYC_NOT_APPROVED": "The customer's KYC has not been approved yet."
"KYC_NOT_APPROVED": "The customer's KYC has not been approved yet.",
"ALREADY_HAS_CARD": "The customer already has a card.",
"DOES_NOT_HAVE_CARD": "The customer does not have a card."
},
"GIFT": {

View File

@ -1,25 +1,19 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsDateString, IsEmail, IsEnum, IsNotEmpty, IsOptional, IsString, IsUUID, Matches } from 'class-validator';
import {
IsDateString,
IsEmail,
IsEnum,
IsNotEmpty,
IsNumberString,
IsOptional,
IsString,
IsUUID,
} from 'class-validator';
import { i18nValidationMessage as i18n } from 'nestjs-i18n';
import { COUNTRY_CODE_REGEX } from '~/auth/constants';
import { IsValidPhoneNumber } from '~/core/decorators/validations';
import { CardColors } from '~/card/enums';
import { Gender } from '~/customer/enums';
import { Relationship } from '~/junior/enums';
export class CreateJuniorRequestDto {
@ApiProperty({ example: '+962' })
@Matches(COUNTRY_CODE_REGEX, {
message: i18n('validation.Matches', { path: 'general', property: 'auth.countryCode' }),
})
@IsOptional()
countryCode: string = '+966';
@ApiProperty({ example: '787259134' })
@IsValidPhoneNumber({
message: i18n('validation.IsValidPhoneNumber', { path: 'general', property: 'auth.phoneNumber' }),
})
@IsOptional()
phoneNumber!: string;
@ApiProperty({ example: 'John' })
@IsString({ message: i18n('validation.IsString', { path: 'general', property: 'customer.firstName' }) })
@IsNotEmpty({ message: i18n('validation.IsNotEmpty', { path: 'general', property: 'customer.firstName' }) })
@ -30,9 +24,9 @@ export class CreateJuniorRequestDto {
@IsNotEmpty({ message: i18n('validation.IsNotEmpty', { path: 'general', property: 'customer.lastName' }) })
lastName!: string;
@ApiProperty({ example: 'MALE' })
@ApiProperty({ enum: Gender })
@IsEnum(Gender, { message: i18n('validation.IsEnum', { path: 'general', property: 'customer.gender' }) })
gender!: string;
gender!: Gender;
@ApiProperty({ example: '2020-01-01' })
@IsDateString({}, { message: i18n('validation.IsDateString', { path: 'general', property: 'customer.dateOfBirth' }) })
@ -46,13 +40,13 @@ export class CreateJuniorRequestDto {
@IsEnum(Relationship, { message: i18n('validation.IsEnum', { path: 'general', property: 'junior.relationship' }) })
relationship!: Relationship;
@ApiProperty({ example: 'bf342-3f3f-3f3f-3f3f' })
@IsUUID('4', { message: i18n('validation.IsUUID', { path: 'general', property: 'junior.civilIdFrontId' }) })
civilIdFrontId!: string;
@ApiProperty({ enum: CardColors })
@IsEnum(CardColors, { message: i18n('validation.IsEnum', { path: 'general', property: 'junior.cardColor' }) })
cardColor!: CardColors;
@ApiProperty({ example: 'bf342-3f3f-3f3f-3f3f' })
@IsUUID('4', { message: i18n('validation.IsUUID', { path: 'general', property: 'junior.civilIdBackId' }) })
civilIdBackId!: string;
@ApiProperty({ example: '1234' })
@IsNumberString({}, { message: i18n('validation.IsEnum', { path: 'general', property: 'junior.cardPin' }) })
cardPin!: string;
@ApiProperty({ example: '123e4567-e89b-12d3-a456-426614174000' })
@IsUUID('4', { message: i18n('validation.IsUUID', { path: 'general', property: 'customer.profilePictureId' }) })

View File

@ -7,10 +7,16 @@ export class JuniorResponseDto {
@ApiProperty({ example: 'id' })
id!: string;
@ApiProperty({ example: 'fullName' })
fullName!: string;
@ApiProperty({ example: 'FirstName' })
firstName!: string;
@ApiProperty({ example: 'relationship' })
@ApiProperty({ example: 'LastName' })
lastName!: string;
@ApiProperty({ example: 'test@junior.com' })
email!: string;
@ApiProperty({ enum: Relationship })
relationship!: Relationship;
@ApiProperty({ type: DocumentMetaResponseDto })
@ -18,7 +24,9 @@ export class JuniorResponseDto {
constructor(junior: Junior) {
this.id = junior.id;
this.fullName = `${junior.customer.firstName} ${junior.customer.lastName}`;
this.firstName = junior.customer.firstName;
this.lastName = junior.customer.lastName;
this.email = junior.customer.user.email;
this.relationship = junior.relationship;
this.profilePicture = junior.customer.user.profilePicture
? new DocumentMetaResponseDto(junior.customer.user.profilePicture)

View File

@ -1,6 +1,8 @@
import { HttpModule } from '@nestjs/axios';
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { CardModule } from '~/card/card.module';
import { NeoLeapModule } from '~/common/modules/neoleap/neoleap.module';
import { CustomerModule } from '~/customer/customer.module';
import { UserModule } from '~/user/user.module';
import { JuniorController } from './controllers';
@ -11,7 +13,14 @@ import { BranchIoService, JuniorService, QrcodeService } from './services';
@Module({
controllers: [JuniorController],
providers: [JuniorService, JuniorRepository, QrcodeService, BranchIoService],
imports: [TypeOrmModule.forFeature([Junior, Theme]), UserModule, CustomerModule, HttpModule],
imports: [
TypeOrmModule.forFeature([Junior, Theme]),
UserModule,
CustomerModule,
HttpModule,
NeoLeapModule,
CardModule,
],
exports: [JuniorService],
})
export class JuniorModule {}

View File

@ -20,7 +20,7 @@ export class JuniorRepository {
}
findJuniorById(juniorId: string, withGuardianRelation = false, guardianId?: string) {
const relations = ['customer', 'customer.user', 'theme', 'theme.avatar'];
const relations = ['customer', 'customer.user', 'theme', 'theme.avatar', 'customer.user.profilePicture'];
if (withGuardianRelation) {
relations.push('guardian', 'guardian.customer', 'guardian.customer.user');
}

View File

@ -1,11 +1,11 @@
import { BadRequestException, Injectable, Logger } from '@nestjs/common';
import { FindOptionsWhere } from 'typeorm';
import { Transactional } from 'typeorm-transactional';
import { Roles } from '~/auth/enums';
import { CardService } from '~/card/services';
import { NeoLeapService } from '~/common/modules/neoleap/services';
import { PageOptionsRequestDto } from '~/core/dtos';
import { CustomerService } from '~/customer/services';
import { DocumentService, OciService } from '~/document/services';
import { User } from '~/user/entities';
import { UserType } from '~/user/enums';
import { UserService } from '~/user/services';
import { UserTokenService } from '~/user/services/user-token.service';
@ -25,43 +25,47 @@ export class JuniorService {
private readonly documentService: DocumentService,
private readonly ociService: OciService,
private readonly qrCodeService: QrcodeService,
private readonly neoleapService: NeoLeapService,
private readonly cardService: CardService,
) {}
@Transactional()
async createJuniors(body: CreateJuniorRequestDto, guardianId: string) {
this.logger.log(`Creating junior for guardian ${guardianId}`);
const searchConditions: FindOptionsWhere<User>[] = [{ email: body.email }];
const parentCustomer = await this.customerService.findCustomerById(guardianId);
if (body.phoneNumber && body.countryCode) {
searchConditions.push({
phoneNumber: body.phoneNumber,
countryCode: body.countryCode,
});
if (!parentCustomer.cards || parentCustomer.cards.length === 0) {
this.logger.error(`Guardian ${guardianId} does not have a card`);
throw new BadRequestException('CUSTOMER.DOES_NOT_HAVE_CARD');
}
const existingUser = await this.userService.findUser(searchConditions);
const existingUser = await this.userService.findUser({ email: body.email });
if (existingUser) {
this.logger.error(`User with email ${body.email} or phone number ${body.phoneNumber} already exists`);
this.logger.error(`User with email ${body.email} already exists`);
throw new BadRequestException('USER.ALREADY_EXISTS');
}
const user = await this.userService.createUser({
email: body.email,
countryCode: body.countryCode,
phoneNumber: body.phoneNumber,
firstName: body.firstName,
lastName: body.lastName,
profilePictureId: body.profilePictureId,
roles: [Roles.JUNIOR],
});
const customer = await this.customerService.createJuniorCustomer(guardianId, user.id, body);
const childCustomer = await this.customerService.createJuniorCustomer(guardianId, user.id, body);
await this.juniorRepository.createJunior(user.id, {
guardianId,
relationship: body.relationship,
customerId: customer.id,
customerId: childCustomer!.id,
});
this.logger.debug('Creating card For Child');
await this.cardService.createCardForChild(parentCustomer, childCustomer!, body.cardColor, body.cardColor);
this.logger.log(`Junior ${user.id} created successfully`);
return this.generateToken(user.id);
@ -75,6 +79,7 @@ export class JuniorService {
this.logger.error(`Junior ${juniorId} not found`);
throw new BadRequestException('JUNIOR.NOT_FOUND');
}
await this.prepareJuniorImages([junior]);
this.logger.log(`Junior ${juniorId} found successfully`);
return junior;

View File

@ -10,7 +10,6 @@ export class QrcodeService {
this.logger.log(`Generating QR code for token ${token}`);
const link = await this.branchIoService.createBranchLink(token);
return qrcode.toDataURL(link);
}
}

View File

@ -236,13 +236,18 @@ export class UserService {
throw new BadRequestException('USER.EMAIL_ALREADY_VERIFIED');
}
await this.otpService.verifyOtp({
const isOtpValid = await this.otpService.verifyOtp({
userId,
value: otp,
scope: OtpScope.VERIFY_EMAIL,
otpType: OtpType.EMAIL,
});
if (!isOtpValid) {
this.logger.error(`Invalid OTP for user with email ${user.email}`);
throw new BadRequestException('OTP.INVALID_OTP');
}
await this.userRepository.update(userId, { isEmailVerified: true });
this.logger.log(`Email for user ${userId} verified successfully`);
}

View File

View File

@ -6,8 +6,8 @@ import {
AccountTransactionWebhookRequest,
CardTransactionWebhookRequest,
KycWebhookRequest,
} from '../dtos/requests';
import { NeoLeapWebhookService } from '../services';
} from '../../common/modules/neoleap/dtos/requests';
import { NeoLeapWebhookService } from '../../common/modules/neoleap/services';
@Controller('neoleap-webhooks')
@ApiTags('Neoleap Webhooks')

View File

@ -0,0 +1 @@
export * from './neoleap-webook.service';

View File

@ -1,4 +1,4 @@
import { Injectable } from '@nestjs/common';
import { forwardRef, Inject, Injectable } from '@nestjs/common';
import { CardService } from '~/card/services';
import { TransactionService } from '~/card/services/transaction.service';
import { CustomerService } from '~/customer/services';
@ -7,14 +7,15 @@ import {
AccountTransactionWebhookRequest,
CardTransactionWebhookRequest,
KycWebhookRequest,
} from '../dtos/requests';
} from '../../common/modules/neoleap/dtos/requests';
@Injectable()
export class NeoLeapWebhookService {
constructor(
@Inject(forwardRef(() => CustomerService))
private readonly customerService: CustomerService,
private readonly transactionService: TransactionService,
private readonly cardService: CardService,
private customerService: CustomerService,
) {}
handleCardTransactionWebhook(body: CardTransactionWebhookRequest) {

View File

@ -0,0 +1,12 @@
import { Module } from '@nestjs/common';
import { CardModule } from '~/card/card.module';
import { CustomerModule } from '~/customer/customer.module';
import { NeoLeapWebhooksController } from './controllers/neoleap-webhooks.controller';
import { NeoLeapWebhookService } from './services';
@Module({
providers: [NeoLeapWebhookService],
controllers: [NeoLeapWebhooksController],
imports: [CustomerModule, CardModule],
})
export class WebhookModule {}