@ozdao/prometheus-framework 0.2.40 → 0.2.41
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/main.css +1 -1
- package/dist/prometheus-framework.cjs.js +19 -19
- package/dist/prometheus-framework.es.js +501 -515
- package/package.json +1 -1
- package/src/components/Countdown/Countdown.vue +4 -3
- package/src/components/Header/Header.vue +2 -0
- package/src/modules/community/components/layouts/Community.vue +2 -2
- package/src/modules/community/components/pages/CreateBlogPost.vue +1 -0
- package/src/modules/constructor/components/sections/Constructor.vue +1 -1
- package/src/modules/events/components/pages/EditEvent.vue +48 -3
- package/src/modules/events/components/pages/Event.vue +16 -8
- package/src/modules/events/components/sections/HeroEvent.vue +32 -28
- package/src/modules/events/components/sections/SectionMainGuest.vue +3 -2
- package/src/modules/events/components/sections/SectionPreviousEvents.vue +22 -15
- package/src/modules/events/models/event.model.js +9 -0
- package/src/modules/files/middlewares/server/middlewareBusboy.js +13 -2
- package/src/modules/marketplace/components/layouts/Marketplace.vue +1 -1
- package/src/modules/orders/store/shopcart.js +21 -5
- package/src/modules/payments/controller/payments.controller.js +54 -200
- package/src/modules/payments/controller/payments.tinkoff.controller.js +242 -0
- package/src/modules/payments/models/payment.model.js +22 -0
- package/src/modules/payments/routes/payments.routes.js +4 -25
- package/src/modules/payments/routes/payments.tinkoff.routes.js +58 -0
- package/src/modules/products/components/pages/Product.vue +3 -1
- package/src/modules/products/components/sections/SectionProduct.vue +3 -0
- package/src/modules/products/controllers/products.controller.js +188 -109
- package/src/modules/products/models/product.model.js +1 -0
- package/src/modules/wallet/components/pages/Wallet.vue +73 -88
- package/src/modules/wallet/controllers/crypto.controller.js +79 -0
- package/src/modules/wallet/models/wallet.model.js +27 -0
- /package/src/modules/{orders/models/payment.model.js → payments/models/payment.tinkoff.model.js} +0 -0
@@ -3,239 +3,93 @@ var jwt = require("jsonwebtoken");
|
|
3
3
|
var axios = require('axios');
|
4
4
|
var bcrypt = require("bcryptjs");
|
5
5
|
var crypto = require('crypto');
|
6
|
-
const { v4: uuidv4 } = require('uuid');
|
7
6
|
|
8
|
-
|
9
|
-
var TerminalPassword = process.env.TINKOFF_TERMINAL_PASSWORD;
|
7
|
+
const QRCode = require('qrcode');
|
10
8
|
|
11
9
|
const controllerFactory = (db) => {
|
12
10
|
const Payment = db.payment;
|
11
|
+
const Wallet = db.wallet;
|
13
12
|
const Order = db.order;
|
14
13
|
|
15
|
-
const getAll = (req, res) => {
|
16
|
-
Payment.find({}).sort({'createdAt': 'desc'}).exec((err, paymentes) => {
|
17
|
-
// If error
|
18
|
-
if (err) {return res.status(500).send({ message: err }); }
|
19
|
-
// If not found
|
20
|
-
if (!paymentes) {return res.status(404).send({ message: "Paymentes not found." }); }
|
21
|
-
// If succes
|
22
|
-
res.status(200).send(paymentes);
|
23
|
-
});
|
24
|
-
};
|
25
|
-
|
26
14
|
const create = (req, res) => {
|
27
|
-
|
28
|
-
Payment.create({
|
29
|
-
type: req.body.type,
|
30
|
-
order: req.body.order,
|
31
|
-
positions: req.body.positions
|
32
|
-
}, (err, payment) => {
|
33
|
-
if (err) {return res.status(500).send({ message: err }); }
|
34
|
-
if (!payment) {return res.status(404).send({ message: "Something wrong when updating product. (with files)" }); }
|
35
|
-
res.status(200).send(payment);
|
36
|
-
})
|
37
|
-
};
|
15
|
+
const { amount, positions, userId } = req.body;
|
38
16
|
|
39
|
-
|
40
|
-
|
41
|
-
// If error
|
42
|
-
if (err) {return res.status(500).send({ message: err }); }
|
43
|
-
// If not found
|
44
|
-
if (!payment) {return res.status(404).send({ message: "Payment not found." }); }
|
45
|
-
// If succes
|
46
|
-
res.status(200).send(payment);
|
47
|
-
});
|
48
|
-
};
|
17
|
+
const newPayment = new Payment({ amount, positions, user: userId });
|
18
|
+
await newPayment.save();
|
49
19
|
|
50
|
-
|
20
|
+
const qrData = `PaymentID:${newPayment._id};Amount:${amount}`;
|
21
|
+
const qrCode = await QRCode.toDataURL(qrData);
|
22
|
+
|
23
|
+
res.send({ qrCode, paymentId: newPayment._id });
|
24
|
+
};
|
51
25
|
|
52
|
-
|
26
|
+
const read = (req, res) => {
|
27
|
+
Payment.find({}).sort({'createdAt': 'desc'}).exec((err, paymentes) => {
|
53
28
|
// If error
|
54
29
|
if (err) {return res.status(500).send({ message: err }); }
|
55
30
|
// If not found
|
56
|
-
if (!
|
31
|
+
if (!paymentes) {return res.status(404).send({ message: "Paymentes not found." }); }
|
57
32
|
// If succes
|
58
|
-
res.status(200).send(
|
33
|
+
res.status(200).send(paymentes);
|
59
34
|
});
|
60
35
|
};
|
61
36
|
|
62
|
-
const
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
})
|
68
|
-
};
|
69
|
-
|
70
|
-
function createToken (request) {
|
71
|
-
request = Object.entries(request).map(function(key) {
|
72
|
-
return { [key[0]]: key[1] }
|
73
|
-
})
|
74
|
-
request.push({Password: TerminalPassword})
|
75
|
-
request.sort(function(a, b){
|
76
|
-
if(Object.keys(a)[0] < Object.keys(b)[0]) { return -1; }
|
77
|
-
if(Object.keys(a)[0] > Object.keys(b)[0]) { return 1; }
|
78
|
-
return 0;
|
79
|
-
})
|
80
|
-
const requestContacted = request.map(function(key) {
|
81
|
-
return Object.values(key)[0]
|
82
|
-
}).join("")
|
83
|
-
|
84
|
-
const hash = crypto.createHash('sha256').update(requestContacted).digest('hex');
|
85
|
-
|
86
|
-
return hash
|
87
|
-
}
|
88
|
-
const newpayment = (req, res) => {
|
89
|
-
// Data for payment init
|
90
|
-
console.log(req.body.phone);
|
91
|
-
// Send request to Tinkoff
|
92
|
-
axios.post('https://securepay.tinkoff.ru/v2/Init', {
|
93
|
-
TerminalKey: TerminalKey,
|
94
|
-
Amount: '350000',
|
95
|
-
OrderId: req.body._id,
|
96
|
-
Recurrent: 'y',
|
97
|
-
PayType: "О",
|
98
|
-
CustomerKey: req.body.phone,
|
99
|
-
Description: 'Оплата в интернет-магазине',
|
100
|
-
Data: {
|
101
|
-
phone: req.body.phone,
|
102
|
-
},
|
103
|
-
// SuccessURL: 'http://tandem.ohmybike.ru/rent/' + OrderId,
|
104
|
-
// FailURL: 'http://tandem.ohmybike.ru/account'
|
105
|
-
// SuccessURL: 'http://localhost:8082/rent/' + OrderId,
|
106
|
-
// FailURL: 'http://localhost:8082/account'
|
107
|
-
}).then(function(response) {
|
108
|
-
const payment = new Payment(response.data);
|
109
|
-
payment.save((err, payment) => {
|
110
|
-
if (err) {
|
111
|
-
res.status(500).send({ message: err });
|
112
|
-
return;
|
113
|
-
}
|
114
|
-
|
115
|
-
payment.save(err => {
|
116
|
-
if (err) {
|
117
|
-
res.status(500).send({ message: err });
|
118
|
-
return;
|
119
|
-
}
|
120
|
-
res.send(response.data);
|
121
|
-
});
|
122
|
-
})
|
123
|
-
}).catch(function(error) {
|
124
|
-
res.send(error);
|
125
|
-
})
|
126
|
-
|
127
|
-
};
|
128
|
-
const setpayment = (req, res) => {
|
129
|
-
// Data for payment
|
130
|
-
const payment = new Payment({
|
131
|
-
OrderId: req.body.OrderId,
|
132
|
-
Success: req.body.Success,
|
133
|
-
Status: req.body.Status,
|
134
|
-
PaymentId: req.body.PaymentId,
|
135
|
-
ErrorCode: req.body.ErrorCode,
|
136
|
-
Message: req.body.Message,
|
137
|
-
Details: req.body.Details
|
138
|
-
});
|
139
|
-
// Wright to db
|
140
|
-
console.log(payment)
|
37
|
+
const update = (req, res) => {
|
38
|
+
const session = await mongoose.startSession();
|
39
|
+
session.startTransaction();
|
40
|
+
try {
|
41
|
+
const { paymentId, walletId } = req.body; // Теперь мы работаем с walletId
|
141
42
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
43
|
+
const payment = await Payment.findById(paymentId).session(session);
|
44
|
+
|
45
|
+
if (!payment) {
|
46
|
+
throw new Error('Payment not found');
|
47
|
+
}
|
48
|
+
if (payment.status !== 'pending') {
|
49
|
+
throw new Error('Payment is not in a pending state');
|
146
50
|
}
|
147
51
|
|
148
|
-
|
149
|
-
if (err) {
|
150
|
-
res.status(500).send({ message: err });
|
151
|
-
return;
|
152
|
-
}
|
52
|
+
const wallet = await Wallet.findById(walletId).session(session);
|
153
53
|
|
154
|
-
|
155
|
-
|
156
|
-
})
|
157
|
-
};
|
158
|
-
const getstatus = (req, res) => {
|
159
|
-
console.log(req.body.order)
|
160
|
-
Payment.findOne({
|
161
|
-
OrderId: req.body.order
|
162
|
-
})
|
163
|
-
.sort({createdAt: -1})
|
164
|
-
.exec((err, payment) => {
|
165
|
-
if (err) {
|
166
|
-
res.status(500).send({ message: err });
|
167
|
-
return;
|
168
|
-
}
|
169
|
-
if (!payment) {
|
170
|
-
return res.status(404).send({ message: "Payment Not found." });
|
54
|
+
if (!wallet) {
|
55
|
+
throw new Error('Wallet not found');
|
171
56
|
}
|
172
57
|
|
173
|
-
|
174
|
-
|
175
|
-
console.log(payment.Status)
|
176
|
-
console.log(req.body.order)
|
177
|
-
Order.findOneAndUpdate({ _id: req.body.order, status: 'Подтвержден' }, {$set: {status: "Ожидает отправки"}},{ new: true}).catch(function(error) {
|
178
|
-
res.status(500).send(error);
|
179
|
-
});
|
58
|
+
if (wallet.amount < payment.amount) {
|
59
|
+
throw new Error('Insufficient funds');
|
180
60
|
}
|
181
61
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
62
|
+
// Списание средств с кошелька
|
63
|
+
wallet.amount -= payment.amount;
|
64
|
+
await wallet.save({ session });
|
65
|
+
|
66
|
+
// Обновление статуса платежа
|
67
|
+
payment.status = 'completed';
|
68
|
+
await payment.save({ session });
|
69
|
+
|
70
|
+
await session.commitTransaction();
|
71
|
+
res.send('Payment processed successfully');
|
72
|
+
} catch (error) {
|
73
|
+
await session.abortTransaction();
|
74
|
+
res.status(500).send(error.message);
|
75
|
+
} finally {
|
76
|
+
session.endSession();
|
77
|
+
}
|
194
78
|
};
|
195
79
|
|
196
|
-
const
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
CustomerKey: req.body,
|
202
|
-
Token: createToken({TerminalKey: TerminalKey, CustomerKey: req.body.phone})
|
203
|
-
})
|
204
|
-
.then(function(response) {
|
205
|
-
res.send(response.data);
|
206
|
-
})
|
207
|
-
.catch(function(error) {
|
208
|
-
res.status(500).send(error);
|
209
|
-
});
|
210
|
-
}
|
211
|
-
|
212
|
-
const getcustomercards = (req, res) => {
|
213
|
-
axios.post('https://securepay.tinkoff.ru/v2/GetCardList', {
|
214
|
-
TerminalKey: TerminalKey,
|
215
|
-
CustomerKey: req.body.phone,
|
216
|
-
Token: createToken({TerminalKey: TerminalKey, CustomerKey: req.body.phone})
|
217
|
-
})
|
218
|
-
.then(function(response) {
|
219
|
-
console.log(response.data)
|
220
|
-
res.send(response.data);
|
80
|
+
const deletePayment = (req, res) => {
|
81
|
+
Payment.findOneAndDelete({_id: req.params._id}, (err, payment) => {
|
82
|
+
if (err) {return res.status(500).send({ message: err }); }
|
83
|
+
if (!payment) {return res.status(404).send({ message: "Something wrong when deleting payment." }); }
|
84
|
+
res.status(200).send(payment);
|
221
85
|
})
|
222
|
-
|
223
|
-
res.status(500).send(error);
|
224
|
-
});
|
225
|
-
}
|
86
|
+
};
|
226
87
|
|
227
88
|
return {
|
228
|
-
getAll,
|
229
89
|
create,
|
230
|
-
|
90
|
+
read,
|
231
91
|
update,
|
232
92
|
delete: deletePayment,
|
233
|
-
createToken,
|
234
|
-
newpayment,
|
235
|
-
setpayment,
|
236
|
-
getstatus,
|
237
|
-
addcustomer,
|
238
|
-
getcustomercards
|
239
93
|
};
|
240
94
|
};
|
241
95
|
|
@@ -0,0 +1,242 @@
|
|
1
|
+
|
2
|
+
var jwt = require("jsonwebtoken");
|
3
|
+
var axios = require('axios');
|
4
|
+
var bcrypt = require("bcryptjs");
|
5
|
+
var crypto = require('crypto');
|
6
|
+
const { v4: uuidv4 } = require('uuid');
|
7
|
+
|
8
|
+
var TerminalKey = process.env.TINKOFF_TERMINAL_KEY;
|
9
|
+
var TerminalPassword = process.env.TINKOFF_TERMINAL_PASSWORD;
|
10
|
+
|
11
|
+
const controllerFactory = (db) => {
|
12
|
+
const Payment = db.payment;
|
13
|
+
const Order = db.order;
|
14
|
+
|
15
|
+
const getAll = (req, res) => {
|
16
|
+
Payment.find({}).sort({'createdAt': 'desc'}).exec((err, paymentes) => {
|
17
|
+
// If error
|
18
|
+
if (err) {return res.status(500).send({ message: err }); }
|
19
|
+
// If not found
|
20
|
+
if (!paymentes) {return res.status(404).send({ message: "Paymentes not found." }); }
|
21
|
+
// If succes
|
22
|
+
res.status(200).send(paymentes);
|
23
|
+
});
|
24
|
+
};
|
25
|
+
|
26
|
+
const create = (req, res) => {
|
27
|
+
console.log(req.body)
|
28
|
+
Payment.create({
|
29
|
+
type: req.body.type,
|
30
|
+
order: req.body.order,
|
31
|
+
positions: req.body.positions
|
32
|
+
}, (err, payment) => {
|
33
|
+
if (err) {return res.status(500).send({ message: err }); }
|
34
|
+
if (!payment) {return res.status(404).send({ message: "Something wrong when updating product. (with files)" }); }
|
35
|
+
res.status(200).send(payment);
|
36
|
+
})
|
37
|
+
};
|
38
|
+
|
39
|
+
const get = (req, res) => {
|
40
|
+
Payment.findOne({ _id: req.params._id }).exec((err, payment) => {
|
41
|
+
// If error
|
42
|
+
if (err) {return res.status(500).send({ message: err }); }
|
43
|
+
// If not found
|
44
|
+
if (!payment) {return res.status(404).send({ message: "Payment not found." }); }
|
45
|
+
// If succes
|
46
|
+
res.status(200).send(payment);
|
47
|
+
});
|
48
|
+
};
|
49
|
+
|
50
|
+
const update = (req, res) => {
|
51
|
+
|
52
|
+
Payment.findOneAndUpdate({ PaymentId: req.params._id }, req.body, { new: true, upsert: true}).exec((err, payment) => {
|
53
|
+
// If error
|
54
|
+
if (err) {return res.status(500).send({ message: err }); }
|
55
|
+
// If not found
|
56
|
+
if (!payment) {return res.status(404).send({ message: "Payment not found." }); }
|
57
|
+
// If succes
|
58
|
+
res.status(200).send(payment);
|
59
|
+
});
|
60
|
+
};
|
61
|
+
|
62
|
+
const deletePayment = (req, res) => {
|
63
|
+
Payment.findOneAndDelete({_id: req.params._id}, (err, payment) => {
|
64
|
+
if (err) {return res.status(500).send({ message: err }); }
|
65
|
+
if (!payment) {return res.status(404).send({ message: "Something wrong when deleting payment." }); }
|
66
|
+
res.status(200).send(payment);
|
67
|
+
})
|
68
|
+
};
|
69
|
+
|
70
|
+
function createToken (request) {
|
71
|
+
request = Object.entries(request).map(function(key) {
|
72
|
+
return { [key[0]]: key[1] }
|
73
|
+
})
|
74
|
+
request.push({Password: TerminalPassword})
|
75
|
+
request.sort(function(a, b){
|
76
|
+
if(Object.keys(a)[0] < Object.keys(b)[0]) { return -1; }
|
77
|
+
if(Object.keys(a)[0] > Object.keys(b)[0]) { return 1; }
|
78
|
+
return 0;
|
79
|
+
})
|
80
|
+
const requestContacted = request.map(function(key) {
|
81
|
+
return Object.values(key)[0]
|
82
|
+
}).join("")
|
83
|
+
|
84
|
+
const hash = crypto.createHash('sha256').update(requestContacted).digest('hex');
|
85
|
+
|
86
|
+
return hash
|
87
|
+
}
|
88
|
+
const newpayment = (req, res) => {
|
89
|
+
// Data for payment init
|
90
|
+
console.log(req.body.phone);
|
91
|
+
// Send request to Tinkoff
|
92
|
+
axios.post('https://securepay.tinkoff.ru/v2/Init', {
|
93
|
+
TerminalKey: TerminalKey,
|
94
|
+
Amount: '350000',
|
95
|
+
OrderId: req.body._id,
|
96
|
+
Recurrent: 'y',
|
97
|
+
PayType: "О",
|
98
|
+
CustomerKey: req.body.phone,
|
99
|
+
Description: 'Оплата в интернет-магазине',
|
100
|
+
Data: {
|
101
|
+
phone: req.body.phone,
|
102
|
+
},
|
103
|
+
// SuccessURL: 'http://tandem.ohmybike.ru/rent/' + OrderId,
|
104
|
+
// FailURL: 'http://tandem.ohmybike.ru/account'
|
105
|
+
// SuccessURL: 'http://localhost:8082/rent/' + OrderId,
|
106
|
+
// FailURL: 'http://localhost:8082/account'
|
107
|
+
}).then(function(response) {
|
108
|
+
const payment = new Payment(response.data);
|
109
|
+
payment.save((err, payment) => {
|
110
|
+
if (err) {
|
111
|
+
res.status(500).send({ message: err });
|
112
|
+
return;
|
113
|
+
}
|
114
|
+
|
115
|
+
payment.save(err => {
|
116
|
+
if (err) {
|
117
|
+
res.status(500).send({ message: err });
|
118
|
+
return;
|
119
|
+
}
|
120
|
+
res.send(response.data);
|
121
|
+
});
|
122
|
+
})
|
123
|
+
}).catch(function(error) {
|
124
|
+
res.send(error);
|
125
|
+
})
|
126
|
+
|
127
|
+
};
|
128
|
+
const setpayment = (req, res) => {
|
129
|
+
// Data for payment
|
130
|
+
const payment = new Payment({
|
131
|
+
OrderId: req.body.OrderId,
|
132
|
+
Success: req.body.Success,
|
133
|
+
Status: req.body.Status,
|
134
|
+
PaymentId: req.body.PaymentId,
|
135
|
+
ErrorCode: req.body.ErrorCode,
|
136
|
+
Message: req.body.Message,
|
137
|
+
Details: req.body.Details
|
138
|
+
});
|
139
|
+
// Wright to db
|
140
|
+
console.log(payment)
|
141
|
+
|
142
|
+
payment.save((err, payment) => {
|
143
|
+
if (err) {
|
144
|
+
res.status(500).send({ message: err });
|
145
|
+
return;
|
146
|
+
}
|
147
|
+
|
148
|
+
payment.save(err => {
|
149
|
+
if (err) {
|
150
|
+
res.status(500).send({ message: err });
|
151
|
+
return;
|
152
|
+
}
|
153
|
+
|
154
|
+
res.send({ message: "Payment was created successfully!" });
|
155
|
+
});
|
156
|
+
})
|
157
|
+
};
|
158
|
+
const getstatus = (req, res) => {
|
159
|
+
console.log(req.body.order)
|
160
|
+
Payment.findOne({
|
161
|
+
OrderId: req.body.order
|
162
|
+
})
|
163
|
+
.sort({createdAt: -1})
|
164
|
+
.exec((err, payment) => {
|
165
|
+
if (err) {
|
166
|
+
res.status(500).send({ message: err });
|
167
|
+
return;
|
168
|
+
}
|
169
|
+
if (!payment) {
|
170
|
+
return res.status(404).send({ message: "Payment Not found." });
|
171
|
+
}
|
172
|
+
|
173
|
+
|
174
|
+
if (payment.Status === 'CONFIRMED') {
|
175
|
+
console.log(payment.Status)
|
176
|
+
console.log(req.body.order)
|
177
|
+
Order.findOneAndUpdate({ _id: req.body.order, status: 'Подтвержден' }, {$set: {status: "Ожидает отправки"}},{ new: true}).catch(function(error) {
|
178
|
+
res.status(500).send(error);
|
179
|
+
});
|
180
|
+
}
|
181
|
+
|
182
|
+
axios.post('https://securepay.tinkoff.ru/v2/GetState', {
|
183
|
+
TerminalKey: TerminalKey,
|
184
|
+
PaymentId: payment.PaymentId,
|
185
|
+
Token: createToken({TerminalKey: TerminalKey, PaymentId: payment.PaymentId})
|
186
|
+
}).then(function(response) {
|
187
|
+
payment.Status = response.data.Status
|
188
|
+
payment.save()
|
189
|
+
res.send(response.data);
|
190
|
+
}).catch(function(error) {
|
191
|
+
res.status(500).send(error);
|
192
|
+
});
|
193
|
+
});
|
194
|
+
};
|
195
|
+
|
196
|
+
const addcustomer = (req, res) => {
|
197
|
+
console.log(req.body)
|
198
|
+
|
199
|
+
axios.post('https://securepay.tinkoff.ru/v2/AddCustomer', {
|
200
|
+
TerminalKey: TerminalKey,
|
201
|
+
CustomerKey: req.body,
|
202
|
+
Token: createToken({TerminalKey: TerminalKey, CustomerKey: req.body.phone})
|
203
|
+
})
|
204
|
+
.then(function(response) {
|
205
|
+
res.send(response.data);
|
206
|
+
})
|
207
|
+
.catch(function(error) {
|
208
|
+
res.status(500).send(error);
|
209
|
+
});
|
210
|
+
}
|
211
|
+
|
212
|
+
const getcustomercards = (req, res) => {
|
213
|
+
axios.post('https://securepay.tinkoff.ru/v2/GetCardList', {
|
214
|
+
TerminalKey: TerminalKey,
|
215
|
+
CustomerKey: req.body.phone,
|
216
|
+
Token: createToken({TerminalKey: TerminalKey, CustomerKey: req.body.phone})
|
217
|
+
})
|
218
|
+
.then(function(response) {
|
219
|
+
console.log(response.data)
|
220
|
+
res.send(response.data);
|
221
|
+
})
|
222
|
+
.catch(function(error) {
|
223
|
+
res.status(500).send(error);
|
224
|
+
});
|
225
|
+
}
|
226
|
+
|
227
|
+
return {
|
228
|
+
getAll,
|
229
|
+
create,
|
230
|
+
get,
|
231
|
+
update,
|
232
|
+
delete: deletePayment,
|
233
|
+
createToken,
|
234
|
+
newpayment,
|
235
|
+
setpayment,
|
236
|
+
getstatus,
|
237
|
+
addcustomer,
|
238
|
+
getcustomercards
|
239
|
+
};
|
240
|
+
};
|
241
|
+
|
242
|
+
module.exports = controllerFactory;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module.exports = (db) => {
|
2
|
+
|
3
|
+
const PaymentSchema = new db.mongoose.Schema({
|
4
|
+
creator: {
|
5
|
+
type: db.mongoose.Schema.Types.ObjectId,
|
6
|
+
ref: 'User',
|
7
|
+
},
|
8
|
+
owner: {
|
9
|
+
type: db.mongoose.Schema.Types.ObjectId,
|
10
|
+
ref: 'User',
|
11
|
+
}
|
12
|
+
}, {
|
13
|
+
timestamps: {
|
14
|
+
currentTime: () => Date.now()
|
15
|
+
}
|
16
|
+
});
|
17
|
+
|
18
|
+
const Payment = db.mongoose.model("Payment", PaymentSchema);
|
19
|
+
|
20
|
+
return Payment;
|
21
|
+
};
|
22
|
+
|
@@ -12,42 +12,21 @@ module.exports = function(app, db) {
|
|
12
12
|
next();
|
13
13
|
});
|
14
14
|
|
15
|
-
app.post(
|
16
|
-
"/payment/newpayment",
|
17
|
-
controller.newpayment,
|
18
|
-
);
|
19
|
-
app.post(
|
20
|
-
"/payment/getstatus",
|
21
|
-
controller.getstatus
|
22
|
-
);
|
23
|
-
app.post(
|
24
|
-
"/payment/addcustomer",
|
25
|
-
controller.addcustomer
|
26
|
-
);
|
27
|
-
app.post(
|
28
|
-
"/payment/getcustomercards",
|
29
|
-
controller.getcustomercards
|
30
|
-
);
|
31
15
|
|
32
|
-
app.
|
16
|
+
app.post(
|
33
17
|
"/payments",
|
34
|
-
controller.
|
18
|
+
controller.create
|
35
19
|
);
|
36
|
-
|
20
|
+
|
37
21
|
app.get(
|
38
22
|
"/payments/:_id",
|
39
|
-
controller.
|
23
|
+
controller.read
|
40
24
|
);
|
41
25
|
|
42
26
|
app.post(
|
43
27
|
"/payments/:_id",
|
44
28
|
controller.update
|
45
29
|
);
|
46
|
-
|
47
|
-
app.post(
|
48
|
-
"/payments",
|
49
|
-
controller.create
|
50
|
-
);
|
51
30
|
|
52
31
|
app.delete(
|
53
32
|
"/payments/:_id",
|
@@ -0,0 +1,58 @@
|
|
1
|
+
// Factories
|
2
|
+
const controllerFactory = require("../controllers/payments.controller");
|
3
|
+
// Middlewares
|
4
|
+
const middlewareFactory = require('@pf/src/modules/middlewares/server');
|
5
|
+
// Routes
|
6
|
+
module.exports = function(app, db) {
|
7
|
+
const controller = controllerFactory(db);
|
8
|
+
const { verifySignUp, verifyUser } = middlewareFactory(db);
|
9
|
+
|
10
|
+
app.use(function(req, res, next) {
|
11
|
+
res.header("Access-Control-Allow-Headers", "Access-Control-Allow-Origin: *", "x-access-token, Origin, Content-Type, Accept");
|
12
|
+
next();
|
13
|
+
});
|
14
|
+
|
15
|
+
app.post(
|
16
|
+
"/payment/newpayment",
|
17
|
+
controller.newpayment,
|
18
|
+
);
|
19
|
+
app.post(
|
20
|
+
"/payment/getstatus",
|
21
|
+
controller.getstatus
|
22
|
+
);
|
23
|
+
app.post(
|
24
|
+
"/payment/addcustomer",
|
25
|
+
controller.addcustomer
|
26
|
+
);
|
27
|
+
app.post(
|
28
|
+
"/payment/getcustomercards",
|
29
|
+
controller.getcustomercards
|
30
|
+
);
|
31
|
+
|
32
|
+
app.get(
|
33
|
+
"/payments",
|
34
|
+
controller.getAll
|
35
|
+
);
|
36
|
+
|
37
|
+
app.get(
|
38
|
+
"/payments/:_id",
|
39
|
+
controller.get
|
40
|
+
);
|
41
|
+
|
42
|
+
app.post(
|
43
|
+
"/payments/:_id",
|
44
|
+
controller.update
|
45
|
+
);
|
46
|
+
|
47
|
+
app.post(
|
48
|
+
"/payments",
|
49
|
+
controller.create
|
50
|
+
);
|
51
|
+
|
52
|
+
app.delete(
|
53
|
+
"/payments/:_id",
|
54
|
+
controller.delete
|
55
|
+
);
|
56
|
+
|
57
|
+
};
|
58
|
+
|
@@ -1,7 +1,8 @@
|
|
1
1
|
<template>
|
2
2
|
<div class="flex flex-column w-100 o-hidden gap-thin pd-thin">
|
3
3
|
<!-- <Breadcrumbs class="bg-grey radius-big pd-small"/> -->
|
4
|
-
|
4
|
+
{{product.quantity}}
|
5
|
+
<SectionProduct v-if="product" :product="product" :user="auth.state.user" class="pos-relative"/>
|
5
6
|
|
6
7
|
<PopularProducts />
|
7
8
|
</div>
|
@@ -22,6 +23,7 @@
|
|
22
23
|
import { useI18n } from 'vue-i18n'
|
23
24
|
import { useMeta } from 'vue-meta'
|
24
25
|
|
26
|
+
import * as auth from '@pf/src/modules/auth/store/auth';
|
25
27
|
import * as products from '@pf/src/modules/products/store/products';
|
26
28
|
import * as categories from '@pf/src/modules/products/store/categories';
|
27
29
|
|