node-paytmpg 3.0.5 → 4.0.1

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.
@@ -0,0 +1,71 @@
1
+ # For most projects, this workflow file will not need changing; you simply need
2
+ # to commit it to your repository.
3
+ #
4
+ # You may wish to alter this file to override the set of languages analyzed,
5
+ # or to provide custom queries or build logic.
6
+ #
7
+ # ******** NOTE ********
8
+ # We have attempted to detect the languages in your repository. Please check
9
+ # the `language` matrix defined below to confirm you have the correct set of
10
+ # supported CodeQL languages.
11
+ #
12
+ name: "CodeQL"
13
+
14
+ on:
15
+ push:
16
+ branches: [ master ]
17
+ pull_request:
18
+ # The branches below must be a subset of the branches above
19
+ branches: [ master ]
20
+ schedule:
21
+ - cron: '16 23 * * 4'
22
+
23
+ jobs:
24
+ analyze:
25
+ name: Analyze
26
+ runs-on: ubuntu-latest
27
+ permissions:
28
+ actions: read
29
+ contents: read
30
+ security-events: write
31
+
32
+ strategy:
33
+ fail-fast: false
34
+ matrix:
35
+ language: [ 'javascript' ]
36
+ # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
37
+ # Learn more:
38
+ # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
39
+
40
+ steps:
41
+ - name: Checkout repository
42
+ uses: actions/checkout@v2
43
+
44
+ # Initializes the CodeQL tools for scanning.
45
+ - name: Initialize CodeQL
46
+ uses: github/codeql-action/init@v1
47
+ with:
48
+ languages: ${{ matrix.language }}
49
+ # If you wish to specify custom queries, you can do so here or in a config file.
50
+ # By default, queries listed here will override any specified in a config file.
51
+ # Prefix the list here with "+" to use these queries and those in the config file.
52
+ # queries: ./path/to/local/query, your-org/your-repo/queries@main
53
+
54
+ # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
55
+ # If this step fails, then you should remove it and run the build manually (see below)
56
+ - name: Autobuild
57
+ uses: github/codeql-action/autobuild@v1
58
+
59
+ # ℹ️ Command-line programs to run using the OS shell.
60
+ # 📚 https://git.io/JvXDl
61
+
62
+ # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
63
+ # and modify them (or add more) to build your code if your project
64
+ # uses a compiled language
65
+
66
+ #- run: |
67
+ # make bootstrap
68
+ # make release
69
+
70
+ - name: Perform CodeQL Analysis
71
+ uses: github/codeql-action/analyze@v1
package/README.MD CHANGED
@@ -1,4 +1,8 @@
1
1
  ## Node JS Payments Easy Integration
2
+
3
+ [![NPM Publish](https://github.com/shiveshnavin/node_paytm/actions/workflows/nodejs.yml/badge.svg)](https://github.com/shiveshnavin/node_paytm/actions/workflows/npm-publish.yml)
4
+ [![Node.js CI](https://github.com/shiveshnavin/node_paytm/actions/workflows/nodejs.yml/badge.svg)](https://github.com/shiveshnavin/node_paytm/actions/workflows/nodejs.yml)
5
+
2
6
  Support for :
3
7
  - Paytm
4
8
  - RazorPay
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+
3
+ var crypto = require('crypto');
4
+
5
+ class PaytmChecksum {
6
+
7
+ static encrypt(input, key) {
8
+ var cipher = crypto.createCipheriv('AES-128-CBC', key, PaytmChecksum.iv);
9
+ var encrypted = cipher.update(input, 'binary', 'base64');
10
+ encrypted += cipher.final('base64');
11
+ return encrypted;
12
+ }
13
+ static decrypt(encrypted, key) {
14
+ var decipher = crypto.createDecipheriv('AES-128-CBC', key, PaytmChecksum.iv);
15
+ var decrypted = decipher.update(encrypted, 'base64', 'binary');
16
+ try {
17
+ decrypted += decipher.final('binary');
18
+ }
19
+ catch (e) {
20
+ console.log(e);
21
+ }
22
+ return decrypted;
23
+ }
24
+ static generateSignature(params, key) {
25
+ if (typeof params !== "object" && typeof params !== "string") {
26
+ var error = "string or object expected, " + (typeof params) + " given.";
27
+ return Promise.reject(error);
28
+ }
29
+ if (typeof params !== "string"){
30
+ params = PaytmChecksum.getStringByParams(params);
31
+ }
32
+ return PaytmChecksum.generateSignatureByString(params, key);
33
+ }
34
+
35
+
36
+ static verifySignature(params, key, checksum) {
37
+ if (typeof params !== "object" && typeof params !== "string") {
38
+ var error = "string or object expected, " + (typeof params) + " given.";
39
+ return Promise.reject(error);
40
+ }
41
+ if(params.hasOwnProperty("CHECKSUMHASH")){
42
+ delete params.CHECKSUMHASH
43
+ }
44
+ if (typeof params !== "string"){
45
+ params = PaytmChecksum.getStringByParams(params);
46
+ }
47
+ return PaytmChecksum.verifySignatureByString(params, key, checksum);
48
+ }
49
+
50
+ static async generateSignatureByString(params, key) {
51
+ var salt = await PaytmChecksum.generateRandomString(4);
52
+ return PaytmChecksum.calculateChecksum(params, key, salt);
53
+ }
54
+
55
+ static verifySignatureByString(params, key, checksum) {
56
+ var paytm_hash = PaytmChecksum.decrypt(checksum, key);
57
+ var salt = paytm_hash.substr(paytm_hash.length - 4);
58
+ return (paytm_hash === PaytmChecksum.calculateHash(params, salt));
59
+ }
60
+
61
+ static generateRandomString(length) {
62
+ return new Promise(function (resolve, reject) {
63
+ crypto.randomBytes((length * 3.0) / 4.0, function (err, buf) {
64
+ if (!err) {
65
+ var salt = buf.toString("base64");
66
+ resolve(salt);
67
+ }
68
+ else {
69
+ console.log("error occurred in generateRandomString: " + err);
70
+ reject(err);
71
+ }
72
+ });
73
+ });
74
+ }
75
+
76
+ static getStringByParams(params) {
77
+ var data = {};
78
+ Object.keys(params).sort().forEach(function(key,value) {
79
+ data[key] = (params[key] !== null && params[key].toLowerCase() !== "null") ? params[key] : "";
80
+ });
81
+ return Object.values(data).join('|');
82
+ }
83
+
84
+ static calculateHash(params, salt) {
85
+ var finalString = params + "|" + salt;
86
+ return crypto.createHash('sha256').update(finalString).digest('hex') + salt;
87
+ }
88
+ static calculateChecksum(params, key, salt) {
89
+ var hashString = PaytmChecksum.calculateHash(params, salt);
90
+ return PaytmChecksum.encrypt(hashString,key);
91
+ }
92
+ }
93
+ PaytmChecksum.iv = '@@@@&&&&####$$$$';
94
+ module.exports = PaytmChecksum;
@@ -15,14 +15,17 @@ module.exports = function (app, callbacks) {
15
15
  var module = {};
16
16
  var config = (app.get('np_config'))
17
17
 
18
+ let usingMultiDbOrm = false;
18
19
  if (config.db_url) {
19
20
  User = require('../models/np_user.model.js');
21
+ usingMultiDbOrm = false;
20
22
  } else if (app.multidborm) {
21
23
  User = require('../models/np_multidbplugin.js')('npusers',app.multidborm);
22
24
  User.db=app.multidborm;
23
25
  User.modelname='npusers'
24
26
  User.idFieldName='id'
25
27
  app.NPUser = User;
28
+ usingMultiDbOrm = true;
26
29
  }
27
30
  module.create = (userData, cb) => {
28
31
 
@@ -55,7 +58,7 @@ module.exports = function (app, callbacks) {
55
58
 
56
59
  // console.log("User New : ",userData.name);
57
60
 
58
- userData.id = makeid(IDLEN);
61
+ userData.id = "user_"+makeid(IDLEN);
59
62
  var userTask = new User(userData);
60
63
  userTask.save()
61
64
  .then(user => {
@@ -69,7 +72,7 @@ module.exports = function (app, callbacks) {
69
72
 
70
73
  }
71
74
 
72
- },User);
75
+ },usingMultiDbOrm ? User : undefined);
73
76
 
74
77
  };
75
78
  return module;
@@ -5,6 +5,8 @@ var Transaction;
5
5
  var IDLEN = 10;
6
6
  var nodeBase64 = require('nodejs-base64-converter');
7
7
  var RazorPay = require('razorpay');
8
+ const PaytmChecksum = require('./checksum/PaytmChecksum.js');
9
+
8
10
 
9
11
  function sanitizeRequest(body) {
10
12
 
@@ -21,14 +23,19 @@ module.exports = function (app, callbacks) {
21
23
  if (config.razor_url)
22
24
  var razorPayInstance = new RazorPay({ key_id: config.KEY, key_secret: config.SECRET })
23
25
 
26
+ let usingMultiDbOrm = false;
24
27
  if (config.db_url) {
25
28
  Transaction = require('../models/np_transaction.model.js');
29
+ usingMultiDbOrm = false;
30
+
26
31
  } else if (app.multidborm) {
27
32
  Transaction = require('../models/np_multidbplugin.js')('nptransactions', app.multidborm);
28
33
  Transaction.db = app.multidborm;
29
34
  Transaction.modelname = 'nptransactions'
30
35
  Transaction.idFieldName = 'orderId'
31
36
  app.NPTransaction = Transaction;
37
+ usingMultiDbOrm = true;
38
+
32
39
  }
33
40
 
34
41
  var module = {};
@@ -109,24 +116,244 @@ module.exports = function (app, callbacks) {
109
116
 
110
117
  if (config.paytm_url) {
111
118
 
119
+ let initTxnbody = {
120
+ "requestType": "Payment",
121
+ "mid": params['MID'],
122
+ "websiteName": params['WEBSITE'],
123
+ "orderId": params['ORDER_ID'],
124
+ "callbackUrl": params['CALLBACK_URL'],
125
+ "txnAmount": {
126
+ "value": params['TXN_AMOUNT'],
127
+ "currency": params['CURRENCY'] || "INR",
128
+ },
129
+ "userInfo": {
130
+ "custId": params['CUST_ID'],
131
+ "mobile": params['MOBILE_NO'],
132
+ "firstName": params['NAME'],
133
+ "email": params['EMAIL']
134
+ }
135
+ };
136
+ let checksum = await PaytmChecksum.generateSignature(JSON.stringify(initTxnbody), config.KEY)
137
+ let initTxnUrl = config.paytm_url + `/theia/api/v1/initiateTransaction?mid=${params['MID']}&orderId=${params['ORDER_ID']}`;
138
+
139
+ request.post(
140
+ initTxnUrl,
141
+ {
142
+ json: {
143
+ "body": initTxnbody,
144
+ "head": {
145
+ "signature": checksum,
146
+ "channelId": params['CHANNEL_ID']
147
+ }
148
+ }
149
+ },
150
+ function (error, response, body) {
112
151
 
113
- checksum_lib.genchecksum(params, config.KEY, function (err, checksum) {
152
+ if (!error && response.statusCode != undefined
153
+ && response.statusCode != NaN &&
154
+ response.statusCode == 200 &&
155
+ body.body &&
156
+ body.body.resultInfo &&
157
+ body.body.resultInfo.resultStatus == "S") {
114
158
 
115
159
 
116
- var txn_url = config.paytm_url + "/theia/processTransaction"; // for staging
160
+ let paytmJsCheckouHtml = `<html>
161
+ <head>
162
+ <title>Merchant Checkout</title>
163
+ <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0"/>
164
+
165
+ </head>
166
+ <body>
167
+ <center>
168
+ <h1>Please donot close this page or press the back button. Processing...</h1>
169
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="margin:auto;background:#fff;display:block;" width="200px" height="200px" viewBox="0 0 100 100" preserveAspectRatio="xMidYMid">
170
+ <g transform="rotate(0 50 50)">
171
+ <rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#fe718d">
172
+ <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.9166666666666666s" repeatCount="indefinite"></animate>
173
+ </rect>
174
+ </g><g transform="rotate(30 50 50)">
175
+ <rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#fe718d">
176
+ <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.8333333333333334s" repeatCount="indefinite"></animate>
177
+ </rect>
178
+ </g><g transform="rotate(60 50 50)">
179
+ <rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#fe718d">
180
+ <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.75s" repeatCount="indefinite"></animate>
181
+ </rect>
182
+ </g><g transform="rotate(90 50 50)">
183
+ <rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#fe718d">
184
+ <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.6666666666666666s" repeatCount="indefinite"></animate>
185
+ </rect>
186
+ </g><g transform="rotate(120 50 50)">
187
+ <rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#fe718d">
188
+ <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.5833333333333334s" repeatCount="indefinite"></animate>
189
+ </rect>
190
+ </g><g transform="rotate(150 50 50)">
191
+ <rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#fe718d">
192
+ <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.5s" repeatCount="indefinite"></animate>
193
+ </rect>
194
+ </g><g transform="rotate(180 50 50)">
195
+ <rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#fe718d">
196
+ <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.4166666666666667s" repeatCount="indefinite"></animate>
197
+ </rect>
198
+ </g><g transform="rotate(210 50 50)">
199
+ <rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#fe718d">
200
+ <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.3333333333333333s" repeatCount="indefinite"></animate>
201
+ </rect>
202
+ </g><g transform="rotate(240 50 50)">
203
+ <rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#fe718d">
204
+ <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.25s" repeatCount="indefinite"></animate>
205
+ </rect>
206
+ </g><g transform="rotate(270 50 50)">
207
+ <rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#fe718d">
208
+ <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.16666666666666666s" repeatCount="indefinite"></animate>
209
+ </rect>
210
+ </g><g transform="rotate(300 50 50)">
211
+ <rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#fe718d">
212
+ <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.08333333333333333s" repeatCount="indefinite"></animate>
213
+ </rect>
214
+ </g><g transform="rotate(330 50 50)">
215
+ <rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#fe718d">
216
+ <animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="0s" repeatCount="indefinite"></animate>
217
+ </rect>
218
+ </g>
219
+ </svg>
220
+ </center>
221
+ <form id="cancelform" action="${params['CALLBACK_URL']}" method="post">
222
+ <input type="hidden" name="TXNID" value="na"/>
223
+ <input type="hidden" name="STATUS" value="TXN_FAILURE"/>
224
+ <input type="hidden" name="CANCELLED" value="cancelled"/>
225
+ <input id="RESPMSG" type="hidden" name="RESPMSG" value=""/>
226
+ <input type="hidden" name="ORDERID" value="${params["ORDER_ID"]}"/>
227
+ </form>
228
+
117
229
 
118
- // console.log(checksum)
119
- var form_fields = "";
120
- for (var x in params) {
121
- form_fields += "<input type='hidden' name='" + x + "' value='" + params[x] + "' >";
122
- }
123
- form_fields += "<input type='hidden' name='CHECKSUMHASH' value='" + checksum + "' >";
230
+ <script>
124
231
 
125
- res.writeHead(200, { 'Content-Type': 'text/html' });
126
- res.write('<html><head><title>Merchant Checkout Page</title></head><body><center><h1>Processing ! 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>');
127
- res.end();
232
+ function getBodyColor(color){
233
+ const hex = color.replace('#', '');
234
+ const c_r = parseInt(hex.substr(0, 2), 16);
235
+ const c_g = parseInt(hex.substr(2, 2), 16);
236
+ const c_b = parseInt(hex.substr(4, 2), 16);
237
+ const brightness = ((c_r * 299) + (c_g * 587) + (c_b * 114)) / 1000;
238
+ // console.log(brightness , brightness > 155 ? "#fff" : "#1a1a1c")
239
+ return brightness > 155 ? "#1a1a1c" : "#ffffff";
240
+ }
241
+
242
+ function shadeColor(color, percent) {
243
+
244
+ var R = parseInt(color.substring(1,3),16);
245
+ var G = parseInt(color.substring(3,5),16);
246
+ var B = parseInt(color.substring(5,7),16);
247
+
248
+ R = parseInt(R * (100 + percent) / 100);
249
+ G = parseInt(G * (100 + percent) / 100);
250
+ B = parseInt(B * (100 + percent) / 100);
251
+
252
+ R = (R<255)?R:255;
253
+ G = (G<255)?G:255;
254
+ B = (B<255)?B:255;
255
+
256
+ var RR = ((R.toString(16).length==1)?"0"+R.toString(16):R.toString(16));
257
+ var GG = ((G.toString(16).length==1)?"0"+G.toString(16):G.toString(16));
258
+ var BB = ((B.toString(16).length==1)?"0"+B.toString(16):B.toString(16));
259
+
260
+ return "#"+RR+GG+BB;
261
+ }
262
+
263
+ function failTxn(reason) {
264
+ var form = document.getElementById("cancelform");
265
+ var element2 = document.getElementById("RESPMSG");
266
+ element2.value=reason;
267
+ form.submit();
268
+ }
269
+ function onScriptLoad(){
270
+ var config = {
271
+ "root": "",
272
+ "flow": "DEFAULT",
273
+ "style": {
274
+ // "bodyColor": shadeColor("${config.theme_color}",+40),
275
+ "themeBackgroundColor": "${config.theme_color}",
276
+ "themeColor": getBodyColor("${config.theme_color}"),
277
+ "headerBackgroundColor": "${config.theme_color}",
278
+ "headerColor": getBodyColor("${config.theme_color}")
279
+ },
280
+ "data": {
281
+ "orderId": "${params['ORDER_ID']}", /* update order id */
282
+ "token": "${body.body.txnToken}", /* update token value */
283
+ "tokenType": "TXN_TOKEN",
284
+ "amount": "${params['TXN_AMOUNT']}" /* update amount */
285
+ },
286
+ "handler": {
287
+ "notifyMerchant": function(eventName,data){
288
+ // console.log("notifyMerchant handler function called");
289
+ // console.log("eventName => ",eventName);
290
+ // console.log("data => ",data);
291
+ if(eventName == "APP_CLOSED"){
292
+ failTxn(eventName)
293
+ }
294
+ }
295
+ }
296
+ };
297
+
298
+ if(window.Paytm && window.Paytm.CheckoutJS){
299
+ window.Paytm.CheckoutJS.onLoad(function excecuteAfterCompleteLoad() {
300
+ // initialze configuration using init method
301
+ window.Paytm.CheckoutJS.init(config).then(function onSuccess() {
302
+ // after successfully updating configuration, invoke JS Checkout
303
+ window.Paytm.CheckoutJS.invoke();
304
+ }).catch(function onError(error){
305
+ // console.log("error => ",error);
306
+ failTxn(error.message)
307
+ });
308
+ });
309
+ }
310
+ }
311
+ </script>
312
+ <script type="application/javascript" crossorigin="anonymous" src="${config.paytm_url}/merchantpgpui/checkoutjs/merchants/${params['MID']}.js" onload="onScriptLoad();" crossorigin="anonymous"></script>
313
+
314
+
315
+ </body>
316
+ </html>`
317
+ return res.send(paytmJsCheckouHtml)
318
+
319
+ }
320
+ else {
321
+ console.log('ERROR:::', error, '\n', body);
322
+ res.status(500)
323
+ var form_fields = "";
324
+ let errorResp = {
325
+ TXNID: "na",
326
+ STATUS: "TXN_FAILURE",
327
+ CANCELLED: "cancelled",
328
+ ORDERID: params["ORDER_ID"]
329
+ }
330
+ for (var x in errorResp) {
331
+ form_fields += "<input type='hidden' name='" + x + "' value='" + errorResp[x] + "' >";
332
+ }
333
+ form_fields += "<input type='hidden' name='CHECKSUMHASH' value='" + checksum + "' >";
334
+
335
+ res.writeHead(200, { 'Content-Type': 'text/html' });
336
+ res.write(`<html>
337
+
338
+ <head>
339
+ <title>Merchant Checkout Error</title>
340
+ </head>
341
+
342
+ <body>
343
+ <center>
344
+ <h1>Something went wrong. Please wait you will be redirected automatically...</h1>
345
+ </center>
346
+ <form method="post" action="${params['CALLBACK_URL']}" name="f1">${form_fields}</form>
347
+ <script type="text/javascript">document.f1.submit();</script>
348
+ </body>
349
+
350
+ </html>`);
351
+ res.end();
352
+
353
+ }
354
+ }
355
+ );
128
356
 
129
- });
130
357
  }
131
358
  else if (config.razor_url) {
132
359
 
@@ -246,7 +473,7 @@ module.exports = function (app, callbacks) {
246
473
 
247
474
  onTxn(objForUpdate);
248
475
 
249
- }, Transaction);
476
+ }, usingMultiDbOrm ? Transaction : undefined);
250
477
 
251
478
 
252
479
 
@@ -261,6 +488,7 @@ module.exports = function (app, callbacks) {
261
488
  orderId: orderId,
262
489
  cusId: user.id,
263
490
  time: Date.now(),
491
+ timeStamp: Date.now(),
264
492
  status: 'INITIATED',
265
493
  name: user.name,
266
494
  email: user.email,
@@ -282,7 +510,7 @@ module.exports = function (app, callbacks) {
282
510
 
283
511
  let orderId;
284
512
  if (config.paytm_url) {
285
- orderId = makeid(config.id_length || IDLEN)
513
+ orderId = "pay_" + makeid(config.id_length || IDLEN)
286
514
  onOrder(orderId)
287
515
  }
288
516
  else if (config.razor_url) {
@@ -354,6 +582,10 @@ module.exports = function (app, callbacks) {
354
582
  if (config.paytm_url) {
355
583
  var checksumhash = req.body.CHECKSUMHASH;
356
584
  result = checksum_lib.verifychecksum(req.body, config.KEY, checksumhash);
585
+ if (req.body.STATUS == 'TXN_FAILURE' && req.body.CANCELLED == "cancelled" && req.body.TXNID) {
586
+ isCancelled = true;
587
+ }
588
+
357
589
  }
358
590
  else if (config.razor_url) {
359
591
 
@@ -392,6 +624,9 @@ module.exports = function (app, callbacks) {
392
624
  res.send({ message: "Transaction Not Found !", ORDERID: req.body.ORDERID, TXNID: req.body.TXNID })
393
625
  return;
394
626
  }
627
+ if (req.body.status == "paid" && !req.body.STATUS) {
628
+ req.body.STATUS = "TXN_SUCCESS"
629
+ }
395
630
  objForUpdate.status = req.body.STATUS;
396
631
  objForUpdate.TXNID = req.body.TXNID;
397
632
  objForUpdate.extra = JSON.stringify(req.body);
@@ -412,7 +647,7 @@ module.exports = function (app, callbacks) {
412
647
  }
413
648
  });
414
649
 
415
- }, Transaction)
650
+ }, usingMultiDbOrm ? Transaction : undefined)
416
651
 
417
652
  }
418
653
  else {
@@ -432,7 +667,7 @@ module.exports = function (app, callbacks) {
432
667
 
433
668
  let id;
434
669
  if (config.paytm_url) {
435
- id = makeid(config.id_length || IDLEN)
670
+ id = "pay_" + makeid(config.id_length || IDLEN)
436
671
  }
437
672
  else if (config.razor_url) {
438
673
 
@@ -575,7 +810,7 @@ module.exports = function (app, callbacks) {
575
810
  }
576
811
 
577
812
 
578
- }, Transaction);
813
+ }, usingMultiDbOrm ? Transaction : undefined);
579
814
 
580
815
 
581
816
  }
@@ -54,13 +54,10 @@ module.exports = (app, express, callbacks) => {
54
54
  app.use("/" + config.path_prefix, express.static(path.join(__dirname, '../../public')));
55
55
  app.use('/' + config.path_prefix, router);
56
56
 
57
- router.all('/', function (req, res) {
58
- res.send({ message: packageInfo.description, developer: packageInfo.author, version: packageInfo.version })
59
-
60
- });
57
+ router.all('/', pc.init);
58
+ router.all('/init', pc.init);
61
59
 
62
60
  router.all('/home', pc.home)
63
- router.all('/init', pc.init)
64
61
  router.all('/callback', pc.callback)
65
62
  router.all('/api/status', pc.status)
66
63
  router.all('/api/createTxn', pc.createTxn)
@@ -7,9 +7,6 @@
7
7
  <tr>
8
8
  <td>Name</td><td>{{name}}</td>
9
9
  </tr>
10
- <tr>
11
- <td>Author</td><td><a href='https://www.linkedin.com/in/shiveshnavin/'>Shivesh Navin</a></td>
12
- </tr>
13
10
  <tr>
14
11
  <td>Version</td><td>{{version}}</td>
15
12
  </tr>
package/example.js CHANGED
@@ -24,6 +24,7 @@ app.set('np_config', {
24
24
  "INDUSTRY_TYPE_ID":"Retail",
25
25
  "homepage":"/",
26
26
  "path_prefix":"_pay",
27
+ "theme_color":"#231530",
27
28
  "db_url":MONGOURL // Remove this property in case you want to use multidborm
28
29
  });
29
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-paytmpg",
3
- "version": "3.0.5",
3
+ "version": "4.0.1",
4
4
  "description": "Payment Gateway Integration using NodeJS",
5
5
  "main": "index.js",
6
6
  "scripts": {