mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 02:58:11 +00:00
payment
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import { Injectable, NotFoundException } from "@nestjs/common";
|
||||
import { DataSource, QueryRunner } from "typeorm";
|
||||
import { DataSource, QueryRunner } from "typeorm";
|
||||
import { PaymentEntity } from "./entities/payment.entity";
|
||||
import { PaymentStrategy } from "./strategies/payment.strategy";
|
||||
import { PaymentTelebirrStrategy } from "./strategies/payment.telebirr.strategy";
|
||||
import { PaymentRepository } from "./payment.repository";
|
||||
import { ClientAction, PaymentPlatform } from "./strategies/payments.types";
|
||||
import * as crypto from 'crypto';
|
||||
import { PaymentStatus, UpdatePaymentStatusDto } from "./dto/update-payment-status.dto";
|
||||
|
||||
type PaymentMethod = PaymentEntity["method"]
|
||||
type CurrencyType = PaymentEntity["currency"]
|
||||
@@ -88,4 +89,25 @@ export class PaymentService {
|
||||
}
|
||||
|
||||
|
||||
async handleTelebirrPaymentCb(dto: UpdatePaymentStatusDto): Promise<void> {
|
||||
switch (dto.status) {
|
||||
case PaymentStatus.SUCCEEDED:
|
||||
await this.paymentRepo.update({ merchantOrderId: dto.orderId }, { status: "success" })
|
||||
break;
|
||||
case PaymentStatus.FAILED:
|
||||
await this.paymentRepo.update({ merchantOrderId: dto.orderId }, { status: "failed", failureMessage: dto.failureMessage })
|
||||
break;
|
||||
case PaymentStatus.CANCELLED:
|
||||
await this.paymentRepo.update({ merchantOrderId: dto.orderId }, { status: "canceled" })
|
||||
break;
|
||||
case PaymentStatus.PROCESSING:
|
||||
await this.paymentRepo.update({ merchantOrderId: dto.orderId }, { status: "canceled" })
|
||||
break;
|
||||
case PaymentStatus.REFUNDED:
|
||||
await this.paymentRepo.update({ merchantOrderId: dto.orderId }, { status: "canceled" })
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user