From 8897561fb2af322b4b37b84ac07b7746fde70586 Mon Sep 17 00:00:00 2001 From: Fringg Date: Mon, 9 Mar 2026 04:08:28 +0300 Subject: [PATCH] fix: cover all payment provider statuses in TopUpResult Add overpaid (PAL24) to PAID_STATUSES, system_fail and refund_paid (Heleket) to FAILED_STATUSES. Harmonize Balance.tsx redirect detection with the same full status sets and case-insensitive matching. --- src/pages/Balance.tsx | 32 +++++++++++++++++++++++++------- src/pages/TopUpResult.tsx | 3 +++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/pages/Balance.tsx b/src/pages/Balance.tsx index 725d9b9..d3ab517 100644 --- a/src/pages/Balance.tsx +++ b/src/pages/Balance.tsx @@ -64,14 +64,32 @@ export default function Balance() { if (paymentHandledRef.current) return; const paymentStatus = searchParams.get('payment') || searchParams.get('status'); - const isSuccess = - paymentStatus === 'success' || - paymentStatus === 'paid' || - paymentStatus === 'completed' || - searchParams.get('success') === 'true'; + const paidSet = new Set([ + 'succeeded', + 'success', + 'paid', + 'paid_over', + 'overpaid', + 'completed', + 'confirmed', + 'closed', + ]); + const failedSet = new Set([ + 'fail', + 'failed', + 'error', + 'canceled', + 'cancelled', + 'declined', + 'expired', + 'cancel', + 'system_fail', + 'refund_paid', + ]); - const isFailed = - paymentStatus === 'failed' || paymentStatus === 'error' || paymentStatus === 'canceled'; + const normalised = paymentStatus?.toLowerCase() ?? ''; + const isSuccess = paidSet.has(normalised) || searchParams.get('success') === 'true'; + const isFailed = failedSet.has(normalised); if (isSuccess) { paymentHandledRef.current = true; diff --git a/src/pages/TopUpResult.tsx b/src/pages/TopUpResult.tsx index 690f141..a0b0b35 100644 --- a/src/pages/TopUpResult.tsx +++ b/src/pages/TopUpResult.tsx @@ -183,6 +183,7 @@ const PAID_STATUSES = new Set([ 'success', 'paid', 'paid_over', + 'overpaid', 'completed', 'confirmed', 'closed', @@ -197,6 +198,8 @@ const FAILED_STATUSES = new Set([ 'declined', 'expired', 'cancel', + 'system_fail', + 'refund_paid', ]); function isPaidStatus(status: string): boolean {