node-paytmpg 8.0.16 → 8.0.18

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.
@@ -72,13 +72,14 @@ class RazorpayAdapter {
72
72
  catch (e) {
73
73
  if (clientConfig && jsonBody && jsonBody.payload && jsonBody.payload.payment && jsonBody.payload.payment.entity) {
74
74
  let orderId = (_c = (_b = (_a = jsonBody === null || jsonBody === void 0 ? void 0 : jsonBody.payload) === null || _a === void 0 ? void 0 : _a.payment) === null || _b === void 0 ? void 0 : _b.entity) === null || _c === void 0 ? void 0 : _c.order_id;
75
- let captureStatusClaimed = (_f = (_e = (_d = jsonBody === null || jsonBody === void 0 ? void 0 : jsonBody.payload) === null || _d === void 0 ? void 0 : _d.payment) === null || _e === void 0 ? void 0 : _e.entity) === null || _f === void 0 ? void 0 : _f.status;
75
+ let captureStatusClaimed = ['captured', 'authorized', 'paid'].includes((_f = (_e = (_d = jsonBody === null || jsonBody === void 0 ? void 0 : jsonBody.payload) === null || _d === void 0 ? void 0 : _d.payment) === null || _e === void 0 ? void 0 : _e.entity) === null || _f === void 0 ? void 0 : _f.status);
76
76
  console.log("Error validating Razorpay signature:", e);
77
77
  if (orderId) {
78
78
  console.log("Attempting fallback validation method using GET Order", orderId);
79
79
  try {
80
80
  const orderDetails = await this.getOrder(orderId, clientConfig);
81
- if (orderDetails && orderDetails.id === orderId && orderDetails.status === captureStatusClaimed) {
81
+ const captureStatusActual = ['captured', 'authorized', 'paid'].includes(orderDetails === null || orderDetails === void 0 ? void 0 : orderDetails.status);
82
+ if (orderDetails && orderDetails.id === orderId && captureStatusActual === captureStatusClaimed) {
82
83
  console.log("Fallback validation successful for order:", orderId);
83
84
  return true;
84
85
  }
@@ -130,8 +130,8 @@ async function handleSubscriptionWebhook(req, res, db, baseConfig, tableNames, m
130
130
  time: Date.now(),
131
131
  status: 'TXN_SUCCESS',
132
132
  name: (user === null || user === void 0 ? void 0 : user.name) || '',
133
- email: paymentEntity.email || (user === null || user === void 0 ? void 0 : user.email) || '',
134
- phone: paymentEntity.contact || (user === null || user === void 0 ? void 0 : user.phone) || '',
133
+ email: (user === null || user === void 0 ? void 0 : user.email) || paymentEntity.email || '',
134
+ phone: (user === null || user === void 0 ? void 0 : user.phone) || paymentEntity.contact || '',
135
135
  amount: paymentEntity.amount / 100,
136
136
  pname: (plan === null || plan === void 0 ? void 0 : plan.name) || 'Subscription Charge',
137
137
  extra: JSON.stringify(paymentEntity),
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-paytmpg",
3
- "version": "8.0.16",
3
+ "version": "8.0.18",
4
4
  "description": "Payment Gateway Integration using NodeJS",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-paytmpg",
3
- "version": "8.0.16",
3
+ "version": "8.0.18",
4
4
  "description": "Payment Gateway Integration using NodeJS",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",