mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-12-01 09:24:46 +00:00
feat(rotation): buy automatic rotation, $29 per team per 30 days (CoinPay) (#272)
- Rotation page button + POST /api/credshare/teams/:slug/rotation/auto/checkout open a CoinPay hosted checkout (owner/admin only). - POST /api/coinpay/webhook and the page's return check settle once per checkout session (rotation_payments); paying again extends from the current end. - Hourly sweep: renewal email 3 days before, switch off when the days run out. A team switched on by hand (paid_until NULL) never expires. - Migration 012 (both dialects), CSP form-action allows coinpayportal.com. Co-authored-by: Anthony Ettinger <anthony@profullstack.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
63ecfb4ed6
commit
0cfb94e56c
12 changed files with 521 additions and 15 deletions
23
apps/pwa/src/migrations/012_auto_rotation_billing.sql
Normal file
23
apps/pwa/src/migrations/012_auto_rotation_billing.sql
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
-- Paid automatic rotation (Anthony, 2026-10-29: $29 per team per 30 days).
|
||||
--
|
||||
-- A CoinPay checkout buys 30 days of rotation_auto_approve for one team.
|
||||
-- rotation_auto_paid_until is when the paid days end: NULL means the switch was
|
||||
-- flipped by hand and never expires. The hourly sweep turns the switch off once
|
||||
-- that time passes, and emails the team's owners and admins a renewal link 3
|
||||
-- days before (rotation_auto_reminded_for = the paid_until it reminded about).
|
||||
-- rotation_payments is the idempotency ledger: one row per checkout session.
|
||||
-- Additive only.
|
||||
ALTER TABLE credshare_teams ADD COLUMN rotation_auto_paid_until INTEGER;
|
||||
ALTER TABLE credshare_teams ADD COLUMN rotation_auto_reminded_for INTEGER;
|
||||
CREATE TABLE IF NOT EXISTS rotation_payments (
|
||||
checkout_session_id TEXT PRIMARY KEY,
|
||||
payment_id TEXT,
|
||||
team_id TEXT NOT NULL REFERENCES credshare_teams(id) ON DELETE CASCADE,
|
||||
user_id TEXT,
|
||||
amount_usd REAL,
|
||||
method TEXT,
|
||||
days INTEGER NOT NULL,
|
||||
paid_until INTEGER,
|
||||
created_at INTEGER NOT NULL
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_rotation_payments_team ON rotation_payments(team_id, created_at);
|
||||
Loading…
Add table
Add a link
Reference in a new issue