WhiskyPay Development Guide
This guide provides comprehensive information for developers working on the WhiskyPay platform. It covers environment setup, development workflows, and system architecture.System Architecture
WhiskyPay consists of three main components that work together:- SDK: React components and utility functions for merchants to integrate
- Payment Gateway: Backend API and database for processing payments
- Workers: Background processing for webhooks and emails
Development Environment Setup
Prerequisites
- Node.js v16+
- npm or yarn
- Git
- Redis (for local development)
- Supabase account (or local Supabase setup)
- Solana CLI tools (optional but recommended)
Clone Repositories
SDK Setup
Payment Gateway Setup
Workers Setup
Local Development Workflow
For a complete local development environment, run all three components:- Start the Payment Gateway:
cd payment-gateway && npm run dev - Start the Workers:
cd workers && npm run dev - Start your test application that uses the SDK
Testing the End-to-End Flow
- Create a test merchant in your local database
- Use the SDK in a test app to create a payment session
- Complete a payment using a Solana wallet (Phantom in dev mode)
- Verify webhook callbacks and email notifications
Project Structure
SDK Structure
Payment Gateway Structure
Workers Structure
Data Flow
Payment Process Flow
-
Session Creation:
- Merchant creates a session via SDK
- Gateway generates a session ID and stores details in Supabase
- Session details returned to frontend
-
Payment Execution:
- Customer connects their wallet via the PaymentModal component
- SDK fetches session details from the Gateway
- Customer selects token and makes payment
- Transaction is submitted to Solana blockchain
-
Payment Verification:
- SDK sends transaction signature to Gateway for verification
- Gateway verifies the transaction on Solana
- On success, Gateway updates the database and queues jobs
-
Notifications:
- Workers process webhook notification to merchant
- Workers send confirmation emails
Deployment Guidelines
SDK Deployment
Payment Gateway Deployment
The Payment Gateway is a Next.js application that can be deployed to Vercel, Netlify, or any Node.js hosting:Workers Deployment
Workers should be deployed as a separate service:Debugging Tips
SDK Debugging
- Set
localStorage.debug = 'whiskypay:*'in the browser console to enable debug logging - Use the browser developer tools to inspect network requests and responses
- Check the console for detailed error messages
Payment Gateway Debugging
- Check the Next.js server logs for API errors
- Verify Supabase connection and queries
- Use the
/api/debugendpoint (in development) to check system status
Workers Debugging
- Check Redis connection status
- Verify job queues are being populated
- Examine worker logs for processing errors
- Use BullMQ’s API to inspect job status
Contributing Guidelines
-
Branch Management:
main: Production-ready codedevelop: Integration branch for featuresfeature/[name]: Individual features
-
Pull Request Process:
- Create feature branches from
develop - Submit PRs back to
develop - Ensure tests pass
- Follow code style guidelines
- Create feature branches from
-
Versioning:
- Follow semantic versioning (MAJOR.MINOR.PATCH)
- Document breaking changes in CHANGELOG.md