diff --git a/web/dashboard/messages/ar.json b/web/dashboard/messages/ar.json index 34ec2cf..e74b5af 100644 --- a/web/dashboard/messages/ar.json +++ b/web/dashboard/messages/ar.json @@ -1019,7 +1019,8 @@ "total": "المبلغ المستحق", "secureNote": "تتم المعالجة عبر بوابة دفع بنكية آمنة.", "payTotal": "ادفع {total}", - "redirecting": "جارٍ التحويل إلى البوابة..." + "redirecting": "جارٍ التحويل إلى البوابة...", + "paymentFailed": "فشل الدفع. الرجاء المحاولة مرة أخرى." } }, "settings": { diff --git a/web/dashboard/messages/en.json b/web/dashboard/messages/en.json index 2b05dce..a2340cd 100644 --- a/web/dashboard/messages/en.json +++ b/web/dashboard/messages/en.json @@ -1091,7 +1091,8 @@ "total": "Amount due", "secureNote": "Payment is processed through a secure bank gateway.", "payTotal": "Pay {total}", - "redirecting": "Redirecting to gateway..." + "redirecting": "Redirecting to gateway...", + "paymentFailed": "Payment failed. Please try again." } }, "settings": { diff --git a/web/dashboard/messages/fa.json b/web/dashboard/messages/fa.json index d45317e..5debd4c 100644 --- a/web/dashboard/messages/fa.json +++ b/web/dashboard/messages/fa.json @@ -1092,7 +1092,8 @@ "total": "مبلغ قابل پرداخت", "secureNote": "پرداخت از طریق درگاه امن بانکی انجام می‌شود.", "payTotal": "پرداخت {total}", - "redirecting": "در حال انتقال به درگاه..." + "redirecting": "در حال انتقال به درگاه...", + "paymentFailed": "پرداخت ناموفق بود. لطفاً دوباره امتحان کنید." } }, "settings": { diff --git a/web/dashboard/src/components/subscription/checkout-screen.tsx b/web/dashboard/src/components/subscription/checkout-screen.tsx index c54cb00..aae4297 100644 --- a/web/dashboard/src/components/subscription/checkout-screen.tsx +++ b/web/dashboard/src/components/subscription/checkout-screen.tsx @@ -46,6 +46,7 @@ export function CheckoutScreen() { const [months, setMonths] = useState(1); const [paymentMethod, setPaymentMethod] = useState(""); + const [payError, setPayError] = useState(null); const numberLocale = typeof document !== "undefined" && document.documentElement.lang === "en" @@ -76,8 +77,13 @@ export function CheckoutScreen() { mutationFn: (body: { planTier: string; months: number; paymentMethod: string }) => apiPost("/api/billing/subscribe", body), onSuccess: (data) => { + setPayError(null); window.location.href = data.paymentUrl; }, + onError: (err: unknown) => { + const msg = err instanceof Error ? err.message : String(err); + setPayError(msg || tc("paymentFailed")); + }, }); if (!cafeId) return null; @@ -255,10 +261,15 @@ export function CheckoutScreen() { {/* Pay action */}
-

- - {tc("secureNote")} -

+
+

+ + {tc("secureNote")} +

+ {payError && ( +

{payError}

+ )} +