flykup_model_production 1.0.20 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/models/orderPayment.model.js +25 -9
- package/package.json +1 -1
|
@@ -13,14 +13,13 @@ const paymentSchema = new mongoose.Schema({
|
|
|
13
13
|
},
|
|
14
14
|
paymentGateway: {
|
|
15
15
|
type: String,
|
|
16
|
-
enum: ['RAZORPAY', 'CASHFREE'],
|
|
16
|
+
enum: ['RAZORPAY', 'CASHFREE','WALLET'],
|
|
17
17
|
required: true
|
|
18
18
|
},
|
|
19
19
|
|
|
20
20
|
// Razorpay-specific fields
|
|
21
21
|
razorpayOrderId: {
|
|
22
22
|
type: String,
|
|
23
|
-
// ✅ This field is now required only if the gateway is RAZORPAY
|
|
24
23
|
required: function() {
|
|
25
24
|
return this.paymentGateway === 'RAZORPAY';
|
|
26
25
|
}
|
|
@@ -33,14 +32,12 @@ const paymentSchema = new mongoose.Schema({
|
|
|
33
32
|
// Cashfree-specific fields
|
|
34
33
|
cfPaymentSessionId: {
|
|
35
34
|
type: String,
|
|
36
|
-
// ✅ This field is now required only if the gateway is CASHFREE
|
|
37
35
|
required: function() {
|
|
38
36
|
return this.paymentGateway === 'CASHFREE';
|
|
39
37
|
}
|
|
40
38
|
},
|
|
41
39
|
cfOrderId: {
|
|
42
40
|
type: String,
|
|
43
|
-
// ✅ This field is now required only if the gateway is CASHFREE
|
|
44
41
|
required: function() {
|
|
45
42
|
return this.paymentGateway === 'CASHFREE';
|
|
46
43
|
}
|
|
@@ -62,24 +59,24 @@ const paymentSchema = new mongoose.Schema({
|
|
|
62
59
|
paymentMethod: String,
|
|
63
60
|
transactionTime: Date,
|
|
64
61
|
|
|
65
|
-
// ✅ SELLER PAYMENTS
|
|
62
|
+
// ✅ SELLER PAYMENTS - Only 4 new fields added
|
|
66
63
|
sellerPayments: [{
|
|
67
64
|
sellerId: {
|
|
68
65
|
type: mongoose.Schema.Types.ObjectId,
|
|
69
66
|
ref: 'users',
|
|
70
67
|
required: true
|
|
71
68
|
},
|
|
72
|
-
payableAmount: {
|
|
69
|
+
payableAmount: {
|
|
73
70
|
type: Number,
|
|
74
71
|
required: true,
|
|
75
72
|
default: 0
|
|
76
73
|
},
|
|
77
|
-
deliveryCharge: {
|
|
74
|
+
deliveryCharge: {
|
|
78
75
|
type: Number,
|
|
79
76
|
required: true,
|
|
80
77
|
default: 0
|
|
81
78
|
},
|
|
82
|
-
totalAmount: {
|
|
79
|
+
totalAmount: {
|
|
83
80
|
type: Number,
|
|
84
81
|
required: true,
|
|
85
82
|
default: 0
|
|
@@ -88,6 +85,24 @@ const paymentSchema = new mongoose.Schema({
|
|
|
88
85
|
type: String,
|
|
89
86
|
enum: ['PENDING', 'SETTLED', 'FAILED'],
|
|
90
87
|
default: 'PENDING'
|
|
88
|
+
},
|
|
89
|
+
// ✅ NEW FIELDS (All optional with defaults - production safe)
|
|
90
|
+
settledAt: {
|
|
91
|
+
type: Date,
|
|
92
|
+
default: null
|
|
93
|
+
},
|
|
94
|
+
settledBy: {
|
|
95
|
+
type: mongoose.Schema.Types.ObjectId,
|
|
96
|
+
ref: 'Admin',
|
|
97
|
+
default: null
|
|
98
|
+
},
|
|
99
|
+
transactionReference: {
|
|
100
|
+
type: String,
|
|
101
|
+
default: null
|
|
102
|
+
},
|
|
103
|
+
failureReason: {
|
|
104
|
+
type: String,
|
|
105
|
+
default: null
|
|
91
106
|
}
|
|
92
107
|
}]
|
|
93
108
|
}, {
|
|
@@ -97,6 +112,8 @@ const paymentSchema = new mongoose.Schema({
|
|
|
97
112
|
// Create indexes for better performance
|
|
98
113
|
paymentSchema.index({ razorpayOrderId: 1 });
|
|
99
114
|
paymentSchema.index({ orderId: 1 });
|
|
115
|
+
paymentSchema.index({ 'sellerPayments.sellerId': 1 });
|
|
116
|
+
paymentSchema.index({ 'sellerPayments.settlementStatus': 1 });
|
|
100
117
|
|
|
101
118
|
const OrderPayment =
|
|
102
119
|
mongoose.models.orderPayment || mongoose.model('orderPayment', paymentSchema);
|
|
@@ -111,7 +128,6 @@ export default OrderPayment;
|
|
|
111
128
|
|
|
112
129
|
|
|
113
130
|
|
|
114
|
-
|
|
115
131
|
// import mongoose from 'mongoose';
|
|
116
132
|
|
|
117
133
|
// const paymentSchema = new mongoose.Schema({
|