forked from zopiolabs/zopio
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
📋 Task Overview
Sprint Day: Day 2 - Morning Session
Time Slot: 9:00 - 13:00 (4 hours)
Task Type: Individual Advanced Backend Development
Estimated Duration: 4 hours
Dependencies: Backend Core Services (Issue #6)
🎯 Objectives
Implement advanced backend features including OTP service with SMS integration, document upload service with Vercel Blob, dispute management system, admin dashboard backend services, and webhook handlers for payment gateway integration.
📝 Detailed Requirements
1. OTP Service Implementation (1 hour)
- Create
services/otp/OTPService.ts
:- Generate 6-digit random codes
- Store OTP with expiry (5 minutes)
- Validate OTP with attempt limits (3 max)
- Clean up expired codes automatically
- Implement SMS integration:
- Integrate with Twilio/MessageBird API
- Send SMS with template:
- Turkish: "Paylox doğrulama kodunuz: {code}"
- English: "Your Paylox verification code: {code}"
- Handle delivery failures gracefully
- Add retry mechanism for failed sends
- Build OTP API endpoints:
POST /api/otp/send
- Generate and send OTPPOST /api/otp/verify
- Validate OTP codePOST /api/otp/resend
- Resend with rate limitingGET /api/otp/status
- Check OTP status
- Add security features:
- Rate limiting (1 OTP per minute per phone)
- Blacklist suspicious numbers
- Log all OTP activities
- Implement captcha for multiple failures
2. Document Upload Service (1 hour)
- Create
services/document/DocumentService.ts
:- Handle file uploads to Vercel Blob
- Generate secure URLs with expiry
- Manage file metadata in database
- Support multiple file types
- Implement file validation:
- Allowed types: PDF, JPG, PNG, DOCX
- Max file size: 10MB per file
- Virus scanning integration prep
- Image optimization for previews
- Build document API endpoints:
POST /api/document/upload
- Handle multipart uploadsGET /api/document/[id]
- Retrieve documentDELETE /api/document/[id]
- Soft deletePOST /api/document/verify
- Mark as verified
- Add access control:
- User can only access own documents
- Admin can access all documents
- Temporary share links generation
- Audit trail for document access
3. Dispute Management System (1 hour)
- Create
services/dispute/DisputeService.ts
:- Create dispute with reason and evidence
- Assign to admin for review
- Track dispute timeline
- Handle resolution outcomes
- Implement dispute workflows:
- States: OPENED, UNDER_REVIEW, PENDING_INFO, RESOLVED, ESCALATED
- Auto-escalation after 48 hours
- Evidence submission system
- Communication thread between parties
- Build dispute API endpoints:
POST /api/dispute/create
- Raise new disputeGET /api/dispute/[id]
- Get dispute detailsPOST /api/dispute/[id]/evidence
- Submit evidencePOST /api/dispute/[id]/message
- Add messagePUT /api/dispute/[id]/resolve
- Admin resolution
- Add notification system:
- Email admin on new dispute
- Notify parties of updates
- Reminder for pending actions
- Resolution notification
4. Admin Dashboard Backend Services (1 hour)
- Create comprehensive admin APIs:
GET /api/admin/dashboard/stats
:- Total transactions (daily, weekly, monthly)
- Transaction volume in TRY
- Success/failure rates
- Average transaction time
- Active disputes count
- User growth metrics
- Implement transaction monitoring:
GET /api/admin/transactions/list
- Paginated list with filtersGET /api/admin/transactions/[id]/details
- Full transaction infoPUT /api/admin/transactions/[id]/override
- Admin actionsGET /api/admin/transactions/export
- CSV/Excel export
- Build user management APIs:
GET /api/admin/users/list
- All platform usersGET /api/admin/users/[id]
- User detailsPUT /api/admin/users/[id]/verify
- Manual verificationPUT /api/admin/users/[id]/suspend
- Suspend accountGET /api/admin/users/[id]/transactions
- User's transactions
- Add admin action logging:
- Log all admin actions with timestamp
- Track admin user ID
- Store action metadata
- Create audit report endpoint
5. Webhook Handlers Implementation (30 minutes)
- Implement Jetcheckout webhooks:
POST /api/payment/webhook/success
- Payment successPOST /api/payment/webhook/failure
- Payment failurePOST /api/payment/webhook/refund
- Refund callback
- Add webhook security:
- Signature verification
- IP whitelist validation
- Timestamp validation (5-minute window)
- Idempotency handling
- Implement webhook processing:
- Update transaction status
- Send confirmation emails
- Trigger next workflow step
- Handle edge cases
6. Performance & Integration Testing (30 minutes)
- Add caching layer:
- Redis integration for frequent queries
- Cache admin dashboard stats (5-minute TTL)
- Session storage optimization
- Implement monitoring:
- API response time tracking
- Error rate monitoring
- Database query performance
- Third-party service health checks
- Create integration tests:
- End-to-end transaction flow
- Payment webhook handling
- OTP verification flow
- Document upload process
🔧 Technical Context
SMS Service Configuration
- Primary: Twilio (production)
- Fallback: MessageBird
- Dev/Test: Console logging
- Rate limits: 100 SMS/hour per account
Document Storage Strategy
- Vercel Blob for file storage
- CDN for fast delivery
- Temporary URLs for security
- Background cleanup of orphaned files
Dispute Resolution SLA
- Initial response: 2 hours
- Resolution target: 48 hours
- Escalation: After 48 hours
- Admin notification: Immediate
Admin Dashboard Requirements
- Real-time statistics
- Export capabilities
- Audit trail
- Role-based permissions
✅ Acceptance Criteria
- OTP service sends and validates codes successfully
- Documents upload and retrieve correctly
- Disputes can be created and managed
- Admin dashboard shows accurate statistics
- Webhooks process payments correctly
- All endpoints have proper authentication
- Error handling covers all edge cases
- Performance metrics meet targets
👥 Developer Assignment
Lead Developer: @uozopio (Umut)
Role: Advanced Backend Services & Integration
Availability for Questions: Slack #dev-backend channel
This task is part of the 2-day MVP sprint for the Paylox Escrow System
Metadata
Metadata
Assignees
Labels
No labels