|
1 | | -import React from 'react' |
| 1 | +import React, { useState } from 'react' |
| 2 | +import PaymentForm from './components/PaymentForm' |
| 3 | +import TransactionHistory from './components/TransactionHistory' |
| 4 | +import PaymentReceipt from './components/PaymentReceipt' |
2 | 5 | import './App.css' |
3 | 6 |
|
| 7 | +interface Transaction { |
| 8 | + id: string |
| 9 | + amount: number |
| 10 | + currency: string |
| 11 | + status: 'succeeded' | 'failed' | 'pending' |
| 12 | + description: string |
| 13 | + customerName: string |
| 14 | + customerEmail: string |
| 15 | + createdAt: string |
| 16 | + updatedAt: string |
| 17 | +} |
| 18 | + |
4 | 19 | function App() { |
| 20 | + const [currentView, setCurrentView] = useState<'home' | 'payment' | 'history'>('home') |
| 21 | + const [showReceipt, setShowReceipt] = useState(false) |
| 22 | + const [receiptData, setReceiptData] = useState<{ |
| 23 | + transactionId: string |
| 24 | + amount: number |
| 25 | + currency: string |
| 26 | + customerName: string |
| 27 | + customerEmail: string |
| 28 | + description: string |
| 29 | + status: 'succeeded' | 'failed' |
| 30 | + timestamp: string |
| 31 | + } | null>(null) |
| 32 | + |
| 33 | + const handlePaymentSuccess = (transactionId: string, amount: number) => { |
| 34 | + setReceiptData({ |
| 35 | + transactionId, |
| 36 | + amount, |
| 37 | + currency: 'USD', |
| 38 | + customerName: 'Customer', |
| 39 | + customerEmail: 'customer@example.com', |
| 40 | + description: 'Payment processed', |
| 41 | + status: 'succeeded', |
| 42 | + timestamp: new Date().toISOString() |
| 43 | + }) |
| 44 | + setShowReceipt(true) |
| 45 | + } |
| 46 | + |
| 47 | + const handlePaymentError = (error: string) => { |
| 48 | + setReceiptData({ |
| 49 | + transactionId: 'TXN_' + Math.random().toString(36).substr(2, 9), |
| 50 | + amount: 0, |
| 51 | + currency: 'USD', |
| 52 | + customerName: 'Customer', |
| 53 | + customerEmail: 'customer@example.com', |
| 54 | + description: 'Payment failed', |
| 55 | + status: 'failed', |
| 56 | + timestamp: new Date().toISOString() |
| 57 | + }) |
| 58 | + setShowReceipt(true) |
| 59 | + } |
| 60 | + |
| 61 | + const handleTransactionClick = (transaction: Transaction) => { |
| 62 | + setReceiptData({ |
| 63 | + transactionId: transaction.id, |
| 64 | + amount: transaction.amount, |
| 65 | + currency: transaction.currency, |
| 66 | + customerName: transaction.customerName, |
| 67 | + customerEmail: transaction.customerEmail, |
| 68 | + description: transaction.description, |
| 69 | + status: transaction.status as 'succeeded' | 'failed', |
| 70 | + timestamp: transaction.createdAt |
| 71 | + }) |
| 72 | + setShowReceipt(true) |
| 73 | + } |
| 74 | + |
| 75 | + const handleCloseReceipt = () => { |
| 76 | + setShowReceipt(false) |
| 77 | + setReceiptData(null) |
| 78 | + } |
| 79 | + |
| 80 | + const handleNewPayment = () => { |
| 81 | + setShowReceipt(false) |
| 82 | + setReceiptData(null) |
| 83 | + setCurrentView('payment') |
| 84 | + } |
| 85 | + |
| 86 | + if (showReceipt && receiptData) { |
| 87 | + return ( |
| 88 | + <PaymentReceipt |
| 89 | + {...receiptData} |
| 90 | + onClose={handleCloseReceipt} |
| 91 | + onNewPayment={handleNewPayment} |
| 92 | + /> |
| 93 | + ) |
| 94 | + } |
| 95 | + |
5 | 96 | return ( |
6 | 97 | <div className="App"> |
7 | | - <header className="App-header"> |
8 | | - <h1>🚀 StripeFlow</h1> |
9 | | - <p>Payment Integration Sandbox</p> |
10 | | - <div className="features"> |
11 | | - <div className="feature"> |
12 | | - <h3>💳 Payment Processing</h3> |
13 | | - <p>Secure payment processing with Stripe integration</p> |
14 | | - </div> |
15 | | - <div className="feature"> |
16 | | - <h3>👥 Customer Management</h3> |
17 | | - <p>Comprehensive customer management system</p> |
18 | | - </div> |
19 | | - <div className="feature"> |
20 | | - <h3>🔔 Webhook System</h3> |
21 | | - <p>Real-time event notifications and processing</p> |
22 | | - </div> |
23 | | - <div className="feature"> |
24 | | - <h3>📊 Analytics Dashboard</h3> |
25 | | - <p>Real-time insights and transaction analytics</p> |
26 | | - </div> |
27 | | - </div> |
28 | | - <div className="status"> |
29 | | - <h3>✅ Deployment Status</h3> |
30 | | - <p>GitHub Pages deployment successful!</p> |
31 | | - <p>Frontend is now live and accessible.</p> |
| 98 | + <nav className="app-nav"> |
| 99 | + <div className="nav-brand"> |
| 100 | + <h1>🚀 StripeFlow</h1> |
32 | 101 | </div> |
33 | | - <div className="links"> |
34 | | - <a href="https://github.com/atheendre130505/stripe-flow" target="_blank" rel="noopener noreferrer"> |
35 | | - View on GitHub |
36 | | - </a> |
37 | | - <a href="https://github.com/atheendre130505/stripe-flow/blob/main/README.md" target="_blank" rel="noopener noreferrer"> |
38 | | - Documentation |
39 | | - </a> |
| 102 | + <div className="nav-links"> |
| 103 | + <button |
| 104 | + className={currentView === 'home' ? 'active' : ''} |
| 105 | + onClick={() => setCurrentView('home')} |
| 106 | + > |
| 107 | + Home |
| 108 | + </button> |
| 109 | + <button |
| 110 | + className={currentView === 'payment' ? 'active' : ''} |
| 111 | + onClick={() => setCurrentView('payment')} |
| 112 | + > |
| 113 | + Process Payment |
| 114 | + </button> |
| 115 | + <button |
| 116 | + className={currentView === 'history' ? 'active' : ''} |
| 117 | + onClick={() => setCurrentView('history')} |
| 118 | + > |
| 119 | + Transaction History |
| 120 | + </button> |
40 | 121 | </div> |
41 | | - </header> |
| 122 | + </nav> |
| 123 | + |
| 124 | + <main className="app-main"> |
| 125 | + {currentView === 'home' && ( |
| 126 | + <div className="home-content"> |
| 127 | + <div className="hero-section"> |
| 128 | + <h2>Payment Integration Sandbox</h2> |
| 129 | + <p>A production-ready payment processing platform with comprehensive features for modern e-commerce.</p> |
| 130 | + </div> |
| 131 | + |
| 132 | + <div className="features"> |
| 133 | + <div className="feature"> |
| 134 | + <h3>💳 Payment Processing</h3> |
| 135 | + <p>Secure payment processing with Stripe integration</p> |
| 136 | + <button onClick={() => setCurrentView('payment')} className="feature-button"> |
| 137 | + Process Payment |
| 138 | + </button> |
| 139 | + </div> |
| 140 | + <div className="feature"> |
| 141 | + <h3>👥 Customer Management</h3> |
| 142 | + <p>Comprehensive customer management system</p> |
| 143 | + </div> |
| 144 | + <div className="feature"> |
| 145 | + <h3>🔔 Webhook System</h3> |
| 146 | + <p>Real-time event notifications and processing</p> |
| 147 | + </div> |
| 148 | + <div className="feature"> |
| 149 | + <h3>📊 Analytics Dashboard</h3> |
| 150 | + <p>Real-time insights and transaction analytics</p> |
| 151 | + <button onClick={() => setCurrentView('history')} className="feature-button"> |
| 152 | + View Transactions |
| 153 | + </button> |
| 154 | + </div> |
| 155 | + </div> |
| 156 | + |
| 157 | + <div className="status"> |
| 158 | + <h3>✅ Deployment Status</h3> |
| 159 | + <p>GitHub Pages deployment successful!</p> |
| 160 | + <p>Frontend is now live and accessible.</p> |
| 161 | + </div> |
| 162 | + |
| 163 | + <div className="links"> |
| 164 | + <a href="https://github.com/atheendre130505/stripe-flow" target="_blank" rel="noopener noreferrer"> |
| 165 | + View on GitHub |
| 166 | + </a> |
| 167 | + <a href="https://github.com/atheendre130505/stripe-flow/blob/main/README.md" target="_blank" rel="noopener noreferrer"> |
| 168 | + Documentation |
| 169 | + </a> |
| 170 | + </div> |
| 171 | + </div> |
| 172 | + )} |
| 173 | + |
| 174 | + {currentView === 'payment' && ( |
| 175 | + <PaymentForm |
| 176 | + onPaymentSuccess={handlePaymentSuccess} |
| 177 | + onPaymentError={handlePaymentError} |
| 178 | + /> |
| 179 | + )} |
| 180 | + |
| 181 | + {currentView === 'history' && ( |
| 182 | + <TransactionHistory |
| 183 | + onTransactionClick={handleTransactionClick} |
| 184 | + /> |
| 185 | + )} |
| 186 | + </main> |
42 | 187 | </div> |
43 | 188 | ) |
44 | 189 | } |
|
0 commit comments