import React from 'react'; export type PaymentMethodItem = { name: string; icon_url?: string; }; export const DEFAULT_PAYMENT_METHODS: PaymentMethodItem[] = [ { name: 'Visa' }, { name: 'Mastercard' }, { name: 'RuPay' }, { name: 'UPI' }, { name: 'Razorpay' }, ]; function methodKey(name?: string): string { return String(name || '') .toLowerCase() .replace(/[^a-z0-9]+/g, ''); } const shell = 'h-8 min-w-[52px] px-2 rounded border border-gray-200 bg-white flex items-center justify-center shadow-[0_1px_2px_rgba(15,23,42,0.04)] select-none'; function VisaMark() { return (
VISA
); } function MastercardMark() { return (
); } function RuPayMark() { return (
RuPay
); } function UpiMark() { return (
UPI
); } function AmexMark() { return (
AMEX
); } function RazorpayMark() { return (
razorpay
); } function PaypalMark() { return (
PayPal
); } function GpayMark() { return (
GPay
); } function PhonePeMark() { return (
PhonePe
); } function PaytmMark() { return (
Paytm
); } function NetBankingMark() { return (
NetBank
); } function WalletMark() { return (
Wallet
); } function TextMark({ name }: { name: string }) { return (
{name}
); } export function PaymentMethodBadge({ name }: { name: string }) { const key = methodKey(name); if (key.includes('visa')) return ; if (key.includes('master') || key.includes('maestro')) return ; if (key.includes('rupay')) return ; if (key === 'upi' || key.includes('bhim')) return ; if (key.includes('amex') || key.includes('americanexpress')) return ; if (key.includes('razor')) return ; if (key.includes('paypal')) return ; if (key.includes('gpay') || key.includes('googlepay')) return ; if (key.includes('phonepe')) return ; if (key.includes('paytm')) return ; if (key.includes('netbank') || key.includes('netbanking')) return ; if (key.includes('wallet')) return ; return ; } export function PaymentMethodBadges({ methods, className = '', }: { methods?: PaymentMethodItem[] | null; className?: string; }) { const seen = new Set(); const list: PaymentMethodItem[] = []; const source = methods && methods.length > 0 ? methods : DEFAULT_PAYMENT_METHODS; for (const item of source) { const name = String(item?.name || '').trim(); if (!name) continue; const key = methodKey(name); if (seen.has(key)) continue; seen.add(key); list.push({ name }); } if (list.length === 0) { DEFAULT_PAYMENT_METHODS.forEach((item) => list.push(item)); } return (
{list.map((pm) => ( ))}
); }