Skip to content

Commit

Permalink
Remove deprecated configuration setter methods (#1597)
Browse files Browse the repository at this point in the history
* Remove deprecated config properties

* Update test and remove config properties from types/

* Remove setProtocol from types, refactor old tests

* Replace more require('../lib/stripe') with Stripe

* Remove global stripe from EphemeralKeys test

* Rename local stripe to newStripe in stripe.spec.js

* Refactor EphemeralKeys.spec.js
  • Loading branch information
anniel-stripe committed Nov 1, 2022
1 parent 47effcf commit 71f615b
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 435 deletions.
158 changes: 0 additions & 158 deletions lib/stripe.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

168 changes: 0 additions & 168 deletions src/stripe.ts
Expand Up @@ -178,98 +178,6 @@ Stripe.createSubtleCryptoProvider = (subtleCrypto) => {
};

Stripe.prototype = {
/**
* @deprecated will be removed in a future major version. Use the config object instead:
*
* const stripe = new Stripe(API_KEY, {
* host: 'example.com',
* port: '8080',
* protocol: 'http',
* });
*
*/
setHost(host, port, protocol) {
emitWarning(
'`setHost` is deprecated. Use the `host` config option instead.'
);
this._setApiField('host', host);
if (port) {
this.setPort(port);
}
if (protocol) {
this.setProtocol(protocol);
}
},

/**
* @deprecated will be removed in a future major version. Use the config object instead:
*
* const stripe = new Stripe(API_KEY, {
* protocol: 'http',
* });
*
*/
setProtocol(protocol) {
emitWarning(
'`setProtocol` is deprecated. Use the `protocol` config option instead.'
);
this._setApiField('protocol', protocol.toLowerCase());
},

/**
* @deprecated will be removed in a future major version. Use the config object instead:
*
* const stripe = new Stripe(API_KEY, {
* port: 3000,
* });
*
*/
setPort(port) {
emitWarning(
'`setPort` is deprecated. Use the `port` config option instead.'
);
this._setApiField('port', port);
},

/**
* @deprecated will be removed in a future major version. Use the config object instead:
*
* const stripe = new Stripe(API_KEY, {
* apiVersion: API_VERSION,
* });
*
*/
setApiVersion(version) {
emitWarning(
'`setApiVersion` is deprecated. Use the `apiVersion` config or request option instead.'
);
if (version) {
this._setApiField('version', version);
}
},

/**
* @deprecated will be removed in a future major version. Use the config object instead:
*
* const stripe = new Stripe(API_KEY);
*
* Or, for Stripe Connect, use `stripeAccount` instead:
*
* const stripe = new Stripe(API_KEY, {
* stripeAccount: 'acct_...',
* });
*
* Or, to use a different apiKey on a given request:
*
* stripe.customers.create(params, {apiKey: 'sk_test_...'});
*/
setApiKey(key) {
emitWarning(
'`setApiKey` is deprecated. Use the `apiKey` request option instead.'
);
this._setApiKey(key);
},

/**
* @private
*/
Expand All @@ -279,39 +187,6 @@ Stripe.prototype = {
}
},

/**
* @deprecated will be removed in a future major version. Use the config object instead:
*
* const stripe = new Stripe(API_KEY, {
* timeout: TIMEOUT_MS,
* });
*/
setTimeout(timeout) {
emitWarning(
'`setTimeout` is deprecated. Use the `timeout` config or request option instead.'
);
this._setApiField('timeout', timeout == null ? DEFAULT_TIMEOUT : timeout);
},

/**
* @deprecated will be removed in a future major version. Use the config object instead:
*
* const stripe = new Stripe(API_KEY, {
* appInfo: {
* name: 'MyPlugin',
* version: '1.4.2',
* url: 'https://myplugin.com',
* partner_id: '1234',
* },
* });
*/
setAppInfo(info) {
emitWarning(
'`setAppInfo` is deprecated. Use the `appInfo` config option instead.'
);
this._setAppInfo(info);
},

/**
* @private
* This may be removed in the future.
Expand Down Expand Up @@ -343,22 +218,6 @@ Stripe.prototype = {
this._appInfo = appInfo;
},

/**
* @deprecated will be removed in a future major version. Use the config object instead:
*
* const ProxyAgent = require('https-proxy-agent');
* const stripe = new Stripe(API_KEY, {
* httpAgent: new ProxyAgent(process.env.http_proxy),
* });
*
*/
setHttpAgent(agent) {
emitWarning(
'`setHttpAgent` is deprecated. Use the `httpAgent` config option instead.'
);
this._setApiField('agent', agent);
},

/**
* @private
* This may be removed in the future.
Expand Down Expand Up @@ -417,18 +276,6 @@ Stripe.prototype = {
return this.getApiField('maxNetworkRetries');
},

/**
* @deprecated will be removed in a future major version. Use the config object instead:
*
* const stripe = new Stripe(API_KEY, {
* maxNetworkRetries: 2,
* });
*
*/
setMaxNetworkRetries(maxNetworkRetries) {
this._setApiNumberField('maxNetworkRetries', maxNetworkRetries);
},

/**
* @private
* This may be removed in the future.
Expand Down Expand Up @@ -533,21 +380,6 @@ Stripe.prototype = {
return formatted;
},

/**
* @deprecated will be removed in a future major version. Use the config object instead:
*
* const stripe = new Stripe(API_KEY, {
* telemetry: false,
* });
*
*/
setTelemetryEnabled(enableTelemetry) {
emitWarning(
'`setTelemetryEnabled` is deprecated. Use the `telemetry` config option instead.'
);
this._enableTelemetry = enableTelemetry;
},

getTelemetryEnabled() {
return this._enableTelemetry;
},
Expand Down

0 comments on commit 71f615b

Please sign in to comment.