Skip to content

Commit

Permalink
Stripe: add initialize option
Browse files Browse the repository at this point in the history
  • Loading branch information
acomagu committed Dec 5, 2019
1 parent 7f9ef75 commit 42ea10b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
13 changes: 12 additions & 1 deletion types/stripe/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ declare class Stripe {
resources: typeof Stripe.resources;
StripeResource: typeof Stripe.StripeResource;

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

accounts: Stripe.resources.Accounts;
balance: Stripe.resources.Balance;
Expand Down Expand Up @@ -173,6 +173,17 @@ declare namespace Stripe {
/** Any Stripe source, including a bank account, credit/debit card, or less common "Source" types (see https://stripe.com/docs/api/sources/object). */
type IStripeSource = cards.ICard | bitcoinReceivers.IBitcoinReceiver | bankAccounts.IBankAccount | sources.ISource;

// The config object for the constructor.
interface Config {
apiVersion?: string | null;
maxNetworkRetries?: number;
httpAgent?: Agent | null;
timeout?: number;
host?: string;
port?: number;
telemetry?: boolean;
}

namespace accounts {
// Helper
type IExternalAccount = bankAccounts.IBankAccount | cards.ICard;
Expand Down
15 changes: 12 additions & 3 deletions types/stripe/stripe-tests.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import Stripe = require('stripe');
import { customers } from 'stripe';

const stripe = new Stripe('sk_test_BF573NobVn98OiIsPAv7A04K');

import { Agent as HttpAgent } from 'http';
import { Agent as HttpsAgent } from 'https';

new Stripe('sk_test_BF573NobVn98OiIsPAv7A04K', {
apiVersion: '2019-08-08',
maxNetworkRetries: 1,
httpAgent: new HttpAgent(),
timeout: 1000,
host: 'api.example.com',
port: 123,
telemetry: true,
});

const stripe = new Stripe('sk_test_BF573NobVn98OiIsPAv7A04K');

stripe.setHttpAgent(new HttpAgent());
stripe.setHttpAgent(new HttpsAgent());

Expand Down

0 comments on commit 42ea10b

Please sign in to comment.