node-paytmpg 5.3.0 → 5.3.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.
@@ -1,101 +1,101 @@
1
- module.exports = function (modelName, db) {
2
-
3
- class MultiDbMapper {
4
-
5
- idFieldName
6
- objectData
7
- constructor(objectData) {
8
- MultiDbMapper.sanitizeRequest(objectData)
9
- this.objectData = objectData;
10
- }
11
-
12
-
13
- static async sanitizeRequest(body) {
14
-
15
- if (!body)
16
- return;
17
- if (body.amount)
18
- body.amount = parseFloat(body.amount);
19
- if (body.TXN_AMOUNT)
20
- body.amount = parseFloat(body.TXN_AMOUNT);
21
- }
22
-
23
- async save() {
24
- var response = await MultiDbMapper.db.insert(MultiDbMapper.modelname, this.objectData,this.objectData[MultiDbMapper.idFieldName]);
25
- if ( typeof response == Object && response.ops[0])
26
- response = response.ops[0];
27
- else
28
- response = this.objectData
29
-
30
- MultiDbMapper.sanitizeRequest(response)
31
-
32
- return response;
33
- }
34
-
35
- //callback(err,resp)
36
- static async findOne(query, cb) {
37
-
38
- var response;
39
- try {
40
- response = await MultiDbMapper.db.getOne(MultiDbMapper.modelname, query);
41
- MultiDbMapper.sanitizeRequest(response)
42
- } catch (e) {
43
- if (cb)
44
- return cb(e, undefined)
45
- else
46
- throw e;
47
- }
48
- if (cb)
49
- cb(undefined, response);
50
- else
51
- return response;
52
- }
53
-
54
- static async updateOne(query, newValue, cb) {
55
-
56
- var response;
57
- try {
58
-
59
- response = await MultiDbMapper.db.update(MultiDbMapper.modelname, query, newValue['$set']);
60
-
61
- } catch (e) {
62
- if (cb)
63
- return cb(e, undefined)
64
- else
65
- throw e;
66
- }
67
-
68
- if (cb)
69
- cb(undefined, response);
70
- else
71
- return response;
72
- }
73
-
74
- static async deleteOne(query, cb) {
75
-
76
- var response;
77
- try {
78
-
79
- response = await MultiDbMapper.db.delete(MultiDbMapper.modelname, query);
80
- MultiDbMapper.sanitizeRequest(response)
81
-
82
- } catch (e) {
83
- if (cb)
84
- return cb(e, undefined)
85
- else
86
- throw e;
87
- }
88
- if (cb)
89
- cb(undefined, response)
90
- else
91
- return response;
92
-
93
- }
94
-
95
- }
96
-
97
- MultiDbMapper.modelname = modelName;
98
- MultiDbMapper.db = db;
99
- return MultiDbMapper;
100
- }
101
-
1
+ module.exports = function (modelName, db) {
2
+
3
+ class MultiDbMapper {
4
+
5
+ idFieldName
6
+ objectData
7
+ constructor(objectData) {
8
+ MultiDbMapper.sanitizeRequest(objectData)
9
+ this.objectData = objectData;
10
+ }
11
+
12
+
13
+ static async sanitizeRequest(body) {
14
+
15
+ if (!body)
16
+ return;
17
+ if (body.amount)
18
+ body.amount = parseFloat(body.amount);
19
+ if (body.TXN_AMOUNT)
20
+ body.amount = parseFloat(body.TXN_AMOUNT);
21
+ }
22
+
23
+ async save() {
24
+ var response = await MultiDbMapper.db.insert(MultiDbMapper.modelname, this.objectData,this.objectData[MultiDbMapper.idFieldName]);
25
+ if ( typeof response == Object && response.ops[0])
26
+ response = response.ops[0];
27
+ else
28
+ response = this.objectData
29
+
30
+ MultiDbMapper.sanitizeRequest(response)
31
+
32
+ return response;
33
+ }
34
+
35
+ //callback(err,resp)
36
+ static async findOne(query, cb) {
37
+
38
+ var response;
39
+ try {
40
+ response = await MultiDbMapper.db.getOne(MultiDbMapper.modelname, query);
41
+ MultiDbMapper.sanitizeRequest(response)
42
+ } catch (e) {
43
+ if (cb)
44
+ return cb(e, undefined)
45
+ else
46
+ throw e;
47
+ }
48
+ if (cb)
49
+ cb(undefined, response);
50
+ else
51
+ return response;
52
+ }
53
+
54
+ static async updateOne(query, newValue, cb) {
55
+
56
+ var response;
57
+ try {
58
+
59
+ response = await MultiDbMapper.db.update(MultiDbMapper.modelname, query, newValue['$set']);
60
+
61
+ } catch (e) {
62
+ if (cb)
63
+ return cb(e, undefined)
64
+ else
65
+ throw e;
66
+ }
67
+
68
+ if (cb)
69
+ cb(undefined, response);
70
+ else
71
+ return response;
72
+ }
73
+
74
+ static async deleteOne(query, cb) {
75
+
76
+ var response;
77
+ try {
78
+
79
+ response = await MultiDbMapper.db.delete(MultiDbMapper.modelname, query);
80
+ MultiDbMapper.sanitizeRequest(response)
81
+
82
+ } catch (e) {
83
+ if (cb)
84
+ return cb(e, undefined)
85
+ else
86
+ throw e;
87
+ }
88
+ if (cb)
89
+ cb(undefined, response)
90
+ else
91
+ return response;
92
+
93
+ }
94
+
95
+ }
96
+
97
+ MultiDbMapper.modelname = modelName;
98
+ MultiDbMapper.db = db;
99
+ return MultiDbMapper;
100
+ }
101
+
@@ -1,16 +1,16 @@
1
- const mongoose=require('mongoose')
2
- let TransactionSchema=mongoose.Schema({
3
-
4
- orderId:String,
5
- cusId:String,
6
- time:Number,
7
- status:String,
8
- name:String,
9
- email:String,
10
- phone:String,
11
- amount:Number,
12
- pname:String,
13
- extra:String
14
-
15
- });
16
- module.exports=mongoose.model('nptransaction',TransactionSchema);
1
+ const mongoose=require('mongoose')
2
+ let TransactionSchema=mongoose.Schema({
3
+
4
+ orderId:String,
5
+ cusId:String,
6
+ time:Number,
7
+ status:String,
8
+ name:String,
9
+ email:String,
10
+ phone:String,
11
+ amount:Number,
12
+ pname:String,
13
+ extra:String
14
+
15
+ });
16
+ module.exports=mongoose.model('nptransaction',TransactionSchema);
@@ -1,12 +1,12 @@
1
- const mongoose = require('mongoose');
2
-
3
- const UserSchema = mongoose.Schema({
4
- email: String,
5
- id: String,
6
- name : String,
7
- phone : String,
8
- }, {
9
- timestamps: true
10
- });
11
-
1
+ const mongoose = require('mongoose');
2
+
3
+ const UserSchema = mongoose.Schema({
4
+ email: String,
5
+ id: String,
6
+ name : String,
7
+ phone : String,
8
+ }, {
9
+ timestamps: true
10
+ });
11
+
12
12
  module.exports = mongoose.model('npuser', UserSchema);
@@ -1,73 +1,73 @@
1
- module.exports = (app, express, callbacks) => {
2
- const bodyParser = require('body-parser');
3
- var exphbs = require('express-handlebars')
4
- var path = require('path')
5
- var packageInfo = require('../../package.json')
6
- var config = (app.get('np_config'))
7
- var pc = require('../controllers/payment_controller.js')(app, callbacks)
8
- var router = express.Router()
9
- app.set('view_path', __dirname + config.view_path)
10
- var vp = app.get('view_path')
11
- if (config.db_url !== undefined) {
12
-
13
- const mongoose = require('mongoose');
14
-
15
- console.log('PaytmPG : Using MongoDB');
16
-
17
- mongoose.Promise = global.Promise;
18
-
19
- mongoose.connect(config.db_url, {
20
- useUnifiedTopology: true,
21
- useNewUrlParser: true
22
- }).then(() => {
23
- console.log("Successfully connected to the database");
24
- }).catch(err => {
25
- console.log('Could not connect to the database. Exiting now...', err);
26
- process.exit();
27
- });
28
-
29
- } else if (app.multidborm !== undefined) {
30
-
31
- console.log('PaytmPG : Using MultiDB ORM');
32
-
33
- }
34
-
35
-
36
-
37
- app.engine('hbs', exphbs({
38
- extname: 'hbs',
39
- defaultLayout: vp + '/layouts/index.hbs',
40
- helpers: {
41
- theme_color: function () {
42
- return config.theme_color;
43
- },
44
- logo: function () {
45
- return config.logo;
46
- }
47
- }
48
- }))
49
-
50
- app.set('view engine', 'handlebars');
51
-
52
- let saveRawBody = function (req, res, buf, encoding) {
53
- req.rawBody = buf.toString();
54
- }
55
- app.use(bodyParser.urlencoded({ extended: true }))
56
- app.use(bodyParser.json({ verify: saveRawBody }))
57
-
58
- app.use("/" + config.path_prefix, express.static(path.join(__dirname, '../../public')));
59
- app.use('/' + config.path_prefix, router);
60
-
61
- router.all('/', pc.init);
62
- router.all('/init', pc.init);
63
-
64
- // router.all('/home', pc.home)
65
- router.all('/callback', pc.callback)
66
- router.all('/api/webhook', pc.webhook)
67
- router.all('/api/status', pc.status)
68
- router.all('/api/createTxn/token', pc.createTxnToken)
69
- router.all('/api/createTxn', pc.createTxn)
70
-
71
-
72
- return router
73
- }
1
+ module.exports = (app, express, callbacks) => {
2
+ const bodyParser = require('body-parser');
3
+ var exphbs = require('express-handlebars')
4
+ var path = require('path')
5
+ var packageInfo = require('../../package.json')
6
+ var config = (app.get('np_config'))
7
+ var pc = require('../controllers/payment_controller.js')(app, callbacks)
8
+ var router = express.Router()
9
+ app.set('view_path', __dirname + config.view_path)
10
+ var vp = app.get('view_path')
11
+ if (config.db_url !== undefined) {
12
+
13
+ const mongoose = require('mongoose');
14
+
15
+ console.log('PaytmPG : Using MongoDB');
16
+
17
+ mongoose.Promise = global.Promise;
18
+
19
+ mongoose.connect(config.db_url, {
20
+ useUnifiedTopology: true,
21
+ useNewUrlParser: true
22
+ }).then(() => {
23
+ console.log("Successfully connected to the database");
24
+ }).catch(err => {
25
+ console.log('Could not connect to the database. Exiting now...', err);
26
+ process.exit();
27
+ });
28
+
29
+ } else if (app.multidborm !== undefined) {
30
+
31
+ console.log('PaytmPG : Using MultiDB ORM');
32
+
33
+ }
34
+
35
+
36
+
37
+ app.engine('hbs', exphbs({
38
+ extname: 'hbs',
39
+ defaultLayout: vp + '/layouts/index.hbs',
40
+ helpers: {
41
+ theme_color: function () {
42
+ return config.theme_color;
43
+ },
44
+ logo: function () {
45
+ return config.logo;
46
+ }
47
+ }
48
+ }))
49
+
50
+ app.set('view engine', 'handlebars');
51
+
52
+ let saveRawBody = function (req, res, buf, encoding) {
53
+ req.rawBody = buf.toString();
54
+ }
55
+ app.use(bodyParser.urlencoded({ extended: true }))
56
+ app.use(bodyParser.json({ verify: saveRawBody }))
57
+
58
+ app.use("/" + config.path_prefix, express.static(path.join(__dirname, '../../public')));
59
+ app.use('/' + config.path_prefix, router);
60
+
61
+ router.all('/', pc.init);
62
+ router.all('/init', pc.init);
63
+
64
+ // router.all('/home', pc.home)
65
+ router.all('/callback', pc.callback)
66
+ router.all('/api/webhook', pc.webhook)
67
+ router.all('/api/status', pc.status)
68
+ router.all('/api/createTxn/token', pc.createTxnToken)
69
+ router.all('/api/createTxn', pc.createTxn)
70
+
71
+
72
+ return router
73
+ }
@@ -1,22 +1,22 @@
1
- <p>
2
- <h4>About</h4>
3
- <div>
4
-
5
- <table border="1">
6
-
7
- <tr>
8
- <td>Name</td><td>{{name}}</td>
9
- </tr>
10
- <tr>
11
- <td>Version</td><td>{{version}}</td>
12
- </tr>
13
- <tr>
14
- <td>Repository</td><td><a href='{{repository.url}}'>GITHUB</a></td>
15
- </tr>
16
-
17
-
18
- </table>
19
-
20
-
21
- </div>
1
+ <p>
2
+ <h4>About</h4>
3
+ <div>
4
+
5
+ <table border="1">
6
+
7
+ <tr>
8
+ <td>Name</td><td>{{name}}</td>
9
+ </tr>
10
+ <tr>
11
+ <td>Version</td><td>{{version}}</td>
12
+ </tr>
13
+ <tr>
14
+ <td>Repository</td><td><a href='{{repository.url}}'>GITHUB</a></td>
15
+ </tr>
16
+
17
+
18
+ </table>
19
+
20
+
21
+ </div>
22
22
  </p>
@@ -1,93 +1,93 @@
1
- <h2>Payment Start</h2>
2
-
3
- <form action="{{action}}" method="POST">
4
- <ul class="form-list">
5
- {{#if check}}
6
-
7
- <li class="form-list__row">
8
- <label>Name</label>
9
- <input type="text" name="NAME" required="" value="{{NAME}}" {{readonly}} />
10
- </li>
11
- {{else}}
12
- <input type="hidden" name="NAME" required="" value="{{NAME}}" {{readonly}} />
13
-
14
- {{/if}}
15
- <li class="form-list__row">
16
- <label>E-Mail</label>
17
- <input type="text" name="EMAIL" required="" value="{{EMAIL}}" {{readonly}} />
18
- </li>
19
-
20
- <li class="form-list__row">
21
- <label>Phone</label>
22
- <input type="text" name="MOBILE_NO" required="" value="{{MOBILE_NO}}" {{readonly}} />
23
- </li>
24
-
25
-
26
- <li class="form-list__row">
27
-
28
- {{#if check}}
29
-
30
- <div>
31
- <label>
32
- Product
33
- </label>
34
- <input type="text" name="PRODUCT_NAME" required="" value="{{PRODUCT_NAME}}" {{readonly}} />
35
- </div>
36
- {{else}}
37
- <input type="hidden" name="PRODUCT_NAME" required="" value="{{PRODUCT_NAME}}" {{readonly}} />
38
- {{/if}}
39
-
40
- </li>
41
- <li class="form-list__row">
42
-
43
- <div>
44
- <label>
45
- Amount
46
- </label>
47
- <input type="text" name="TXN_AMOUNT" required="" value="{{TXN_AMOUNT}}" {{readonly}} />
48
- </div>
49
-
50
- </li>
51
-
52
- {{#if check}}
53
-
54
- <li class="form-list__row form-list__row--agree">
55
- <label>
56
- <input type="checkbox" name="save_cc" checked="checked">
57
- I agree to terms and conditions
58
- </label>
59
- </li>
60
- {{/if}}
61
-
62
- <li>
63
- <button id="show_button" type="submit" class="button">{{BUTTON}}</button>
64
- </li>
65
-
66
- <script>
67
- var button = document.getElementById('show_button')
68
- button.addEventListener('click',hideshow,false);
69
-
70
- function hideshow() {
71
- document.getElementById('show_button').style.display = 'none';
72
- }
73
- </script>
74
-
75
- </ul>
76
-
77
-
78
-
79
- <input type="hidden" name="MID" value="{{MID}}" {{readonly}}>
80
- <input type="hidden" name="WEBSITE" value="{{WEBSITE}}" {{readonly}}>
81
- <input type="hidden" name="ORDER_ID" value="{{ORDER_ID}}" {{readonly}}>
82
- <input type="hidden" name="CUST_ID" value="{{CUST_ID}}" {{readonly}}>
83
- <input type="hidden" name="INDUSTRY_TYPE_ID" value="{{INDUSTRY_TYPE_ID}}" {{readonly}}>
84
- <input type="hidden" name="CHANNEL_ID" value="{{CHANNEL_ID}}" {{readonly}}>
85
- <input type="hidden" name="CALLBACK_URL" value="{{CALLBACK_URL}}" {{readonly}}>
86
- <input type="hidden" name="CHECKSUMHASH" value="{{CHECKSUMHASH}}" {{readonly}}>
87
-
88
-
89
-
90
-
91
-
92
-
1
+ <h2>Payment Start</h2>
2
+
3
+ <form action="{{action}}" method="POST">
4
+ <ul class="form-list">
5
+ {{#if check}}
6
+
7
+ <li class="form-list__row">
8
+ <label>Name</label>
9
+ <input type="text" name="NAME" required="" value="{{NAME}}" {{readonly}} />
10
+ </li>
11
+ {{else}}
12
+ <input type="hidden" name="NAME" required="" value="{{NAME}}" {{readonly}} />
13
+
14
+ {{/if}}
15
+ <li class="form-list__row">
16
+ <label>E-Mail</label>
17
+ <input type="text" name="EMAIL" required="" value="{{EMAIL}}" {{readonly}} />
18
+ </li>
19
+
20
+ <li class="form-list__row">
21
+ <label>Phone</label>
22
+ <input type="text" name="MOBILE_NO" required="" value="{{MOBILE_NO}}" {{readonly}} />
23
+ </li>
24
+
25
+
26
+ <li class="form-list__row">
27
+
28
+ {{#if check}}
29
+
30
+ <div>
31
+ <label>
32
+ Product
33
+ </label>
34
+ <input type="text" name="PRODUCT_NAME" required="" value="{{PRODUCT_NAME}}" {{readonly}} />
35
+ </div>
36
+ {{else}}
37
+ <input type="hidden" name="PRODUCT_NAME" required="" value="{{PRODUCT_NAME}}" {{readonly}} />
38
+ {{/if}}
39
+
40
+ </li>
41
+ <li class="form-list__row">
42
+
43
+ <div>
44
+ <label>
45
+ Amount
46
+ </label>
47
+ <input type="text" name="TXN_AMOUNT" required="" value="{{TXN_AMOUNT}}" {{readonly}} />
48
+ </div>
49
+
50
+ </li>
51
+
52
+ {{#if check}}
53
+
54
+ <li class="form-list__row form-list__row--agree">
55
+ <label>
56
+ <input type="checkbox" name="save_cc" checked="checked">
57
+ I agree to terms and conditions
58
+ </label>
59
+ </li>
60
+ {{/if}}
61
+
62
+ <li>
63
+ <button id="show_button" type="submit" class="button">{{BUTTON}}</button>
64
+ </li>
65
+
66
+ <script>
67
+ var button = document.getElementById('show_button')
68
+ button.addEventListener('click',hideshow,false);
69
+
70
+ function hideshow() {
71
+ document.getElementById('show_button').style.display = 'none';
72
+ }
73
+ </script>
74
+
75
+ </ul>
76
+
77
+
78
+
79
+ <input type="hidden" name="MID" value="{{MID}}" {{readonly}}>
80
+ <input type="hidden" name="WEBSITE" value="{{WEBSITE}}" {{readonly}}>
81
+ <input type="hidden" name="ORDER_ID" value="{{ORDER_ID}}" {{readonly}}>
82
+ <input type="hidden" name="CUST_ID" value="{{CUST_ID}}" {{readonly}}>
83
+ <input type="hidden" name="INDUSTRY_TYPE_ID" value="{{INDUSTRY_TYPE_ID}}" {{readonly}}>
84
+ <input type="hidden" name="CHANNEL_ID" value="{{CHANNEL_ID}}" {{readonly}}>
85
+ <input type="hidden" name="CALLBACK_URL" value="{{CALLBACK_URL}}" {{readonly}}>
86
+ <input type="hidden" name="CHECKSUMHASH" value="{{CHECKSUMHASH}}" {{readonly}}>
87
+
88
+
89
+
90
+
91
+
92
+
93
93
  </form>