node-paytmpg 7.3.6 → 7.3.9
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.
- package/dist/app/controllers/payment.controller.js +10 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -7
- package/dist/package.json +1 -1
- package/package.json +1 -1
|
@@ -695,11 +695,20 @@ class PaymentController {
|
|
|
695
695
|
console.log(`Razorpay webhook payment order=${razorpay_order_id} payid=${razorpay_payment_id} status=${status}`);
|
|
696
696
|
const reqBody = req.rawBody;
|
|
697
697
|
const signature = req.headers["x-razorpay-signature"];
|
|
698
|
+
console.log("Razorpay webhook signature:", signature);
|
|
699
|
+
console.log("Razorpay rawBody:", reqBody);
|
|
700
|
+
console.log("Razorpay SECRET:", config.SECRET);
|
|
698
701
|
if (signature === undefined) {
|
|
699
702
|
res.status(400).send({ message: "Missing Razorpay signature" });
|
|
700
703
|
return;
|
|
701
704
|
}
|
|
702
|
-
|
|
705
|
+
let signatureValid;
|
|
706
|
+
try {
|
|
707
|
+
signatureValid = razorpay_1.default.validateWebhookSignature(reqBody, signature, config.SECRET);
|
|
708
|
+
}
|
|
709
|
+
catch (e) {
|
|
710
|
+
signatureValid = false;
|
|
711
|
+
}
|
|
703
712
|
if (signatureValid) {
|
|
704
713
|
if (event === events[0]) {
|
|
705
714
|
req.body.STATUS = "TXN_SUCCESS";
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Application, RequestHandler, Router } from 'express';
|
|
|
2
2
|
import { NPCallbacks, NPConfig, NPTableNames } from './app/models';
|
|
3
3
|
import { MultiDbORM } from 'multi-db-orm';
|
|
4
4
|
export * from './app/models';
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function attachRawBodyAndEngine(app: Application, userConfig?: Partial<NPConfig>): void;
|
|
6
6
|
export declare function createPaymentMiddleware(app: Application, userConfig: NPConfig, db: MultiDbORM, callbacks?: NPCallbacks, authenticationMiddleware?: RequestHandler, tableNames?: NPTableNames): Router;
|
|
7
7
|
declare const _default: {
|
|
8
8
|
createPaymentMiddleware: typeof createPaymentMiddleware;
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.
|
|
20
|
+
exports.attachRawBodyAndEngine = attachRawBodyAndEngine;
|
|
21
21
|
exports.createPaymentMiddleware = createPaymentMiddleware;
|
|
22
22
|
const express_1 = __importDefault(require("express"));
|
|
23
23
|
const path_1 = __importDefault(require("path"));
|
|
@@ -26,7 +26,7 @@ const express_handlebars_1 = __importDefault(require("express-handlebars"));
|
|
|
26
26
|
const payment_controller_1 = require("./app/controllers/payment.controller");
|
|
27
27
|
const buildConfig_1 = require("./app/utils/buildConfig");
|
|
28
28
|
__exportStar(require("./app/models"), exports);
|
|
29
|
-
function
|
|
29
|
+
function attachRawBodyAndEngine(app, userConfig = {}) {
|
|
30
30
|
const config = (0, buildConfig_1.buildConfig)(userConfig);
|
|
31
31
|
const saveRawBody = (req, res, buf) => {
|
|
32
32
|
req.rawBody = buf && buf.toString();
|
|
@@ -47,13 +47,13 @@ function attachViewEngine(app, userConfig = {}) {
|
|
|
47
47
|
},
|
|
48
48
|
}));
|
|
49
49
|
app.set('view engine', 'handlebars');
|
|
50
|
-
app.set('
|
|
50
|
+
app.set('attachRawBodyAndEngine', true);
|
|
51
51
|
}
|
|
52
52
|
function createPaymentMiddleware(app, userConfig, db, callbacks, authenticationMiddleware, tableNames) {
|
|
53
|
-
//check
|
|
54
|
-
if (!app.get('
|
|
55
|
-
console.warn('[node-paytmpg]:
|
|
56
|
-
|
|
53
|
+
//check attachRawBodyAndEngine
|
|
54
|
+
if (!app.get('attachRawBodyAndEngine')) {
|
|
55
|
+
console.warn('[node-paytmpg]: attachRawBodyAndEngine not attached. Attaching default view engine. Either call attachRawBodyAndEngine() before createPaymentMiddleware() or ensure that your Express app has a view engine attached. req.rawBody needed for some webhooks will not be available if this is not called.');
|
|
56
|
+
attachRawBodyAndEngine(app, userConfig);
|
|
57
57
|
}
|
|
58
58
|
const config = (0, buildConfig_1.buildConfig)(userConfig);
|
|
59
59
|
const subApp = express_1.default.Router();
|
package/dist/package.json
CHANGED