mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2026-03-10 20:51:44 +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
77 lines
2.1 KiB
TypeScript
77 lines
2.1 KiB
TypeScript
import {
|
|
BaseEntity,
|
|
Column,
|
|
CreateDateColumn,
|
|
Entity,
|
|
JoinColumn,
|
|
ManyToOne,
|
|
PrimaryGeneratedColumn,
|
|
UpdateDateColumn,
|
|
} from 'typeorm';
|
|
import { Customer } from './customer.entity';
|
|
import { User } from '~/user/entities';
|
|
|
|
@Entity('kyc_transactions')
|
|
export class KycTransaction extends BaseEntity {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id!: string;
|
|
|
|
@Column('uuid', { name: 'customer_id' })
|
|
customerId!: string;
|
|
|
|
@Column('uuid', { name: 'user_id' })
|
|
userId!: string;
|
|
|
|
// National ID from form
|
|
@Column('varchar', { length: 50, name: 'national_id', nullable: false })
|
|
nationalId!: string;
|
|
|
|
// Neoleap IDs
|
|
@Column('varchar', { length: 255, unique: true, name: 'state_id' })
|
|
stateId!: string;
|
|
|
|
@Column('varchar', { length: 255, nullable: true, name: 'external_customer_id' })
|
|
externalCustomerId!: string | null;
|
|
|
|
// Nafath details
|
|
@Column('varchar', { length: 10, nullable: true, name: 'nafath_random_code' })
|
|
nafathRandomCode!: string | null;
|
|
|
|
// Status tracking
|
|
@Column('varchar', { length: 50, default: 'INITIATED', name: 'status' })
|
|
status!: string;
|
|
|
|
// Audit trail
|
|
@Column('jsonb', { name: 'form_data' })
|
|
formData!: any;
|
|
|
|
@Column('varchar', { length: 255, nullable: true, name: 'callback_id' })
|
|
callbackId!: string | null;
|
|
|
|
// Timestamps
|
|
@Column('timestamp', { default: () => 'CURRENT_TIMESTAMP', name: 'initiated_at' })
|
|
initiatedAt!: Date;
|
|
|
|
@Column('timestamp', { nullable: true, name: 'completed_at' })
|
|
completedAt!: Date | null;
|
|
|
|
@Column('timestamp', { nullable: true, name: 'expires_at' })
|
|
expiresAt!: Date | null;
|
|
|
|
@CreateDateColumn({ type: 'timestamp with time zone', default: () => 'CURRENT_TIMESTAMP', name: 'created_at' })
|
|
createdAt!: Date;
|
|
|
|
@UpdateDateColumn({ type: 'timestamp with time zone', default: () => 'CURRENT_TIMESTAMP', name: 'updated_at' })
|
|
updatedAt!: Date;
|
|
|
|
// Relationships
|
|
@ManyToOne(() => Customer, { onDelete: 'CASCADE' })
|
|
@JoinColumn({ name: 'customer_id' })
|
|
customer!: Customer;
|
|
|
|
@ManyToOne(() => User, { onDelete: 'CASCADE' })
|
|
@JoinColumn({ name: 'user_id' })
|
|
user!: User;
|
|
}
|
|
|