node-paytmpg 7.5.9 → 7.5.10
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.
|
@@ -20,7 +20,7 @@ export declare class PaymentController {
|
|
|
20
20
|
private generateChecksum;
|
|
21
21
|
home(req: Request, res: Response): void | Response<any, Record<string, any>>;
|
|
22
22
|
init(req: Request, res: Response): Promise<void | Response<any, Record<string, any>>>;
|
|
23
|
-
updateTransaction(req: Request, res: Response): Promise<void>;
|
|
23
|
+
updateTransaction(req: Request, res: Response, fromWebhook?: boolean): Promise<void>;
|
|
24
24
|
private getOrder;
|
|
25
25
|
callback(req: Request, res: Response): Promise<void>;
|
|
26
26
|
getServiceUsed(req: Request, baseConfig: NPConfig): string;
|
|
@@ -505,7 +505,7 @@ class PaymentController {
|
|
|
505
505
|
});
|
|
506
506
|
}
|
|
507
507
|
}
|
|
508
|
-
async updateTransaction(req, res) {
|
|
508
|
+
async updateTransaction(req, res, fromWebhook = false) {
|
|
509
509
|
const vp = this.viewPath;
|
|
510
510
|
const callbacks = this.callbacks;
|
|
511
511
|
const orderToFind = req.body.ORDERID || req.body.ORDER_ID || req.body.ORDERId || (req.query && req.query.order_id) || req.body.ORDER_ID;
|
|
@@ -561,14 +561,19 @@ class PaymentController {
|
|
|
561
561
|
console.log("Error sending webhook to ", webhookUrl, (e === null || e === void 0 ? void 0 : e.message) || e, 'orderId:', req.body.ORDERID, 'txnId:', req.body.TXNID);
|
|
562
562
|
}
|
|
563
563
|
}
|
|
564
|
-
if (
|
|
565
|
-
|
|
566
|
-
|
|
564
|
+
if (!fromWebhook) {
|
|
565
|
+
if (returnUrl) {
|
|
566
|
+
const separator = returnUrl.indexOf('?') > -1 ? '&' : '?';
|
|
567
|
+
return res.redirect(`${returnUrl}${separator}status=${objForUpdate.status}&ORDERID=${objForUpdate.orderId}&TXNID=${objForUpdate.txnId}`);
|
|
568
|
+
}
|
|
569
|
+
(0, htmlhelper_1.renderView)(req, res, vp + "result.hbs", {
|
|
570
|
+
path_prefix: config.path_prefix,
|
|
571
|
+
...objForUpdate
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
res.send({ message: "Webhook already processed !", ORDERID: req.body.ORDERID, TXNID: req.body.TXNID, status: objForUpdate.status });
|
|
567
576
|
}
|
|
568
|
-
(0, htmlhelper_1.renderView)(req, res, vp + "result.hbs", {
|
|
569
|
-
path_prefix: config.path_prefix,
|
|
570
|
-
...objForUpdate
|
|
571
|
-
});
|
|
572
577
|
return;
|
|
573
578
|
}
|
|
574
579
|
if (req.body.status === "paid" && !req.body.STATUS)
|
|
@@ -600,15 +605,20 @@ class PaymentController {
|
|
|
600
605
|
console.log("Error sending webhook to ", webhookUrl, (e === null || e === void 0 ? void 0 : e.message) || e, 'orderId:', req.body.ORDERID, 'txnId:', req.body.TXNID);
|
|
601
606
|
}
|
|
602
607
|
}
|
|
603
|
-
if (
|
|
604
|
-
|
|
605
|
-
|
|
608
|
+
if (!fromWebhook) {
|
|
609
|
+
if (returnUrl) {
|
|
610
|
+
const separator = returnUrl.indexOf('?') > -1 ? '&' : '?';
|
|
611
|
+
return res.redirect(`${returnUrl}${separator}status=${objForUpdate.status}&ORDERID=${objForUpdate.orderId}&TXNID=${objForUpdate.txnId}`);
|
|
612
|
+
}
|
|
613
|
+
(0, htmlhelper_1.renderView)(req, res, vp + "result.hbs", {
|
|
614
|
+
theme: config.theme,
|
|
615
|
+
path_prefix: config.path_prefix,
|
|
616
|
+
...objForUpdate
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
else {
|
|
620
|
+
res.send({ message: "Transaction Updated !", ORDERID: req.body.ORDERID, TXNID: req.body.TXNID, status: objForUpdate.status });
|
|
606
621
|
}
|
|
607
|
-
(0, htmlhelper_1.renderView)(req, res, vp + "result.hbs", {
|
|
608
|
-
theme: config.theme,
|
|
609
|
-
path_prefix: config.path_prefix,
|
|
610
|
-
...objForUpdate
|
|
611
|
-
});
|
|
612
622
|
}
|
|
613
623
|
async getOrder(req = { body: {}, query: {} }, orderId) {
|
|
614
624
|
const orderToFind = orderId || req.body.ORDERID || req.body.ORDER_ID || req.body.ORDER_ID || req.body.ORDERId || req.query.ORDERID || req.query.ORDERId || req.query.ORDER_ID || req.query.order_id;
|
|
@@ -789,7 +799,7 @@ class PaymentController {
|
|
|
789
799
|
req.body.ORDERID = razorpay_order_id;
|
|
790
800
|
req.body.TXNID = razorpay_payment_id;
|
|
791
801
|
setTimeout(() => {
|
|
792
|
-
this.updateTransaction(req, res);
|
|
802
|
+
this.updateTransaction(req, res, true);
|
|
793
803
|
}, 3000);
|
|
794
804
|
}
|
|
795
805
|
else {
|
package/dist/package.json
CHANGED