chore: add new route for get single transaction for user
This commit is contained in:
@@ -139,10 +139,17 @@ export class PaymentsService {
|
||||
|
||||
try {
|
||||
const paymentGateway = this.gatewayFactory.getPaymentGateway(gateway);
|
||||
const payment = await queryRunner.manager.findOne(Payment, {
|
||||
where: { reference: queryDto.Authority },
|
||||
relations: ["user"],
|
||||
});
|
||||
// const payment = await queryRunner.manager.findOne(Payment, {
|
||||
// where: { reference: queryDto.Authority },
|
||||
// relations: ["user"],
|
||||
// });
|
||||
|
||||
const payment = await queryRunner.manager
|
||||
.createQueryBuilder(Payment, "payment")
|
||||
.innerJoinAndSelect("payment.user", "user")
|
||||
.where("payment.reference = :reference", { reference: queryDto.Authority })
|
||||
.setLock("pessimistic_write")
|
||||
.getOne();
|
||||
|
||||
if (!payment) throw new BadRequestException(PaymentMessage.PAYMENT_NOT_FOUND_WITH_REF);
|
||||
if (payment.status === PaymentStatus.COMPLETED) throw new BadRequestException(PaymentMessage.VALIDATED_BEFORE);
|
||||
@@ -162,7 +169,7 @@ export class PaymentsService {
|
||||
|
||||
if (verifyData.code === 100) {
|
||||
const { wallet } = await this.handleSuccessfulPayment(
|
||||
payment.id,
|
||||
payment,
|
||||
payment.user.id,
|
||||
payment.amount,
|
||||
`${verifyData.ref_id}`,
|
||||
@@ -248,9 +255,9 @@ export class PaymentsService {
|
||||
}
|
||||
|
||||
//*********************************** */
|
||||
async handleSuccessfulPayment(paymentId: string, userId: string, amount: Decimal, transactionId: string, queryRunner: QueryRunner) {
|
||||
await queryRunner.manager.update(Payment, { id: paymentId }, { status: PaymentStatus.COMPLETED, transactionId });
|
||||
return this.walletsService.createPaymentTransaction(userId, amount, queryRunner);
|
||||
async handleSuccessfulPayment(payment: Payment, userId: string, amount: Decimal, transactionId: string, queryRunner: QueryRunner) {
|
||||
await queryRunner.manager.update(Payment, { id: payment.id }, { status: PaymentStatus.COMPLETED, transactionId });
|
||||
return this.walletsService.createPaymentTransaction(userId, amount, payment, queryRunner);
|
||||
}
|
||||
|
||||
//*********************************** */
|
||||
@@ -399,7 +406,7 @@ export class PaymentsService {
|
||||
|
||||
await queryRunner.manager.update(DepositRequest, { id: depositRequest.id }, { status: DepositRequestStatus.APPROVED });
|
||||
|
||||
await this.walletsService.createDepositTransaction(depositRequest.amount, depositRequest.user.id, queryRunner);
|
||||
await this.walletsService.createDepositTransaction(depositRequest.user.id, depositRequest.amount, depositRequest, queryRunner);
|
||||
|
||||
await queryRunner.commitTransaction();
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user