node-paytmpg 5.1.0 → 5.1.4
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.
|
@@ -23,7 +23,7 @@ class OpenMoney {
|
|
|
23
23
|
"currency": params['CURRENCY'] || "INR",
|
|
24
24
|
"name": params['NAME'],
|
|
25
25
|
"email_id": params['EMAIL'],
|
|
26
|
-
"contact_number": params['MOBILE_NO'],
|
|
26
|
+
"contact_number": ("" + params['MOBILE_NO']).replace("+91", ""),
|
|
27
27
|
"mtx": params['ORDER_ID']
|
|
28
28
|
}
|
|
29
29
|
create_payment_token(open_txn,
|
|
@@ -185,7 +185,7 @@ class OpenMoney {
|
|
|
185
185
|
processWebhook(req, res, updateTransaction) {
|
|
186
186
|
let config = this.config;
|
|
187
187
|
let events = [
|
|
188
|
-
"payment_captured", "payment_pending",
|
|
188
|
+
"payment_captured", "payment_pending",
|
|
189
189
|
"payment_failed",
|
|
190
190
|
"payment_cancelled"]
|
|
191
191
|
if (req.body.event && events.indexOf(req.body.event) > -1) {
|
|
@@ -224,7 +224,7 @@ class OpenMoney {
|
|
|
224
224
|
req.body.TXNID = paymentid;
|
|
225
225
|
}
|
|
226
226
|
else {
|
|
227
|
-
let status = ""
|
|
227
|
+
let status = "INITIATED"
|
|
228
228
|
if (payment_data.status == "captured" ||
|
|
229
229
|
payment_data.status == "late_authorized") {
|
|
230
230
|
status = 'TXN_SUCCESS'
|
|
@@ -232,17 +232,17 @@ class OpenMoney {
|
|
|
232
232
|
else if (payment_data.status == "pending") {
|
|
233
233
|
status = 'TXN_PENDING'
|
|
234
234
|
}
|
|
235
|
-
else {
|
|
236
|
-
|
|
237
|
-
}
|
|
235
|
+
// else {
|
|
236
|
+
// status = 'TXN_FAILURE'
|
|
237
|
+
// }
|
|
238
238
|
|
|
239
239
|
if (status != 'TXN_SUCCESS') {
|
|
240
240
|
if (req.body.status == "paid" || req.body.status == 'captured') {
|
|
241
241
|
status = 'TXN_SUCCESS'
|
|
242
242
|
}
|
|
243
|
-
else if (req.body.status == 'failed') {
|
|
244
|
-
|
|
245
|
-
}
|
|
243
|
+
// else if (req.body.status == 'failed') {
|
|
244
|
+
// status = 'TXN_FAILURE'
|
|
245
|
+
// }
|
|
246
246
|
else if (req.body.status == 'pending') {
|
|
247
247
|
status = 'TXN_PENDING'
|
|
248
248
|
}
|
|
@@ -282,11 +282,11 @@ class OpenMoney {
|
|
|
282
282
|
})
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
-
renderProcessingPage(params, pmttoken, res) {
|
|
285
|
+
renderProcessingPage(params, pmttoken, res, loadingSVG) {
|
|
286
286
|
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
287
287
|
res.write(`<html><head><title>Merchant Checkout Page</title>
|
|
288
288
|
<script src="${this.config.script_url}"></script>
|
|
289
|
-
</head><body><center><h1>Processing ! Please do not refresh this page...</h1><br>${pmttoken.html}<br
|
|
289
|
+
</head><body><center><h1>Processing ! Please do not refresh this page...</h1><br>${pmttoken.html}<br><br>${loadingSVG}</center><script>triggerLayer();</script></body></html>`);
|
|
290
290
|
res.end();
|
|
291
291
|
}
|
|
292
292
|
|
|
@@ -10,6 +10,57 @@ const PaytmChecksum = require('./checksum/PaytmChecksum.js');
|
|
|
10
10
|
const { stat } = require('fs');
|
|
11
11
|
const { config } = require('process');
|
|
12
12
|
|
|
13
|
+
let loadingSVG = ` <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">
|
|
14
|
+
<g transform="rotate(0 50 50)">
|
|
15
|
+
<rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#0097a7">
|
|
16
|
+
<animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.9166666666666666s" repeatCount="indefinite"></animate>
|
|
17
|
+
</rect>
|
|
18
|
+
</g><g transform="rotate(30 50 50)">
|
|
19
|
+
<rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#0097a7">
|
|
20
|
+
<animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.8333333333333334s" repeatCount="indefinite"></animate>
|
|
21
|
+
</rect>
|
|
22
|
+
</g><g transform="rotate(60 50 50)">
|
|
23
|
+
<rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#0097a7">
|
|
24
|
+
<animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.75s" repeatCount="indefinite"></animate>
|
|
25
|
+
</rect>
|
|
26
|
+
</g><g transform="rotate(90 50 50)">
|
|
27
|
+
<rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#0097a7">
|
|
28
|
+
<animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.6666666666666666s" repeatCount="indefinite"></animate>
|
|
29
|
+
</rect>
|
|
30
|
+
</g><g transform="rotate(120 50 50)">
|
|
31
|
+
<rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#0097a7">
|
|
32
|
+
<animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.5833333333333334s" repeatCount="indefinite"></animate>
|
|
33
|
+
</rect>
|
|
34
|
+
</g><g transform="rotate(150 50 50)">
|
|
35
|
+
<rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#0097a7">
|
|
36
|
+
<animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.5s" repeatCount="indefinite"></animate>
|
|
37
|
+
</rect>
|
|
38
|
+
</g><g transform="rotate(180 50 50)">
|
|
39
|
+
<rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#0097a7">
|
|
40
|
+
<animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.4166666666666667s" repeatCount="indefinite"></animate>
|
|
41
|
+
</rect>
|
|
42
|
+
</g><g transform="rotate(210 50 50)">
|
|
43
|
+
<rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#0097a7">
|
|
44
|
+
<animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.3333333333333333s" repeatCount="indefinite"></animate>
|
|
45
|
+
</rect>
|
|
46
|
+
</g><g transform="rotate(240 50 50)">
|
|
47
|
+
<rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#0097a7">
|
|
48
|
+
<animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.25s" repeatCount="indefinite"></animate>
|
|
49
|
+
</rect>
|
|
50
|
+
</g><g transform="rotate(270 50 50)">
|
|
51
|
+
<rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#0097a7">
|
|
52
|
+
<animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.16666666666666666s" repeatCount="indefinite"></animate>
|
|
53
|
+
</rect>
|
|
54
|
+
</g><g transform="rotate(300 50 50)">
|
|
55
|
+
<rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#0097a7">
|
|
56
|
+
<animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.08333333333333333s" repeatCount="indefinite"></animate>
|
|
57
|
+
</rect>
|
|
58
|
+
</g><g transform="rotate(330 50 50)">
|
|
59
|
+
<rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#0097a7">
|
|
60
|
+
<animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="0s" repeatCount="indefinite"></animate>
|
|
61
|
+
</rect>
|
|
62
|
+
</g>
|
|
63
|
+
</svg>`
|
|
13
64
|
|
|
14
65
|
function sanitizeRequest(body) {
|
|
15
66
|
|
|
@@ -175,57 +226,7 @@ module.exports = function (app, callbacks) {
|
|
|
175
226
|
<body>
|
|
176
227
|
<center>
|
|
177
228
|
<h1>Please donot close this page or press the back button. Processing...</h1>
|
|
178
|
-
|
|
179
|
-
<g transform="rotate(0 50 50)">
|
|
180
|
-
<rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#fe718d">
|
|
181
|
-
<animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.9166666666666666s" repeatCount="indefinite"></animate>
|
|
182
|
-
</rect>
|
|
183
|
-
</g><g transform="rotate(30 50 50)">
|
|
184
|
-
<rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#fe718d">
|
|
185
|
-
<animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.8333333333333334s" repeatCount="indefinite"></animate>
|
|
186
|
-
</rect>
|
|
187
|
-
</g><g transform="rotate(60 50 50)">
|
|
188
|
-
<rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#fe718d">
|
|
189
|
-
<animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.75s" repeatCount="indefinite"></animate>
|
|
190
|
-
</rect>
|
|
191
|
-
</g><g transform="rotate(90 50 50)">
|
|
192
|
-
<rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#fe718d">
|
|
193
|
-
<animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.6666666666666666s" repeatCount="indefinite"></animate>
|
|
194
|
-
</rect>
|
|
195
|
-
</g><g transform="rotate(120 50 50)">
|
|
196
|
-
<rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#fe718d">
|
|
197
|
-
<animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.5833333333333334s" repeatCount="indefinite"></animate>
|
|
198
|
-
</rect>
|
|
199
|
-
</g><g transform="rotate(150 50 50)">
|
|
200
|
-
<rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#fe718d">
|
|
201
|
-
<animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.5s" repeatCount="indefinite"></animate>
|
|
202
|
-
</rect>
|
|
203
|
-
</g><g transform="rotate(180 50 50)">
|
|
204
|
-
<rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#fe718d">
|
|
205
|
-
<animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.4166666666666667s" repeatCount="indefinite"></animate>
|
|
206
|
-
</rect>
|
|
207
|
-
</g><g transform="rotate(210 50 50)">
|
|
208
|
-
<rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#fe718d">
|
|
209
|
-
<animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.3333333333333333s" repeatCount="indefinite"></animate>
|
|
210
|
-
</rect>
|
|
211
|
-
</g><g transform="rotate(240 50 50)">
|
|
212
|
-
<rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#fe718d">
|
|
213
|
-
<animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.25s" repeatCount="indefinite"></animate>
|
|
214
|
-
</rect>
|
|
215
|
-
</g><g transform="rotate(270 50 50)">
|
|
216
|
-
<rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#fe718d">
|
|
217
|
-
<animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.16666666666666666s" repeatCount="indefinite"></animate>
|
|
218
|
-
</rect>
|
|
219
|
-
</g><g transform="rotate(300 50 50)">
|
|
220
|
-
<rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#fe718d">
|
|
221
|
-
<animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="-0.08333333333333333s" repeatCount="indefinite"></animate>
|
|
222
|
-
</rect>
|
|
223
|
-
</g><g transform="rotate(330 50 50)">
|
|
224
|
-
<rect x="47" y="24" rx="3" ry="6" width="6" height="12" fill="#fe718d">
|
|
225
|
-
<animate attributeName="opacity" values="1;0" keyTimes="0;1" dur="1s" begin="0s" repeatCount="indefinite"></animate>
|
|
226
|
-
</rect>
|
|
227
|
-
</g>
|
|
228
|
-
</svg>
|
|
229
|
+
${loadingSVG}
|
|
229
230
|
</center>
|
|
230
231
|
<form id="cancelform" action="${params['CALLBACK_URL']}" method="post">
|
|
231
232
|
<input type="hidden" name="TXNID" value="na"/>
|
|
@@ -404,14 +405,14 @@ module.exports = function (app, callbacks) {
|
|
|
404
405
|
</script>`;
|
|
405
406
|
|
|
406
407
|
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
407
|
-
res.write(`<html><head><title>Merchant Checkout Page</title></head><body><center><h1>Processing ! Please do not refresh this page...</h1><br>${html}<br>${fail}</center></body></html>`);
|
|
408
|
+
res.write(`<html><head><title>Merchant Checkout Page</title></head><body><center><h1>Processing ! Please do not refresh this page...</h1><br>${html}<br>${fail}<br>${loadingSVG}</center></body></html>`);
|
|
408
409
|
res.end();
|
|
409
410
|
|
|
410
411
|
}
|
|
411
412
|
else if (config.open_money_url) {
|
|
412
413
|
try {
|
|
413
414
|
let pmttoken = await openMoneyInstance.generatePaymentToken(params);
|
|
414
|
-
openMoneyInstance.renderProcessingPage(params, pmttoken, res);
|
|
415
|
+
openMoneyInstance.renderProcessingPage(params, pmttoken, res, loadingSVG);
|
|
415
416
|
|
|
416
417
|
var myquery = { orderId: params['ORDER_ID'] };
|
|
417
418
|
Transaction.findOne(myquery, function (err, objForUpdate) {
|
|
@@ -794,6 +795,9 @@ module.exports = function (app, callbacks) {
|
|
|
794
795
|
let order = await razorPayInstance.orders.create(options);
|
|
795
796
|
id = order.id;
|
|
796
797
|
}
|
|
798
|
+
else if (config.open_money_url) {
|
|
799
|
+
id = "pay_" + makeid(config.id_length || IDLEN)
|
|
800
|
+
}
|
|
797
801
|
|
|
798
802
|
var txnTask = new Transaction({
|
|
799
803
|
id: id,
|
|
@@ -940,11 +944,11 @@ module.exports = function (app, callbacks) {
|
|
|
940
944
|
result.TXNID = result.id
|
|
941
945
|
onStatusUpdate(result)
|
|
942
946
|
}
|
|
943
|
-
else if (result.status == 'failed' || result.status == 'cancelled') {
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
}
|
|
947
|
+
// else if (result.status == 'failed' || result.status == 'cancelled') {
|
|
948
|
+
// result.STATUS = 'TXN_FAILED'
|
|
949
|
+
// result.TXNID = result.id
|
|
950
|
+
// onStatusUpdate(result)
|
|
951
|
+
// }
|
|
948
952
|
else {
|
|
949
953
|
res.send(orderData);
|
|
950
954
|
}
|
package/app/views/init.hbs
CHANGED
|
@@ -60,8 +60,18 @@
|
|
|
60
60
|
{{/if}}
|
|
61
61
|
|
|
62
62
|
<li>
|
|
63
|
-
<button type="submit" class="button">{{BUTTON}}</button>
|
|
63
|
+
<button id="show_button" type="submit" class="button">{{BUTTON}}</button>
|
|
64
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
|
+
|
|
65
75
|
</ul>
|
|
66
76
|
|
|
67
77
|
|