mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-05 01:30:17 +00:00
[@types/stripe] Added config param to constructor (#40846)
* [@types/stripe] Added breaking test for constructor * [@types/stripe] Added missing config to constructor * [@types/stripe] Marked all StripeConfig keys as optional * [@types/stripe] Allowed null for apiVersion & httpAgent
This commit is contained in:
11
types/stripe/index.d.ts
vendored
11
types/stripe/index.d.ts
vendored
@@ -64,6 +64,16 @@ interface ResponseEvent {
|
||||
request_end_time: number;
|
||||
}
|
||||
|
||||
interface StripeConfig {
|
||||
apiVersion?: string | null;
|
||||
maxNetworkRetries?: number;
|
||||
httpAgent?: Agent | null;
|
||||
timeout?: number;
|
||||
host?: string;
|
||||
port?: number;
|
||||
telemetry?: boolean;
|
||||
}
|
||||
|
||||
declare class Stripe {
|
||||
DEFAULT_HOST: string;
|
||||
DEFAULT_PORT: string;
|
||||
@@ -85,6 +95,7 @@ declare class Stripe {
|
||||
StripeResource: typeof Stripe.StripeResource;
|
||||
|
||||
constructor(apiKey: string, version?: string);
|
||||
constructor(apiKey: string, config?: StripeConfig);
|
||||
|
||||
accounts: Stripe.resources.Accounts;
|
||||
balance: Stripe.resources.Balance;
|
||||
|
||||
@@ -1,11 +1,24 @@
|
||||
import Stripe = require('stripe');
|
||||
import { customers } from 'stripe';
|
||||
|
||||
const stripe = new Stripe('sk_test_BF573NobVn98OiIsPAv7A04K');
|
||||
let stripe = new Stripe('sk_test_BF573NobVn98OiIsPAv7A04K');
|
||||
stripe = new Stripe('sk_test_BF573NobVn98OiIsPAv7A04K', 'latest');
|
||||
|
||||
import { Agent as HttpAgent } from 'http';
|
||||
import { Agent as HttpsAgent } from 'https';
|
||||
|
||||
stripe = new Stripe('sk_test_BF573NobVn98OiIsPAv7A04K', {
|
||||
apiVersion: 'latest',
|
||||
maxNetworkRetries: 1,
|
||||
httpAgent: new HttpAgent(),
|
||||
timeout: 1000,
|
||||
host: 'api.example.com',
|
||||
port: 123,
|
||||
telemetry: true
|
||||
});
|
||||
|
||||
stripe = new Stripe('sk_test_BF573NobVn98OiIsPAv7A04K', {});
|
||||
|
||||
stripe.setHttpAgent(new HttpAgent());
|
||||
stripe.setHttpAgent(new HttpsAgent());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user