node-paytmpg 8.0.10 → 8.0.12
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.
|
@@ -881,16 +881,19 @@ class PaymentController {
|
|
|
881
881
|
const signature = req.headers["x-razorpay-signature"];
|
|
882
882
|
console.log("Razorpay webhook signature:", signature);
|
|
883
883
|
if (signature === undefined) {
|
|
884
|
+
console.log("Razorpay webhook missing signature");
|
|
884
885
|
res.status(200).send({ message: "Missing Razorpay signature" });
|
|
885
886
|
return;
|
|
886
887
|
}
|
|
887
888
|
let signatureValid;
|
|
889
|
+
const razorPayInstance = this.getProviderInstance(serviceUsed, config);
|
|
888
890
|
try {
|
|
889
|
-
signatureValid =
|
|
891
|
+
signatureValid = await razorPayInstance.validateWebhookSignature(reqBody, signature, config.SECRET, req.body, config);
|
|
890
892
|
}
|
|
891
893
|
catch (e) {
|
|
892
894
|
signatureValid = false;
|
|
893
895
|
}
|
|
896
|
+
console.log("Razorpay webhook signature valid:", signatureValid);
|
|
894
897
|
if (signatureValid) {
|
|
895
898
|
if (event === events[0]) {
|
|
896
899
|
req.body.STATUS = "TXN_SUCCESS";
|
|
@@ -908,10 +911,12 @@ class PaymentController {
|
|
|
908
911
|
}, 3000);
|
|
909
912
|
}
|
|
910
913
|
else {
|
|
914
|
+
console.log("Razorpay webhook invalid signature");
|
|
911
915
|
res.status(200).send({ message: "Invalid Rzpay signature" });
|
|
912
916
|
}
|
|
913
917
|
}
|
|
914
918
|
else {
|
|
919
|
+
console.log("Razorpay webhook invalid payload");
|
|
915
920
|
res.status(200).send({ message: "Invalid Payload" });
|
|
916
921
|
}
|
|
917
922
|
}
|
|
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.handleSubscriptionWebhook = handleSubscriptionWebhook;
|
|
7
|
-
const razorpay_1 = __importDefault(require("razorpay"));
|
|
8
7
|
const axios_1 = __importDefault(require("axios"));
|
|
9
8
|
const buildConfig_1 = require("../utils/buildConfig");
|
|
9
|
+
const razorpay_1 = require("./adapters/razorpay");
|
|
10
10
|
async function handleSubscriptionWebhook(req, res, db, baseConfig, tableNames, makeid) {
|
|
11
11
|
var _a;
|
|
12
12
|
const event = req.body.event;
|
|
@@ -30,9 +30,10 @@ async function handleSubscriptionWebhook(req, res, db, baseConfig, tableNames, m
|
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
const clientConf = (0, buildConfig_1.withClientConfigOverrides)(baseConfig, req, { clientId: sub.clientId });
|
|
33
|
+
const razorPayInstance = new razorpay_1.RazorpayAdapter();
|
|
33
34
|
let signatureValid;
|
|
34
35
|
try {
|
|
35
|
-
signatureValid =
|
|
36
|
+
signatureValid = await razorPayInstance.validateWebhookSignature(reqBody, signature, config.SECRET, jsonBody, clientConf);
|
|
36
37
|
}
|
|
37
38
|
catch (e) {
|
|
38
39
|
signatureValid = false;
|
package/dist/package.json
CHANGED