diff --git a/packages/apps/job-launcher/server/src/common/constants/errors.ts b/packages/apps/job-launcher/server/src/common/constants/errors.ts index 9168755ee7..9c3d0fc72d 100644 --- a/packages/apps/job-launcher/server/src/common/constants/errors.ts +++ b/packages/apps/job-launcher/server/src/common/constants/errors.ts @@ -4,7 +4,7 @@ export enum ErrorJob { NotFound = 'Job not found', NotCreated = 'Job has not been created', - NotActiveCard = 'Credit card not found', + NotActiveCard = 'Credit card not found. Please, add a credit card to your account.', ManifestNotFound = 'Manifest not found', ManifestValidationFailed = 'Manifest validation failed', ResultNotFound = 'Result not found', diff --git a/packages/apps/job-launcher/server/src/modules/job/job.service.ts b/packages/apps/job-launcher/server/src/modules/job/job.service.ts index 5f5e0b2761..0c2d854853 100644 --- a/packages/apps/job-launcher/server/src/modules/job/job.service.ts +++ b/packages/apps/job-launcher/server/src/modules/job/job.service.ts @@ -878,13 +878,6 @@ export class JobService { }); } - const paymentEntity = await this.paymentService.createWithdrawalPayment( - user.id, - totalPaymentAmount, - dto.paymentCurrency, - paymentCurrencyRate, - ); - const { createManifest } = this.createJobSpecificActions[requestType]; let jobEntity = new JobEntity(); @@ -923,6 +916,13 @@ export class JobService { jobEntity.manifestHash = hash; } + const paymentEntity = await this.paymentService.createWithdrawalPayment( + user.id, + totalPaymentAmount, + dto.paymentCurrency, + paymentCurrencyRate, + ); + jobEntity.chainId = chainId; jobEntity.reputationOracle = reputationOracle; jobEntity.exchangeOracle = exchangeOracle; diff --git a/packages/apps/job-launcher/server/src/modules/whitelist/whitelist.service.spec.ts b/packages/apps/job-launcher/server/src/modules/whitelist/whitelist.service.spec.ts index eb7f01b040..99448f4f1f 100644 --- a/packages/apps/job-launcher/server/src/modules/whitelist/whitelist.service.spec.ts +++ b/packages/apps/job-launcher/server/src/modules/whitelist/whitelist.service.spec.ts @@ -37,16 +37,16 @@ describe('WhitelistService', () => { expect(result).toBe(true); }); - // it('should return false if user is not whitelisted', async () => { - // const userId = 2; - // jest - // .spyOn(whitelistRepository, 'findOneByUserId') - // .mockResolvedValue(null); + it('should return false if user is not whitelisted', async () => { + const userId = 2; + jest + .spyOn(whitelistRepository, 'findOneByUserId') + .mockResolvedValue(null); - // const result = await whitelistService.isUserWhitelisted(userId); + const result = await whitelistService.isUserWhitelisted(userId); - // expect(whitelistRepository.findOneByUserId).toHaveBeenCalledWith(userId); - // expect(result).toBe(false); - // }); + expect(whitelistRepository.findOneByUserId).toHaveBeenCalledWith(userId); + expect(result).toBe(false); + }); }); }); diff --git a/packages/apps/job-launcher/server/src/modules/whitelist/whitelist.service.ts b/packages/apps/job-launcher/server/src/modules/whitelist/whitelist.service.ts index 5c8e55e861..fc64f07319 100644 --- a/packages/apps/job-launcher/server/src/modules/whitelist/whitelist.service.ts +++ b/packages/apps/job-launcher/server/src/modules/whitelist/whitelist.service.ts @@ -6,8 +6,6 @@ export class WhitelistService { constructor(private readonly whitelistRepository: WhitelistRepository) {} async isUserWhitelisted(userId: number): Promise { - // TODO: Enable it when billing system is active - return true; const user = await this.whitelistRepository.findOneByUserId(userId); return !!user; }