diff --git a/src/card/services/card.service.ts b/src/card/services/card.service.ts index 92df9ab..5138824 100644 --- a/src/card/services/card.service.ts +++ b/src/card/services/card.service.ts @@ -34,6 +34,10 @@ export class CardService { throw new BadRequestException('CUSTOMER.KYC_NOT_APPROVED'); } + if (!customer.neoleapExternalCustomerId) { + throw new BadRequestException('CUSTOMER.KYC_NOT_COMPLETED'); + } + if (customer.cards.length > 0) { throw new BadRequestException('CUSTOMER.ALREADY_HAS_CARD'); } diff --git a/src/common/modules/neoleap/services/neoleap.service.ts b/src/common/modules/neoleap/services/neoleap.service.ts index bd881cc..463a72f 100644 --- a/src/common/modules/neoleap/services/neoleap.service.ts +++ b/src/common/modules/neoleap/services/neoleap.service.ts @@ -188,7 +188,9 @@ export class NeoLeapService { }, BillingCycle: 'C1', }, - ApplicationOtherInfo: {}, + ApplicationOtherInfo: { + ExternalCorporateId: customer.neoleapExternalCustomerId, + }, ApplicationCustomerDetails: { FirstName: customer.firstName, LastName: customer.lastName, diff --git a/src/customer/services/customer.service.ts b/src/customer/services/customer.service.ts index a7b8694..5fc67fb 100644 --- a/src/customer/services/customer.service.ts +++ b/src/customer/services/customer.service.ts @@ -163,14 +163,15 @@ export class CustomerService { completedAt: new Date(), }); - // Update customer KYC status + // Update customer KYC status and external customer ID const kycStatus = body.status === 'ONBOARDING_SUCCESS' ? KycStatus.APPROVED : KycStatus.REJECTED; - + await this.customerRepository.updateCustomer(customer.id, { kycStatus, + neoleapExternalCustomerId: body.entity.externalId, }); - this.logger.log(`KYC updated successfully for customer ${customer.id}, status: ${body.status}`); + this.logger.log(`KYC updated successfully for customer ${customer.id}, status: ${body.status}, externalId: ${body.entity.externalId}`); } // TO BE REMOVED: This function is for testing only and will be removed