Imported from nikhea/rallya (
internal/payment/AGENTS.md). Install upstream withnpx skills add nikhea/rallya --skill payment. Copyright stays with the author.
AGENTS.md — Payments domain (internal/payment/)
Stripe Checkout + webhooks for priced orders. Free orders never enter. Fulfillment runs ONLY in the webhook handler.
Rules
- Checkout Sessions API, payment mode, dynamic methods (never pass
payment_method_types);integration_identifieron create; idempotency key per order.StripeClientinstance — global key pattern is banned. - Webhook: verify signature FIRST (raw body + header), then dispatch.
Fulfill only
payment_status == paidacrosscompleted+async_payment_succeeded;async_payment_failedand unknown types ack silently. Bad signature 400, handled outcomes 200 (no retry storms). MarkPaididempotent (redelivery-safe); wrong states rejected. Session recorded at creation; priced-only gate before any Stripe call.- Seams:
OrderStore+CheckoutProviderinterfaces (fakes in tests). Payments never touches order tables; never log secrets. - Test webhook payloads must carry the SDK-pinned
api_version(2026-08-26.dahlia) orConstructEventrejects them — real Stripe events always include it.
Tests
go test ./internal/payment/... -count=1 — checkout guards, locally-signed
webhook vectors (bad sig, unpaid defer, fulfill, redelivery, unknown order,
async-failed), HTTP shapes incl. 503 when unconfigured.