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:
Anthony Ettinger 2026-10-21 05:02:09 -07:00 • committed by GitHub
parent 7171c2cdeb
commit 54ec1a4925
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 292 additions and 16 deletions

View file

@ -199,6 +199,8 @@ describe("POST /api/hire-us/coinpay-checkout", () => {
hours: 10,
rate_usd_per_hour: 400,
source: "logicsrc.com/hire-us",
property: "logicsrc.com",
email: "buyer@example.com",
buyer_email: "buyer@example.com"
}
});
@ -556,6 +558,7 @@ describe("POST /api/webhooks/coinpay", () => {
const body = await response.json();
expect(response.status).toBe(200);
expect(body).toEqual({ received: true, complete: true, payment_id: "pay_123" });
// No Hire Us metadata: acknowledged as a handled no-op, nothing recorded.
expect(body).toEqual({ received: true, handled: true, settled: false, reason: "unknown payment", payment_id: "pay_123" });
});
});