chore: complete payment service but not tested

This commit is contained in:
mahyargdz
2025-02-04 09:15:22 +03:30
parent 31368610dd
commit 5d91afcc6e
22 changed files with 313 additions and 77 deletions
@@ -1,5 +1,5 @@
import { BadRequestException, HttpException, Injectable, InternalServerErrorException } from "@nestjs/common";
import { DataSource } from "typeorm";
import { DataSource, QueryRunner } from "typeorm";
import { WalletMessage } from "../../../common/enums/message.enum";
import { PaymentsService } from "../../payments/providers/payments.service";
@@ -42,9 +42,14 @@ export class WalletsService {
wallet.user.phone,
);
const payment = await this.paymentsService.createPaymentForUser(wallet.user, amount, gatewayData.reference, queryRunner);
console.log(gatewayData);
const payment = await this.paymentsService.createPaymentForUser(wallet.user, amount, gatewayData.reference, gateway, queryRunner);
await queryRunner.commitTransaction();
return {
payment,
...gatewayData,
};
} catch (error) {
await queryRunner.rollbackTransaction();
@@ -54,4 +59,12 @@ export class WalletsService {
await queryRunner.release();
}
}
//*********************************** */
async createUserWallet(userId: string, queryRunner: QueryRunner) {
const wallet = queryRunner.manager.create(Wallet, { balance: 0, user: { id: userId } });
await queryRunner.manager.save(Wallet, wallet);
//
return wallet;
}
}