feat: implement merchant dashboard, secure auth, and short_id system

- Added dedicated merchant dashboard with analytics and transactions
- Implemented API Key based authentication for merchants
- Introduced 8-character Short IDs for merchants to use in URLs
- Refactored checkout and payment intent APIs to support multi-gateway
- Enhanced Landing Page with Merchant Portal access and marketing copy
- Fixed Next.js 15 async params build issues
- Updated internal branding to P2CGateway
- Added AyrisTech credits to footer
This commit is contained in:
mstfyldz
2026-01-20 21:58:41 +03:00
parent af09543374
commit 3562e10713
46 changed files with 3505 additions and 414 deletions

View File

@@ -5,8 +5,14 @@ CREATE TABLE admin_users (
created_at TIMESTAMPTZ DEFAULT NOW()
);
-- Register initial admin (User should replace this or add via dashboard)
-- INSERT INTO admin_users (email) VALUES ('your-email@example.com');
-- Merchants (Firms) table
CREATE TABLE merchants (
id UUID DEFAULT gen_random_uuid() PRIMARY KEY,
name TEXT NOT NULL,
api_key TEXT UNIQUE DEFAULT encode(gen_random_bytes(32), 'hex'),
webhook_url TEXT,
created_at TIMESTAMPTZ DEFAULT NOW()
);
-- Transactions table
CREATE TABLE transactions (
@@ -20,18 +26,27 @@ CREATE TABLE transactions (
customer_name TEXT,
customer_phone TEXT,
callback_url TEXT,
merchant_id UUID REFERENCES merchants(id),
metadata JSONB DEFAULT '{}'::jsonb
);
-- Enable RLS
ALTER TABLE transactions ENABLE ROW LEVEL SECURITY;
ALTER TABLE merchants ENABLE ROW LEVEL SECURITY;
-- Create policy for admins to read all
CREATE POLICY "Admins can read all transactions" ON transactions
FOR SELECT
USING (auth.jwt() ->> 'email' IN (SELECT email FROM admin_users));
CREATE POLICY "Admins can manage merchants" ON merchants
USING (auth.jwt() ->> 'email' IN (SELECT email FROM admin_users));
-- Create policy for service role to manage all
CREATE POLICY "Service role can manage all" ON transactions
CREATE POLICY "Service role can manage all transactions" ON transactions
USING (true)
WITH CHECK (true);
CREATE POLICY "Service role can manage all merchants" ON merchants
USING (true)
WITH CHECK (true);