From 19a6c4d994825d9fc36a27cef289c8fb1e41f642 Mon Sep 17 00:00:00 2001 From: javayhu Date: Tue, 17 Jun 2025 22:35:27 +0800 Subject: [PATCH] cf: fix stripe api issue by setting httpClient --- src/payment/provider/stripe.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/payment/provider/stripe.ts b/src/payment/provider/stripe.ts index 92c976f..48dd03f 100644 --- a/src/payment/provider/stripe.ts +++ b/src/payment/provider/stripe.ts @@ -48,7 +48,13 @@ export class StripeProvider implements PaymentProvider { } // Initialize Stripe without specifying apiVersion to use default/latest version - this.stripe = new Stripe(apiKey); + // https://opennext.js.org/cloudflare/howtos/stripeAPI + // When creating a Stripe object, the default http client implementation is based on + // node:https which is not implemented on Workers. + this.stripe = new Stripe(apiKey, { + // Cloudflare Workers use the Fetch API for their API requests. + httpClient: Stripe.createFetchHttpClient(), + }); this.webhookSecret = webhookSecret; }