[Plugin] Wire the Stripe payment gateway into the in-process commerce client - #298
Merged
Merged
Conversation
… 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
make-commerce-client.tswiresx402intoInProcessCommerceClient's payment gateways but never wiresstripe, which is the only payment method the storefront checkout actually requests (checkout-routes.ts's hardcodedPAYMENT_METHODconstant).createOrderFromCartresolves an empty gateway slot and throws before it can return a typed reason, so the failure surfaces as an opaqueRENDER_FAILEDrather than a real PaymentIntent or a clean "not configured" message.packages/plugin/src/payments/stripe-wiring.ts, mirroring the existingx402-wiring.tspattern, using the already-built@otta-sh/payments-stripeadapter —webhooks/stripe-settle-route.tsalready constructs aStripePaymentGatewayto verify inbound webhooks; nothing ever constructed one to create a PaymentIntent forcreateOrder.settings:stripeSecretKeyandsettings:stripeWebhookSecrettogether, 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" posturex402GatewayFromCtxalready uses.allowedHostschange needed —api.stripe.comis the one constantresolveAllowedHostsalways grants regardless of deployment config.Test plan
pnpm lint— cleanpnpm typecheck— cleanstripe-wiring.test.ts— 6 cases (both-required fail-closed, kv-rejection degrades safely, live createIntent call routed throughctx.http.fetchrather than global fetch)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 elsepnpm vitest run packages/plugin packages/payments-stripe— 69 files, 1252 passed, 0 failedpnpm --filter @otta-sh/plugin build— clean🤖 Generated with Claude Code
https://claude.ai/code/session_01HPywdmMJ9B4V1ME6GrxuDu