feat: payment service with IPG
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user