node-paytmpg 5.1.5 → 5.2.0

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.
@@ -216,6 +216,18 @@ module.exports = function (app, callbacks) {
216
216
  body.body.resultInfo &&
217
217
  body.body.resultInfo.resultStatus == "S") {
218
218
 
219
+ let paytmJsToken = {}
220
+ paytmJsToken.CALLBACK_URL = params['CALLBACK_URL']
221
+ paytmJsToken.ORDERID = params['ORDER_ID']
222
+ paytmJsToken.ORDER_ID = params['ORDER_ID']
223
+ paytmJsToken.CANCELLED = "cancelled"
224
+ paytmJsToken.TOKEN = body.body.txnToken
225
+ paytmJsToken.TXN_AMOUNT = params['TXN_AMOUNT']
226
+ paytmJsToken.MID = params['MID']
227
+ paytmJsToken.CALLBACK_URL = params['CALLBACK_URL']
228
+ paytmJsToken.CALLBACK_URL = params['CALLBACK_URL']
229
+
230
+
219
231
 
220
232
  let paytmJsCheckouHtml = `<html>
221
233
  <head>
@@ -324,6 +336,9 @@ module.exports = function (app, callbacks) {
324
336
 
325
337
  </body>
326
338
  </html>`
339
+ if (res.token) {
340
+ res.token(paytmJsToken)
341
+ }
327
342
  return res.send(paytmJsCheckouHtml)
328
343
 
329
344
  }
@@ -341,7 +356,9 @@ module.exports = function (app, callbacks) {
341
356
  form_fields += "<input type='hidden' name='" + x + "' value='" + errorResp[x] + "' >";
342
357
  }
343
358
  form_fields += "<input type='hidden' name='CHECKSUMHASH' value='" + checksum + "' >";
344
-
359
+ if (res.token) {
360
+ res.token(undefined)
361
+ }
345
362
  res.writeHead(200, { 'Content-Type': 'text/html' });
346
363
  res.write(`<html>
347
364
 
@@ -838,6 +855,66 @@ module.exports = function (app, callbacks) {
838
855
 
839
856
 
840
857
 
858
+ };
859
+
860
+ module.createTxnToken = (req, res) => {
861
+
862
+
863
+ module.createTxn(req, {
864
+ send: function (createTxnResult) {
865
+
866
+ // console.log(createTxnResult)
867
+
868
+ req.body.NAME = createTxnResult.name
869
+ req.body.EMAIL = createTxnResult.email
870
+ req.body.MOBILE_NO = createTxnResult.phone
871
+ req.body.ORDER_ID = createTxnResult.orderId
872
+ module.init(req, {
873
+ render: (renderPath, initResultRender) => {
874
+ // console.log(initResultRender)
875
+ req.body = initResultRender
876
+
877
+ module.init(req, {
878
+ send: (initResult) => {
879
+
880
+ },
881
+ status: (status) => {
882
+ console.log('status', status)
883
+
884
+ },
885
+ token: (tokenData) => {
886
+ if (!tokenData) {
887
+ res.status(500)
888
+ res.send('Something went wrong. Please try again later.')
889
+ }
890
+ else
891
+ {
892
+ tokenData.payurl = createTxnResult.payurl;
893
+ res.send(tokenData)
894
+ }
895
+ },
896
+ render: (renderPath2, init2ResultRender) => {
897
+ console.log('init2ResultRender', init2ResultRender)
898
+ },
899
+ end: (initResultWrite) => {
900
+ console.log('initResultWrite', initResultWrite)
901
+ },
902
+ write: (initResultWrite) => {
903
+ console.log('initResultWrite', initResultWrite)
904
+ },
905
+ writeHead: (initResultWriteHead) => {
906
+ console.log('initResultWriteHead', initResultWriteHead)
907
+ }
908
+
909
+ })
910
+
911
+ }
912
+ })
913
+ },
914
+ redirect: res.redirect
915
+ })
916
+
917
+
841
918
  };
842
919
 
843
920
 
@@ -65,6 +65,7 @@ module.exports = (app, express, callbacks) => {
65
65
  router.all('/callback', pc.callback)
66
66
  router.all('/api/webhook', pc.webhook)
67
67
  router.all('/api/status', pc.status)
68
+ router.all('/api/createTxn/token', pc.createTxnToken)
68
69
  router.all('/api/createTxn', pc.createTxn)
69
70
 
70
71
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-paytmpg",
3
- "version": "5.1.5",
3
+ "version": "5.2.0",
4
4
  "description": "Payment Gateway Integration using NodeJS",
5
5
  "main": "index.js",
6
6
  "scripts": {