mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2026-03-10 19:51:46 +00:00
- Added address fields to registration (verify-user DTO) - Added address fields to KYC initiation (initiate-kyc DTO) - Added national_id column to kyc_transactions table - Changed duplicate KYC check from customerId to nationalId - Added KYC webhook endpoint (/api/neoleap-webhooks/kyc) - Added webhook processing logic - Updated customer service to save address during registration and KYC - Added validation to require address before card creation - Removed duplicate src/migrations/ directory
46 lines
1.8 KiB
TypeScript
46 lines
1.8 KiB
TypeScript
import { Body, Controller, Get, Post, UseGuards } from '@nestjs/common';
|
|
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
|
import { IJwtPayload } from '~/auth/interfaces';
|
|
import { AuthenticatedUser } from '~/common/decorators';
|
|
import { AccessTokenGuard } from '~/common/guards';
|
|
import { ApiDataResponse, ApiLangRequestHeader } from '~/core/decorators';
|
|
import { ResponseFactory } from '~/core/utils';
|
|
import { InitiateKycRequestDto } from '../dtos/request';
|
|
import { CustomerResponseDto, InitiateKycResponseDto, KycMetadataResponseDto } from '../dtos/response';
|
|
import { CustomerService } from '../services';
|
|
|
|
@Controller('customers')
|
|
@ApiTags('Customers')
|
|
@ApiBearerAuth()
|
|
@ApiLangRequestHeader()
|
|
export class CustomerController {
|
|
constructor(private readonly customerService: CustomerService) {}
|
|
@Get('/kyc')
|
|
@UseGuards(AccessTokenGuard)
|
|
@ApiDataResponse(CustomerResponseDto)
|
|
async getCustomerProfile(@AuthenticatedUser() { sub }: IJwtPayload) {
|
|
const customer = await this.customerService.findCustomerById(sub);
|
|
|
|
return ResponseFactory.data(new CustomerResponseDto(customer));
|
|
}
|
|
|
|
@Post('/kyc/initiate')
|
|
@UseGuards(AccessTokenGuard)
|
|
@ApiDataResponse(InitiateKycResponseDto)
|
|
async initiateKyc(@AuthenticatedUser() { sub }: IJwtPayload, @Body() body: InitiateKycRequestDto) {
|
|
const res = await this.customerService.initiateKycRequest(sub, body);
|
|
|
|
return ResponseFactory.data(new InitiateKycResponseDto(res));
|
|
}
|
|
|
|
@Get('/kyc/onboard-metadata')
|
|
@UseGuards(AccessTokenGuard)
|
|
@ApiOperation({ summary: 'Get KYC onboarding form metadata' })
|
|
@ApiDataResponse(KycMetadataResponseDto)
|
|
async getKycMetadata() {
|
|
const metadata = await this.customerService.getKycOnboardMetadata();
|
|
|
|
return ResponseFactory.data(metadata);
|
|
}
|
|
}
|