Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stripe-node v12 #1744

Merged
merged 6 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ We therefore encourage [upgrading your API version][api-version-upgrading]
if you would like to take advantage of Stripe's TypeScript definitions.

If you are on an older API version (e.g., `2019-10-17`) and not able to upgrade,
you may pass another version or `apiVersion: null` to use your account's default API version,
and use a comment like `// @ts-ignore stripe-version-2019-10-17` to silence type errors here
you may pass another version and use a comment like `// @ts-ignore stripe-version-2019-10-17` to silence type errors here
and anywhere the types differ between your API version and the latest.
When you upgrade, you should remove these comments.

Expand Down Expand Up @@ -176,7 +175,7 @@ const stripe = Stripe('sk_test_...', {

| Option | Default | Description |
| ------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `apiVersion` | `null` | Stripe API version to be used. If not set the account's default version will be used. |
| `apiVersion` | `null` | Stripe API version to be used. If not set, stripe-node will use the latest version at the time of release. |
| `maxNetworkRetries` | 0 | The amount of times a request should be [retried](#network-retries). |
| `httpAgent` | `null` | [Proxy](#configuring-a-proxy) agent to be used by the library. |
| `timeout` | 80000 | [Maximum time each request can take in ms.](#configuring-timeout) |
Expand Down
8 changes: 2 additions & 6 deletions src/stripe.core.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as _Error from './Error.js';
import * as apiVersion from './apiVersion.js';
import * as resources from './resources.js';
import {HttpClient, HttpClientResponse} from './net/HttpClient.js';
import {
Expand All @@ -16,7 +17,7 @@ import {StripeObject, AppInfo, UserProvidedConfig} from './Types.js';
const DEFAULT_HOST = 'api.stripe.com';
const DEFAULT_PORT = '443';
const DEFAULT_BASE_PATH = '/v1/';
const DEFAULT_API_VERSION = (null as unknown) as string;
const DEFAULT_API_VERSION = apiVersion.ApiVersion;

const DEFAULT_TIMEOUT = 80000;

Expand Down Expand Up @@ -63,11 +64,6 @@ export function createStripe(
Stripe.HttpClientResponse = HttpClientResponse;
Stripe.CryptoProvider = CryptoProvider;

// For backwards compatibiblity after moving to separate CJS and ESM entrypoints.
// To be removed in the next major version.
Stripe.Stripe = Stripe;
Stripe.default = Stripe;

function Stripe(
this: StripeObject,
key: string,
Expand Down
3 changes: 2 additions & 1 deletion test/stripe.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {FetchHttpClient} from '../cjs/net/FetchHttpClient.js';
import {NodeHttpClient} from '../cjs/net/NodeHttpClient.js';
import {createStripe} from '../cjs/stripe.core.js';
import {getMockPlatformFunctions} from './testUtils.js';
import {ApiVersion} from '../cjs/apiVersion.js';

const testUtils = require('./testUtils.js');
const Stripe = require('../cjs/stripe.cjs.node.js');
Expand Down Expand Up @@ -119,7 +120,7 @@ describe('Stripe Module', function() {

cases.forEach((item) => {
const newStripe = Stripe(testUtils.getUserStripeKey(), item);
expect(newStripe.getApiField('version')).to.equal(null);
expect(newStripe.getApiField('version')).to.equal(ApiVersion);
});
});

Expand Down
3 changes: 0 additions & 3 deletions testProjects/mjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ assert(Stripe.StripeResource.MAX_BUFFERED_REQUEST_METRICS);
assert(Stripe.webhooks);
assert(Stripe.resources);

assert(Stripe.Stripe);
assert(Stripe.default);

const stripe = new Stripe(process.argv[2]);
const defaultStripe = new DefaultStripe(process.argv[2]);

Expand Down