feat(registry): Square web checkout: payment links and a signed webhook that grants and revokes #15
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/square-checkout"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Phase 3 of the premium-content plan: the registry sells catalog items through Square-hosted checkout and grants entitlements from Square's webhook.
POST /api/v1/checkout(account, rate limited):{game, itemId}->{url}. Price fromcatalog_items, never the client; refuses unknown or inactive (404), owned (409), free (400); Square failure is 502. Stores a pending row insquare_checkoutskeyed by order id.POST /api/v1/webhooks/square: base64 HMAC-SHA256 of notification URL + raw body, constant-time compare, 401 otherwise. Event ids recorded insquare_eventsin the same transaction as the grant, so a replay does nothing.payment.updatedCOMPLETED with a matching amount and currency grants (sourcesquare, receipt = payment id);refund.*COMPLETED orrefunded_moneyon a payment revokes via the newrevokeByReceipt.SQUARE_ACCESS_TOKEN,SQUARE_LOCATION_ID,SQUARE_WEBHOOK_SIGNATURE_KEY,SQUARE_WEBHOOK_URL,SQUARE_ENVIRONMENT(sandbox default, bad value stops boot),SQUARE_API_BASE_URL,CHECKOUT_REDIRECT_URL. Any of the first four unset -> both routes 503.0005_square_checkout.sql.grantEntitlement, shared with the webhook.Tested against a fake Square server (
square_test.go);go vet ./...andgo test -count=1 ./...green locally. No real Square credentials yet.https://claude.ai/code/session_01BALUC4Q8G6QL3byFZR6Mhu