fix: handle cancel payment
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user