fix: handle cancel payment

This commit is contained in:
Matin
2025-01-06 00:55:45 +03:30
parent cc7f487e0d
commit 494c2e7b8f
5 changed files with 23 additions and 20 deletions
+1 -2
View File
@@ -115,13 +115,12 @@ export class PaymentService {
async verifyPayment(authority: string, status: string) {
console.log({ authorityInService: authority })
const paymentData = await this.paymentDataAccess.getPaymentByAuthority(authority);
console.log({ paymentData })
if (!paymentData) {
throw new Error("payment not found");
}
const verifyData = await this.paymentGateway.verifyPayment({ authority, amount: paymentData.amount });
console.log({verifyData})
if (verifyData.code === 100 || verifyData.code === 101) {
await this.purchaseDataAccess.createPurchase(paymentData.userId.toString(), paymentData.courseId.toString(), paymentData._id.toString());
paymentData.paymentStatus = PaymentStatus.Completed;