Skip to content

Commit

Permalink
Merge branch 'master' into latest-codegen-master
Browse files Browse the repository at this point in the history
  • Loading branch information
anniel-stripe authored Oct 25, 2023
2 parents 9b72f96 + 0e1ea9f commit 6bdf4f3
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 28 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ and instantiate it as `new Stripe()` with the latest API version.

```ts
import Stripe from 'stripe';
const stripe = new Stripe('sk_test_...', {
apiVersion: '2023-10-16',
});
const stripe = new Stripe('sk_test_...');

const createCustomer = async () => {
const params: Stripe.CustomerCreateParams = {
Expand Down Expand Up @@ -158,11 +156,13 @@ stripe.customers
});
});
```

### Usage with Deno

As of 11.16.0, stripe-node provides a `deno` export target. In your Deno project, import stripe-node using an npm specifier:

Import using npm specifiers:

```js
import Stripe from 'npm:stripe';
```
Expand All @@ -179,7 +179,6 @@ The package can be initialized with several options:
import ProxyAgent from 'https-proxy-agent';

const stripe = Stripe('sk_test_...', {
apiVersion: '2019-08-08',
maxNetworkRetries: 1,
httpAgent: new ProxyAgent(process.env.http_proxy),
timeout: 1000,
Expand Down Expand Up @@ -265,8 +264,8 @@ As of [v13](https://github.com/stripe/stripe-node/releases/tag/v13.0.0) stripe-n
const stripe = Stripe('sk_test_...', {
maxNetworkRetries: 0, // Disable retries
});

```

```js
const stripe = Stripe('sk_test_...', {
maxNetworkRetries: 2, // Retry a request twice before giving up
Expand Down Expand Up @@ -394,7 +393,7 @@ const stripe = require('stripe')('sk_test_...', {
name: 'MyAwesomePlugin',
version: '1.2.34', // Optional
url: 'https://myawesomeplugin.info', // Optional
}
},
});
```

Expand All @@ -406,7 +405,7 @@ const stripe = new Stripe(apiKey, {
name: 'MyAwesomePlugin',
version: '1.2.34', // Optional
url: 'https://myawesomeplugin.info', // Optional
}
},
});
```

Expand Down Expand Up @@ -496,6 +495,7 @@ const stripe = new Stripe('sk_test_...', {
Stripe has features in the beta phase that can be accessed via the beta version of this package.
We would love for you to try these and share feedback with us before these features reach the stable phase.
The beta versions can be installed in one of two ways

- To install the latest beta version, run the command `npm install stripe@beta --save`
- To install a specific beta version, replace the term "beta" in the above command with the version number like `npm install stripe@1.2.3-beta.1 --save`

Expand Down
4 changes: 1 addition & 3 deletions examples/webhook-signing/express/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import {AddressInfo} from 'net';

env.config();

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2023-08-16',
});
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);

const webhookSecret: string = process.env.STRIPE_WEBHOOK_SECRET;

Expand Down
4 changes: 1 addition & 3 deletions examples/webhook-signing/koa/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ const app = new Koa();
env.config();
const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET;

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2023-08-16',
});
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);

const handleWebhook = async (ctx: Koa.ParameterizedContext, next: Koa.Next) => {
const sig = ctx.request.headers['stripe-signature'];
Expand Down
1 change: 0 additions & 1 deletion examples/webhook-signing/nestjs/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export class AppController {
private readonly client: Stripe;
constructor(@Inject(ConfigService) private readonly config: ConfigService) {
this.client = new Stripe(this.config.get('Stripe.secret_key'), {
apiVersion: '2022-11-15',
typescript: true,
});
}
Expand Down
4 changes: 1 addition & 3 deletions examples/webhook-signing/nextjs/pages/api/webhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ const handler = async (
req: NextApiRequest,
res: NextApiResponse
): Promise<void> => {
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2023-08-16',
});
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);

const webhookSecret: string = process.env.STRIPE_WEBHOOK_SECRET;

Expand Down
4 changes: 1 addition & 3 deletions examples/webhook-signing/test/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ env.config({
});

const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET;
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2023-08-16',
});
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);

const payload = Buffer.from(
JSON.stringify(
Expand Down
4 changes: 0 additions & 4 deletions scripts/updateAPIVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ const main = () => {
'types/test/typescriptTest.ts',
'apiVersion: [\'"]API_VERSION[\'"]'
);
replaceAPIVersion(
'testProjects/mjs-ts/index.ts',
'apiVersion: [\'"]API_VERSION[\'"]'
);
};

if (require.main === module) {
Expand Down
1 change: 0 additions & 1 deletion testProjects/cloudflare-pages/functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export async function onRequestPost({env, request}) {
const body = await request.text();

const stripe = new Stripe(env.STRIPE_API_KEY, {
apiVersion: '2023-08-16',
httpClient: Stripe.createFetchHttpClient(),
});
const webCrypto = Stripe.createSubtleCryptoProvider();
Expand Down
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ declare module 'stripe' {
export class Stripe {
static Stripe: typeof Stripe;

constructor(apiKey: string, config: Stripe.StripeConfig);
constructor(apiKey: string, config?: Stripe.StripeConfig);

StripeResource: Stripe.StripeResource;

Expand Down
2 changes: 1 addition & 1 deletion types/lib.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ declare module 'stripe' {
*
* @docs https://stripe.com/docs/api/versioning
*/
apiVersion: LatestApiVersion;
apiVersion?: LatestApiVersion;

/**
* Optionally indicate that you are using TypeScript.
Expand Down
1 change: 0 additions & 1 deletion types/test/typescriptTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ let stripe = new Stripe('sk_test_123', {
apiVersion: '2023-10-16',
});

// @ts-ignore lazily ignore apiVersion requirement.
stripe = new Stripe('sk_test_123');

stripe = new Stripe('sk_test_123', {
Expand Down

0 comments on commit 6bdf4f3

Please sign in to comment.