@pandait.tech/payment-nuvei 1.1.4 → 1.1.5
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/handlers/index.cjs +25 -23
- package/dist/handlers/index.cjs.map +1 -1
- package/dist/handlers/index.js +25 -23
- package/dist/handlers/index.js.map +1 -1
- package/package.json +1 -1
package/dist/handlers/index.js
CHANGED
|
@@ -407,7 +407,7 @@ var NUVEI_ERROR_MESSAGES = {
|
|
|
407
407
|
23: "Transacci\xF3n rechazada. Intenta de nuevo m\xE1s tarde.",
|
|
408
408
|
31: "Tu banco requiere verificaci\xF3n OTP. Ingresa el c\xF3digo enviado a tu tel\xE9fono.",
|
|
409
409
|
36: "Tu banco requiere verificaci\xF3n adicional 3DS. Completa el proceso en la ventana emergente.",
|
|
410
|
-
37: "Tu banco
|
|
410
|
+
37: "Tu banco rechaz\xF3 la autenticaci\xF3n 3DS. Intenta con otra tarjeta."
|
|
411
411
|
};
|
|
412
412
|
var THREEDS_AUTH_MESSAGES = {
|
|
413
413
|
N: "Autenticaci\xF3n 3DS rechazada por tu banco. Intenta con otra tarjeta.",
|
|
@@ -894,7 +894,7 @@ function createWebhookHandler(deps) {
|
|
|
894
894
|
const finalStatuses = ["paid", "delivered", "shipped", "refunded"];
|
|
895
895
|
const statusDetail = Number(transaction.status_detail);
|
|
896
896
|
const currentStatusRaw = transaction.current_status;
|
|
897
|
-
const isPendingNotice = typeof currentStatusRaw === "string" && currentStatusRaw.toUpperCase() === "PENDING" || [1, 31, 35, 36
|
|
897
|
+
const isPendingNotice = typeof currentStatusRaw === "string" && currentStatusRaw.toUpperCase() === "PENDING" || [1, 31, 35, 36].includes(statusDetail);
|
|
898
898
|
const shouldUpdateStatus = isApproved || !isPendingNotice && !finalStatuses.includes(currentStatus);
|
|
899
899
|
const orderData = orderDoc.data() ?? {};
|
|
900
900
|
const webhookAuthCode = transaction.authorization_code;
|
|
@@ -1248,7 +1248,29 @@ function create3dsCompleteHandler(deps) {
|
|
|
1248
1248
|
const txId = verifyResult.transaction?.id ?? raw["transaction_id"] ?? transactionId;
|
|
1249
1249
|
const txAuthCode = verifyResult.transaction?.authorization_code ?? raw["authorization_code"] ?? null;
|
|
1250
1250
|
const isSuccess = (txStatus === "success" || txStatus === 1) && txStatusDetail === 3;
|
|
1251
|
-
const isStillPending = !isSuccess && (
|
|
1251
|
+
const isStillPending = !isSuccess && // 37 = "Rejected by 3DS" (doc oficial): no espera. Un 37 que llegue pendiente
|
|
1252
|
+
// sigue entrando por txStatus === "pending".
|
|
1253
|
+
(txStatusDetail === 36 || txStatus === "pending");
|
|
1254
|
+
if (!isSuccess && (txStatusDetail === 36 || txStatusDetail === 37)) {
|
|
1255
|
+
const threeDSData = verifyResult["3ds"];
|
|
1256
|
+
const challengeHtml = threeDSData?.browser_response?.challenge_request || threeDSData?.browser_response?.hidden_iframe || "";
|
|
1257
|
+
if (challengeHtml) {
|
|
1258
|
+
await db.collection("orders").doc(orderId).update({
|
|
1259
|
+
nuveiTransactionId: txId,
|
|
1260
|
+
isDeviceFingerprint: FieldValue.delete(),
|
|
1261
|
+
updatedAt: /* @__PURE__ */ new Date(),
|
|
1262
|
+
threeDSCres: FieldValue.delete()
|
|
1263
|
+
});
|
|
1264
|
+
return json({
|
|
1265
|
+
challenge: true,
|
|
1266
|
+
challengeHtml,
|
|
1267
|
+
isDeviceFingerprint: false,
|
|
1268
|
+
orderId,
|
|
1269
|
+
nuveiTransactionId: txId,
|
|
1270
|
+
statusDetail: txStatusDetail
|
|
1271
|
+
});
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1252
1274
|
if (isStillPending) {
|
|
1253
1275
|
logger.log(
|
|
1254
1276
|
`[3ds-complete] Still pending: txStatus=${txStatus} detail=${txStatusDetail}. Polling continues.`
|
|
@@ -1292,26 +1314,6 @@ function create3dsCompleteHandler(deps) {
|
|
|
1292
1314
|
orderId
|
|
1293
1315
|
});
|
|
1294
1316
|
}
|
|
1295
|
-
if (txStatusDetail === 36 || txStatusDetail === 37) {
|
|
1296
|
-
const threeDSData = verifyResult["3ds"];
|
|
1297
|
-
const challengeHtml = threeDSData?.browser_response?.challenge_request || threeDSData?.browser_response?.hidden_iframe || "";
|
|
1298
|
-
if (challengeHtml) {
|
|
1299
|
-
await db.collection("orders").doc(orderId).update({
|
|
1300
|
-
nuveiTransactionId: txId,
|
|
1301
|
-
isDeviceFingerprint: FieldValue.delete(),
|
|
1302
|
-
updatedAt: /* @__PURE__ */ new Date(),
|
|
1303
|
-
threeDSCres: FieldValue.delete()
|
|
1304
|
-
});
|
|
1305
|
-
return json({
|
|
1306
|
-
challenge: true,
|
|
1307
|
-
challengeHtml,
|
|
1308
|
-
isDeviceFingerprint: false,
|
|
1309
|
-
orderId,
|
|
1310
|
-
nuveiTransactionId: txId,
|
|
1311
|
-
statusDetail: txStatusDetail
|
|
1312
|
-
});
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
1317
|
await db.collection("orders").doc(orderId).update({
|
|
1316
1318
|
status: "failed",
|
|
1317
1319
|
chargeResponseAt: /* @__PURE__ */ new Date(),
|