mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-11-29 15:51:52 +00:00
fix(coinpay): settle paid Hire Us checkouts from the signed webhook (#252)
The CoinPay webhook only logged. It now verifies X-CoinPay-Signature (t=,v1= over t.rawBody), reads the nested payload (data.payment_id, not the top-level event id), and records a confirmed/forwarded Hire Us payment once in hire_us_payments (payment_id primary key), mapped to the buyer via metadata.account_id/email. Unknown or pending payments are a 200 no-op. Hire Us checkout now sends property, account_id (CoinPay session) and email in metadata. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7171c2cdeb
commit
54ec1a4925
7 changed files with 292 additions and 16 deletions
28
supabase/migrations/20261021010000_hire_us_payments.sql
Normal file
28
supabase/migrations/20261021010000_hire_us_payments.sql
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
-- Settled CoinPay payments for Hire Us (metered agent-hours).
|
||||
-- Written only by the signed CoinPay webhook (/api/webhooks/coinpay) through the
|
||||
-- service-role key. payment_id is CoinPay's payment id (data.payment_id in the
|
||||
-- webhook, NOT the top-level event id), unique so a redelivered or duplicate
|
||||
-- event can never book the same purchase twice.
|
||||
|
||||
create table if not exists public.hire_us_payments (
|
||||
payment_id text primary key,
|
||||
event_id text,
|
||||
event_type text,
|
||||
status text not null,
|
||||
amount_usd numeric(12, 2),
|
||||
hours numeric(10, 2),
|
||||
rate_usd_per_hour numeric(10, 2),
|
||||
account_id text,
|
||||
buyer_email text,
|
||||
property text,
|
||||
metadata jsonb not null default '{}'::jsonb,
|
||||
paid_at timestamptz not null default now(),
|
||||
created_at timestamptz not null default now()
|
||||
);
|
||||
|
||||
create index if not exists hire_us_payments_account_idx on public.hire_us_payments (account_id);
|
||||
create index if not exists hire_us_payments_email_idx on public.hire_us_payments (buyer_email);
|
||||
|
||||
-- No policies: anon/authenticated cannot read or write; the service role bypasses RLS.
|
||||
alter table public.hire_us_payments enable row level security;
|
||||
grant all on public.hire_us_payments to service_role;
|
||||
Loading…
Add table
Add a link
Reference in a new issue