feat: payment service with IPG

This commit is contained in:
matin jamshidi
2025-01-03 11:29:33 +03:30
parent f2fb7188ad
commit 6c80c1138f
23 changed files with 495 additions and 96 deletions
+10 -2
View File
@@ -2,8 +2,10 @@ import Models from "../models";
import Payment from "../models/payment.model";
export class PaymentDataAccess {
async createPayment(userId: string, amount: number, paymentNumber: string,reason:string):Promise<Payment> {
const payment = Models.Payment.create({ userId, amount, paymentNumber,reason });
async createPayment(userId: string, amount: number, courseId: string, authority: string, session: any): Promise<Payment> {
const paymentDoc = await Models.Payment.create([{ userId, amount, courseId, authority }], { session });
console.log({ paymentDoc });
const payment = paymentDoc.map(doc => doc.toObject())[0];
return payment;
}
@@ -12,6 +14,12 @@ export class PaymentDataAccess {
return payment;
}
async getPaymentByAuthority(authority: string): Promise<Payment | null> {
console.log({ authority })
const payment = await Models.Payment.findOne({ authority });
console.log(payment, "ssssss")
return payment;
}
async getPaymentsByUserId(userId: string): Promise<Payment[]> {
const payments = await Models.Payment.find({ userId });
return payments;