chore: complete payment service but not tested
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user