@pandait.tech/payment-nuvei 1.1.1 → 1.1.4
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.
|
@@ -161,6 +161,8 @@ interface NuveiWebhookPayload {
|
|
|
161
161
|
id: string;
|
|
162
162
|
status: string;
|
|
163
163
|
status_detail: number;
|
|
164
|
+
/** Desenlace en texto: APPROVED, CANCELLED, EXPIRED, REJECTED o PENDING. */
|
|
165
|
+
current_status?: string;
|
|
164
166
|
dev_reference: string;
|
|
165
167
|
amount: number;
|
|
166
168
|
authorization_code: string | null;
|
package/dist/handlers/index.d.ts
CHANGED
|
@@ -161,6 +161,8 @@ interface NuveiWebhookPayload {
|
|
|
161
161
|
id: string;
|
|
162
162
|
status: string;
|
|
163
163
|
status_detail: number;
|
|
164
|
+
/** Desenlace en texto: APPROVED, CANCELLED, EXPIRED, REJECTED o PENDING. */
|
|
165
|
+
current_status?: string;
|
|
164
166
|
dev_reference: string;
|
|
165
167
|
amount: number;
|
|
166
168
|
authorization_code: string | null;
|
package/dist/handlers/index.js
CHANGED
|
@@ -892,7 +892,10 @@ function createWebhookHandler(deps) {
|
|
|
892
892
|
const isApproved = transaction.status === "success" && transaction.status_detail === 3;
|
|
893
893
|
const currentStatus = orderDoc.data()?.status;
|
|
894
894
|
const finalStatuses = ["paid", "delivered", "shipped", "refunded"];
|
|
895
|
-
const
|
|
895
|
+
const statusDetail = Number(transaction.status_detail);
|
|
896
|
+
const currentStatusRaw = transaction.current_status;
|
|
897
|
+
const isPendingNotice = typeof currentStatusRaw === "string" && currentStatusRaw.toUpperCase() === "PENDING" || [1, 31, 35, 36, 37].includes(statusDetail);
|
|
898
|
+
const shouldUpdateStatus = isApproved || !isPendingNotice && !finalStatuses.includes(currentStatus);
|
|
896
899
|
const orderData = orderDoc.data() ?? {};
|
|
897
900
|
const webhookAuthCode = transaction.authorization_code;
|
|
898
901
|
const hasValidAuthCode = typeof webhookAuthCode === "string" && webhookAuthCode.trim().length > 0 && webhookAuthCode !== "null";
|