Skip to content

Commit f5312a4

Browse files
authored
doc(cloudflare) add an HowTo for Stripe (#72)
1 parent b989555 commit f5312a4

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

pages/cloudflare/howtos/_meta.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"NextAuth": "NextAuth",
3+
"stripeAPI": "Stripe API"
4+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
## [Stripe API](https://www.npmjs.com/package/stripe)
3+
4+
When [creating a Stripe object](https://docs.stripe.com/js/initializing), the default http client implementation is based on `node:https` which is not implemented on Workers.
5+
6+
However you can use an http client based on fetch ([`FetchHttpClient`](https://github.com/stripe/stripe-node/blob/54d423e5d1118dc35c4b76260889826003e00e9f/src/net/FetchHttpClient.ts)) via the `httpClient` option:
7+
8+
```ts
9+
import Stripe from "stripe";
10+
11+
const stripe = Stripe(STRIPE_API_KEY, {
12+
// Cloudflare Workers use the Fetch API for their API requests.
13+
httpClient: Stripe.createFetchHttpClient()
14+
});
15+
```
16+

0 commit comments

Comments
 (0)