Skip to content

[Plugin] Wire the Stripe payment gateway into the in-process commerce client - #298

Merged
urumi-fde merged 1 commit into
mainfrom
feat/stripe-in-process-gateway
Sep 22, 2026
Merged

urumi-fde merged 1 commit into
mainfrom
feat/stripe-in-process-gateway

Conversation

@urumi-fde

Copy link
Copy Markdown

Summary

  • Every card checkout on the current deployment fails: make-commerce-client.ts wires x402 into InProcessCommerceClient's payment gateways but never wires stripe, which is the only payment method the storefront checkout actually requests (checkout-routes.ts's hardcoded PAYMENT_METHOD constant). createOrderFromCart resolves an empty gateway slot and throws before it can return a typed reason, so the failure surfaces as an opaque RENDER_FAILED rather than a real PaymentIntent or a clean "not configured" message.
  • Added packages/plugin/src/payments/stripe-wiring.ts, mirroring the existing x402-wiring.ts pattern, using the already-built @otta-sh/payments-stripe adapter — webhooks/stripe-settle-route.ts already constructs a StripePaymentGateway to verify inbound webhooks; nothing ever constructed one to create a PaymentIntent for createOrder.
  • Fail-closed on both settings:stripeSecretKey and settings:stripeWebhookSecret together, even though only the secret key is strictly needed to create an intent: a gateway that can take a buyer's live payment but whose confirmation nothing can ever verify (or the reverse) is a half-armed state worse than off, matching the "both configured or no gateway" posture x402GatewayFromCtx already uses.
  • No allowedHosts change needed — api.stripe.com is the one constant resolveAllowedHosts always grants regardless of deployment config.

Test plan

  • pnpm lint — clean
  • pnpm typecheck — clean
  • New stripe-wiring.test.ts — 6 cases (both-required fail-closed, kv-rejection degrades safely, live createIntent call routed through ctx.http.fetch rather than global fetch)
  • Updated make-commerce-client.test.ts — its "reads no credential from kv" assumption no longer holds (Stripe has no build-time gate the way x402's facilitator URL does), corrected to assert exactly the two Stripe keys are read and nothing else
  • pnpm vitest run packages/plugin packages/payments-stripe — 69 files, 1252 passed, 0 failed
  • pnpm --filter @otta-sh/plugin build — clean
  • Post-merge: rebuild+redeploy with a real Stripe test publishable key baked in and test-mode credentials provisioned in admin Settings, then drive a real checkout end-to-end

🤖 Generated with Claude Code

https://claude.ai/code/session_01HPywdmMJ9B4V1ME6GrxuDu

… client

make-commerce-client.ts wired x402 into InProcessCommerceClient's payment
gateways at the work-order-02 fold-in but never wired stripe -- the only
payment method storefront checkout actually requests (checkout-routes.ts's
PAYMENT_METHOD constant). Every card checkout resolved gateways.stripe to
undefined and createOrderFromCart threw before returning a typed reason,
surfacing as an opaque RENDER_FAILED instead of a real PaymentIntent.

Added payments/stripe-wiring.ts, mirroring x402-wiring.ts's pattern, using
the already-built @otta-sh/payments-stripe adapter (webhooks/stripe-settle-
route.ts already constructed one to verify inbound webhooks; nothing ever
constructed one to create a PaymentIntent). Fail-closed on BOTH
settings:stripeSecretKey and settings:stripeWebhookSecret together -- a
gateway that can take a live payment but can never verify its confirmation
(or the reverse) is a half-armed state worse than off. api.stripe.com needed
no allowedHosts change; it is the one constant STRIPE_API_HOST always
grants.

Updated make-commerce-client.test.ts's kv-read assertion: Stripe has no
build-time gate the way x402's facilitator URL does, so resolving it means
reading both its kv keys on every construction now, not zero.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HPywdmMJ9B4V1ME6GrxuDu
@urumi-fde
urumi-fde merged commit 3264354 into main Sep 22, 2026
6 checks passed
@urumi-fde
urumi-fde deleted the feat/stripe-in-process-gateway branch September 22, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants