'use client'; import React, { useState } from 'react'; import { Loader2, CreditCard, Lock, ShieldCheck, HelpCircle } from 'lucide-react'; import { useRouter } from 'next/navigation'; interface MockCheckoutFormProps { amount: number; currency: string; callbackUrl: string; clientSecret: string; refId?: string; } export default function MockCheckoutForm({ amount, currency, callbackUrl, clientSecret, refId }: MockCheckoutFormProps) { const router = useRouter(); const [name, setName] = useState(''); const [phone, setPhone] = useState(''); const [isLoading, setIsLoading] = useState(false); const [status, setStatus] = useState<'idle' | 'processing'>('idle'); const handleMockPayment = async (mode: 'success' | 'failed') => { if (mode === 'success' && (!name || !phone)) { alert('Lütfen ad soyad ve telefon numaranızı giriniz.'); return; } setIsLoading(true); setStatus('processing'); // Simulate API delay await new Promise(resolve => setTimeout(resolve, 2000)); if (mode === 'success') { try { await fetch('/api/mock-complete-payment', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ clientSecret, status: 'succeeded', customer_name: name, customer_phone: phone }), }); } catch (e) { console.error('Mock update fail', e); } router.push(`/checkout/success?callback_url=${encodeURIComponent(callbackUrl)}&payment_intent=${clientSecret}`); } else { alert('Ödeme başarısız (Test Modu)'); setIsLoading(false); setStatus('idle'); } }; return (

TOPLAM TUTAR

{amount.toLocaleString('tr-TR', { minimumFractionDigits: 2 })} {currency.toUpperCase() === 'TRY' || currency.toUpperCase() === 'TL' ? '₺' : currency.toUpperCase()}

{refId && (

Referans: #{refId}

)}
{/* Customer Details */}
setName(e.target.value)} className="w-full p-4 bg-gray-50 border border-gray-200 rounded-2xl text-gray-900 focus:ring-2 focus:ring-blue-500 outline-none text-sm font-bold" />
setPhone(e.target.value)} className="w-full p-4 bg-gray-50 border border-gray-200 rounded-2xl text-gray-900 focus:ring-2 focus:ring-blue-500 outline-none text-sm font-bold" />
VISA
{/* Failed scenario trigger for testing */} {process.env.NEXT_PUBLIC_USE_MOCK_PAYMENTS === 'true' && !isLoading && ( )}

256-BIT SSL ŞİFRELİ İŞLEM

Stripe GÜVENCESİYLE
PCI DSS UYUMLU
); }