webfast 0.1.88 → 0.1.89
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/example.js +68 -0
- package/modules/payment/init.js +10 -1
- package/modules/payment/providers/mollie/startup.js +19 -4
- package/package.json +1 -1
package/example.js
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
const path = require(`path`);
|
2
|
+
const contentPath = path.join(__dirname,`example`,`content`)
|
3
|
+
let setArray = {
|
4
|
+
wget : '/usr/local/bin/wget',
|
5
|
+
process : {
|
6
|
+
ts : Date.now(),
|
7
|
+
socket : {
|
8
|
+
api : {
|
9
|
+
list : function(program,ws,json,data,path) {
|
10
|
+
// Example to create process for websocket path action and process data
|
11
|
+
console.log(`Example of list process`);
|
12
|
+
|
13
|
+
function generateRandomText(length) {
|
14
|
+
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
15
|
+
let result = '';
|
16
|
+
|
17
|
+
for (let i = 0; i < length; i++) {
|
18
|
+
result += characters.charAt(Math.floor(Math.random() * characters.length));
|
19
|
+
}
|
20
|
+
|
21
|
+
return result;
|
22
|
+
}
|
23
|
+
|
24
|
+
|
25
|
+
// Loop for example through
|
26
|
+
let exampleData = {
|
27
|
+
list : [],
|
28
|
+
ell : data.ell,
|
29
|
+
action : data.action
|
30
|
+
}
|
31
|
+
|
32
|
+
const pushData = {};
|
33
|
+
for (let i in data.other.items) {
|
34
|
+
const item = data.other.items[i];
|
35
|
+
// We have itme
|
36
|
+
const id = item.id;
|
37
|
+
const key = item.name;
|
38
|
+
|
39
|
+
pushData[key] = {
|
40
|
+
id : id,
|
41
|
+
text : generateRandomText(10)
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
pushData.uuid = program.uuid.v4();
|
46
|
+
exampleData.list.push(pushData);
|
47
|
+
|
48
|
+
// Send websocket message create standard
|
49
|
+
const sendObject = {
|
50
|
+
func : data.function,
|
51
|
+
data : exampleData,
|
52
|
+
js : `console.log("RUN FROM BACKEND")`
|
53
|
+
}
|
54
|
+
|
55
|
+
// Sedn back to front-end
|
56
|
+
//ws.send();
|
57
|
+
|
58
|
+
return sendObject;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
62
|
+
},
|
63
|
+
contentPath : contentPath
|
64
|
+
};
|
65
|
+
|
66
|
+
|
67
|
+
let program = require(path.join(__dirname,`index.js`))(setArray);
|
68
|
+
console.log(`Required`);
|
package/modules/payment/init.js
CHANGED
@@ -28,7 +28,16 @@ module.exports = {
|
|
28
28
|
if (program.set.path == undefined) {
|
29
29
|
continue;
|
30
30
|
}
|
31
|
-
const configRead = JSON.parse(program.fs.readFileSync(program.path.join(program.set.path,`payment.config.json`),`UTF-8`));
|
31
|
+
//const configRead = JSON.parse(program.fs.readFileSync(program.path.join(program.set.path,`payment.config.json`),`UTF-8`));
|
32
|
+
const configRead = {
|
33
|
+
"mollie" : {
|
34
|
+
"active" : process.env.MOLLIE_ACTIVE,
|
35
|
+
"key" : process.env.MOLLIE_KEY,
|
36
|
+
"partnerId" : process.env.MOLLIE_PARTNER_ID,
|
37
|
+
"profileId" : process.env.MOLLIE_PROFILE_ID,
|
38
|
+
"url" : process.env.MOLLIE_URL
|
39
|
+
}
|
40
|
+
};
|
32
41
|
// Read
|
33
42
|
const json = configRead[module.name];
|
34
43
|
if (json == undefined) {
|
@@ -282,7 +282,19 @@ module.exports = async function(program,json) {
|
|
282
282
|
paid : Date.now()
|
283
283
|
}
|
284
284
|
});
|
285
|
-
|
285
|
+
|
286
|
+
validate.package = payment.package;
|
287
|
+
validate.order = payment.order;
|
288
|
+
validate.uuid = payment.uuid;
|
289
|
+
validate.user = payment.user;
|
290
|
+
|
291
|
+
const paymentFinale =await program.modules.data.update(process.env.dbName,`payment`,{
|
292
|
+
uuid : payment.uuid
|
293
|
+
},{
|
294
|
+
$set: validate
|
295
|
+
});
|
296
|
+
|
297
|
+
console.log(`Final Update`,updatedFinal,paymentFinale);
|
286
298
|
|
287
299
|
// Check also for message now
|
288
300
|
// Grab message
|
@@ -302,9 +314,9 @@ module.exports = async function(program,json) {
|
|
302
314
|
let packageData = await program.modules.data.aggregate(program,process.env.dbName, 'pricing', packageLine);
|
303
315
|
|
304
316
|
// Okay we have message data
|
305
|
-
const orderURL = `${process.env.webURL.slice(0,-1)}/concepts/esimco/order#${
|
306
|
-
const howToURL = `${process.env.webURL.slice(0,-1)}/concepts/esimco/order#${
|
307
|
-
const referralURL = `${process.env.webURL.slice(0,-1)}/concepts/esimco/order#${
|
317
|
+
const orderURL = `${process.env.webURL.slice(0,-1)}/concepts/esimco/order#${order.uuid}__redirect`;
|
318
|
+
const howToURL = `${process.env.webURL.slice(0,-1)}/concepts/esimco/order#${order.uuid}__how-to`;
|
319
|
+
const referralURL = `${process.env.webURL.slice(0,-1)}/concepts/esimco/order#${order.uuid}__referral`;
|
308
320
|
|
309
321
|
const textMessage = `<b>✅ Your payment is received!</b>\n<span class="tg-spoiler">Order ID: <b>${order.uuid}</b></span>\n\nWe are now matching your order and payment. You will receive your ordered prodcut in a few minutes: <b>${String(packageData[0].description).toUpperCase()}</b>`
|
310
322
|
try {
|
@@ -317,6 +329,9 @@ module.exports = async function(program,json) {
|
|
317
329
|
],messageData.message_id);
|
318
330
|
|
319
331
|
console.log(`Sending telegram`);
|
332
|
+
|
333
|
+
// Update order messages
|
334
|
+
|
320
335
|
} catch(err) {
|
321
336
|
console.error(err);
|
322
337
|
console.error(`Error updating message`);
|