node-paytmpg 5.3.1 → 5.4.2
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/.github/workflows/codeql-analysis.yml +71 -71
- package/.github/workflows/nodejs.yml +24 -24
- package/.github/workflows/npm-publish.yml +23 -23
- package/Dockerfile +8 -8
- package/LICENSE +674 -674
- package/README.MD +245 -245
- package/app/controllers/adapters/open_money.js +515 -514
- package/app/controllers/adapters/payu.js +251 -0
- package/app/controllers/checksum/checksum.js +154 -154
- package/app/controllers/checksum/crypt.js +98 -98
- package/app/controllers/checksum/server.js +132 -132
- package/app/controllers/np_user.controller.js +18 -9
- package/app/controllers/payment_controller.js +1171 -1067
- package/app/models/np_multidbplugin.js +14 -4
- package/app/models/np_transaction.model.js +16 -16
- package/app/models/np_user.model.js +11 -11
- package/app/routes/payment_route.js +73 -73
- package/app/views/home.hbs +21 -21
- package/app/views/init.hbs +92 -92
- package/app/views/layouts/index.hbs +57 -57
- package/app/views/result.hbs +49 -49
- package/app.yaml +18 -18
- package/example.js +42 -51
- package/index.js +23 -23
- package/package.json +5 -2
- package/public/css/style.css +268 -268
- package/public/js/index.js +282 -282
- package/public/layer_checkout.js +38 -38
- package/public/test.html +24 -24
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var crypto = require('crypto');
|
|
4
|
-
var util = require('util');
|
|
5
|
-
|
|
6
|
-
var crypt = {
|
|
7
|
-
iv: '@@@@&&&&####$$$$',
|
|
8
|
-
|
|
9
|
-
encrypt: function (data,custom_key) {
|
|
10
|
-
var iv = this.iv;
|
|
11
|
-
var key = custom_key;
|
|
12
|
-
var algo = '256';
|
|
13
|
-
switch (key.length) {
|
|
14
|
-
case 16:
|
|
15
|
-
algo = '128';
|
|
16
|
-
break;
|
|
17
|
-
case 24:
|
|
18
|
-
algo = '192';
|
|
19
|
-
break;
|
|
20
|
-
case 32:
|
|
21
|
-
algo = '256';
|
|
22
|
-
break;
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
var cipher = crypto.createCipheriv('AES-' + algo + '-CBC', key, iv);
|
|
26
|
-
//var cipher = crypto.createCipher('aes256',key);
|
|
27
|
-
var encrypted = cipher.update(data, 'binary', 'base64');
|
|
28
|
-
encrypted += cipher.final('base64');
|
|
29
|
-
return encrypted;
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
decrypt: function (data,custom_key) {
|
|
33
|
-
var iv = this.iv;
|
|
34
|
-
var key = custom_key;
|
|
35
|
-
var algo = '256';
|
|
36
|
-
switch (key.length) {
|
|
37
|
-
case 16:
|
|
38
|
-
algo = '128';
|
|
39
|
-
break;
|
|
40
|
-
case 24:
|
|
41
|
-
algo = '192';
|
|
42
|
-
break;
|
|
43
|
-
case 32:
|
|
44
|
-
algo = '256';
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
var decipher = crypto.createDecipheriv('AES-' + algo + '-CBC', key, iv);
|
|
48
|
-
var decrypted = decipher.update(data, 'base64', 'binary');
|
|
49
|
-
try {
|
|
50
|
-
decrypted += decipher.final('binary');
|
|
51
|
-
} catch (e) {
|
|
52
|
-
util.log(util.inspect(e));
|
|
53
|
-
}
|
|
54
|
-
return decrypted;
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
gen_salt: function (length, cb) {
|
|
58
|
-
crypto.randomBytes((length * 3.0) / 4.0, function (err, buf) {
|
|
59
|
-
var salt;
|
|
60
|
-
if (!err) {
|
|
61
|
-
salt = buf.toString("base64");
|
|
62
|
-
}
|
|
63
|
-
//salt=Math.floor(Math.random()*8999)+1000;
|
|
64
|
-
cb(err, salt);
|
|
65
|
-
});
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
/* one way md5 hash with salt */
|
|
69
|
-
md5sum: function (salt, data) {
|
|
70
|
-
return crypto.createHash('md5').update(salt + data).digest('hex');
|
|
71
|
-
},
|
|
72
|
-
sha256sum: function (salt, data) {
|
|
73
|
-
return crypto.createHash('sha256').update(data + salt).digest('hex');
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
module.exports = crypt;
|
|
78
|
-
|
|
79
|
-
(function () {
|
|
80
|
-
var i;
|
|
81
|
-
|
|
82
|
-
function logsalt(err, salt) {
|
|
83
|
-
if (!err) {
|
|
84
|
-
console.log('salt is ' + salt);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (require.main === module) {
|
|
89
|
-
var enc = crypt.encrypt('One97');
|
|
90
|
-
console.log('encrypted - ' + enc);
|
|
91
|
-
console.log('decrypted - ' + crypt.decrypt(enc));
|
|
92
|
-
|
|
93
|
-
for (i = 0; i < 5; i++) {
|
|
94
|
-
crypt.gen_salt(4, logsalt);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
}());
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var crypto = require('crypto');
|
|
4
|
+
var util = require('util');
|
|
5
|
+
|
|
6
|
+
var crypt = {
|
|
7
|
+
iv: '@@@@&&&&####$$$$',
|
|
8
|
+
|
|
9
|
+
encrypt: function (data,custom_key) {
|
|
10
|
+
var iv = this.iv;
|
|
11
|
+
var key = custom_key;
|
|
12
|
+
var algo = '256';
|
|
13
|
+
switch (key.length) {
|
|
14
|
+
case 16:
|
|
15
|
+
algo = '128';
|
|
16
|
+
break;
|
|
17
|
+
case 24:
|
|
18
|
+
algo = '192';
|
|
19
|
+
break;
|
|
20
|
+
case 32:
|
|
21
|
+
algo = '256';
|
|
22
|
+
break;
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
var cipher = crypto.createCipheriv('AES-' + algo + '-CBC', key, iv);
|
|
26
|
+
//var cipher = crypto.createCipher('aes256',key);
|
|
27
|
+
var encrypted = cipher.update(data, 'binary', 'base64');
|
|
28
|
+
encrypted += cipher.final('base64');
|
|
29
|
+
return encrypted;
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
decrypt: function (data,custom_key) {
|
|
33
|
+
var iv = this.iv;
|
|
34
|
+
var key = custom_key;
|
|
35
|
+
var algo = '256';
|
|
36
|
+
switch (key.length) {
|
|
37
|
+
case 16:
|
|
38
|
+
algo = '128';
|
|
39
|
+
break;
|
|
40
|
+
case 24:
|
|
41
|
+
algo = '192';
|
|
42
|
+
break;
|
|
43
|
+
case 32:
|
|
44
|
+
algo = '256';
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
var decipher = crypto.createDecipheriv('AES-' + algo + '-CBC', key, iv);
|
|
48
|
+
var decrypted = decipher.update(data, 'base64', 'binary');
|
|
49
|
+
try {
|
|
50
|
+
decrypted += decipher.final('binary');
|
|
51
|
+
} catch (e) {
|
|
52
|
+
util.log(util.inspect(e));
|
|
53
|
+
}
|
|
54
|
+
return decrypted;
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
gen_salt: function (length, cb) {
|
|
58
|
+
crypto.randomBytes((length * 3.0) / 4.0, function (err, buf) {
|
|
59
|
+
var salt;
|
|
60
|
+
if (!err) {
|
|
61
|
+
salt = buf.toString("base64");
|
|
62
|
+
}
|
|
63
|
+
//salt=Math.floor(Math.random()*8999)+1000;
|
|
64
|
+
cb(err, salt);
|
|
65
|
+
});
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
/* one way md5 hash with salt */
|
|
69
|
+
md5sum: function (salt, data) {
|
|
70
|
+
return crypto.createHash('md5').update(salt + data).digest('hex');
|
|
71
|
+
},
|
|
72
|
+
sha256sum: function (salt, data) {
|
|
73
|
+
return crypto.createHash('sha256').update(data + salt).digest('hex');
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
module.exports = crypt;
|
|
78
|
+
|
|
79
|
+
(function () {
|
|
80
|
+
var i;
|
|
81
|
+
|
|
82
|
+
function logsalt(err, salt) {
|
|
83
|
+
if (!err) {
|
|
84
|
+
console.log('salt is ' + salt);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (require.main === module) {
|
|
89
|
+
var enc = crypt.encrypt('One97');
|
|
90
|
+
console.log('encrypted - ' + enc);
|
|
91
|
+
console.log('decrypted - ' + crypt.decrypt(enc));
|
|
92
|
+
|
|
93
|
+
for (i = 0; i < 5; i++) {
|
|
94
|
+
crypt.gen_salt(4, logsalt);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
}());
|
|
@@ -1,132 +1,132 @@
|
|
|
1
|
-
const http = require('http');
|
|
2
|
-
const https = require('https');
|
|
3
|
-
const qs = require('querystring');
|
|
4
|
-
const port = 8080;
|
|
5
|
-
const checksum_lib = require('./checksum.js');
|
|
6
|
-
|
|
7
|
-
var PaytmConfig = {
|
|
8
|
-
mid: "XXXXXXXXXXXXXXXXXXXX",
|
|
9
|
-
key: "XXXXXXXXXXXXXXXX",
|
|
10
|
-
website: "XXXXXXXXXX"
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
http.createServer(function (req, res) {
|
|
15
|
-
|
|
16
|
-
switch(req.url){
|
|
17
|
-
case "/":
|
|
18
|
-
var params = {};
|
|
19
|
-
params['MID'] = PaytmConfig.mid;
|
|
20
|
-
params['WEBSITE'] = PaytmConfig.website;
|
|
21
|
-
params['CHANNEL_ID'] = 'WEB';
|
|
22
|
-
params['INDUSTRY_TYPE_ID'] = 'Retail';
|
|
23
|
-
params['ORDER_ID'] = 'TEST_' + new Date().getTime();
|
|
24
|
-
params['CUST_ID'] = 'Customer001';
|
|
25
|
-
params['TXN_AMOUNT'] = '1.00';
|
|
26
|
-
params['CALLBACK_URL'] = 'http://localhost:'+port+'/callback';
|
|
27
|
-
params['EMAIL'] = 'abc@mailinator.com';
|
|
28
|
-
params['MOBILE_NO'] = '7777777777';
|
|
29
|
-
|
|
30
|
-
checksum_lib.genchecksum(params, PaytmConfig.key, function (err, checksum) {
|
|
31
|
-
|
|
32
|
-
var txn_url = "https://securegw-stage.paytm.in/theia/processTransaction"; // for staging
|
|
33
|
-
// var txn_url = "https://securegw.paytm.in/theia/processTransaction"; // for production
|
|
34
|
-
|
|
35
|
-
var form_fields = "";
|
|
36
|
-
for(var x in params){
|
|
37
|
-
form_fields += "<input type='hidden' name='"+x+"' value='"+params[x]+"' >";
|
|
38
|
-
}
|
|
39
|
-
form_fields += "<input type='hidden' name='CHECKSUMHASH' value='"+checksum+"' >";
|
|
40
|
-
|
|
41
|
-
res.writeHead(200, {'Content-Type': 'text/html'});
|
|
42
|
-
res.write('<html><head><title>Merchant Checkout Page</title></head><body><center><h1>Please do not refresh this page...</h1></center><form method="post" action="'+txn_url+'" name="f1">'+form_fields+'</form><script type="text/javascript">document.f1.submit();</script></body></html>');
|
|
43
|
-
res.end();
|
|
44
|
-
});
|
|
45
|
-
break;
|
|
46
|
-
|
|
47
|
-
case "/callback":
|
|
48
|
-
|
|
49
|
-
var body = '';
|
|
50
|
-
|
|
51
|
-
req.on('data', function (data) {
|
|
52
|
-
body += data;
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
req.on('end', function () {
|
|
56
|
-
var html = "";
|
|
57
|
-
var post_data = qs.parse(body);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
// received params in callback
|
|
61
|
-
console.log('Callback Response: ', post_data, "\n");
|
|
62
|
-
html += "<b>Callback Response</b><br>";
|
|
63
|
-
for(var x in post_data){
|
|
64
|
-
html += x + " => " + post_data[x] + "<br/>";
|
|
65
|
-
}
|
|
66
|
-
html += "<br/><br/>";
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// verify the checksum
|
|
70
|
-
var checksumhash = post_data.CHECKSUMHASH;
|
|
71
|
-
// delete post_data.CHECKSUMHASH;
|
|
72
|
-
var result = checksum_lib.verifychecksum(post_data, PaytmConfig.key, checksumhash);
|
|
73
|
-
console.log("Checksum Result => ", result, "\n");
|
|
74
|
-
html += "<b>Checksum Result</b> => " + (result? "True" : "False");
|
|
75
|
-
html += "<br/><br/>";
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
// Send Server-to-Server request to verify Order Status
|
|
80
|
-
var params = {"MID": PaytmConfig.mid, "ORDERID": post_data.ORDERID};
|
|
81
|
-
|
|
82
|
-
checksum_lib.genchecksum(params, PaytmConfig.key, function (err, checksum) {
|
|
83
|
-
|
|
84
|
-
params.CHECKSUMHASH = checksum;
|
|
85
|
-
post_data = 'JsonData='+JSON.stringify(params);
|
|
86
|
-
|
|
87
|
-
var options = {
|
|
88
|
-
hostname: 'securegw-stage.paytm.in', // for staging
|
|
89
|
-
// hostname: 'securegw.paytm.in', // for production
|
|
90
|
-
port: 443,
|
|
91
|
-
path: '/merchant-status/getTxnStatus',
|
|
92
|
-
method: 'POST',
|
|
93
|
-
headers: {
|
|
94
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
95
|
-
'Content-Length': post_data.length
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
// Set up the request
|
|
101
|
-
var response = "";
|
|
102
|
-
var post_req = https.request(options, function(post_res) {
|
|
103
|
-
post_res.on('data', function (chunk) {
|
|
104
|
-
response += chunk;
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
post_res.on('end', function(){
|
|
108
|
-
console.log('S2S Response: ', response, "\n");
|
|
109
|
-
|
|
110
|
-
var _result = JSON.parse(response);
|
|
111
|
-
html += "<b>Status Check Response</b><br>";
|
|
112
|
-
for(var x in _result){
|
|
113
|
-
html += x + " => " + _result[x] + "<br/>";
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
res.writeHead(200, {'Content-Type': 'text/html'});
|
|
117
|
-
res.write(html);
|
|
118
|
-
res.end();
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
// post the data
|
|
123
|
-
post_req.write(post_data);
|
|
124
|
-
post_req.end();
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
break;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}).listen(port);
|
|
1
|
+
const http = require('http');
|
|
2
|
+
const https = require('https');
|
|
3
|
+
const qs = require('querystring');
|
|
4
|
+
const port = 8080;
|
|
5
|
+
const checksum_lib = require('./checksum.js');
|
|
6
|
+
|
|
7
|
+
var PaytmConfig = {
|
|
8
|
+
mid: "XXXXXXXXXXXXXXXXXXXX",
|
|
9
|
+
key: "XXXXXXXXXXXXXXXX",
|
|
10
|
+
website: "XXXXXXXXXX"
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
http.createServer(function (req, res) {
|
|
15
|
+
|
|
16
|
+
switch(req.url){
|
|
17
|
+
case "/":
|
|
18
|
+
var params = {};
|
|
19
|
+
params['MID'] = PaytmConfig.mid;
|
|
20
|
+
params['WEBSITE'] = PaytmConfig.website;
|
|
21
|
+
params['CHANNEL_ID'] = 'WEB';
|
|
22
|
+
params['INDUSTRY_TYPE_ID'] = 'Retail';
|
|
23
|
+
params['ORDER_ID'] = 'TEST_' + new Date().getTime();
|
|
24
|
+
params['CUST_ID'] = 'Customer001';
|
|
25
|
+
params['TXN_AMOUNT'] = '1.00';
|
|
26
|
+
params['CALLBACK_URL'] = 'http://localhost:'+port+'/callback';
|
|
27
|
+
params['EMAIL'] = 'abc@mailinator.com';
|
|
28
|
+
params['MOBILE_NO'] = '7777777777';
|
|
29
|
+
|
|
30
|
+
checksum_lib.genchecksum(params, PaytmConfig.key, function (err, checksum) {
|
|
31
|
+
|
|
32
|
+
var txn_url = "https://securegw-stage.paytm.in/theia/processTransaction"; // for staging
|
|
33
|
+
// var txn_url = "https://securegw.paytm.in/theia/processTransaction"; // for production
|
|
34
|
+
|
|
35
|
+
var form_fields = "";
|
|
36
|
+
for(var x in params){
|
|
37
|
+
form_fields += "<input type='hidden' name='"+x+"' value='"+params[x]+"' >";
|
|
38
|
+
}
|
|
39
|
+
form_fields += "<input type='hidden' name='CHECKSUMHASH' value='"+checksum+"' >";
|
|
40
|
+
|
|
41
|
+
res.writeHead(200, {'Content-Type': 'text/html'});
|
|
42
|
+
res.write('<html><head><title>Merchant Checkout Page</title></head><body><center><h1>Please do not refresh this page...</h1></center><form method="post" action="'+txn_url+'" name="f1">'+form_fields+'</form><script type="text/javascript">document.f1.submit();</script></body></html>');
|
|
43
|
+
res.end();
|
|
44
|
+
});
|
|
45
|
+
break;
|
|
46
|
+
|
|
47
|
+
case "/callback":
|
|
48
|
+
|
|
49
|
+
var body = '';
|
|
50
|
+
|
|
51
|
+
req.on('data', function (data) {
|
|
52
|
+
body += data;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
req.on('end', function () {
|
|
56
|
+
var html = "";
|
|
57
|
+
var post_data = qs.parse(body);
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
// received params in callback
|
|
61
|
+
console.log('Callback Response: ', post_data, "\n");
|
|
62
|
+
html += "<b>Callback Response</b><br>";
|
|
63
|
+
for(var x in post_data){
|
|
64
|
+
html += x + " => " + post_data[x] + "<br/>";
|
|
65
|
+
}
|
|
66
|
+
html += "<br/><br/>";
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
// verify the checksum
|
|
70
|
+
var checksumhash = post_data.CHECKSUMHASH;
|
|
71
|
+
// delete post_data.CHECKSUMHASH;
|
|
72
|
+
var result = checksum_lib.verifychecksum(post_data, PaytmConfig.key, checksumhash);
|
|
73
|
+
console.log("Checksum Result => ", result, "\n");
|
|
74
|
+
html += "<b>Checksum Result</b> => " + (result? "True" : "False");
|
|
75
|
+
html += "<br/><br/>";
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
// Send Server-to-Server request to verify Order Status
|
|
80
|
+
var params = {"MID": PaytmConfig.mid, "ORDERID": post_data.ORDERID};
|
|
81
|
+
|
|
82
|
+
checksum_lib.genchecksum(params, PaytmConfig.key, function (err, checksum) {
|
|
83
|
+
|
|
84
|
+
params.CHECKSUMHASH = checksum;
|
|
85
|
+
post_data = 'JsonData='+JSON.stringify(params);
|
|
86
|
+
|
|
87
|
+
var options = {
|
|
88
|
+
hostname: 'securegw-stage.paytm.in', // for staging
|
|
89
|
+
// hostname: 'securegw.paytm.in', // for production
|
|
90
|
+
port: 443,
|
|
91
|
+
path: '/merchant-status/getTxnStatus',
|
|
92
|
+
method: 'POST',
|
|
93
|
+
headers: {
|
|
94
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
95
|
+
'Content-Length': post_data.length
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
// Set up the request
|
|
101
|
+
var response = "";
|
|
102
|
+
var post_req = https.request(options, function(post_res) {
|
|
103
|
+
post_res.on('data', function (chunk) {
|
|
104
|
+
response += chunk;
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
post_res.on('end', function(){
|
|
108
|
+
console.log('S2S Response: ', response, "\n");
|
|
109
|
+
|
|
110
|
+
var _result = JSON.parse(response);
|
|
111
|
+
html += "<b>Status Check Response</b><br>";
|
|
112
|
+
for(var x in _result){
|
|
113
|
+
html += x + " => " + _result[x] + "<br/>";
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
res.writeHead(200, {'Content-Type': 'text/html'});
|
|
117
|
+
res.write(html);
|
|
118
|
+
res.end();
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// post the data
|
|
123
|
+
post_req.write(post_data);
|
|
124
|
+
post_req.end();
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
}).listen(port);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var User
|
|
1
|
+
var User;
|
|
2
2
|
var Transaction = require('../models/np_transaction.model.js');
|
|
3
|
-
var IDLEN = 10
|
|
3
|
+
var IDLEN = 10;
|
|
4
4
|
function makeid(length) {
|
|
5
5
|
var text = "";
|
|
6
6
|
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
@@ -20,10 +20,19 @@ module.exports = function (app, callbacks) {
|
|
|
20
20
|
User = require('../models/np_user.model.js');
|
|
21
21
|
usingMultiDbOrm = false;
|
|
22
22
|
} else if (app.multidborm) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
const sample = {
|
|
24
|
+
"id": "user_aB3dE9xY1Z",
|
|
25
|
+
"name": "tset",
|
|
26
|
+
"email": "testgmailcom",
|
|
27
|
+
"phone": "12345678",
|
|
28
|
+
"createdAt": "stringlarge",
|
|
29
|
+
"updatedAt": "stringlarge",
|
|
30
|
+
"returnUrl": "stringlarge"
|
|
31
|
+
}
|
|
32
|
+
User = require('../models/np_multidbplugin.js')('npusers', app.multidborm, sample);
|
|
33
|
+
User.db = app.multidborm;
|
|
34
|
+
User.modelname = 'npusers'
|
|
35
|
+
User.idFieldName = 'id'
|
|
27
36
|
app.NPUser = User;
|
|
28
37
|
usingMultiDbOrm = true;
|
|
29
38
|
}
|
|
@@ -40,7 +49,7 @@ module.exports = function (app, callbacks) {
|
|
|
40
49
|
if (userData.email && userData.email.indexOf("@") !== -1) objForUpdate.email = userData.email;
|
|
41
50
|
if (userData.phone && userData.phone.length > 2) objForUpdate.phone = userData.phone;
|
|
42
51
|
if (userData.name && userData.name.length > 2) objForUpdate.name = userData.name;
|
|
43
|
-
delete objForUpdate._id
|
|
52
|
+
delete objForUpdate._id;
|
|
44
53
|
var newvalues = { $set: objForUpdate };
|
|
45
54
|
//console.log("User Old : ",userData.name);
|
|
46
55
|
User.updateOne(myquery, newvalues, function (err, saveRes) {
|
|
@@ -58,7 +67,7 @@ module.exports = function (app, callbacks) {
|
|
|
58
67
|
|
|
59
68
|
// console.log("User New : ",userData.name);
|
|
60
69
|
|
|
61
|
-
userData.id = "user_"+makeid(IDLEN);
|
|
70
|
+
userData.id = "user_" + makeid(IDLEN);
|
|
62
71
|
var userTask = new User(userData);
|
|
63
72
|
userTask.save()
|
|
64
73
|
.then(user => {
|
|
@@ -72,7 +81,7 @@ module.exports = function (app, callbacks) {
|
|
|
72
81
|
|
|
73
82
|
}
|
|
74
83
|
|
|
75
|
-
},usingMultiDbOrm ? User : undefined);
|
|
84
|
+
}, usingMultiDbOrm ? User : undefined);
|
|
76
85
|
|
|
77
86
|
};
|
|
78
87
|
return module;
|