d138dae2ca3b928248c49e499e868804a62cf123
420Deals.ch
A premium collective buying platform for CBD in Switzerland.
Setup
Database
- Create the database using the provided SQL file:
mysql -u root -p < cbd420.sql
- Run the migration to add image support (optional but recommended):
mysql -u root -p cbd420 < migrations/add_image_url.sql
- Create a
.env.localfile in the root directory:
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=cbd420
# NOWPayments Configuration
# For testnet/sandbox testing:
NOWPAYMENTS_TESTNET=true
NOWPAYMENTS_SANDBOX_API_KEY=your_sandbox_api_key_here
NOWPAYMENTS_CURRENCY=usd # Sandbox doesn't support CHF, use USD or other supported currency
# For production:
# NOWPAYMENTS_TESTNET=false
# NOWPAYMENTS_API_KEY=your_production_api_key_here
# NOWPAYMENTS_CURRENCY=chf # Default is CHF for production
# IPN Callback URL (your external Node.js service that handles IPN callbacks)
IPN_CALLBACK_URL=http://your-ipn-service.com/api/payments/ipn-callback
# Payment Currency (crypto currency for payments, e.g. btc, eth, usdt)
# Default: btc
NOWPAYMENTS_PAY_CURRENCY=btc
# Use Fixed Rate (optional, true/false)
# If true, exchange rate is frozen for 20 minutes. Payment expires if not paid within 20 minutes.
# Default: false
NOWPAYMENTS_FIXED_RATE=false
# Base URL (use your domain in production)
NEXT_PUBLIC_BASE_URL=http://localhost:3420
Installation
npm install
Development
npm run dev
Visit http://localhost:3000 for the main site and http://localhost:3000/admin for the admin panel.
Admin Panel
Access the admin panel at /admin to:
- Create new drops
- View all drops
- Monitor drop progress and sold out status
Creating a Drop
- Navigate to
/admin - Fill in the form:
- Product Name: e.g., "Harlequin – Collective Drop"
- Batch Size: Total amount (e.g., 1000)
- Unit: Custom unit (e.g., g, kg, ml, etc.)
- Price Per Gram: Price in CHF (e.g., 2.50)
- Product Image: Optional product image upload (JPEG, PNG, WebP, max 5MB)
- Click "Create Drop"
Payment Integration (NOWPayments)
Testnet/Sandbox Setup
-
Create a Sandbox Account: Register at https://sandbox.nowpayments.io/
-
Generate Sandbox API Key:
- Log in to your sandbox dashboard
- Navigate to Settings > Payments > API keys
- Generate a test API key
-
Configure Environment Variables:
NOWPAYMENTS_TESTNET=true NOWPAYMENTS_SANDBOX_API_KEY=your_sandbox_api_key_here -
Run Pending Orders Migration:
mysql -u root -p cbd420 < migrations/create_pending_orders.sql -
Test Payments:
- Create test payments through the application
- Payments will use the sandbox environment
- No real money will be charged
Production Setup
-
Get Production API Key from NOWPayments Dashboard
-
Update Environment Variables:
NOWPAYMENTS_TESTNET=false NOWPAYMENTS_API_KEY=your_production_api_key_here NEXT_PUBLIC_BASE_URL=https://yourdomain.com
Project Structure
app/- Next.js app directoryapi/drops/- API routes for drop managementapi/payments/- Payment integration endpointsadmin/- Admin panel pagecomponents/- React components
lib/db.ts- Database connection poollib/nowpayments.ts- NOWPayments API configurationcbd420.sql- Database schemamigrations/- Database migration files
Description
Languages
TypeScript
93.1%
HTML
4.4%
CSS
2.4%