From f5ffcc4d5ec691741c52c2eea08905b476176f01 Mon Sep 17 00:00:00 2001 From: Simon Schick Date: Thu, 6 Dec 2018 15:18:49 -0800 Subject: [PATCH] feat(stripe): add errors --- types/stripe/index.d.ts | 249 ++++++++------- types/stripe/stripe-tests.ts | 576 +++++++++++++++++------------------ types/stripe/tslint.json | 74 +---- 3 files changed, 421 insertions(+), 478 deletions(-) diff --git a/types/stripe/index.d.ts b/types/stripe/index.d.ts index 592d0b0430..0a4ce86a0a 100644 --- a/types/stripe/index.d.ts +++ b/types/stripe/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for stripe 6.0.0 +// Type definitions for stripe 6.18 // Project: https://github.com/stripe/stripe-node/ // Definitions by: William Johnston // Peter Harris @@ -13,6 +13,7 @@ // Tyler Jones // Troy Zarger // Ifiok Jr. +// Simon Schick // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -76,8 +77,6 @@ declare class Stripe { usageRecords: Stripe.resources.UsageRecords; usageRecordSummarys: Stripe.resources.UsageRecordSummarys; - - setHost(host: string): void; setHost(host: string, port: string|number): void; setHost(host: string, port: string|number, protocol: string): void; @@ -161,8 +160,8 @@ declare namespace Stripe { * standing. Nested fields are separated by "." (for example, * "legal_entity.first_name"). */ - fields_needed: Array; - } + fields_needed: string[]; + }; } interface IAccountCreationOptions extends IAccountUpdateOptions { @@ -262,7 +261,7 @@ declare namespace Stripe { * Information about the holder of this account, i.e. the user receiving funds * from this account */ - legal_entity?: {}; //TODO: Implement this type definition. + legal_entity?: {}; // TODO: Implement this type definition. /** * A set of key/value pairs that you can attach to an account object. It can be @@ -356,7 +355,7 @@ declare namespace Stripe { * ‘tuesday’, etc. Required and available only if interval is weekly. */ weekly_anchor?: "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday" | "sunday"; - } + }; /** * The text that appears on the bank account statement for payouts. @@ -421,7 +420,7 @@ declare namespace Stripe { * required. */ routing_number?: string; - } + }; } interface IExternalAccountCreationOptions extends IDataOptionsWithMetadata { @@ -449,11 +448,11 @@ declare namespace Stripe { } interface IBankAccountListOptions extends IListOptions { - object: "bank_account" + object: "bank_account"; } interface ICardListOptions extends IListOptions { - object: "card" + object: "card"; } interface IRejectReason { @@ -541,7 +540,7 @@ declare namespace Stripe { /** * Value is "fee_refund" */ - object:string; + object: string; /** * Amount, in cents/pence. @@ -597,7 +596,7 @@ declare namespace Stripe { * via the transfers API. The available balance for each currency and payment * type can be found in the source_types property. */ - available: Array; + available: ISourceType[]; livemode: boolean; @@ -606,7 +605,7 @@ declare namespace Stripe { * cycle. The pending balance for each currency and payment type can be * found in the source_types property */ - pending: Array; + pending: ISourceType[]; } interface ISourceType { @@ -617,7 +616,7 @@ declare namespace Stripe { bitcoin_receiver?: number; customer_bank_account?: number; alipay_account?: number; - } + }; } interface IBalanceTransaction extends IResourceObject { @@ -735,7 +734,6 @@ declare namespace Stripe { } namespace charges { - /** * To charge a credit or a debit card, you create a charge object. You can retrieve and refund individual * charges as well as list all charges. Charges are identified by a unique random ID. @@ -860,7 +858,7 @@ declare namespace Stripe { * Details about whether the payment was accepted, and why. See * understanding declines for details. [Expandable] */ - outcome?: charges.IOutcome; + outcome?: IOutcome; /** * true if the charge succeeded, or was successfully authorized for later capture. @@ -1093,7 +1091,7 @@ declare namespace Stripe { * the user_report to fraudulent. Stripe will use the information you send to improve our fraud detection algorithm */ user_report?: "fraudulent" | "safe"; - } + }; /** * This is the email address that the receipt for this charge will be sent to. @@ -1124,7 +1122,7 @@ declare namespace Stripe { * "all", "alipay_account", "bitcoin_receiver", or "card". */ object: "all" | "alipay_account" | "bitcoin_receiver" | "card"; - } + }; } interface IOutcome { @@ -1520,11 +1518,11 @@ declare namespace Stripe { } interface IBankAccountSourceListOptions extends IListOptions { - object: "bank_account" + object: "bank_account"; } interface ICardSourceListOptions extends IListOptions { - object: "card" + object: "card"; } } @@ -1551,7 +1549,7 @@ declare namespace Stripe { * List of zero, one, or two balance transactions that show funds withdrawn and reinstated to your * Stripe account as a result of this dispute. */ - balance_transactions: Array; + balance_transactions: balance.IBalanceTransaction[]; /** * ID of the charge that was disputed. [Expandable] @@ -1777,7 +1775,7 @@ declare namespace Stripe { /** * Evidence to upload to respond to a dispute. Updating any field in the hash will submit all fields in the hash for review. */ - evidence?: disputes.IDisputeEvidence; + evidence?: IDisputeEvidence; } } @@ -1807,9 +1805,6 @@ declare namespace Stripe { */ object: IObject; - /** - * - */ previous_attributes?: {}; }; @@ -1888,7 +1883,7 @@ declare namespace Stripe { data: string | Buffer; name: string; type: string | "application/octet-stream"; - } + }; } interface IFileUploadListOptions extends IListOptionsCreated { @@ -2213,7 +2208,7 @@ declare namespace Stripe { /** * Extra information about a charge for the customer’s credit card statement. */ - statement_descriptor?: string + statement_descriptor?: string; /** * The ID of the subscription to invoice. If not set, the created invoice will include all pending invoice items for @@ -2252,7 +2247,7 @@ declare namespace Stripe { /** * Extra information about a charge for the customer’s credit card statement. */ - statement_descriptor?: string + statement_descriptor?: string; /** * The percent tax rate applied to the invoice, represented as a decimal number. @@ -2261,11 +2256,11 @@ declare namespace Stripe { } interface IInvoicePayOptions extends IDataOptionsWithMetadata { - /** + /** * A payment source to be charged. The source must be the ID of a source * belonging to the customer associated with the invoice being paid. */ - source?: sources.ISourceCreationOptions; + source?: sources.ISourceCreationOptions; } interface IInvoiceListOptions extends IListOptions { @@ -2377,7 +2372,7 @@ declare namespace Stripe { /** * If null, the invoice item is pending and will be included in the upcoming invoice. - */ + */ invoice: string | null; livemode: boolean; metadata: IMetadata; @@ -2530,7 +2525,7 @@ declare namespace Stripe { /** * List of items constituting the order. */ - items: Array; + items: IOrderItem[]; livemode: boolean; metadata: IMetadata; @@ -2551,7 +2546,7 @@ declare namespace Stripe { * A list of supported shipping methods for this order. The desired shipping method can be specified either by updating the order, or * when paying it. */ - shipping_methods: Array; + shipping_methods: IShippingMethod[]; status: OrderStatus; @@ -2634,7 +2629,7 @@ declare namespace Stripe { /** * List of items constituting the order. */ - items?: Array; + items?: IOrderItemCreationHash[]; /** * Shipping address for the order. Required if any of the SKUs are for products that have shippable set to true. @@ -2699,7 +2694,7 @@ declare namespace Stripe { /** * Only return orders with the given IDs */ - ids?: Array; + ids?: string[]; /** * Only return orders that have the given status. One of "created", "paid", "fulfilled", or "refunded". @@ -2733,7 +2728,7 @@ declare namespace Stripe { * or it can be a dictionary with the following options: */ returned?: IDateFilter; - } + }; } interface IOrderItemCreationHash { @@ -3076,7 +3071,7 @@ declare namespace Stripe { /** * Each element represents a pricing tier. This parameter requires `billing_scheme` to be set to `tiered`. See also the documentation for `billing_scheme`. */ - tiers: plans.ITier[] | null; + tiers: ITier[] | null; /** * Defines if the tiering price should be `graduated` or `volume` based. In `volume`-based tiering, the maximum quantity within a period determines the per unit price, in `graduated` tiering pricing can successively change as the quantity grows. @@ -3086,7 +3081,7 @@ declare namespace Stripe { /** * Apply a transformation to the reported usage or set quantity before computing the billed price. Cannot be combined with `tiers`. */ - transform_usage: plans.ITransformUsage | null; + transform_usage: ITransformUsage | null; /** * Default number of trial days when subscribing a customer to this plan using `trial_from_plan=true`. @@ -3162,7 +3157,7 @@ declare namespace Stripe { /** * Each element represents a pricing tier. This parameter requires `billing_scheme` to be set to `tiered`. See also the documentation for `billing_scheme`. */ - tiers?: plans.ITier[]; + tiers?: ITier[]; /** * Defines if the tiering price should be `graduated` or `volume` based. In `volume`-based tiering, the maximum quantity within a period determines the per unit price, in `graduated` tiering pricing can successively change as the quantity grows. @@ -3172,7 +3167,7 @@ declare namespace Stripe { /** * Apply a transformation to the reported usage or set quantity before computing the billed price. Cannot be combined with `tiers`. */ - transform_usage?: plans.ITransformUsage; + transform_usage?: ITransformUsage; /** * Default number of trial days when subscribing a customer to this plan using `trial_from_plan=true`. @@ -3241,7 +3236,7 @@ declare namespace Stripe { /** * A list of up to 5 attributes that each SKU can provide values for (e.g. ["color", "size"]). */ - attributes: Array; + attributes: string[]; /** * A short one-line description of the product, meant to be displayable to the customer. @@ -3256,7 +3251,7 @@ declare namespace Stripe { /** * An array of connect application identifiers that cannot purchase this product. */ - deactivated_on: Array; + deactivated_on: string[]; /** * The product’s description, meant to be displayable to the customer. @@ -3266,7 +3261,7 @@ declare namespace Stripe { /** * A list of up to 8 URLs of images for this product, meant to be displayable to the customer. */ - images: Array; + images: string[]; livemode: boolean; metadata: IMetadata; @@ -3336,7 +3331,7 @@ declare namespace Stripe { * A list of up to 5 alphanumeric attributes that each SKU can provide values for (e.g. ["color", "size"]). * Applicable to both service and good types. */ - attributes?: Array; + attributes?: string[]; /** * A short one-line description of the product, meant to be displayable to the customer. May only be set if type=good. @@ -3347,7 +3342,7 @@ declare namespace Stripe { * An array of Connect application names or identifiers that should not be able to order the SKUs for this product. * May only be set if type=good. */ - deactivate_on?: Array; + deactivate_on?: string[]; /** * The product’s description, meant to be displayable to the customer. May only be set if type=good. @@ -3357,7 +3352,7 @@ declare namespace Stripe { /** * A list of up to 8 URLs of images for this product, meant to be displayable to the customer. May only be set if type=good. */ - images?: Array; + images?: string[]; /** * The dimensions of this product for shipping purposes. A SKU associated with this product can override this value by having its own @@ -3400,7 +3395,7 @@ declare namespace Stripe { * An array of Connect application names or identifiers that should not be able to order the SKUs for this product. This can be unset * by updating the value to null and then saving. */ - deactivate_on?: Array; + deactivate_on?: string[]; /** * The product’s description, meant to be displayable to the customer. @@ -3411,7 +3406,7 @@ declare namespace Stripe { * A list of up to 8 URLs of images for this product, meant to be displayable to the customer. This can be unset by updating the value to * null and then saving. */ - images?: Array; + images?: string[]; /** * The product’s name, meant to be displayable to the customer. @@ -3452,7 +3447,7 @@ declare namespace Stripe { /** * Only return products with the given IDs. */ - ids?: Array; + ids?: string[]; /** * Only return products that can be shipped (i.e., physical, not digital products). @@ -3494,8 +3489,8 @@ declare namespace Stripe { namespace recipientCards { } namespace recipients { + // tslint:disable-next-line:no-empty-interface interface IRecipient extends IResourceObject { - } } @@ -3642,7 +3637,7 @@ declare namespace Stripe { /** * Only return SKUs with the given IDs. */ - ids?: Array; + ids?: string[]; /** * Only return SKUs that are either in stock or out of stock (e.g. pass false to list all SKUs that are out of stock). @@ -3684,6 +3679,7 @@ declare namespace Stripe { * If, for example, a product’s attributes are ["size", "gender"], * a valid SKU has the following dictionary of attributes: {"size": "Medium", "gender": "Unisex"}. */ + // tslint:disable-next-line:no-empty-interface interface ISkuAttributes {} } @@ -3723,7 +3719,7 @@ declare namespace Stripe { interface IEphemeralKey extends IResourceObject { object: "ephemeral_key"; - associated_objects: Array + associated_objects: IAssociatedObject[]; created: number; expires: number; livemode: boolean; @@ -3816,7 +3812,7 @@ declare namespace Stripe { * The personal_id_number for PII in string form. */ personal_id_number: string; - } + }; } } @@ -4929,7 +4925,7 @@ declare namespace Stripe { /** * Quantity for this item. */ - quantity?: number + quantity?: number; } interface ISubscriptionUpdateItem { @@ -4963,7 +4959,7 @@ declare namespace Stripe { /** * Quantity for this item. */ - quantity?: number + quantity?: number; } } @@ -5240,13 +5236,13 @@ declare namespace Stripe { /** * Currencies that can be accepted in the specified country (for payments). */ - supported_payment_currencies: Array; + supported_payment_currencies: string[]; /** * Payment methods available in the specified country. You will need to enable bitcoin and ACH payments on your account for those methods to * appear in this list. The stripe payment method refers to charging through your platform. */ - supported_payment_methods: Array; + supported_payment_methods: string[]; /** * Lists the types of verification data needed to keep an account open. Includes 'minimum' fields, which every account must eventually @@ -5254,14 +5250,14 @@ declare namespace Stripe { */ verification_fields: { individual: { - minimum: Array; - additional: Array; + minimum: string[]; + additional: string[]; }, company: { - minimum: Array; - additional: Array; + minimum: string[]; + additional: string[]; } - } + }; } } @@ -5348,8 +5344,8 @@ declare namespace Stripe { * starting after summary starting_after. Each entry in the array is a separate summary object. * If no more summaries are available, the resulting array is empty. */ - interface IUsageRecordSummarys extends IList{ - object: 'list' + interface IUsageRecordSummarys extends IList { + object: 'list'; } interface IUsageRecordSummarysItem { @@ -5362,7 +5358,7 @@ declare namespace Stripe { total_usage: number; } - interface IUsageRecordSummarysListOptions extends IListOptions{ + interface IUsageRecordSummarysListOptions extends IListOptions { /** * Only summary items for the given subscription item. */ @@ -5375,6 +5371,7 @@ declare namespace Stripe { } } + // tslint:disable-next-line:no-unnecessary-class class StripeResource { constructor(stripe: Stripe, urlData: any); } @@ -5620,7 +5617,6 @@ declare namespace Stripe { retrieve(refundId: string, options: HeaderOptions, response?: IResponseFn): Promise; retrieve(refundId: string, response?: IResponseFn): Promise; - /** * Updates the specified application fee refund by setting the values of the parameters passed. Any parameters not provided will be left * unchanged. @@ -5670,17 +5666,16 @@ declare namespace Stripe { retrieve(id: string, options: HeaderOptions, response?: IResponseFn): Promise; retrieve(id: string, response?: IResponseFn): Promise; - /** * Returns a list of your receivers. Receivers are returned sorted by creation date, with the most recently created receivers appearing first. */ list(data: bitcoinReceivers.IBitcoinReceiverListOptions, options: HeaderOptions, response?: IResponseFn>): Promise>; list(data: bitcoinReceivers.IBitcoinReceiverListOptions, response?: IResponseFn>): Promise>; - //update(id: string): void; // This does seem to be a method in the library (https://github.com/stripe/stripe-node/blob/master/lib/resources/BitcoinReceivers.js#L12), but isn't in the API documentation. + // update(id: string): void; // This does seem to be a method in the library (https://github.com/stripe/stripe-node/blob/master/lib/resources/BitcoinReceivers.js#L12), but isn't in the API documentation. - setMetadata(): void; //TODO: Implement placeholder method - getMetadata(): void; //TODO: Implement placeholder method + setMetadata(): void; // TODO: Implement placeholder method + getMetadata(): void; // TODO: Implement placeholder method } class Charges extends StripeResource { @@ -5713,7 +5708,6 @@ declare namespace Stripe { retrieve(id: string, options: HeaderOptions, response?: IResponseFn): Promise; retrieve(id: string, response?: IResponseFn): Promise; - /** * Updates the specified charge by setting the values of the parameters passed. Any parameters not provided will be left unchanged. * This request accepts only the description, metadata, receipt_emailand fraud_details as arguments. @@ -5848,7 +5842,6 @@ declare namespace Stripe { retrieve?(id: string, options: HeaderOptions, response?: IResponseFn): Promise; retrieve?(id: string, response?: IResponseFn): Promise; - /** * Updates the specified refund by setting the values of the parameters passed. * Any parameters not provided will be left unchanged. @@ -5896,7 +5889,6 @@ declare namespace Stripe { retrieve(id: string, options: HeaderOptions, response?: IResponseFn): Promise; retrieve(id: string, response?: IResponseFn): Promise; - /** * Updates the metadata of a coupon. Other coupon details (currency, duration, amount_off) are, by design, not editable. * @@ -6084,8 +6076,6 @@ declare namespace Stripe { del(id: string, options: HeaderOptions, response?: IResponseFn): Promise; del(id: string, response?: IResponseFn): Promise; - - /** * When you create a new credit card, you must specify a customer or recipient to create it on. If the card's owner has no default card, * then the new card will become the default. However, if the owner already has a default then it will not change. To change the default, @@ -6165,7 +6155,6 @@ declare namespace Stripe { listCards(customerId: string, options: HeaderOptions, response?: IResponseFn>): Promise>; listCards(customerId: string, response?: IResponseFn>): Promise>; - /** * When adding a card to a customer, the parameter name is source. When * adding to an account, the parameter name is external_account. The @@ -6279,7 +6268,6 @@ declare namespace Stripe { deleteSource(customerId: string, sourceId: string, options: HeaderOptions, response?: IResponseFn): Promise; deleteSource(customerId: string, sourceId: string, response?: IResponseFn): Promise; - /** * A customer's bank account must first be verified before it can be charged. Stripe supports instant verification using Plaid for many of * the most popular banks. If your customer's bank is not supported or you do not wish to integrate with Plaid, you must manually verify @@ -6293,7 +6281,6 @@ declare namespace Stripe { verifySource(customerId: string, sourceId: string, data: bankAccounts.IBankAccountVerifyOptions, options: HeaderOptions): Promise; verifySource(customerId: string, sourceId: string, data: bankAccounts.IBankAccountVerifyOptions): Promise; - /** * Creates a new subscription on an existing customer. * @@ -6386,7 +6373,6 @@ declare namespace Stripe { listSubscriptions(customerId: string, options: HeaderOptions, response?: IResponseFn>): Promise>; listSubscriptions(customerId: string, response?: IResponseFn>): Promise>; - /** * Removes the currently applied discount on a customer. * @@ -6395,8 +6381,8 @@ declare namespace Stripe { * * @param customerId The ID of the customer. */ - deleteDiscount(customerId: string, options: HeaderOptions, response?: IResponseFn): Promise;; - deleteDiscount(customerId: string, response?: IResponseFn): Promise;; + deleteDiscount(customerId: string, options: HeaderOptions, response?: IResponseFn): Promise; + deleteDiscount(customerId: string, response?: IResponseFn): Promise; /** * Removes the currently applied discount on a subscription. @@ -6407,8 +6393,8 @@ declare namespace Stripe { * @param customerId The ID of the customer. * @param subscriptionId The ID of the subscription. */ - deleteSubscriptionDiscount(customerId: string, subscriptionId: string, options: HeaderOptions, response?: IResponseFn): Promise;; - deleteSubscriptionDiscount(customerId: string, subscriptionId: string, response?: IResponseFn): Promise;; + deleteSubscriptionDiscount(customerId: string, subscriptionId: string, options: HeaderOptions, response?: IResponseFn): Promise; + deleteSubscriptionDiscount(customerId: string, subscriptionId: string, response?: IResponseFn): Promise; } class SubscriptionsBase extends StripeResource { @@ -6496,8 +6482,8 @@ declare namespace Stripe { * * @param subscriptionId The ID of the subscription. */ - deleteDiscount(subscriptionId: string, options: HeaderOptions, response?: IResponseFn): Promise;; - deleteDiscount(subscriptionId: string, response?: IResponseFn): Promise;; + deleteDiscount(subscriptionId: string, options: HeaderOptions, response?: IResponseFn): Promise; + deleteDiscount(subscriptionId: string, response?: IResponseFn): Promise; } class Subscriptions extends SubscriptionsBase { @@ -6591,7 +6577,6 @@ declare namespace Stripe { retrieve(disputeId: string, options: HeaderOptions, response?: IResponseFn): Promise; retrieve(disputeId: string, response?: IResponseFn): Promise; - /** * When you get a dispute, contacting your customer is always the best first step. If that doesn't work, you can submit evidence in * order to help us resolve the dispute in your favor. You can do this in your dashboard, but if you prefer, you can use the API to @@ -6623,8 +6608,8 @@ declare namespace Stripe { list(options: HeaderOptions, response?: IResponseFn>): Promise>; list(response?: IResponseFn>): Promise>; - setMetadata(): void; //TODO: Implement placeholder method - getMetadata(): void; //TODO: Implement placeholder method + setMetadata(): void; // TODO: Implement placeholder method + getMetadata(): void; // TODO: Implement placeholder method } class Events extends StripeResource { @@ -6637,7 +6622,6 @@ declare namespace Stripe { retrieve(id: string, options: HeaderOptions, response?: IResponseFn): Promise; retrieve(id: string, response?: IResponseFn): Promise; - /** * List events, going back up to 30 days. */ @@ -6933,7 +6917,7 @@ declare namespace Stripe { /** * Only return plans for the given product. */ - product?: string + product?: string; } /** @@ -6956,7 +6940,7 @@ declare namespace Stripe { * @deprecated */ retrieve(id: string): void; - //options: IDataOptions + // options: IDataOptions /** * @deprecated */ @@ -6983,7 +6967,7 @@ declare namespace Stripe { * @deprecated */ retrieve(id: string): void; - //options: IDataOptions + // options: IDataOptions /** * @deprecated */ @@ -7015,7 +6999,6 @@ declare namespace Stripe { retrieve(id: string, options: HeaderOptions, response?: IResponseFn): Promise; retrieve(id: string, response?: IResponseFn): Promise; - /** * Updates the specified refund by setting the values of the parameters passed. * Any parameters not provided will be left unchanged. @@ -7068,7 +7051,6 @@ declare namespace Stripe { retrieve(tokenId: string, data: IDataOptions, response?: IResponseFn): Promise; retrieve(tokenId: string, options: HeaderOptions, response?: IResponseFn): Promise; retrieve(tokenId: string, response?: IResponseFn): Promise; - } class Transfers extends StripeResource { @@ -7094,7 +7076,6 @@ declare namespace Stripe { retrieve(id: string, options: HeaderOptions, response?: IResponseFn): Promise; retrieve(id: string, response?: IResponseFn): Promise; - /** * Updates the specified transfer by setting the values of the parameters passed. Any parameters not provided will be left * unchanged. @@ -7116,8 +7097,8 @@ declare namespace Stripe { cancel(id: string, options: HeaderOptions, response?: IResponseFn): Promise; cancel(id: string, response?: IResponseFn): Promise; - listTransactions(options: HeaderOptions, response?: IResponseFn>): Promise>; //TODO: Not sure if this should be a list of balance transactions or charges. - listTransactions(response?: IResponseFn>): Promise>; //TODO: Not sure if this should be a list of balance transactions or charges. + listTransactions(options: HeaderOptions, response?: IResponseFn>): Promise>; // TODO: Not sure if this should be a list of balance transactions or charges. + listTransactions(response?: IResponseFn>): Promise>; // TODO: Not sure if this should be a list of balance transactions or charges. /** * When you create a new reversal, you must specify a transfer to create it on. @@ -7176,8 +7157,8 @@ declare namespace Stripe { listReversals(transferId: string, options: HeaderOptions, response?: IResponseFn>): Promise>; listReversals(transferId: string, response?: IResponseFn>): Promise>; - setMetadata(): void; //TODO: Implement placeholder method - getMetadata(): void; //TODO: Implement placeholder method + setMetadata(): void; // TODO: Implement placeholder method + getMetadata(): void; // TODO: Implement placeholder method } class TransferReversals extends StripeResource { @@ -7364,7 +7345,7 @@ declare namespace Stripe { } class WebHooks { - constructEvent(requestBody: any, signature: string | string[], endpointSecret: string, tolerance?: number): webhooks.StripeWebhookEvent; + constructEvent(requestBody: any, signature: string | string[], endpointSecret: string, tolerance?: number): webhooks.StripeWebhookEvent; } class EphemeralKeys { @@ -7380,9 +7361,7 @@ declare namespace Stripe { id: string; } - interface IResponseFn { - (err: IStripeError, value: R): void; - } + type IResponseFn = (err: IStripeError, value: R) => void; interface IDeleteConfirmation { id: string; @@ -7415,7 +7394,7 @@ declare namespace Stripe { * Return values where the created field is before or equal to this timestamp. */ lte?: string; - } + }; /** * A set of key/value pairs that you can attach to an object. It can be useful for storing @@ -7491,7 +7470,6 @@ declare namespace Stripe { tracking_number?: string; } - interface IList { /** * Value is 'list' @@ -7501,7 +7479,7 @@ declare namespace Stripe { /** * An array containing the actual response elements, paginated by any request parameters. */ - data: Array; + data: T[]; /** * Whether or not there are more elements available after this set. If false, this set comprises the end of the list. @@ -7549,8 +7527,8 @@ declare namespace Stripe { } interface IDataOptions { - expand?: Array; - include?: Array; + expand?: string[]; + include?: string[]; } interface IDataOptionsWithMetadata extends IDataOptions { @@ -7598,6 +7576,61 @@ declare namespace Stripe { */ type HeaderOptions = IHeaderOptions | string; + /** + * Contains all stripe error classes + */ + namespace errors { + class _Error extends Error { + readonly message: string; + } + namespace _Error { + } + + type RawType = 'card_error' | 'invalid_request_error' | 'api_error' | 'idempotency_error'; + + abstract class StripeError extends _Error implements IStripeError { + static populate(type: RawType): StripeError; + readonly rawType: RawType; + readonly code?: string; + readonly raw: any; + readonly headers: { + [key: string]: string; + }; + readonly requestId: string; + readonly detail?: any; + readonly: number; + readonly params?: string; + readonly type: string; + } + class StripeCardError extends StripeError { + readonly type: 'StripeCardError'; + } + class StripeInvalidRequestError extends StripeError { + readonly type: 'StripeInvalidRequestError'; + } + class StripeAPIError extends StripeError { + readonly type: 'StripeAPIError'; + } + class StripeAuthenticationError extends StripeError { + readonly type: 'StripeAuthenticationError'; + } + class StripePermissionError extends StripeError { + readonly type: 'StripePermissionError'; + } + class StripeRateLimitError extends StripeError { + readonly type: 'StripeRateLimitError'; + } + class StripeConnectionError extends StripeError { + readonly type: 'StripeConnectionError'; + } + class StripeSignatureVerificationError extends StripeError { + readonly type: 'StripeSignatureVerificationError'; + } + class StripeIdempotencyError extends StripeError { + readonly type: 'StripeIdempotencyError'; + } + } + /** * Stripe uses conventional HTTP response codes to indicate success or failure of an API request. * In general, codes in the 2xx range indicate success, codes in the 4xx range indicate an error that diff --git a/types/stripe/stripe-tests.ts b/types/stripe/stripe-tests.ts index 46362b9f8c..685f29cd77 100644 --- a/types/stripe/stripe-tests.ts +++ b/types/stripe/stripe-tests.ts @@ -1,40 +1,40 @@ import Stripe = require('stripe'); import { customers } from 'stripe'; -var stripe = new Stripe("sk_test_BF573NobVn98OiIsPAv7A04K") +const stripe = new Stripe("sk_test_BF573NobVn98OiIsPAv7A04K"); stripe.setApiVersion('2017-04-06'); //#region Balance tests // ################################################################################## -stripe.balance.retrieve(function (err, balance) { +stripe.balance.retrieve((err, balance) => { // asynchronously called }); -stripe.balance.retrieve().then(function (balance) { +stripe.balance.retrieve().then((balance) => { // asynchronously called }); stripe.balance.retrieveTransaction( "txn_17xMvmBoqMA9o2xkYNH2ewNj", - function (err, balanceTransaction) { + (err, balanceTransaction) => { // asynchronously called } ); stripe.balance.retrieveTransaction( "txn_17xMvmBoqMA9o2xkYNH2ewNj").then( - function (balanceTransaction) { + (balanceTransaction) => { // asynchronously called } ); -stripe.balance.listTransactions({ limit: 3 }, function (err, transactions) { +stripe.balance.listTransactions({ limit: 3 }, (err, transactions) => { // asynchronously called }); -stripe.balance.listTransactions({ limit: 3 }).then( function (transactions) { +stripe.balance.listTransactions({ limit: 3 }).then((transactions) => { // asynchronously called }); -stripe.balance.listTransactions().then(function (transactions) { +stripe.balance.listTransactions().then((transactions) => { // asynchronously called }); //#endregion @@ -47,7 +47,7 @@ stripe.charges.create({ currency: "gbp", source: "tok_17wV94BoqMA9o2xkhlAd3ALf", // obtained with Stripe.js description: "Charge for test@example.com" -}, function (err, charge) { +}, (err, charge) => { // asynchronously called }); stripe.charges.create({ @@ -55,40 +55,37 @@ stripe.charges.create({ currency: "gbp", source: "tok_17wV94BoqMA9o2xkhlAd3ALf", // obtained with Stripe.js description: "Charge for test@example.com" -}).then(function (charge) { +}).then((charge) => { // asynchronously called - charge.refunds.create().then(function (refund) { + charge.refunds.create().then((refund) => { const reason = refund.failure_reason; // asynchronously called }); - charge.refunds.create({ amount: 100 }).then(function (refund) { + charge.refunds.create({ amount: 100 }).then((refund) => { // asynchronously called }); - charge.refunds.retrieve("re_15jzA4Ee31JkLCeQcxbTbjaL").then(function (refund) { - var status: "pending" | "succeeded" | "failed" | "canceled" = refund.status; + charge.refunds.retrieve("re_15jzA4Ee31JkLCeQcxbTbjaL").then((refund) => { + const status: "pending" | "succeeded" | "failed" | "canceled" = refund.status; }); - charge.refunds.update("re_15jzA4Ee31JkLCeQcxbTbjaL", { metadata: { test: "data" } }).then(function (refund) { - + charge.refunds.update("re_15jzA4Ee31JkLCeQcxbTbjaL", { metadata: { test: "data" } }).then((refund) => { }); - charge.refunds.list({ limit: 3 }).then(function (refund) { - + charge.refunds.list({ limit: 3 }).then((refund) => { }); - charge.refunds.list().then(function (refund) { - + charge.refunds.list().then((refund) => { }); }); -stripe.charges.retrieve("ch_15fvyXEe31JkLCeQOo0SwFk9", function (err, charge) { +stripe.charges.retrieve("ch_15fvyXEe31JkLCeQOo0SwFk9", (err, charge) => { // asynchronously called if (typeof charge.application_fee === "object") { charge.application_fee.amount; } }); -stripe.charges.retrieve("ch_15fvyXEe31JkLCeQOo0SwFk9").then(function (charge) { +stripe.charges.retrieve("ch_15fvyXEe31JkLCeQOo0SwFk9").then((charge) => { // asynchronously called if (typeof charge.application_fee === "object") { charge.application_fee.amount; @@ -100,7 +97,7 @@ stripe.charges.update( { description: "Charge for test@example.com" }, - function (err, charge) { + (err, charge) => { // asynchronously called } ); @@ -109,55 +106,55 @@ stripe.charges.update( { description: "Charge for test@example.com" }) - .then(function (charge) { + .then((charge) => { // asynchronously called }); -stripe.charges.capture("ch_15fvyXEe31JkLCeQOo0SwFk9", {amount: 1}, {}, function (err, charge) { +stripe.charges.capture("ch_15fvyXEe31JkLCeQOo0SwFk9", {amount: 1}, {}, (err, charge) => { // asynchronously called }); -stripe.charges.capture("ch_15fvyXEe31JkLCeQOo0SwFk9", {amount: 1}, {}).then( function (charge) { +stripe.charges.capture("ch_15fvyXEe31JkLCeQOo0SwFk9", {amount: 1}, {}).then((charge) => { // asynchronously called }); -stripe.charges.capture("ch_15fvyXEe31JkLCeQOo0SwFk9", {}, {},function (err, charge) { +stripe.charges.capture("ch_15fvyXEe31JkLCeQOo0SwFk9", {}, {}, (err, charge) => { // asynchronously called }); -stripe.charges.capture("ch_15fvyXEe31JkLCeQOo0SwFk9", {}).then( function (charge) { +stripe.charges.capture("ch_15fvyXEe31JkLCeQOo0SwFk9", {}).then((charge) => { // asynchronously called }); -stripe.charges.capture("ch_15fvyXEe31JkLCeQOo0SwFk9").then( function (charge) { +stripe.charges.capture("ch_15fvyXEe31JkLCeQOo0SwFk9").then((charge) => { // asynchronously called }); -stripe.charges.list({ limit: 3 }, function (err, charges) { +stripe.charges.list({ limit: 3 }, (err, charges) => { // asynchronously called }); -stripe.charges.list({ limit: 3 }).then(function (charges) { +stripe.charges.list({ limit: 3 }).then((charges) => { // asynchronously called }); stripe.charges.refund("ch_15fvyXEe31JkLCeQOo0SwFk9", {}, - function (err, refund) { + (err, refund) => { // asynchronously called } ); -stripe.charges.refund("ch_15fvyXEe31JkLCeQOo0SwFk9", {}).then(function (refund) { +stripe.charges.refund("ch_15fvyXEe31JkLCeQOo0SwFk9", {}).then((refund) => { // asynchronously called }); -stripe.charges.refund("ch_15fvyXEe31JkLCeQOo0SwFk9").then(function (refund) { +stripe.charges.refund("ch_15fvyXEe31JkLCeQOo0SwFk9").then((refund) => { // asynchronously called }); stripe.charges.retrieveRefund( "ch_15fvyXEe31JkLCeQOo0SwFk9", "re_15jzA4Ee31JkLCeQcxbTbjaL", - function (err, refund) { + (err, refund) => { // asynchronously called } ); stripe.charges.retrieveRefund( "ch_15fvyXEe31JkLCeQOo0SwFk9", - "re_15jzA4Ee31JkLCeQcxbTbjaL").then(function (refund) { + "re_15jzA4Ee31JkLCeQcxbTbjaL").then((refund) => { // asynchronously called } ); @@ -165,17 +162,17 @@ stripe.charges.retrieveRefund( stripe.charges.createRefund( "ch_15fvyXEe31JkLCeQOo0SwFk9", {}, - function (err, refund) { + (err, refund) => { // asynchronously called } ); stripe.charges.createRefund( "ch_15fvyXEe31JkLCeQOo0SwFk9", - function (err, refund) { + (err, refund) => { // asynchronously called } ); -stripe.charges.createRefund("ch_15fvyXEe31JkLCeQOo0SwFk9").then(function (refund) { +stripe.charges.createRefund("ch_15fvyXEe31JkLCeQOo0SwFk9").then((refund) => { // asynchronously called }); @@ -183,45 +180,43 @@ stripe.charges.updateRefund( "ch_15fvyXEe31JkLCeQOo0SwFk9", "re_15jzA4Ee31JkLCeQcxbTbjaL", { metadata: { key: "value" } }, - function (err: Stripe.IStripeError, refund: Stripe.refunds.IRefund) { + (err: Stripe.IStripeError, refund: Stripe.refunds.IRefund) => { // asynchronously called - } ); stripe.charges.updateRefund( "ch_15fvyXEe31JkLCeQOo0SwFk9", "re_15jzA4Ee31JkLCeQcxbTbjaL", { metadata: { key: "value" } }).then( - function (refund) { + (refund) => { // asynchronously called - } ); -stripe.charges.listRefunds('ch_15fvyXEe31JkLCeQOo0SwFk9', function (err, refunds) { +stripe.charges.listRefunds('ch_15fvyXEe31JkLCeQOo0SwFk9', (err, refunds) => { // asynchronously called }); -stripe.charges.listRefunds('ch_15fvyXEe31JkLCeQOo0SwFk9').then(function (refunds) { +stripe.charges.listRefunds('ch_15fvyXEe31JkLCeQOo0SwFk9').then((refunds) => { // asynchronously called }); -stripe.charges.listRefunds('ch_15fvyXEe31JkLCeQOo0SwFk9', { limit: 3 }, function (err, refunds) { +stripe.charges.listRefunds('ch_15fvyXEe31JkLCeQOo0SwFk9', { limit: 3 }, (err, refunds) => { // asynchronously called }); -stripe.charges.listRefunds('ch_15fvyXEe31JkLCeQOo0SwFk9', { limit: 3 }).then(function (refunds) { +stripe.charges.listRefunds('ch_15fvyXEe31JkLCeQOo0SwFk9', { limit: 3 }).then((refunds) => { // asynchronously called }); -stripe.charges.markAsSafe('ch_15fvyXEe31JkLCeQOo0SwFk9', function (err, refunds) { +stripe.charges.markAsSafe('ch_15fvyXEe31JkLCeQOo0SwFk9', (err, refunds) => { // asynchronously called }); -stripe.charges.markAsSafe('ch_15fvyXEe31JkLCeQOo0SwFk9').then(function (refunds) { +stripe.charges.markAsSafe('ch_15fvyXEe31JkLCeQOo0SwFk9').then((refunds) => { // asynchronously called }); -stripe.charges.markAsFraudulent('ch_15fvyXEe31JkLCeQOo0SwFk9', function (err, refunds) { +stripe.charges.markAsFraudulent('ch_15fvyXEe31JkLCeQOo0SwFk9', (err, refunds) => { // asynchronously called }); -stripe.charges.markAsFraudulent('ch_15fvyXEe31JkLCeQOo0SwFk9').then(function (refunds) { +stripe.charges.markAsFraudulent('ch_15fvyXEe31JkLCeQOo0SwFk9').then((refunds) => { // asynchronously called }); @@ -234,73 +229,71 @@ stripe.customers.create({ description: 'Customer for test@example.com', source: "tok_15V2YhEe31JkLCeQy9iUgsJX", // obtained with Stripe.js metadata: { test: "123", test2: 123 } // IOptionsMetadata test -}, function (err, customer) { +}, (err, customer) => { // asynchronously called }); stripe.customers.create({ description: 'Customer for test@example.com', source: "tok_15V2YhEe31JkLCeQy9iUgsJX", // obtained with Stripe.js metadata: null // IOptionsMetadata test -}).then( function (customer) { +}).then((customer) => { // asynchronously called - customer.cards.create({ card: "tok_17wV94BoqMA9o2xkhlAd3ALf"}).then(function (customer) {}); - customer.cards.retrieve("card_17xMvXBoqMA9o2xkq6W5gamx").then(function (card) { - let strCustomer: string = card.customer; - let objCustomer: customers.ICustomer = card.customer; + customer.cards.create({ card: "tok_17wV94BoqMA9o2xkhlAd3ALf"}).then((customer) => {}); + customer.cards.retrieve("card_17xMvXBoqMA9o2xkq6W5gamx").then((card) => { + const strCustomer: string = card.customer as string; + const objCustomer: customers.ICustomer = card.customer as customers.ICustomer; }); - customer.cards.update("card_17xMvXBoqMA9o2xkq6W5gamx", { name: "Test" }).then(function (card) {}); - customer.cards.list().then(function (cards) {}); - customer.cards.del("card_17xMvXBoqMA9o2xkq6W5gamx").then(function (confirmation) {}); + customer.cards.update("card_17xMvXBoqMA9o2xkq6W5gamx", { name: "Test" }).then((card) => {}); + customer.cards.list().then((cards) => {}); + customer.cards.del("card_17xMvXBoqMA9o2xkq6W5gamx").then((confirmation) => {}); - customer.subscriptions.create({ items: [{ plan: "gold" }], trial_period_days: 7 }).then(function (subscription) { }); - customer.subscriptions.create({ items: [{ plan: "gold" }], trial_end: "now", billing_cycle_anchor: 1516881177, prorate: true }).then(function (subscription) { }); - customer.subscriptions.create({ items: [{ plan: "gold" }], trial_end: 1516881177, billing: "send_invoice", days_until_due: 7 }).then(function (subscription) { }); - customer.subscriptions.create({ items: [{ plan: "gold" }], billing: "charge_automatically" }).then(function (subscription) { }); - customer.subscriptions.retrieve("sub_8Eluur5KoIKxuy").then(function (subscription) { - customer.subscriptions.update("sub_8Eluur5KoIKxuy", { items: [{ id: subscription.items.data[0].id, plan: "silver" }] }).then(function (subscription) { }); + customer.subscriptions.create({ items: [{ plan: "gold" }], trial_period_days: 7 }).then((subscription) => { }); + customer.subscriptions.create({ items: [{ plan: "gold" }], trial_end: "now", billing_cycle_anchor: 1516881177, prorate: true }).then((subscription) => { }); + customer.subscriptions.create({ items: [{ plan: "gold" }], trial_end: 1516881177, billing: "send_invoice", days_until_due: 7 }).then((subscription) => { }); + customer.subscriptions.create({ items: [{ plan: "gold" }], billing: "charge_automatically" }).then((subscription) => { }); + customer.subscriptions.retrieve("sub_8Eluur5KoIKxuy").then((subscription) => { + customer.subscriptions.update("sub_8Eluur5KoIKxuy", { items: [{ id: subscription.items.data[0].id, plan: "silver" }] }).then((subscription) => { }); }); customer.subscriptions.update("sub_8Eluur5KoIKxuy", { trial_end: "now", billing_cycle_anchor: "now" }); customer.subscriptions.update("sub_8Eluur5KoIKxuy", { trial_end: 1516881177, billing: "send_invoice", days_until_due: 7, billing_cycle_anchor: "unchanged", cancel_at_period_end: false }); - customer.subscriptions.list().then(function (subscriptions) { }); - customer.subscriptions.del("sub_8Eluur5KoIKxuy").then(function (subscription) { }); - customer.subscriptions.deleteDiscount("sub_8Eluur5KoIKxuy").then(function (confirmation) { }); + customer.subscriptions.list().then((subscriptions) => { }); + customer.subscriptions.del("sub_8Eluur5KoIKxuy").then((subscription) => { }); + customer.subscriptions.deleteDiscount("sub_8Eluur5KoIKxuy").then((confirmation) => { }); // IMetadata tests: - let str: string; - customer.metadata["test"] == str; - customer.metadata.test1 == str; + const str = '123'; + customer.metadata["test"] === str; + customer.metadata.test1 === str; - //IOptionsMetadata tests: + // IOptionsMetadata tests: let metadata: Stripe.IOptionsMetadata; - let num: number; + const num = 123; metadata["test"] = str; metadata["test"] = num; - metadata["test"] == str; - metadata["test"] == num; + metadata["test"] === str; + metadata["test"] === num; metadata.testStr = str; metadata.testNum = num; - metadata.test1 == str; - metadata.test2 == num; + metadata.test1 === str; + metadata.test2 === num; metadata = { test1: str, test2: num - } + }; metadata = {}; metadata = null; }); - stripe.customers.create({ description: 'Customer for test@example.com', source: "tok_15V2YhEe31JkLCeQy9iUgsJX" // obtained with Stripe.js -}, { stripe_account: "" }, function (err, customer) { +}, { stripe_account: "" }, (err, customer) => { // asynchronously called }); stripe.customers.create({ description: 'Customer for test@example.com', source: "tok_15V2YhEe31JkLCeQy9iUgsJX" // obtained with Stripe.js -}, { stripe_account: "" }).then(function (customer) { - +}, { stripe_account: "" }).then((customer) => { }); // {"now"} for trial_end @@ -321,76 +314,76 @@ stripe.customers.create({ stripe.customers.retrieve( "cus_5rfJKDJkuxzh5Q", - function (err, customer) { + (err, customer) => { // asynchronously called customer.cards.create( { card: "tok_15V2YhEe31JkLCeQy9iUgsJX" }, - function (err, card) { + (err, card) => { // asynchronously called card.brand; } ); } ); -stripe.customers.retrieve("cus_5rfJKDJkuxzh5Q").then(function (customer) { +stripe.customers.retrieve("cus_5rfJKDJkuxzh5Q").then((customer) => { // asynchronously called }); stripe.customers.update("cus_5rfJKDJkuxzh5Q", { description: "Customer for test@example.com" -}, function (err, customer) { +}, (err, customer) => { // asynchronously called }); stripe.customers.update("cus_5rfJKDJkuxzh5Q", { description: "Customer for test@example.com" -}).then(function (customer) { +}).then((customer) => { // asynchronously called }); stripe.customers.del( "cus_5rfJKDJkuxzh5Q", - function (err, confirmation) { + (err, confirmation) => { // asynchronously called } ); -stripe.customers.del("cus_5rfJKDJkuxzh5Q").then(function (confirmation) { +stripe.customers.del("cus_5rfJKDJkuxzh5Q").then((confirmation) => { // asynchronously called } ); -stripe.customers.list({ limit: 3 }, function (err, customers) { +stripe.customers.list({ limit: 3 }, (err, customers) => { // asynchronously called }); -stripe.customers.list({ limit: 3 }).then(function (customers) { +stripe.customers.list({ limit: 3 }).then((customers) => { // asynchronously called }); -stripe.customers.list({ email: "test@example.com" }).then(function (customers) { +stripe.customers.list({ email: "test@example.com" }).then((customers) => { // asynchronously called }); stripe.customers.createCard( "cus_5rfJKDJkuxzh5Q", { card: "tok_15V2YhEe31JkLCeQy9iUgsJX" }, - function (err, card) { + (err, card) => { // asynchronously called } ); -stripe.customers.createCard("cus_5rfJKDJkuxzh5Q", { card: "tok_15V2YhEe31JkLCeQy9iUgsJX" }).then(function (card) { +stripe.customers.createCard("cus_5rfJKDJkuxzh5Q", { card: "tok_15V2YhEe31JkLCeQy9iUgsJX" }).then((card) => { // asynchronously called }); stripe.customers.createSource( "cus_5rfJKDJkuxzh5Q", { source: "tok_15V2YhEe31JkLCeQy9iUgsJX" }, - function (err, source) { - var card = source; - var bankAcc = source; + (err, source) => { + const card = source as Stripe.ICard; + const bankAcc = source as Stripe.IBankAccount; } ); -stripe.customers.createSource("cus_5rfJKDJkuxzh5Q", { source: "tok_15V2YhEe31JkLCeQy9iUgsJX" }).then(function (source) { - var card = source; - var bankAcc = source; +stripe.customers.createSource("cus_5rfJKDJkuxzh5Q", { source: "tok_15V2YhEe31JkLCeQy9iUgsJX" }).then((source) => { + const card = source as Stripe.ICard; + const bankAcc = source as Stripe.IBankAccount; }); stripe.customers.createSource( @@ -403,9 +396,9 @@ stripe.customers.createSource( number: '4242424242424242' } }, - function (err, card) { + (err, card) => { // asynchronously called - var obj: Stripe.ICard = card; + const obj: Stripe.ICard = card; } ); stripe.customers.createSource( @@ -418,23 +411,23 @@ stripe.customers.createSource( number: '4242424242424242' } }).then( - function (card) { + (card) => { // asynchronously called - var obj: Stripe.ICard = card; + const obj: Stripe.ICard = card; } ); stripe.customers.createSource( "cus_5rfJKDJkuxzh5Q", { source: "btok_8E264Lxsbyvj3E" }, - function (err: Stripe.IStripeError, bankAcc: Stripe.IBankAccount) { + (err: Stripe.IStripeError, bankAcc: Stripe.IBankAccount) => { // asynchronously called bankAcc.bank_name; } ); stripe.customers.createSource( "cus_5rfJKDJkuxzh5Q", - { source: "btok_8E264Lxsbyvj3E" }).then(function (bankAcc: Stripe.IBankAccount) { + { source: "btok_8E264Lxsbyvj3E" }).then((bankAcc: Stripe.IBankAccount) => { // asynchronously called bankAcc.bank_name; } @@ -443,99 +436,99 @@ stripe.customers.createSource( stripe.customers.retrieveCard( "cus_5rfJKDJkuxzh5Q", "card_15fvyXEe31JkLCeQ9KMktP5S", - function (err, card) { + (err, card) => { // asynchronously called - var obj: Stripe.ICard = card; + const obj: Stripe.ICard = card; } ); stripe.customers.retrieveCard( "cus_5rfJKDJkuxzh5Q", - "card_15fvyXEe31JkLCeQ9KMktP5S").then(function (card) { + "card_15fvyXEe31JkLCeQ9KMktP5S").then((card) => { // asynchronously called - var obj: Stripe.ICard = card; + const obj: Stripe.ICard = card; }); stripe.customers.updateCard( "cus_5rfJKDJkuxzh5Q", "card_15fvyXEe31JkLCeQ9KMktP5S", { name: "Jane Austen" }, - function (err, card) { + (err, card) => { // asynchronously called - var obj: Stripe.ICard = card; + const obj: Stripe.ICard = card; } ); stripe.customers.updateCard( "cus_5rfJKDJkuxzh5Q", "card_15fvyXEe31JkLCeQ9KMktP5S", - { name: "Jane Austen" }).then(function (card) { + { name: "Jane Austen" }).then((card) => { // asynchronously called - var obj: Stripe.ICard = card; + const obj: Stripe.ICard = card; }); stripe.customers.deleteCard( "cus_5rfJKDJkuxzh5Q", "card_15fvyXEe31JkLCeQ9KMktP5S", - function (err, confirmation) { + (err, confirmation) => { // asynchronously called } ); stripe.customers.deleteCard( "cus_5rfJKDJkuxzh5Q", - "card_15fvyXEe31JkLCeQ9KMktP5S").then(function (confirmation) { + "card_15fvyXEe31JkLCeQ9KMktP5S").then((confirmation) => { // asynchronously called }); -stripe.customers.listCards('cu_15fvyVEe31JkLCeQvr155iqc', null, function (err, cards) { +stripe.customers.listCards('cu_15fvyVEe31JkLCeQvr155iqc', null, (err, cards) => { // asynchronously called }); -stripe.customers.listCards('cu_15fvyVEe31JkLCeQvr155iqc', null).then(function (cards) { +stripe.customers.listCards('cu_15fvyVEe31JkLCeQvr155iqc', null).then((cards) => { // asynchronously called }); -stripe.customers.listCards('cu_15fvyVEe31JkLCeQvr155iqc', function (err, cards) { +stripe.customers.listCards('cu_15fvyVEe31JkLCeQvr155iqc', (err, cards) => { // asynchronously called }); -stripe.customers.listCards('cu_15fvyVEe31JkLCeQvr155iqc').then(function (cards) { +stripe.customers.listCards('cu_15fvyVEe31JkLCeQvr155iqc').then((cards) => { // asynchronously called }); -stripe.customers.listSources('cu_15fvyVEe31JkLCeQvr155iqc', null, function (err, cards) { +stripe.customers.listSources('cu_15fvyVEe31JkLCeQvr155iqc', null, (err, cards) => { // asynchronously called }); -stripe.customers.listSources('cu_15fvyVEe31JkLCeQvr155iqc', null).then(function (cards) { +stripe.customers.listSources('cu_15fvyVEe31JkLCeQvr155iqc', null).then((cards) => { // asynchronously called }); stripe.customers.listSources('cu_15fvyVEe31JkLCeQvr155iqc', { object: "card", limit: 100 -}).then(function (cards) { +}).then((cards) => { // asynchronously called }); stripe.customers.listSources('cu_15fvyVEe31JkLCeQvr155iqc', { object: "bank_account", limit: 100 -}).then(function (cards) { +}).then((cards) => { // asynchronously called }); stripe.customers.retrieveSubscription( "cus_5rfJKDJkuxzh5Q", "sub_5rfJxnBLGSwsYp", - function (err, subscription) { + (err, subscription) => { // asynchronously called } ); -stripe.customers.retrieveSubscription("cus_5rfJKDJkuxzh5Q", "sub_5rfJxnBLGSwsYp").then(function (subscription) { +stripe.customers.retrieveSubscription("cus_5rfJKDJkuxzh5Q", "sub_5rfJxnBLGSwsYp").then((subscription) => { // asynchronously called }); stripe.customers.updateSubscription("cus_5rfJKDJkuxzh5Q", "sub_5rfJxnBLGSwsYp", { items: [{ id: "si_62U5U5BoqBA2o2xp6Eqcl6J7", plan: "platypi-dev" }] }, - function (err, subscription) { + (err, subscription) => { // asynchronously called } ); -stripe.customers.updateSubscription("cus_5rfJKDJkuxzh5Q", "sub_5rfJxnBLGSwsYp", { items: [{ id: "si_62U5U5BoqBA2o2xp6Eqcl6J7", plan: "platypi-dev" }] }).then(function (subscription) { +stripe.customers.updateSubscription("cus_5rfJKDJkuxzh5Q", "sub_5rfJxnBLGSwsYp", { items: [{ id: "si_62U5U5BoqBA2o2xp6Eqcl6J7", plan: "platypi-dev" }] }).then((subscription) => { // asynchronously called }); @@ -543,50 +536,50 @@ stripe.customers.cancelSubscription( "cus_5rfJKDJkuxzh5Q", "sub_5rfJxnBLGSwsYp", null, - function (err, confirmation) { + (err, confirmation) => { // asynchronously called } ); -stripe.customers.cancelSubscription("cus_5rfJKDJkuxzh5Q", "sub_5rfJxnBLGSwsYp", null).then(function (confirmation) { +stripe.customers.cancelSubscription("cus_5rfJKDJkuxzh5Q", "sub_5rfJxnBLGSwsYp", null).then((confirmation) => { // asynchronously called }); stripe.customers.cancelSubscription( "cus_5rfJKDJkuxzh5Q", "sub_5rfJxnBLGSwsYp", - function (err, confirmation) { + (err, confirmation) => { // asynchronously called } ); -stripe.customers.cancelSubscription("cus_5rfJKDJkuxzh5Q", "sub_5rfJxnBLGSwsYp").then(function (confirmation) { +stripe.customers.cancelSubscription("cus_5rfJKDJkuxzh5Q", "sub_5rfJxnBLGSwsYp").then((confirmation) => { // asynchronously called }); -stripe.customers.listSubscriptions('cu_15fvyVEe31JkLCeQvr155iqc', null, function (err, subscriptions) { +stripe.customers.listSubscriptions('cu_15fvyVEe31JkLCeQvr155iqc', null, (err, subscriptions) => { // asynchronously called }); -stripe.customers.listSubscriptions('cu_15fvyVEe31JkLCeQvr155iqc', null).then(function (subscriptions) { +stripe.customers.listSubscriptions('cu_15fvyVEe31JkLCeQvr155iqc', null).then((subscriptions) => { // asynchronously called }); -stripe.customers.listSubscriptions('cu_15fvyVEe31JkLCeQvr155iqc', function (err, subscriptions) { +stripe.customers.listSubscriptions('cu_15fvyVEe31JkLCeQvr155iqc', (err, subscriptions) => { // asynchronously called }); -stripe.customers.listSubscriptions('cu_15fvyVEe31JkLCeQvr155iqc').then(function (subscriptions) { +stripe.customers.listSubscriptions('cu_15fvyVEe31JkLCeQvr155iqc').then((subscriptions) => { // asynchronously called }); -stripe.customers.deleteDiscount("cus_5rfJKDJkuxzh5Q", function (err, confirmation) { +stripe.customers.deleteDiscount("cus_5rfJKDJkuxzh5Q", (err, confirmation) => { // asynchronously called }); -stripe.customers.deleteDiscount("cus_5rfJKDJkuxzh5Q").then(function (confirmation) { +stripe.customers.deleteDiscount("cus_5rfJKDJkuxzh5Q").then((confirmation) => { // asynchronously called }); -stripe.customers.deleteSubscriptionDiscount("cus_5rfJKDJkuxzh5Q", "sub_5rfJxnBLGSwsYp", function (err, confirmation) { +stripe.customers.deleteSubscriptionDiscount("cus_5rfJKDJkuxzh5Q", "sub_5rfJxnBLGSwsYp", (err, confirmation) => { // asynchronously called }); -stripe.customers.deleteSubscriptionDiscount("cus_5rfJKDJkuxzh5Q", "sub_5rfJxnBLGSwsYp").then(function (confirmation) { +stripe.customers.deleteSubscriptionDiscount("cus_5rfJKDJkuxzh5Q", "sub_5rfJxnBLGSwsYp").then((confirmation) => { // asynchronously called }); @@ -610,7 +603,6 @@ stripe.customers.deleteSubscriptionDiscount("cus_5rfJKDJkuxzh5Q", "sub_5rfJxnBLG //#region Refunds tests // ################################################################################## - //#endregion //#region Tokens tests @@ -626,15 +618,14 @@ stripe.customers.deleteSubscriptionDiscount("cus_5rfJKDJkuxzh5Q", "sub_5rfJxnBLG //#region Transfers Reversals tests // ################################################################################## -stripe.transfers.createReversal("tr_17F2JBFuhr4V1legrq97JrFE", function (err, reversal) { +stripe.transfers.createReversal("tr_17F2JBFuhr4V1legrq97JrFE", (err, reversal) => { // asynchronously called }); -stripe.transfers.createReversal("tr_17F2JBFuhr4V1legrq97JrFE").then(function (reversal) { +stripe.transfers.createReversal("tr_17F2JBFuhr4V1legrq97JrFE").then((reversal) => { // asynchronously called }); - //#endregion //#region Accounts test @@ -643,26 +634,26 @@ stripe.transfers.createReversal("tr_17F2JBFuhr4V1legrq97JrFE").then(function (re stripe.accounts.create({ email: "", type: "standard" -}, function (err, customer) { +}, (err, customer) => { // asynchronously called } ); stripe.accounts.create({ type: "custom" -}).then(function (customer) { +}).then((customer) => { // asynchronously called } ); stripe.accounts.retrieve( "acct_17wV8KBoqMA9o2xk", - function (err, account) { + (err, account) => { // asynchronously called } ); stripe.accounts.retrieve( "acct_17wV8KBoqMA9o2xk").then( - function (account) { + (account) => { // asynchronously called } ); @@ -671,7 +662,7 @@ stripe.accounts.update("acct_17wV8KBoqMA9o2xk", { support_phone: "555-867-5309" }, - function(err, account) { + (err, account) => { // asynchronously called } ); @@ -679,7 +670,7 @@ stripe.accounts.update("acct_17wV8KBoqMA9o2xk", { support_phone: "555-867-5309" }).then( - function(account) { + (account) => { // asynchronously called } ); @@ -688,7 +679,7 @@ stripe.accounts.update("acct_17wV8KBoqMA9o2xk", { payout_statement_descriptor: "From Stripe" }).then( - function (account) { + (account) => { // asynchronously called } ); @@ -702,36 +693,36 @@ stripe.accounts.update("acct_17wV8KBoqMA9o2xk", weekly_anchor: "monday" } }).then( - function (account) { + (account) => { // asynchronously called } ); -stripe.accounts.del("acct_17wV8KBoqMA9o2xk", function (err, confirmation) { }); -stripe.accounts.del("acct_17wV8KBoqMA9o2xk").then(function (confirmation) { }); +stripe.accounts.del("acct_17wV8KBoqMA9o2xk", (err, confirmation) => { }); +stripe.accounts.del("acct_17wV8KBoqMA9o2xk").then((confirmation) => { }); -stripe.accounts.reject("acct_17wV8KBoqMA9o2xk", { reason: 'fraud' }, function (err, account) { +stripe.accounts.reject("acct_17wV8KBoqMA9o2xk", { reason: 'fraud' }, (err, account) => { // asynchronously called }); -stripe.accounts.reject("acct_17wV8KBoqMA9o2xk", { reason: 'fraud' }).then(function (account) { +stripe.accounts.reject("acct_17wV8KBoqMA9o2xk", { reason: 'fraud' }).then((account) => { // asynchronously called }); stripe.accounts.list( { limit: 3 }, - function (err, accounts) { + (err, accounts) => { // asynchronously called } ); stripe.accounts.list( { limit: 3 }).then( - function (accounts) { + (accounts) => { // asynchronously called } ); stripe.accounts.retrieve("acct_17wV8KBoqMA9o2xk").then( - function (accounts) { - var payouts_enabled: boolean = accounts.payouts_enabled; + (accounts) => { + const payouts_enabled: boolean = accounts.payouts_enabled; } ); //#endregion @@ -739,43 +730,37 @@ stripe.accounts.retrieve("acct_17wV8KBoqMA9o2xk").then( //#region Application Fee Refunds tests // ################################################################################## - - //#endregion //#region Application Fees tests // ################################################################################## - - //#endregion //#region Country Specs tests // ################################################################################## - - //#endregion //#region External Accounts tests // ################################################################################## -stripe.accounts.createExternalAccount("", { external_account: "btok_8E264Lxsbyvj3E" }, function (err, extAcc) { - var card = extAcc; - var bankAcc = extAcc; +stripe.accounts.createExternalAccount("", { external_account: "btok_8E264Lxsbyvj3E" }, (err, extAcc) => { + const card = extAcc as Stripe.ICard; + const bankAcc = extAcc as Stripe.IBankAccount; }); -stripe.accounts.createExternalAccount("", { external_account: "tok_15V2YhEe31JkLCeQy9iUgsJX" }).then(function (extAcc) { - var card = extAcc; - var bankAcc = extAcc; +stripe.accounts.createExternalAccount("", { external_account: "tok_15V2YhEe31JkLCeQy9iUgsJX" }).then((extAcc) => { + const card = extAcc as Stripe.ICard; + const bankAcc = extAcc as Stripe.IBankAccount; }); -stripe.accounts.createExternalAccount("", { external_account: "tok_15V2YhEe31JkLCeQy9iUgsJX" }, { stripe_account: "acct_17wV8KOoqMF9a2xk" }).then(function (extAcc) { - var card = extAcc; - var bankAcc = extAcc; +stripe.accounts.createExternalAccount("", { external_account: "tok_15V2YhEe31JkLCeQy9iUgsJX" }, { stripe_account: "acct_17wV8KOoqMF9a2xk" }).then((extAcc) => { + const card = extAcc as Stripe.ICard; + const bankAcc = extAcc as Stripe.IBankAccount; }); -stripe.accounts.createExternalAccount("", { external_account: "tok_15V2YhEe31JkLCeQy9iUgsJX" }, "acct_17wV8KOoqMF9a2xk").then(function (extAcc) { - var card = extAcc; - var bankAcc = extAcc; +stripe.accounts.createExternalAccount("", { external_account: "tok_15V2YhEe31JkLCeQy9iUgsJX" }, "acct_17wV8KOoqMF9a2xk").then((extAcc) => { + const card = extAcc as Stripe.ICard; + const bankAcc = extAcc as Stripe.IBankAccount; }); //#endregion @@ -783,39 +768,30 @@ stripe.accounts.createExternalAccount("", { external_account: "tok_15V2YhEe31JkL //#region Bank Accounts tests // ################################################################################## - - //#endregion //#region Bitcoin Receivers tests // ################################################################################## - - //#endregion //#region Cards tests // ################################################################################## - - //#endregion //#region Orders tests // ################################################################################## -stripe.orders.retrieve("or_1C8XKwEe31JkLCeQHg0jcisf", function (err, order) { +stripe.orders.retrieve("or_1C8XKwEe31JkLCeQHg0jcisf", (err, order) => { // asynchronously called - var amount_returned: number = order.amount_returned; + const amount_returned: number = order.amount_returned; }); - //#endregion //#region Order Items tests // ################################################################################## - - //#endregion //#region Products tests @@ -825,14 +801,14 @@ stripe.products.create({ name: "My amazing product", type: "service", attributes: ["color"] -}, function (err, coupon) { +}, (err, coupon) => { // asynchronously called }); stripe.products.create({ name: "My amazing product", type: "service", attributes: ["color"] -}).then(function (product) { +}).then((product) => { // asynchronously called const prodType: "service" | "good" = product.type; }); @@ -842,8 +818,6 @@ stripe.products.create({ //#region SKUs tests // ################################################################################## - - //#endregion //#region WebHooks tests @@ -855,11 +829,11 @@ const webhookRequest = { }; const webhookSecret = ''; -const event = stripe.webhooks.constructEvent( +const event = stripe.webhooks.constructEvent( webhookRequest.rawBody, webhookRequest.headers['stripe-signature'], webhookSecret -); +) as Stripe.webhooks.StripeWebhookEvent; //#endregion @@ -871,7 +845,7 @@ stripe.coupons.create({ duration: 'repeating', duration_in_months: 3, id: '25OFF' -}, function (err, coupon) { +}, (err, coupon) => { // asynchronously called }); stripe.coupons.create({ @@ -879,42 +853,40 @@ stripe.coupons.create({ duration: 'repeating', duration_in_months: 3, id: '25OFF' -}).then(function (coupon) { +}).then((coupon) => { // asynchronously called }); stripe.coupons.retrieve( "25OFF", - function (err, coupon) { + (err, coupon) => { // asynchronously called } ); -stripe.coupons.retrieve("25OFF").then(function (coupon) { +stripe.coupons.retrieve("25OFF").then((coupon) => { // asynchronously called }); stripe.coupons.update("25OFF", { metadata: { key: "value" } -}, function (err: Stripe.IStripeError, coupon: Stripe.coupons.ICoupon) { +}, (err: Stripe.IStripeError, coupon: Stripe.coupons.ICoupon) => { // asynchronously called }); stripe.coupons.update("25OFF", { metadata: { key: "value" } -}).then(function (coupon) { +}).then((coupon) => { // asynchronously called }); -stripe.coupons.del("25OFF", function (err, confirmation) { - +stripe.coupons.del("25OFF", (err, confirmation) => { }); -stripe.coupons.del("25OFF").then(function (confirmation) { - +stripe.coupons.del("25OFF").then((confirmation) => { }); -stripe.coupons.list({ limit: 3 }, function (err, coupons) { +stripe.coupons.list({ limit: 3 }, (err, coupons) => { // asynchronously called }); -stripe.coupons.list({ limit: 3 }).then(function (coupons) { +stripe.coupons.list({ limit: 3 }).then((coupons) => { // asynchronously called }); @@ -923,8 +895,6 @@ stripe.coupons.list({ limit: 3 }).then(function (coupons) { //#region Discounts tests // ################################################################################## - - //#endregion //#region Invoices tests @@ -932,55 +902,55 @@ stripe.coupons.list({ limit: 3 }).then(function (coupons) { stripe.invoices.create({ customer: "cus_5rfJKDJkuxzh5Q" -}, function (err, invoice) { +}, (err, invoice) => { // asynchronously called }); stripe.invoices.create({ customer: "cus_5rfJKDJkuxzh5Q" -}).then(function (invoice) { +}).then((invoice) => { // asynchronously called }); stripe.invoices.retrieve( "in_15fvyXEe31JkLCeQH7QbgZZb", - function (err, invoice) { + (err, invoice) => { // asynchronously called } ); -stripe.invoices.retrieve("in_15fvyXEe31JkLCeQH7QbgZZb").then(function (invoice) { +stripe.invoices.retrieve("in_15fvyXEe31JkLCeQH7QbgZZb").then((invoice) => { // asynchronously called }); stripe.invoices.retrieveLines( "in_15fvyXEe31JkLCeQH7QbgZZb", { limit: 5 }, - function (err, lines) { + (err, lines) => { // asynchronously called - lines.data[0].type = "invoiceitem" + lines.data[0].type = "invoiceitem"; } ); -stripe.invoices.retrieveLines("in_15fvyXEe31JkLCeQH7QbgZZb", { limit: 5 }).then(function (lines) { +stripe.invoices.retrieveLines("in_15fvyXEe31JkLCeQH7QbgZZb", { limit: 5 }).then((lines) => { // asynchronously called }); stripe.invoices.retrieveUpcoming( "cus_5rfJKDJkuxzh5Q", null, - function (err, upcoming) { + (err, upcoming) => { // asynchronously called } ); -stripe.invoices.retrieveUpcoming("cus_5rfJKDJkuxzh5Q", null).then(function (upcoming) { +stripe.invoices.retrieveUpcoming("cus_5rfJKDJkuxzh5Q", null).then((upcoming) => { // asynchronously called }); stripe.invoices.retrieveUpcoming( "cus_5rfJKDJkuxzh5Q", - function (err, upcoming) { + (err, upcoming) => { // asynchronously called } ); -stripe.invoices.retrieveUpcoming("cus_5rfJKDJkuxzh5Q").then(function (upcoming) { +stripe.invoices.retrieveUpcoming("cus_5rfJKDJkuxzh5Q").then((upcoming) => { // asynchronously called }); @@ -989,7 +959,7 @@ stripe.invoices.update( { closed: true }, - function (err, invoice) { + (err, invoice) => { // asynchronously called } ); @@ -997,43 +967,41 @@ stripe.invoices.update( "in_15fvyXEe31JkLCeQH7QbgZZb", { closed: true - }).then(function (invoice) { + }).then((invoice) => { // asynchronously called } ); -stripe.invoices.pay("in_15fvyXEe31JkLCeQH7QbgZZb", function (err, invoice) { +stripe.invoices.pay("in_15fvyXEe31JkLCeQH7QbgZZb", (err, invoice) => { // asynchronously called }); -stripe.invoices.pay("in_15fvyXEe31JkLCeQH7QbgZZb").then(function (invoice) { +stripe.invoices.pay("in_15fvyXEe31JkLCeQH7QbgZZb").then((invoice) => { // asynchronously called }); -stripe.invoices.pay("in_15fvyXEe31JkLCeQH7QbgZZb", { source: "source_id" }).then(function (invoice) { +stripe.invoices.pay("in_15fvyXEe31JkLCeQH7QbgZZb", { source: "source_id" }).then((invoice) => { // asynchronously called }); stripe.invoices.list( { customer: "cus_5rfJKDJkuxzh5Q", limit: 3 }, - function (err, invoices) { + (err, invoices) => { // asynchronously called } ); -stripe.invoices.list({ customer: "cus_5rfJKDJkuxzh5Q", limit: 3 }).then(function (invoices) { +stripe.invoices.list({ customer: "cus_5rfJKDJkuxzh5Q", limit: 3 }).then((invoices) => { // asynchronously called }); -stripe.invoices.retrieve("in_15fvyXEe31JkLCeQH7QbgZZb", { expand: ["subscription"] }).then(function (invoice) { - invoice.subscription -}) +stripe.invoices.retrieve("in_15fvyXEe31JkLCeQH7QbgZZb", { expand: ["subscription"] }).then((invoice) => { + invoice.subscription; +}); //#endregion //#region Invoice Items tests // ################################################################################## - - //#endregion //#region Payouts tests @@ -1042,109 +1010,109 @@ stripe.payouts.create({ amount: 2000, currency: "usd", description: "The Payout", -}, function(err, payout) {}); +}, (err, payout) => {}); stripe.payouts.create({ amount: 2000, currency: "usd", description: "The Payout", -}).then(function(payout) {}); +}).then((payout) => {}); stripe.payouts.create({ amount: 2000, currency: "usd", description: "The Payout", }, { stripe_account: "acct_abc12345678", -}, function(err, payout) {}); +}, (err, payout) => {}); stripe.payouts.create({ amount: 2000, currency: "usd", description: "The Payout", }, { stripe_account: "acct_abc12345678", -}).then(function(payout) {}); +}).then((payout) => {}); stripe.payouts.retrieve( "po_5rfJKDJkuxzh5Q", - function(err, payout) {} + (err, payout) => {} ); stripe.payouts.retrieve("po_5rfJKDJkuxzh5Q").then( - function(payout) {} + (payout) => {} ); stripe.payouts.retrieve( "po_5rfJKDJkuxzh5Q", { stripe_account: "acct_abc12345678" }, - function(err, payout) {} + (err, payout) => {} ); stripe.payouts.retrieve( "po_5rfJKDJkuxzh5Q", { stripe_account: "acct_abc12345678" } -).then(function(payout) {}); +).then((payout) => {}); stripe.payouts.update( "po_5rfJKDJkuxzh5Q", { metadata: { key: "value" } }, - function(err: Stripe.IStripeError, payout: Stripe.payouts.IPayout) {} + (err: Stripe.IStripeError, payout: Stripe.payouts.IPayout) => {} ); stripe.payouts.update( "po_5rfJKDJkuxzh5Q", { metadata: { key: "value" } }, -).then(function(payout) {}); +).then((payout) => {}); stripe.payouts.update( "po_5rfJKDJkuxzh5Q", { metadata: { key: "value" } }, { stripe_account: "acct_abc12345678" }, - function(err, payout) {} + (err, payout) => {} ); stripe.payouts.update( "po_5rfJKDJkuxzh5Q", { metadata: { key: "value" } }, { stripe_account: "acct_abc12345678" }, -).then(function(payout) {}); +).then((payout) => {}); stripe.payouts.list( { limit: 100 }, { stripe_account: "acct_abc12345678" }, - function(err, payouts) {} + (err, payouts) => {} ); stripe.payouts.list( { limit: 100 }, { stripe_account: "acct_abc12345678" }, -).then(function(payouts) {}); +).then((payouts) => {}); stripe.payouts.list( { limit: 100 }, - function(err, payouts) {} + (err, payouts) => {} ); stripe.payouts.list( { limit: 100 }, -).then(function(payouts) {}); +).then((payouts) => {}); stripe.payouts.list( { stripe_account: "acct_abc12345678" }, - function(err, payouts) {} + (err, payouts) => {} ); stripe.payouts.list( { stripe_account: "acct_abc12345678" }, -).then(function(payouts) {}); +).then((payouts) => {}); stripe.payouts.list( - function(err, payouts) {} + (err, payouts) => {} ); -stripe.payouts.list().then(function(payouts) {}); +stripe.payouts.list().then((payouts) => {}); stripe.payouts.cancel( "po_5rfJKDJkuxzh5Q", { stripe_account: "acct_abc12345678" }, - function(err, payout) {} + (err, payout) => {} ); stripe.payouts.cancel( "po_5rfJKDJkuxzh5Q", { stripe_account: "acct_abc12345678" }, -).then(function(payout) {}); +).then((payout) => {}); stripe.payouts.cancel( "po_5rfJKDJkuxzh5Q", - function(err, payout) {} + (err, payout) => {} ); stripe.payouts.cancel( "po_5rfJKDJkuxzh5Q", -).then(function(payout) {}); +).then((payout) => {}); //#endregion @@ -1167,7 +1135,7 @@ stripe.plans.create({ id: "gold-plan", usage_type: 'metered', billing_scheme: 'per_unit' -}, function (err, plan) { +}, (err, plan) => { // asynchronously called }); @@ -1179,7 +1147,7 @@ stripe.plans.create({ product: { name: "Amazing Gold Plan" } -}).then(function (plan) { +}).then((plan) => { // asynchronously called }); @@ -1189,7 +1157,7 @@ stripe.plans.create({ currency: "usd", interval: "month", product: "prod_UT1t06yZ3iBEHi" -}).then(function (plan) { +}).then((plan) => { // asynchronously called const productId = plan.product as string; }); @@ -1199,52 +1167,52 @@ stripe.plans.retrieve( { expand: ["product"] }, - function (err, plan) { + (err, plan) => { // asynchronously called const product = plan.product as Stripe.products.IProduct; } ); -stripe.plans.retrieve("gold-plan").then(function (plan) { +stripe.plans.retrieve("gold-plan").then((plan) => { // asynchronously called }); stripe.plans.update("gold-plan", { product: "prod_UT1t06yZ3iBEHi" -}, function (err, plan) { +}, (err, plan) => { // asynchronously called }); -stripe.plans.update("gold-plan", { nickname: "New gold plan nickname" }).then(function (plan) { +stripe.plans.update("gold-plan", { nickname: "New gold plan nickname" }).then((plan) => { // asynchronously called }); stripe.plans.del( "gold-plan", - function (err, confirmation) { + (err, confirmation) => { // asynchronously called } ); -stripe.plans.del("gold-plan").then(function (confirmation) { +stripe.plans.del("gold-plan").then((confirmation) => { // asynchronously called }); -stripe.plans.list({ active: true, product: 'prod_someproduct' }, function(err, plans) { +stripe.plans.list({ active: true, product: 'prod_someproduct' }, (err, plans) => { // asynchronously called }); -stripe.plans.list({ active: true, product: 'prod_someproduct' }).then(function (plans) { +stripe.plans.list({ active: true, product: 'prod_someproduct' }).then((plans) => { // asynchronously called }); -stripe.plans.list(null, function (err, plans) { +stripe.plans.list(null, (err, plans) => { // asynchronously called }); -stripe.plans.list(null).then(function (plans) { +stripe.plans.list(null).then((plans) => { // asynchronously called }); -stripe.plans.list(function (err, plans) { +stripe.plans.list((err, plans) => { // asynchronously called }); -stripe.plans.list().then(function (plans) { +stripe.plans.list().then((plans) => { // asynchronously called }); @@ -1253,44 +1221,44 @@ stripe.plans.list().then(function (plans) { //#region Subscriptions tests // ################################################################################## -stripe.subscriptions.create({ items: [{ plan: "platypi-dev" }], customer: "cus_5rfJKDJkuxzh5Q" }, function(err, subscription) { +stripe.subscriptions.create({ items: [{ plan: "platypi-dev" }], customer: "cus_5rfJKDJkuxzh5Q" }, (err, subscription) => { // asynchronously called }); -stripe.subscriptions.create({ items: [{ plan: "platypi-dev" }], customer: "cus_5rfJKDJkuxzh5Q" }).then(function(subscription) { +stripe.subscriptions.create({ items: [{ plan: "platypi-dev" }], customer: "cus_5rfJKDJkuxzh5Q" }).then((subscription) => { // asynchronously called - stripe.subscriptions.update("sub_8QwCiwZ9tmMSpt", { items: [{ id: subscription.items.data[0].id, plan: "platypi" }] }, function(err, subscription) { + stripe.subscriptions.update("sub_8QwCiwZ9tmMSpt", { items: [{ id: subscription.items.data[0].id, plan: "platypi" }] }, (err, subscription) => { // asynchronously called }); - stripe.subscriptions.update("sub_8QwCiwZ9tmMSpt", { items: [{ id: subscription.items.data[0].id, plan: "platypi" }] }).then(function(subscription) { + stripe.subscriptions.update("sub_8QwCiwZ9tmMSpt", { items: [{ id: subscription.items.data[0].id, plan: "platypi" }] }).then((subscription) => { // asynchronously called }); }); -stripe.subscriptions.retrieve("sub_8QwCiwZ9tmMSpt", function(err, subscription) { +stripe.subscriptions.retrieve("sub_8QwCiwZ9tmMSpt", (err, subscription) => { // asynchronously called if (typeof subscription.customer === "object") { subscription.customer.email; } }); -stripe.subscriptions.retrieve("sub_8QwCiwZ9tmMSpt").then(function(subscription) { +stripe.subscriptions.retrieve("sub_8QwCiwZ9tmMSpt").then((subscription) => { // asynchronously called if (typeof subscription.customer === "object") { subscription.customer.email; } }); -stripe.subscriptions.del("sub_8QwCiwZ9tmMSpt", function(err, subscription) { +stripe.subscriptions.del("sub_8QwCiwZ9tmMSpt", (err, subscription) => { // asynchronously called }); -stripe.subscriptions.del("sub_8QwCiwZ9tmMSpt").then(function(subscription) { +stripe.subscriptions.del("sub_8QwCiwZ9tmMSpt").then((subscription) => { // asynchronously called }); -stripe.subscriptions.list({ customer: "cus_5rfJKDJkuxzh5Q", plan: "platypi-dev" }, function(err, subscriptions) { +stripe.subscriptions.list({ customer: "cus_5rfJKDJkuxzh5Q", plan: "platypi-dev" }, (err, subscriptions) => { // asynchronously called }); -stripe.subscriptions.list({ customer: "cus_5rfJKDJkuxzh5Q", plan: "platypi-dev" }).then(function(subscriptions) { +stripe.subscriptions.list({ customer: "cus_5rfJKDJkuxzh5Q", plan: "platypi-dev" }).then((subscriptions) => { // asynchronously called }); @@ -1299,42 +1267,42 @@ stripe.subscriptions.list({ customer: "cus_5rfJKDJkuxzh5Q", plan: "platypi-dev" //#region Subscription Items tests // ################################################################################## -stripe.subscriptionItems.create({ subscription: "sub_C9giwDfCeN8fwt", plan: "platypi-dev" }, function(err, subscriptionItem) { +stripe.subscriptionItems.create({ subscription: "sub_C9giwDfCeN8fwt", plan: "platypi-dev" }, (err, subscriptionItem) => { // asynchronously called }); -stripe.subscriptionItems.create({ subscription: "sub_C9giwDfCeN8fwt", plan: "platypi-dev" }).then(function(subscriptionItem) { +stripe.subscriptionItems.create({ subscription: "sub_C9giwDfCeN8fwt", plan: "platypi-dev" }).then((subscriptionItem) => { // asynchronously called }); -stripe.subscriptionItems.create({ subscription: "sub_C9giwDfCeN8fwt", plan: "platypi-dev", prorate: true, proration_date: Math.round(new Date().valueOf() / 1000) }).then(function(subscriptionItem) { +stripe.subscriptionItems.create({ subscription: "sub_C9giwDfCeN8fwt", plan: "platypi-dev", prorate: true, proration_date: Math.round(new Date().valueOf() / 1000) }).then((subscriptionItem) => { // asynchronously called }); -stripe.subscriptionItems.retrieve("si_C9gimdd2l9qvCU", function(err, subscriptionItem) { +stripe.subscriptionItems.retrieve("si_C9gimdd2l9qvCU", (err, subscriptionItem) => { // asynchronously called }); -stripe.subscriptionItems.retrieve("si_C9gimdd2l9qvCU").then(function(subscriptionItem) { +stripe.subscriptionItems.retrieve("si_C9gimdd2l9qvCU").then((subscriptionItem) => { // asynchronously called }); -stripe.subscriptionItems.update("si_C9gimdd2l9qvCU", { plan: "platypi" }, function(err, subscriptionItem) { +stripe.subscriptionItems.update("si_C9gimdd2l9qvCU", { plan: "platypi" }, (err, subscriptionItem) => { // asynchronously called }); -stripe.subscriptionItems.update("si_C9gimdd2l9qvCU", { plan: "platypi" }).then(function(subscriptionItem) { +stripe.subscriptionItems.update("si_C9gimdd2l9qvCU", { plan: "platypi" }).then((subscriptionItem) => { // asynchronously called }); -stripe.subscriptionItems.del("si_C9gimdd2l9qvCU", function(err, subscriptionItem) { +stripe.subscriptionItems.del("si_C9gimdd2l9qvCU", (err, subscriptionItem) => { // asynchronously called }); -stripe.subscriptionItems.del("si_C9gimdd2l9qvCU").then(function(subscriptionItem) { +stripe.subscriptionItems.del("si_C9gimdd2l9qvCU").then((subscriptionItem) => { // asynchronously called }); -stripe.subscriptionItems.list({ subscription: "si_C9gimdd2l9qvCU" }, function(err, subscriptionItems) { +stripe.subscriptionItems.list({ subscription: "si_C9gimdd2l9qvCU" }, (err, subscriptionItems) => { // asynchronously called }); -stripe.subscriptionItems.list({ subscription: "si_C9gimdd2l9qvCU" }).then(function(subscriptionItems) { +stripe.subscriptionItems.list({ subscription: "si_C9gimdd2l9qvCU" }).then((subscriptionItems) => { // asynchronously called }); @@ -1343,13 +1311,27 @@ stripe.subscriptionItems.list({ subscription: "si_C9gimdd2l9qvCU" }).then(functi //#region Ephemeral keys tests // ################################################################################## -stripe.ephemeralKeys.create({ customer: "cus_5rfJKDJkuxzh5Q" }, { stripe_version: "2017-08-15" }).then(function(ephemeralKeys) { +stripe.ephemeralKeys.create({ customer: "cus_5rfJKDJkuxzh5Q" }, { stripe_version: "2017-08-15" }).then((ephemeralKeys) => { // asynchronously called }); - stripe.usageRecords.create('sub_8QwCiwZ9tmMSpt', { action: 'set', quantity: 10000, timestamp: 1537006853 }).then((usageRecord: Stripe.usageRecords.IUsageRecord) => {}); -stripe.usageRecords.create('sub_8QwCiwZ9tmMSpt', { action: 'set', quantity: 10000, timestamp: 1537006853 }, (err, usageRecord: Stripe.usageRecords.IUsageRecord) => {}) +stripe.usageRecords.create('sub_8QwCiwZ9tmMSpt', { action: 'set', quantity: 10000, timestamp: 1537006853 }, (err, usageRecord: Stripe.usageRecords.IUsageRecord) => {}); stripe.usageRecordSummarys.list({ subscription_item: 'si_C9gimdd2l9qvCU', limit: 10 }).then((usageRecordSummarys: Stripe.usageRecordSummarys.IUsageRecordSummarys) => {}); -stripe.usageRecordSummarys.list({ subscription_item: 'si_C9gimdd2l9qvCU', limit: 10 }, (err, usageRecordSummarys: Stripe.usageRecordSummarys.IUsageRecordSummarys) => {}) +stripe.usageRecordSummarys.list({ subscription_item: 'si_C9gimdd2l9qvCU', limit: 10 }, (err, usageRecordSummarys: Stripe.usageRecordSummarys.IUsageRecordSummarys) => {}); + +//#region Errors +// ################################################################################## + +stripe.charges.create({ + amount: 123, + currency: 'usd', +}).catch(err => { + if (err instanceof Stripe.errors.StripeCardError) { + const type = err.type; + } +}); + +//#endregion Errors +// ################################################################################## diff --git a/types/stripe/tslint.json b/types/stripe/tslint.json index d67ffb3a73..840cbcf66d 100644 --- a/types/stripe/tslint.json +++ b/types/stripe/tslint.json @@ -1,80 +1,8 @@ { "extends": "dtslint/dt.json", "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-angle-bracket-type-assertion": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false + "unified-signatures": false } }