Cloudflare
操作指南
Stripe API

Stripe API (opens in a new tab)

创建 Stripe 对象 (opens in a new tab) 时,默认的 HTTP 客户端实现基于 node:https,这在 Workers 上并未实现。

不过,您可以通过 httpClient 选项使用基于 fetch 的 HTTP 客户端 (FetchHttpClient (opens in a new tab)):

import Stripe from "stripe";
 
const stripe = Stripe(STRIPE_API_KEY, {
  // Cloudflare Workers 使用 Fetch API 进行其 API 请求。
  httpClient: Stripe.createFetchHttpClient(),
});