node-paytmpg 7.5.14 → 7.5.16
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/adapters/open_money.d.ts +1 -1
- package/dist/app/controllers/adapters/open_money.js +1 -1
- package/dist/app/controllers/adapters/payu.d.ts +1 -1
- package/dist/app/controllers/adapters/payu.js +7 -2
- package/dist/app/controllers/payment.controller.js +5 -6
- package/dist/package.json +1 -1
- package/package.json +1 -1
|
@@ -15,7 +15,7 @@ export default class OpenMoney {
|
|
|
15
15
|
constructor(npconfig: AnyObject);
|
|
16
16
|
generatePaymentToken(params: AnyObject): Promise<AnyObject>;
|
|
17
17
|
verifyResult(req: AnyObject): Promise<AnyObject>;
|
|
18
|
-
processWebhook(req: AnyObject, res: AnyObject, updateTransaction: Function): void;
|
|
18
|
+
processWebhook(req: AnyObject, res: AnyObject, updateTransaction: Function, getOrder: Function): void;
|
|
19
19
|
getPaymentStatus(paymentTokenId: string, cb?: (data: any) => void): Promise<any>;
|
|
20
20
|
renderProcessingPage(params: AnyObject, pmttoken: AnyObject, res: AnyObject, loadingSVG: string): void;
|
|
21
21
|
renderError(params: AnyObject, error: any, res: AnyObject): void;
|
|
@@ -166,7 +166,7 @@ class OpenMoney {
|
|
|
166
166
|
}
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
|
-
processWebhook(req, res, updateTransaction) {
|
|
169
|
+
processWebhook(req, res, updateTransaction, getOrder) {
|
|
170
170
|
const config = this.config;
|
|
171
171
|
const events = ['payment_captured', 'payment_pending', 'payment_failed', 'payment_cancelled'];
|
|
172
172
|
if (req.body.event && events.indexOf(req.body.event) > -1) {
|
|
@@ -33,7 +33,7 @@ declare class PayU {
|
|
|
33
33
|
payload: Dict;
|
|
34
34
|
};
|
|
35
35
|
decodeTransactionResponse(txnDataBase64FromPayu: string): Dict;
|
|
36
|
-
verifyResult(req: PayURequestLike): Promise<Dict>;
|
|
36
|
+
verifyResult(req: PayURequestLike, _orderId?: string): Promise<Dict>;
|
|
37
37
|
getPaymentStatus(txnId: string): Promise<Dict>;
|
|
38
38
|
postCommand(command: string, transactionId: string): Promise<Dict>;
|
|
39
39
|
checkBqrTxnStatus(transactionId: string): Promise<Dict>;
|
|
@@ -99,10 +99,10 @@ class PayU {
|
|
|
99
99
|
const txnDataJson = Buffer.from(txnDataBase64FromPayu, 'base64').toString('utf-8');
|
|
100
100
|
return JSON.parse(txnDataJson);
|
|
101
101
|
}
|
|
102
|
-
async verifyResult(req) {
|
|
102
|
+
async verifyResult(req, _orderId) {
|
|
103
103
|
var _a, _b, _c;
|
|
104
104
|
const originalBody = req.body || {};
|
|
105
|
-
const lookupId = originalBody.txnid || ((_a = req.query) === null || _a === void 0 ? void 0 : _a.order_id);
|
|
105
|
+
const lookupId = (originalBody === null || originalBody === void 0 ? void 0 : originalBody.txnid) || ((_a = req.query) === null || _a === void 0 ? void 0 : _a.order_id) || _orderId;
|
|
106
106
|
const statusResp = await this.checkBqrTxnStatus(lookupId);
|
|
107
107
|
let resData = null;
|
|
108
108
|
if (!resData && statusResp && statusResp.transaction_details) {
|
|
@@ -217,6 +217,11 @@ class PayU {
|
|
|
217
217
|
return;
|
|
218
218
|
}
|
|
219
219
|
let originalOrder = await getOrder(req, orderId);
|
|
220
|
+
if (!originalOrder) {
|
|
221
|
+
console.log('PayU Webhook: Original order not found for orderId', orderId);
|
|
222
|
+
res.status(200).send({ error: 'Original order not found' });
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
220
225
|
let updatedConfig = (0, buildConfig_1.withClientConfigOverrides)(this.baseConfig, req, originalOrder);
|
|
221
226
|
this.initParams(updatedConfig);
|
|
222
227
|
const payuRest = await this.verifyResult(req);
|
|
@@ -745,7 +745,7 @@ class PaymentController {
|
|
|
745
745
|
else if (req.body.PAYMENTMODE)
|
|
746
746
|
serviceUsed = 'Paytm';
|
|
747
747
|
// https://docs.payu.in/docs/webhooks
|
|
748
|
-
else if (req.body.payment_source)
|
|
748
|
+
else if (req.body.payment_source || req.body.merchantTransactionId)
|
|
749
749
|
serviceUsed = 'PayU';
|
|
750
750
|
return serviceUsed;
|
|
751
751
|
}
|
|
@@ -819,12 +819,11 @@ class PaymentController {
|
|
|
819
819
|
}
|
|
820
820
|
return;
|
|
821
821
|
}
|
|
822
|
-
if (serviceUsed === 'PayU') {
|
|
823
|
-
payuInstance.processWebhook(req, res, this.updateTransaction, this.getOrder);
|
|
824
|
-
return;
|
|
822
|
+
else if (serviceUsed === 'PayU') {
|
|
823
|
+
await payuInstance.processWebhook(req, res, this.updateTransaction.bind(this), this.getOrder.bind(this));
|
|
825
824
|
}
|
|
826
|
-
if (serviceUsed === 'OpenMoney') {
|
|
827
|
-
openMoneyInstance.processWebhook(req, res, this.updateTransaction, this.getOrder);
|
|
825
|
+
else if (serviceUsed === 'OpenMoney') {
|
|
826
|
+
await openMoneyInstance.processWebhook(req, res, this.updateTransaction.bind(this), this.getOrder.bind(this));
|
|
828
827
|
}
|
|
829
828
|
}
|
|
830
829
|
catch (e) {
|
package/dist/package.json
CHANGED