@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.cjs
CHANGED
|
@@ -413,7 +413,7 @@ var NUVEI_ERROR_MESSAGES = {
|
|
|
413
413
|
23: "Transacci\xF3n rechazada. Intenta de nuevo m\xE1s tarde.",
|
|
414
414
|
31: "Tu banco requiere verificaci\xF3n OTP. Ingresa el c\xF3digo enviado a tu tel\xE9fono.",
|
|
415
415
|
36: "Tu banco requiere verificaci\xF3n adicional 3DS. Completa el proceso en la ventana emergente.",
|
|
416
|
-
37: "Tu banco
|
|
416
|
+
37: "Tu banco rechaz\xF3 la autenticaci\xF3n 3DS. Intenta con otra tarjeta."
|
|
417
417
|
};
|
|
418
418
|
var THREEDS_AUTH_MESSAGES = {
|
|
419
419
|
N: "Autenticaci\xF3n 3DS rechazada por tu banco. Intenta con otra tarjeta.",
|
|
@@ -900,7 +900,7 @@ function createWebhookHandler(deps) {
|
|
|
900
900
|
const finalStatuses = ["paid", "delivered", "shipped", "refunded"];
|
|
901
901
|
const statusDetail = Number(transaction.status_detail);
|
|
902
902
|
const currentStatusRaw = transaction.current_status;
|
|
903
|
-
const isPendingNotice = typeof currentStatusRaw === "string" && currentStatusRaw.toUpperCase() === "PENDING" || [1, 31, 35, 36
|
|
903
|
+
const isPendingNotice = typeof currentStatusRaw === "string" && currentStatusRaw.toUpperCase() === "PENDING" || [1, 31, 35, 36].includes(statusDetail);
|
|
904
904
|
const shouldUpdateStatus = isApproved || !isPendingNotice && !finalStatuses.includes(currentStatus);
|
|
905
905
|
const orderData = orderDoc.data() ?? {};
|
|
906
906
|
const webhookAuthCode = transaction.authorization_code;
|
|
@@ -1254,7 +1254,29 @@ function create3dsCompleteHandler(deps) {
|
|
|
1254
1254
|
const txId = verifyResult.transaction?.id ?? raw["transaction_id"] ?? transactionId;
|
|
1255
1255
|
const txAuthCode = verifyResult.transaction?.authorization_code ?? raw["authorization_code"] ?? null;
|
|
1256
1256
|
const isSuccess = (txStatus === "success" || txStatus === 1) && txStatusDetail === 3;
|
|
1257
|
-
const isStillPending = !isSuccess && (
|
|
1257
|
+
const isStillPending = !isSuccess && // 37 = "Rejected by 3DS" (doc oficial): no espera. Un 37 que llegue pendiente
|
|
1258
|
+
// sigue entrando por txStatus === "pending".
|
|
1259
|
+
(txStatusDetail === 36 || txStatus === "pending");
|
|
1260
|
+
if (!isSuccess && (txStatusDetail === 36 || txStatusDetail === 37)) {
|
|
1261
|
+
const threeDSData = verifyResult["3ds"];
|
|
1262
|
+
const challengeHtml = threeDSData?.browser_response?.challenge_request || threeDSData?.browser_response?.hidden_iframe || "";
|
|
1263
|
+
if (challengeHtml) {
|
|
1264
|
+
await db.collection("orders").doc(orderId).update({
|
|
1265
|
+
nuveiTransactionId: txId,
|
|
1266
|
+
isDeviceFingerprint: firestore.FieldValue.delete(),
|
|
1267
|
+
updatedAt: /* @__PURE__ */ new Date(),
|
|
1268
|
+
threeDSCres: firestore.FieldValue.delete()
|
|
1269
|
+
});
|
|
1270
|
+
return json({
|
|
1271
|
+
challenge: true,
|
|
1272
|
+
challengeHtml,
|
|
1273
|
+
isDeviceFingerprint: false,
|
|
1274
|
+
orderId,
|
|
1275
|
+
nuveiTransactionId: txId,
|
|
1276
|
+
statusDetail: txStatusDetail
|
|
1277
|
+
});
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1258
1280
|
if (isStillPending) {
|
|
1259
1281
|
logger.log(
|
|
1260
1282
|
`[3ds-complete] Still pending: txStatus=${txStatus} detail=${txStatusDetail}. Polling continues.`
|
|
@@ -1298,26 +1320,6 @@ function create3dsCompleteHandler(deps) {
|
|
|
1298
1320
|
orderId
|
|
1299
1321
|
});
|
|
1300
1322
|
}
|
|
1301
|
-
if (txStatusDetail === 36 || txStatusDetail === 37) {
|
|
1302
|
-
const threeDSData = verifyResult["3ds"];
|
|
1303
|
-
const challengeHtml = threeDSData?.browser_response?.challenge_request || threeDSData?.browser_response?.hidden_iframe || "";
|
|
1304
|
-
if (challengeHtml) {
|
|
1305
|
-
await db.collection("orders").doc(orderId).update({
|
|
1306
|
-
nuveiTransactionId: txId,
|
|
1307
|
-
isDeviceFingerprint: firestore.FieldValue.delete(),
|
|
1308
|
-
updatedAt: /* @__PURE__ */ new Date(),
|
|
1309
|
-
threeDSCres: firestore.FieldValue.delete()
|
|
1310
|
-
});
|
|
1311
|
-
return json({
|
|
1312
|
-
challenge: true,
|
|
1313
|
-
challengeHtml,
|
|
1314
|
-
isDeviceFingerprint: false,
|
|
1315
|
-
orderId,
|
|
1316
|
-
nuveiTransactionId: txId,
|
|
1317
|
-
statusDetail: txStatusDetail
|
|
1318
|
-
});
|
|
1319
|
-
}
|
|
1320
|
-
}
|
|
1321
1323
|
await db.collection("orders").doc(orderId).update({
|
|
1322
1324
|
status: "failed",
|
|
1323
1325
|
chargeResponseAt: /* @__PURE__ */ new Date(),
|