Files
corrosion-admin-panel/backend/migrations/010_payment_orders.sql
Vantz Stockwell 6c2436dfc6
All checks were successful
Test Asgard Runner / test (push) Successful in 2s
feat: Phase 4 module auto-installation + Phase 5 webstore backend
Phase 4 Contributions (Agent Golf):
- Module auto-installation service (module_installer.rs)
- NATS subject pattern for module installation commands
- Companion agent contract documentation
- API endpoint: POST /api/modules/install

Phase 5 XO Direct Touch:
- Webstore subscription API (PayPal recurring billing)
  * POST /api/webstore/subscription/create
  * GET /api/webstore/subscription
  * POST /api/webstore/subscription/cancel
  * POST /api/webstore/subscription/webhook
- Store configuration API (CRUD for store settings)
  * GET /api/webstore/config
  * PUT /api/webstore/config
- Store category/item management APIs (multi-tenant CRUD)
  * GET/POST/PUT/DELETE /api/webstore/categories
  * GET/POST/PUT/DELETE /api/webstore/items
- Public store API (customer-facing, subdomain-scoped)
  * GET /api/public-store/:subdomain
  * GET /api/public-store/:subdomain/items
  * POST /api/public-store/:subdomain/purchase
  * POST /api/public-store/:subdomain/webhook
- Transaction history API
  * GET /api/webstore/transactions
- Delivery system (NATS command execution on purchase)
- Migrations: payment_orders, webstore_subscriptions, store_config, store_items, store_transactions

Security:
- JWT auth + license_id scoping on admin endpoints
- Subdomain → license_id mapping on public endpoints
- Purchase limit enforcement
- Command injection prevention via placeholder replacement

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-15 14:53:53 -05:00

24 lines
1.1 KiB
SQL

-- Payment order tracking for PayPal transactions
CREATE TABLE IF NOT EXISTS payment_orders (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
order_id VARCHAR(255) UNIQUE NOT NULL, -- PayPal order ID
module_id UUID REFERENCES modules(id) ON DELETE SET NULL, -- For module purchases
webstore_subscription_id UUID REFERENCES licenses(id) ON DELETE SET NULL, -- For Phase 5
license_id UUID NOT NULL REFERENCES licenses(id) ON DELETE CASCADE,
amount DECIMAL(10,2) NOT NULL,
currency VARCHAR(3) DEFAULT 'USD',
status VARCHAR(50) NOT NULL, -- 'pending', 'completed', 'failed', 'refunded'
transaction_id VARCHAR(255), -- PayPal transaction/capture ID
payer_email VARCHAR(255),
created_at TIMESTAMPTZ DEFAULT NOW(),
completed_at TIMESTAMPTZ,
metadata JSONB -- Additional payment details
);
CREATE INDEX idx_payment_orders_license ON payment_orders(license_id);
CREATE INDEX idx_payment_orders_status ON payment_orders(status);
CREATE INDEX idx_payment_orders_order_id ON payment_orders(order_id);
COMMENT ON TABLE payment_orders IS 'PayPal payment tracking for module purchases and webstore subscriptions';