flykup_model_development 3.0.8 → 3.1.0

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.
@@ -291,9 +291,7 @@ payment: {
291
291
  );
292
292
 
293
293
 
294
- const Order = mongoose.model('Order', orderSchema);
295
- export default Order;
296
294
 
297
295
 
298
- // const Order = mongoose.models.Order || mongoose.model('Order', orderSchema);
299
- // export default Order;
296
+ const Order = mongoose.models.Order || mongoose.model('Order', orderSchema);
297
+ export default Order;
@@ -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
- 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
- },
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,12 @@ paymentGatewayPaymentId: {
56
136
  }]
57
137
  }, { timestamps: true });
58
138
 
59
- const OrderPayment = mongoose.model('orderPayment', paymentSchema);
139
+ // Create indexes for better performance
140
+ paymentSchema.index({ razorpayOrderId: 1 });
141
+ paymentSchema.index({ cfOrderId: 1 });
142
+ paymentSchema.index({ orderId: 1 });
143
+
144
+ const OrderPayment =
145
+ mongoose.models.OrderPayment || mongoose.model('OrderPayment', paymentSchema);
146
+
60
147
  export default OrderPayment;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flykup_model_development",
3
- "version": "3.0.8",
3
+ "version": "3.1.0",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "private": false,