flykup_model_development 3.0.8 → 3.0.9
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 +100 -15
- package/package.json +1 -1
|
@@ -1,3 +1,66 @@
|
|
|
1
|
+
// import mongoose from 'mongoose';
|
|
2
|
+
|
|
3
|
+
// const paymentSchema = new mongoose.Schema({
|
|
4
|
+
// orderId: {
|
|
5
|
+
// type: mongoose.Schema.Types.ObjectId,
|
|
6
|
+
// ref: 'Order',
|
|
7
|
+
// required: true
|
|
8
|
+
// },
|
|
9
|
+
// userId: {
|
|
10
|
+
// type: mongoose.Schema.Types.ObjectId,
|
|
11
|
+
// ref: 'users',
|
|
12
|
+
// required: true
|
|
13
|
+
// },
|
|
14
|
+
// paymentGateway: {
|
|
15
|
+
// type: String,
|
|
16
|
+
// enum: ['RAZORPAY', 'CASHFREE'],
|
|
17
|
+
// required: true
|
|
18
|
+
// },
|
|
19
|
+
// paymentGatewayOrderId: {
|
|
20
|
+
// type: String,
|
|
21
|
+
// required: false
|
|
22
|
+
// },
|
|
23
|
+
// paymentGatewayPaymentId: {
|
|
24
|
+
// type: String,
|
|
25
|
+
// required: false
|
|
26
|
+
// },
|
|
27
|
+
|
|
28
|
+
// amount: {
|
|
29
|
+
// type: Number,
|
|
30
|
+
// required: true
|
|
31
|
+
// },
|
|
32
|
+
// currency: {
|
|
33
|
+
// type: String,
|
|
34
|
+
// default: 'INR'
|
|
35
|
+
// },
|
|
36
|
+
// status: {
|
|
37
|
+
// type: String,
|
|
38
|
+
// enum: ['PENDING', 'SUCCESS', 'FAILED', 'REFUNDED'],
|
|
39
|
+
// default: 'PENDING'
|
|
40
|
+
// },
|
|
41
|
+
// paymentMethod: String,
|
|
42
|
+
// transactionId: String,
|
|
43
|
+
// transactionTime: Date,
|
|
44
|
+
// sellerPayments: [{
|
|
45
|
+
// sellerId: {
|
|
46
|
+
// type: mongoose.Schema.Types.ObjectId,
|
|
47
|
+
// ref: 'users',
|
|
48
|
+
// required: true
|
|
49
|
+
// },
|
|
50
|
+
// amount: Number,
|
|
51
|
+
// settlementStatus: {
|
|
52
|
+
// type: String,
|
|
53
|
+
// enum: ['PENDING', 'SETTLED'],
|
|
54
|
+
// default: 'PENDING'
|
|
55
|
+
// }
|
|
56
|
+
// }]
|
|
57
|
+
// }, { timestamps: true });
|
|
58
|
+
|
|
59
|
+
// const OrderPayment = mongoose.model('orderPayment', paymentSchema);
|
|
60
|
+
// export default OrderPayment;
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
// models/OrderPayment.js
|
|
1
64
|
import mongoose from 'mongoose';
|
|
2
65
|
|
|
3
66
|
const paymentSchema = new mongoose.Schema({
|
|
@@ -11,19 +74,37 @@ const paymentSchema = new mongoose.Schema({
|
|
|
11
74
|
ref: 'users',
|
|
12
75
|
required: true
|
|
13
76
|
},
|
|
14
|
-
paymentGateway: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
77
|
+
paymentGateway: {
|
|
78
|
+
type: String,
|
|
79
|
+
enum: ['RAZORPAY', 'CASHFREE'],
|
|
80
|
+
required: true
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
// Razorpay-specific fields
|
|
84
|
+
razorpayOrderId: {
|
|
85
|
+
type: String,
|
|
86
|
+
required: function() {
|
|
87
|
+
return this.paymentGateway === 'RAZORPAY';
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
razorpayPaymentId: {
|
|
91
|
+
type: String,
|
|
92
|
+
default: null
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
// Cashfree-specific fields
|
|
96
|
+
cfPaymentSessionId: {
|
|
97
|
+
type: String,
|
|
98
|
+
required: function() {
|
|
99
|
+
return this.paymentGateway === 'CASHFREE';
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
cfOrderId: {
|
|
103
|
+
type: String,
|
|
104
|
+
required: function() {
|
|
105
|
+
return this.paymentGateway === 'CASHFREE';
|
|
106
|
+
}
|
|
107
|
+
},
|
|
27
108
|
|
|
28
109
|
amount: {
|
|
29
110
|
type: Number,
|
|
@@ -39,7 +120,6 @@ paymentGatewayPaymentId: {
|
|
|
39
120
|
default: 'PENDING'
|
|
40
121
|
},
|
|
41
122
|
paymentMethod: String,
|
|
42
|
-
transactionId: String,
|
|
43
123
|
transactionTime: Date,
|
|
44
124
|
sellerPayments: [{
|
|
45
125
|
sellerId: {
|
|
@@ -56,5 +136,10 @@ paymentGatewayPaymentId: {
|
|
|
56
136
|
}]
|
|
57
137
|
}, { timestamps: true });
|
|
58
138
|
|
|
139
|
+
// Create indexes for better performance
|
|
140
|
+
paymentSchema.index({ razorpayOrderId: 1 });
|
|
141
|
+
paymentSchema.index({ cfOrderId: 1 });
|
|
142
|
+
paymentSchema.index({ orderId: 1 });
|
|
143
|
+
|
|
59
144
|
const OrderPayment = mongoose.model('orderPayment', paymentSchema);
|
|
60
|
-
export default OrderPayment;
|
|
145
|
+
export default OrderPayment;
|