You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 1edce9d
Browse filesBrowse the repository at this point in the historyBrowse files
feat(payments): extract a provider seam and neutralise the payment columns (#246)
Step 1 of #246. No behaviour change: Stripe is still the only implementation and
the endpoint, settings and user-visible flow are untouched. What changes is that
the handler no longer names Stripe.
New package internal/payments:
type Provider interface {
Name() string
Capabilities() Capabilities
CreateCheckout(ctx, CheckoutRequest) (*CheckoutSession, error)
GetSession(ctx, id) (*CheckoutSession, error)
ParseWebhook(payload, headers, now) (*Event, error)
Refund(ctx, RefundRequest) error
}
Two decisions are fixed at the boundary rather than left to each adapter:
- Money crosses as an integer count of minor units plus an ISO currency code
(Stripe's model). A gateway wanting a decimal string converts at its own edge,
once; nothing else in Calnode sees a decimal amount.
- Refunds are a declared capability. Capabilities{Refunds:false} means the UI must
not offer the action, rather than offering a button that fails.
Webhooks are verified per provider and normalized to EventKind (completed,
expired, other). A failed signature returns an error and no event, never a
zero-value one the handler could mistake for "nothing to do".
Handler changes: stripe.Client -> payments.Provider (SetPaymentProvider /
getPaymentProvider, guarded by the same mutex). The refund path now checks the
refund capability before claiming the row, so a provider without refunds cannot
half-claim it.
Schema, migration 00072:
stripe_session_id -> payment_session_id
stripe_payment_intent_id -> payment_ref
+ payment_provider TEXT NOT NULL DEFAULT 'stripe'
Existing rows are Stripe by definition, so the default is correct for them and
for new rows until step 3 writes it explicitly.
Verified:
- Old binary on a fresh DB, with a paid booking holding cs_old_1/pi_old_1, then
the new binary on the same database: 00072 applies and the row reads
payment_provider=stripe, payment_session_id=cs_old_1, payment_ref=pi_old_1,
payment_status=paid. Data survives the rename.
- Payments-off paths unchanged: POST /v1/stripe/webhook 503, / 302, /admin/ 200.
- New internal/payments tests cover the neutral session mapping, all three event
kinds, and rejection of missing/wrong-secret/wrong-payload/stale signatures.
- go test ./... green.
0 commit comments