feat(payment): implement Zibal IPG payment gateway integration, admin merchant configuration and verification page
Deploy Canina / deploy (push) Successful in 3m28s

This commit is contained in:
parsa aghaei committed 2026-08-16 11:40:24 +03:30
1 parent 03900e726a
commit 8992060cb7
94 files changed
+53456 -29275

No files matched your search

@@ -26,6 +26,7 @@ import SearchableSelect from "./SearchableSelect";
import { IRAN_PROVINCES, PROVINCE_CITIES } from "../lib/data/provinces";
import { toast } from "sonner";
import { useRouter } from 'next/navigation';
import api from "../lib/services/api";
export default function CheckoutPage() {
const router = useRouter();
@@ -146,6 +147,28 @@ export default function CheckoutPage() {
shippingAddress: shippingAddressStr
});
// 3. Handle Online Payment via Zibal IPG
if (paymentMethod === 'online') {
try {
const res = await api.post('/payment/zibal/initiate', { orderId });
if (res.data?.paymentUrl) {
toast.success("در حال انتقال به درگاه پرداخت زیبال...");
window.location.href = res.data.paymentUrl;
return;
} else {
toast.error("خطا در ایجاد تراکنش پرداخت زیبال");
}
} catch (gatewayErr: any) {
const errMsg =
gatewayErr.response?.data?.message ||
gatewayErr.message ||
"خطا در اتصال به درگاه پرداخت زیبال";
toast.error(errMsg);
router.push(`/checkout/success/${orderId}`);
return;
}
}
// Re-fetch user profile from backend to sync PostgreSQL wallet balance and charity donation total
const { fetchProfile } = useUserStore.getState();
await fetchProfile();
@@ -420,10 +443,10 @@ export default function CheckoutPage() {
},
{
id: 'online',
label: getText('PAY_GATEWAY_ONLINE_LABEL', 'درگاه پرداخت آنلاین (شتاب)'),
desc: getText('PAY_GATEWAY_ONLINE_DESC', 'پرداخت مستقیم با کلیه کارت‌های شتاب'),
label: getText('PAY_GATEWAY_ONLINE_LABEL', 'درگاه پرداخت اینترنتی (زیبال / شتاب)'),
desc: getText('PAY_GATEWAY_ONLINE_DESC', 'پرداخت امن و آنی با کلیه کارت‌های عضو شتاب'),
icon: <ShieldCheck className="w-5 h-5 sm:w-6 sm:h-6" />,
enabled: getText('PAY_GATEWAY_ONLINE_ENABLE', 'false') === 'true'
enabled: getText('PAY_GATEWAY_ONLINE_ENABLE', 'true') === 'true'
},
{
id: 'cod',