ZeroTrade Billing Portal Setup

Last step - Create your database tables

Step 1: Go to Supabase SQL Editor

  1. Open your Supabase project: https://app.supabase.com
  2. Click SQL Editor in the left sidebar
  3. Click New Query

Step 2: Copy and Run This SQL

-- Create Products Table CREATE TABLE IF NOT EXISTS public.products ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), name TEXT NOT NULL, description TEXT, product_type TEXT NOT NULL, features JSONB, created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP ); ALTER TABLE public.products ENABLE ROW LEVEL SECURITY; CREATE POLICY "products_all" ON public.products FOR ALL USING (true); INSERT INTO public.products (name, description, product_type) VALUES ('Starter Plan', 'Basic forex trading - 1:1 leverage, 1 account, 20 pairs', 'forex'), ('Professional Plan', 'Professional trading - 1:100 leverage, 3 accounts, 80 pairs', 'forex'), ('Premium Plan', 'Premium trading - 1:500 leverage, 5 accounts, 150 pairs', 'forex') ON CONFLICT DO NOTHING; -- Create Clients Table CREATE TABLE IF NOT EXISTS public.clients ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), name TEXT NOT NULL, company TEXT NOT NULL, email TEXT NOT NULL, phone TEXT, whatsapp_number TEXT, telegram_id TEXT, product_id UUID REFERENCES public.products(id), custom_pricing DECIMAL(10,2), billing_day INTEGER DEFAULT 1, status TEXT DEFAULT 'active', created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP ); ALTER TABLE public.clients ENABLE ROW LEVEL SECURITY; CREATE POLICY "clients_all" ON public.clients FOR ALL USING (true); -- Create Invoices Table CREATE TABLE IF NOT EXISTS public.invoices ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), invoice_number TEXT NOT NULL UNIQUE, client_id UUID NOT NULL REFERENCES public.clients(id), billing_cycle_id UUID, amount DECIMAL(10,2) NOT NULL, currency TEXT DEFAULT 'USD', due_date DATE NOT NULL, status TEXT DEFAULT 'sent', created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP ); ALTER TABLE public.invoices ENABLE ROW LEVEL SECURITY; CREATE POLICY "invoices_all" ON public.invoices FOR ALL USING (true); -- Create Payments Table CREATE TABLE IF NOT EXISTS public.payments ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), invoice_id UUID NOT NULL REFERENCES public.invoices(id), amount DECIMAL(10,2) NOT NULL, payment_date DATE NOT NULL, payment_method TEXT, reference TEXT, notes TEXT, created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP ); ALTER TABLE public.payments ENABLE ROW LEVEL SECURITY; CREATE POLICY "payments_all" ON public.payments FOR ALL USING (true); -- Create Reminders Table CREATE TABLE IF NOT EXISTS public.reminders ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), invoice_id UUID NOT NULL REFERENCES public.invoices(id), client_id UUID NOT NULL REFERENCES public.clients(id), reminder_type TEXT, sent_date DATE, channels TEXT[], status TEXT DEFAULT 'pending', created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP ); ALTER TABLE public.reminders ENABLE ROW LEVEL SECURITY; CREATE POLICY "reminders_all" ON public.reminders FOR ALL USING (true);

Step 3: Execute & Redirect

  1. Paste the SQL into Supabase SQL Editor
  2. Click the green Run button
  3. Refresh this page (or click below)
Go to Dashboard

Already ran the SQL? Then your database is ready! You can now:

  • Add clients with WhatsApp & Telegram contacts
  • Create invoices with custom billing dates
  • Send reminders via Email, SMS, WhatsApp, Telegram