import { Button } from '../../../components/ui/button' import { usePaymentNavigation } from '../lib/navigation' import React from 'react' import { PaymentInstructions } from '../components/PaymentInstructions' import { CardLogosRow } from '../components/PaymentLogos' import { ensureMidtrans3ds, getCardToken, authenticate3ds } from '../lib/midtrans3ds' import { Logger } from '../../../lib/logger' import { Env } from '../../../lib/env' import { postCharge } from '../../../services/api' import { InlinePaymentStatus } from '../components/InlinePaymentStatus' import { toast } from '../../../components/ui/toast' export function CardPanel({ orderId, amount, locked, onChargeInitiated }: { orderId: string; amount: number; locked?: boolean; onChargeInitiated?: () => void }) { const nav = usePaymentNavigation() const [saveCard, setSaveCard] = React.useState(false) const [showGuide, setShowGuide] = React.useState(false) const [busy, setBusy] = React.useState(false) const [charged, setCharged] = React.useState(false) const [cardNumber, setCardNumber] = React.useState('') const [exp, setExp] = React.useState('') const [cvv, setCvv] = React.useState('') function formatCard(value: string) { const digits = value.replace(/\D/g, '') const groups = digits.match(/.{1,4}/g) return groups ? groups.join('-') : digits } function formatExp(value: string) { let digits = value.replace(/\D/g, '') if (digits.length > 4) digits = digits.slice(0, 4) if (digits.length >= 3) return `${digits.slice(0,2)}/${digits.slice(2)}` if (digits.length >= 1) return digits return '' } function formatCvv(value: string) { return value.replace(/\D/g, '').slice(0, 4) } React.useEffect(() => { ensureMidtrans3ds().catch(() => {}) }, []) return (
Kartu kredit/debit
{showGuide && } {locked && (
Metode terkunci. Lanjutkan verifikasi 3DS/OTP pada kartu Anda.
)}
{/* Status inline dengan polling otomatis */}
) }