mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-11-29 15:51:52 +00:00
feat(hire-us): CoinPay hosted checkout sessions for Hire Us (#254)
Some checks failed
CI / build (push) Has been cancelled
Deploy to dev2 / deploy (push) Has been cancelled
test / test (push) Has been cancelled
Some checks failed
CI / build (push) Has been cancelled
Deploy to dev2 / deploy (push) Has been cancelled
test / test (push) Has been cancelled
POST /api/hire-us/coinpay-checkout now opens a CoinPay checkout session instead of a single-chain USDC_POL /api/payments/create. The buyer picks any coin the business has a wallet for, or PayPal. Each session sends customer_email (required), account_id (CoinPay OAuth sub when signed in, else the buyer email for guests), property logicsrc.com and the Hire Us metadata. The cs_ id is recorded in the new hire_us_checkouts table. The webhook records session payments from the session fields (checkout_session_id, account_id, customer_email, property), stores the session id on hire_us_payments, marks the checkout paid, and stays idempotent on payment_id across confirmed, forwarded and replays. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
5192684de9
commit
580817b06f
6 changed files with 341 additions and 215 deletions
26
supabase/migrations/20261021020000_hire_us_checkouts.sql
Normal file
26
supabase/migrations/20261021020000_hire_us_checkouts.sql
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
-- CoinPay hosted checkout sessions opened for Hire Us (metered agent-hours).
|
||||
-- One row per cs_ session, written when the session opens; the signed webhook
|
||||
-- marks it paid. Settled payments stay in hire_us_payments (one row per CoinPay
|
||||
-- payment id), which now also carries the session id.
|
||||
|
||||
create table if not exists public.hire_us_checkouts (
|
||||
session_id text primary key, -- CoinPay checkout session id (cs_...)
|
||||
account_id text not null, -- CoinPay account (OAuth sub) or the buyer email for guests
|
||||
buyer_email text not null,
|
||||
hours numeric(10, 2) not null,
|
||||
rate_usd_per_hour numeric(10, 2) not null,
|
||||
amount_usd numeric(12, 2) not null,
|
||||
status text not null default 'open' check (status in ('open', 'paid', 'expired')),
|
||||
payment_id text,
|
||||
created_at timestamptz not null default now(),
|
||||
paid_at timestamptz
|
||||
);
|
||||
|
||||
create index if not exists hire_us_checkouts_account_idx on public.hire_us_checkouts (account_id);
|
||||
|
||||
alter table public.hire_us_payments add column if not exists checkout_session_id text;
|
||||
create index if not exists hire_us_payments_session_idx on public.hire_us_payments (checkout_session_id);
|
||||
|
||||
-- No policies: anon/authenticated cannot read or write; the service role bypasses RLS.
|
||||
alter table public.hire_us_checkouts enable row level security;
|
||||
grant all on public.hire_us_checkouts to service_role;
|
||||
Loading…
Add table
Add a link
Reference in a new issue