@pandait.tech/payment-nuvei 1.1.2 → 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
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.",
|
|
@@ -899,8 +899,9 @@ function createWebhookHandler(deps) {
|
|
|
899
899
|
const currentStatus = orderDoc.data()?.status;
|
|
900
900
|
const finalStatuses = ["paid", "delivered", "shipped", "refunded"];
|
|
901
901
|
const statusDetail = Number(transaction.status_detail);
|
|
902
|
-
const
|
|
903
|
-
const
|
|
902
|
+
const currentStatusRaw = transaction.current_status;
|
|
903
|
+
const isPendingNotice = typeof currentStatusRaw === "string" && currentStatusRaw.toUpperCase() === "PENDING" || [1, 31, 35, 36].includes(statusDetail);
|
|
904
|
+
const shouldUpdateStatus = isApproved || !isPendingNotice && !finalStatuses.includes(currentStatus);
|
|
904
905
|
const orderData = orderDoc.data() ?? {};
|
|
905
906
|
const webhookAuthCode = transaction.authorization_code;
|
|
906
907
|
const hasValidAuthCode = typeof webhookAuthCode === "string" && webhookAuthCode.trim().length > 0 && webhookAuthCode !== "null";
|
|
@@ -1253,7 +1254,29 @@ function create3dsCompleteHandler(deps) {
|
|
|
1253
1254
|
const txId = verifyResult.transaction?.id ?? raw["transaction_id"] ?? transactionId;
|
|
1254
1255
|
const txAuthCode = verifyResult.transaction?.authorization_code ?? raw["authorization_code"] ?? null;
|
|
1255
1256
|
const isSuccess = (txStatus === "success" || txStatus === 1) && txStatusDetail === 3;
|
|
1256
|
-
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
|
+
}
|
|
1257
1280
|
if (isStillPending) {
|
|
1258
1281
|
logger.log(
|
|
1259
1282
|
`[3ds-complete] Still pending: txStatus=${txStatus} detail=${txStatusDetail}. Polling continues.`
|
|
@@ -1297,26 +1320,6 @@ function create3dsCompleteHandler(deps) {
|
|
|
1297
1320
|
orderId
|
|
1298
1321
|
});
|
|
1299
1322
|
}
|
|
1300
|
-
if (txStatusDetail === 36 || txStatusDetail === 37) {
|
|
1301
|
-
const threeDSData = verifyResult["3ds"];
|
|
1302
|
-
const challengeHtml = threeDSData?.browser_response?.challenge_request || threeDSData?.browser_response?.hidden_iframe || "";
|
|
1303
|
-
if (challengeHtml) {
|
|
1304
|
-
await db.collection("orders").doc(orderId).update({
|
|
1305
|
-
nuveiTransactionId: txId,
|
|
1306
|
-
isDeviceFingerprint: firestore.FieldValue.delete(),
|
|
1307
|
-
updatedAt: /* @__PURE__ */ new Date(),
|
|
1308
|
-
threeDSCres: firestore.FieldValue.delete()
|
|
1309
|
-
});
|
|
1310
|
-
return json({
|
|
1311
|
-
challenge: true,
|
|
1312
|
-
challengeHtml,
|
|
1313
|
-
isDeviceFingerprint: false,
|
|
1314
|
-
orderId,
|
|
1315
|
-
nuveiTransactionId: txId,
|
|
1316
|
-
statusDetail: txStatusDetail
|
|
1317
|
-
});
|
|
1318
|
-
}
|
|
1319
|
-
}
|
|
1320
1323
|
await db.collection("orders").doc(orderId).update({
|
|
1321
1324
|
status: "failed",
|
|
1322
1325
|
chargeResponseAt: /* @__PURE__ */ new Date(),
|