/** * Client-side components and utilities for the billing plugin * These components run in the browser and have access to React hooks and client-side APIs */ 'use client' import React from 'react' // Example client component that could be used in the admin dashboard export const BillingDashboardWidget: React.FC = () => { return (

Billing Overview

Payment statistics and recent transactions will be displayed here.

) } // Client-side utilities export const formatCurrency = (amount: number, currency: string) => { return new Intl.NumberFormat('en-US', { currency: currency.toUpperCase(), style: 'currency', }).format(amount / 100) } export const getPaymentStatusColor = (status: string) => { switch (status) { case 'canceled': return 'gray' case 'failed': return 'red' case 'pending': return 'yellow' case 'succeeded': return 'green' default: return 'blue' } } // Example of a client component for payment status display export const PaymentStatusBadge: React.FC<{ status: string }> = ({ status }) => { const color = getPaymentStatusColor(status) return ( {status.toUpperCase()} ) } // Test mode indicator components export const TestModeWarningBanner: React.FC<{ visible?: boolean }> = ({ visible = true }) => { if (!visible) {return null} return (
๐Ÿงช TEST MODE - Payment system is running in test mode for development
) } export const TestModeBadge: React.FC<{ visible?: boolean }> = ({ visible = true }) => { if (!visible) {return null} return ( Test ) } export const TestPaymentControls: React.FC<{ paymentId?: string onScenarioSelect?: (scenario: string) => void onMethodSelect?: (method: string) => void }> = ({ paymentId, onScenarioSelect, onMethodSelect }) => { const [selectedScenario, setSelectedScenario] = React.useState('') const [selectedMethod, setSelectedMethod] = React.useState('') const scenarios = [ { id: 'instant-success', name: 'Instant Success', description: 'Payment succeeds immediately' }, { id: 'delayed-success', name: 'Delayed Success', description: 'Payment succeeds after delay' }, { id: 'cancelled-payment', name: 'Cancelled Payment', description: 'User cancels payment' }, { id: 'declined-payment', name: 'Declined Payment', description: 'Payment declined' }, { id: 'expired-payment', name: 'Expired Payment', description: 'Payment expires' }, { id: 'pending-payment', name: 'Pending Payment', description: 'Payment stays pending' } ] const methods = [ { id: 'ideal', name: 'iDEAL', icon: '๐Ÿฆ' }, { id: 'creditcard', name: 'Credit Card', icon: '๐Ÿ’ณ' }, { id: 'paypal', name: 'PayPal', icon: '๐Ÿ…ฟ๏ธ' }, { id: 'applepay', name: 'Apple Pay', icon: '๐ŸŽ' }, { id: 'banktransfer', name: 'Bank Transfer', icon: '๐Ÿ›๏ธ' } ] return (

๐Ÿงช Test Payment Controls

{paymentId && (
Payment ID: {paymentId}
)}
) } export default { BillingDashboardWidget, formatCurrency, getPaymentStatusColor, PaymentStatusBadge, TestModeWarningBanner, TestModeBadge, TestPaymentControls, }