import { Schema, model } from "mongoose"; import { ICartPayment, IPRPriceDetails, IPriceDetails, IProductRequestPayment } from "./Abstraction/IPayments"; import { PaymentStatus } from "../../../common/enums/order.enum"; const PaymentPriceDetails = new Schema( { shipping_cost: { type: Number, required: true }, shipping_cost_on_delivery: { type: Number, default: 0 }, process_cost: { type: Number, required: true }, total_retail_price: { type: Number, required: true }, total_discount: { type: Number, default: 0 }, coupon_discount: { type: Number, default: 0 }, total_payable_price: { type: Number, required: true }, }, { _id: false }, ); const CartPaymentSchema = new Schema( { user_id: { type: Schema.Types.ObjectId, ref: "User", required: true }, authority: { type: String, required: true }, transaction_id: { type: String, default: null }, payment_method: { type: Schema.Types.ObjectId, ref: "PaymentMethod", required: true }, priceDetails: { type: PaymentPriceDetails, required: true }, totalPrice: { type: Number, required: true }, paymentStatus: { type: String, enum: PaymentStatus, default: PaymentStatus.Pending }, }, { timestamps: true, toJSON: { versionKey: false }, id: false }, ); const CartPaymentModel = model("CartPayment", CartPaymentSchema); //=======================================> product request payment const PRPriceDetailSchema = new Schema( { insertion_price: { type: Number, required: true }, unboxing_price: { type: Number, required: true }, photography_price: { type: Number, required: true }, expertReviews_price: { type: Number, required: true }, }, { _id: false, }, ); const PRPaymentSchema = new Schema( { seller_id: { type: Schema.Types.ObjectId, ref: "Seller", required: true }, authority: { type: String, required: true }, transaction_id: { type: String, default: null }, payment_method: { type: Schema.Types.ObjectId, ref: "PaymentMethod", required: true }, priceDetails: { type: PRPriceDetailSchema }, totalPrice: { type: Number, required: true }, paymentStatus: { type: String, enum: PaymentStatus, default: PaymentStatus.Pending }, }, { timestamps: true, toJSON: { versionKey: false }, id: false }, ); const PRPaymentModel = model("PRPayment", PRPaymentSchema); export { CartPaymentModel, PRPaymentModel };