Skip to content

Commit 6347134

Browse files
committed
Updated the registration and ps
1 parent e136409 commit 6347134

File tree

9 files changed

+960
-283
lines changed

9 files changed

+960
-283
lines changed

PAYMENT_INTEGRATION.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Payment Gateway Integration - Implementation Summary
2+
3+
## Changes Made
4+
5+
### 1. Registration Flow Update (`Register.tsx`)
6+
7+
#### Removed Components:
8+
- ❌ QR Code section from payment page
9+
- ❌ Payment verification form (screenshot upload, UPI reference ID, transaction ID inputs)
10+
- ❌ QrCode import from lucide-react
11+
12+
#### Updated Components:
13+
- ✅ Modified payment details layout to be centered and more compact
14+
- ✅ Updated "Complete Registration" button to redirect to payment gateway
15+
- ✅ Replaced payment verification with payment process instructions
16+
17+
#### New Functionality:
18+
-**Payment Gateway Integration**: On "Complete Registration" click, redirects to SBI Collect
19+
- URL: `https://onlinesbi.sbi.bank.in/sbicollect/icollecthome.htm?saralID=-924485972&categoryName=SRKREC-CODING%20CLUB`
20+
- Includes return URL parameter for redirect after payment
21+
-**Payment Success Handling**: Detects return from payment gateway via URL parameters
22+
-**Session Storage**: Stores registration data temporarily during payment process
23+
-**Backend Integration**: Calls payment confirmation API when user returns
24+
25+
### 2. New Payment Success Page (`PaymentSuccess.tsx`)
26+
27+
- ✅ Dedicated page for handling payment success callbacks
28+
- ✅ Loading state while processing payment confirmation
29+
- ✅ Error handling for failed payment confirmations
30+
- ✅ WhatsApp group integration for successful registrations
31+
- ✅ Clean UI matching the registration theme
32+
33+
### 3. Routing Updates (`App.tsx`)
34+
35+
- ✅ Added `/payment-success` route
36+
- ✅ Updated navbar/footer hiding logic to include payment success page
37+
- ✅ Imported PaymentSuccess component
38+
39+
### 4. API Service Enhancement (`service.ts`)
40+
41+
- ✅ Added `confirmPayment()` method for backend payment confirmation
42+
- ✅ Handles payment verification with transaction details
43+
44+
## User Flow
45+
46+
### Registration Process:
47+
1. **Step 1**: Welcome screen
48+
2. **Step 2**: Team details and problem statement selection
49+
3. **Step 3**: Payment details display
50+
4. **Complete Registration**: Redirects to SBI Collect payment gateway
51+
52+
### Payment Process:
53+
1. User completes payment on SBI Collect portal
54+
2. Payment gateway redirects back to `/payment-success?teamId=xxx&txnId=xxx`
55+
3. Frontend calls backend API to confirm payment
56+
4. Success modal shows with registration details and WhatsApp group link
57+
58+
## Technical Implementation
59+
60+
### Payment Gateway Integration:
61+
```typescript
62+
const returnUrl = `${baseUrl}/payment-success?teamId=${response.sccId}`
63+
const paymentUrl = `https://onlinesbi.sbi.bank.in/sbicollect/icollecthome.htm?saralID=-924485972&categoryName=SRKREC-CODING%20CLUB&returnUrl=${encodeURIComponent(returnUrl)}`
64+
window.location.href = paymentUrl
65+
```
66+
67+
### Payment Success Detection:
68+
```typescript
69+
const paymentStatus = searchParams.get('payment')
70+
const teamId = searchParams.get('teamId')
71+
const transactionId = searchParams.get('txnId')
72+
73+
if (paymentStatus === 'success' && teamId) {
74+
// Handle payment success
75+
await ApiService.public.confirmPayment(teamId, paymentDetails)
76+
}
77+
```
78+
79+
## Backend Requirements
80+
81+
The backend should handle:
82+
1. **Registration endpoint**: `/teams/register` (already exists)
83+
2. **Payment confirmation endpoint**: `/teams/confirm-payment` (needs implementation)
84+
85+
### Expected API Structure:
86+
```typescript
87+
POST /teams/confirm-payment
88+
{
89+
teamId: string
90+
paymentDetails: {
91+
transactionId: string
92+
paymentStatus: 'success'
93+
timestamp: string
94+
}
95+
}
96+
```
97+
98+
## Benefits
99+
100+
1. **Seamless Payment**: Users are redirected to official SBI payment portal
101+
2. **Secure Processing**: No need to handle sensitive payment data directly
102+
3. **Better UX**: Cleaner UI without complex payment verification forms
103+
4. **Automated Verification**: Backend can verify payment status automatically
104+
5. **Fallback Support**: Multiple routes handle payment success for reliability
105+
106+
## Testing Recommendations
107+
108+
1. Test payment gateway redirection
109+
2. Verify return URL handling
110+
3. Test session storage functionality
111+
4. Verify WhatsApp group integration
112+
5. Test error handling scenarios
113+
6. Verify responsive design on mobile devices
114+
115+
## Notes
116+
117+
- The payment gateway URL includes the specific `saralID` and `categoryName` as provided
118+
- Return URL handling supports both `/register` and `/payment-success` routes for flexibility
119+
- Session storage ensures registration data persists through payment process
120+
- WhatsApp group QR code functionality maintained in success modal

src/AdminStructure.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import TeamsTable from "./components/admin/teamdetails";
66
import TeamPhotos from "./components/admin/TeamPhotos";
77
import LeaderBoard from "./components/admin/LeaderBoard";
88
import Announcements from "./components/admin/announcements"
9+
import ProblemStatements from "./components/admin/ProblemStatements";
910
// import TasksPage from "./components/admin/TasksPage";
1011
import TeamTaskManagement from "./components/admin/teamtaskManagement";
1112

@@ -31,6 +32,7 @@ const AdminStructure = () => {
3132
<Route path="/team-photos" element={<TeamPhotos />} />
3233
<Route path="/leaderboard" element={<LeaderBoard />}/>
3334
<Route path="/announcements" element={<Announcements/>}/>
35+
<Route path="/problem-statements" element={<ProblemStatements/>}/>
3436
{/* <Route path="/tasks" element={<TasksPage/>}/> */}
3537
<Route path="/teamtaskmanagment" element={<TeamTaskManagement/>}/>
3638
</Routes>

src/App.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import AdminStructure from './AdminStructure'
66
import Login from './components/Login'
77
import AdminLogin from './components/AdminLogin'
88
import Register from './components/Register'
9+
import PaymentSuccess from './components/PaymentSuccess'
910
import Footer from './components/Footer'
1011
import ProblemStatements from './components/ProblemStatement'
1112
import Home from './components/Home'
@@ -19,7 +20,7 @@ import { useAuth } from './lib/hooks'
1920
function AppContent() {
2021
const location = useLocation()
2122
const { user } = useAuth()
22-
const hideNavbarFooter = ['/login', '/admin-login', '/register'].includes(location.pathname) || location.pathname.startsWith('/team') || location.pathname.startsWith('/admin/')
23+
const hideNavbarFooter = ['/login', '/admin-login', '/register', '/payment-success'].includes(location.pathname) || location.pathname.startsWith('/team') || location.pathname.startsWith('/admin/')
2324
const marginLeft = (location.pathname.startsWith("/team") || location.pathname.startsWith("/admin/")) ? "ml-[60px]" : ""
2425

2526
return (
@@ -33,6 +34,7 @@ function AppContent() {
3334
<Route path="/login" element={<Login />} />
3435
<Route path="/admin-login" element={<AdminLogin />} />
3536
<Route path="/register" element={<Register />} />
37+
<Route path="/payment-success" element={<PaymentSuccess />} />
3638
<Route path="/problem-statements" element={<ProblemStatements />} />
3739
<Route path="/schedule" element={<Schedule />} />
3840
<Route path="/teams" element={<div>Teams Page</div>} />

src/components/PaymentSuccess.tsx

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
import { useEffect, useState } from "react"
2+
import { useNavigate, useSearchParams } from "react-router-dom"
3+
import { CheckCircle, Home, MessageCircle } from "lucide-react"
4+
import Button from '@/components/ui/button'
5+
import { ApiService } from '@/lib/api/service'
6+
7+
export default function PaymentSuccess() {
8+
const navigate = useNavigate()
9+
const [searchParams] = useSearchParams()
10+
const [loading, setLoading] = useState(true)
11+
const [registrationData, setRegistrationData] = useState<{
12+
message: string
13+
sccId?: string
14+
teamName?: string
15+
} | null>(null)
16+
const [error, setError] = useState<string | null>(null)
17+
18+
useEffect(() => {
19+
const handlePaymentSuccess = async () => {
20+
try {
21+
const teamId = searchParams.get('teamId')
22+
const transactionId = searchParams.get('txnId')
23+
24+
if (!teamId) {
25+
setError("Invalid payment confirmation. Team ID not found.")
26+
setLoading(false)
27+
return
28+
}
29+
30+
// Get registration data from session storage if available
31+
const storedData = sessionStorage.getItem('registrationData')
32+
let data = null
33+
34+
if (storedData) {
35+
data = JSON.parse(storedData)
36+
sessionStorage.removeItem('registrationData')
37+
}
38+
39+
// Confirm payment with backend
40+
if (transactionId) {
41+
await ApiService.public.confirmPayment(teamId, {
42+
transactionId,
43+
paymentStatus: 'success',
44+
timestamp: new Date().toISOString()
45+
})
46+
}
47+
48+
setRegistrationData({
49+
message: data?.message || 'Your payment has been processed successfully! Your registration is now complete.',
50+
sccId: data?.sccId || teamId,
51+
teamName: data?.teamName
52+
})
53+
} catch (err) {
54+
console.error('Payment confirmation error:', err)
55+
setError("There was an issue confirming your payment. Please contact support with your transaction details.")
56+
} finally {
57+
setLoading(false)
58+
}
59+
}
60+
61+
handlePaymentSuccess()
62+
}, [searchParams])
63+
64+
if (loading) {
65+
return (
66+
<main className="min-h-screen flex items-center justify-center bg-background text-foreground">
67+
<div className="text-center">
68+
<div className="w-16 h-16 border-4 border-primary/30 border-t-primary rounded-full animate-spin mx-auto mb-4" />
69+
<p className="text-lg text-muted-foreground">Processing payment confirmation...</p>
70+
</div>
71+
</main>
72+
)
73+
}
74+
75+
if (error) {
76+
return (
77+
<main className="min-h-screen flex items-center justify-center bg-background text-foreground p-4">
78+
<div className="bg-card border border-border/50 rounded-2xl p-8 shadow-2xl max-w-lg w-full text-center">
79+
<div className="inline-flex p-4 bg-red-100 rounded-full mb-6">
80+
<div className="h-12 w-12 text-red-600 flex items-center justify-center"></div>
81+
</div>
82+
<h1 className="text-2xl font-bold text-foreground mb-4">Payment Confirmation Error</h1>
83+
<p className="text-muted-foreground mb-6">{error}</p>
84+
<Button
85+
onClick={() => navigate("/", { replace: true })}
86+
className="w-full px-6 py-3 bg-primary text-primary-foreground hover:bg-primary/90 rounded-xl font-semibold"
87+
>
88+
<Home className="h-5 w-5 mr-2" />
89+
Back to Home
90+
</Button>
91+
</div>
92+
</main>
93+
)
94+
}
95+
96+
return (
97+
<main className="min-h-screen flex items-center justify-center bg-background text-foreground p-4">
98+
<div className="bg-card border border-border/50 rounded-2xl p-8 shadow-2xl max-w-lg w-full text-center">
99+
<div className="inline-flex p-4 bg-green-100 rounded-full mb-6">
100+
<CheckCircle className="h-12 w-12 text-green-600" />
101+
</div>
102+
<h1 className="text-2xl font-bold text-foreground mb-4">Payment Successful!</h1>
103+
<div className="text-muted-foreground mb-6 space-y-3">
104+
<p>{registrationData?.message}</p>
105+
{registrationData?.sccId && (
106+
<div className="bg-primary/10 border border-primary/20 rounded-lg p-4 mt-4">
107+
<p className="text-sm text-primary font-semibold">
108+
Your SCC ID: <span className="font-mono text-lg">{registrationData.sccId}</span>
109+
</p>
110+
</div>
111+
)}
112+
{registrationData?.teamName && (
113+
<p className="text-sm text-muted-foreground">
114+
Team: <span className="font-medium">{registrationData.teamName}</span>
115+
</p>
116+
)}
117+
</div>
118+
119+
{/* WhatsApp Group Section */}
120+
<div className="bg-green-50/50 border border-green-200/50 rounded-xl p-6 mb-6">
121+
<h4 className="text-lg font-semibold text-green-800 mb-3 flex items-center justify-center gap-2">
122+
<MessageCircle className="h-5 w-5" />
123+
Join our WhatsApp Group
124+
</h4>
125+
<p className="text-sm text-green-700 mb-4">
126+
Stay updated with the latest announcements and connect with other participants!
127+
</p>
128+
129+
<Button
130+
onClick={() => window.open('https://chat.whatsapp.com/GUg1kFD0let90x7LCA3amy', '_blank')}
131+
className="w-full px-4 py-2 bg-green-600 text-white hover:bg-green-700 rounded-lg font-medium transition-all duration-300 flex items-center justify-center gap-2"
132+
>
133+
<MessageCircle className="h-4 w-4" />
134+
Join WhatsApp Group
135+
</Button>
136+
</div>
137+
138+
<Button
139+
onClick={() => navigate("/", { replace: true })}
140+
className="w-full px-6 py-3 bg-primary text-primary-foreground hover:bg-primary/90 rounded-xl font-semibold transition-all duration-300 hover:scale-[1.02] shadow-lg"
141+
>
142+
<Home className="h-5 w-5 mr-2" />
143+
Back to Home
144+
</Button>
145+
</div>
146+
</main>
147+
)
148+
}

0 commit comments

Comments
 (0)