Skip to content

Commit

Permalink
Merge pull request #826 from stripe/remi/codegen-0e77e37
Browse files Browse the repository at this point in the history
Updates Typescript definitions for the latest API version `2020-03-02` and related changes
  • Loading branch information
remi-stripe authored Mar 3, 2020
2 parents b574444 + f1dbba5 commit 02da7dc
Show file tree
Hide file tree
Showing 92 changed files with 47 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ and instantiate it as `new Stripe()` with the latest API version.
```ts
import Stripe from 'stripe';
const stripe = new Stripe('sk_test_...', {
apiVersion: '2019-12-03',
apiVersion: '2020-03-02',
});

const createCustomer = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import env from 'dotenv';
env.config();

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2019-12-03',
apiVersion: '2020-03-02',
});

const webhookSecret: string = process.env.STRIPE_WEBHOOK_SECRET;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"node": "^8.1 || >=10.*"
},
"main": "lib/stripe.js",
"types": "types/2019-12-03/index.d.ts",
"types": "types/2020-03-02/index.d.ts",
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^2.13.0",
"@typescript-eslint/parser": "^2.13.0",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ declare module 'stripe' {
account_holder_type: Fpx.AccountHolderType | null;

/**
* The customer's bank. Can be one of `affin_bank`, `alliance_bank`, `ambank`, `bank_islam`, `bank_muamalat`, `bank_rakyat`, `bsn`, `cimb`, `hong_leong_bank`, `hsbc`, `kfh`, `maybank2u`, `ocbc`, `public_bank`, `rhb`, `standard_chartered`, `uob`, `deutsche_bank`, `maybank2e`, `pb_enterprise`, or `uob_regional`.
* The customer's bank. Can be one of `affin_bank`, `alliance_bank`, `ambank`, `bank_islam`, `bank_muamalat`, `bank_rakyat`, `bsn`, `cimb`, `hong_leong_bank`, `hsbc`, `kfh`, `maybank2u`, `ocbc`, `public_bank`, `rhb`, `standard_chartered`, `uob`, `deutsche_bank`, `maybank2e`, or `pb_enterprise`.
*/
bank: Fpx.Bank;

Expand Down Expand Up @@ -964,8 +964,7 @@ declare module 'stripe' {
| 'public_bank'
| 'rhb'
| 'standard_chartered'
| 'uob'
| 'uob_regional';
| 'uob';
}

interface Giropay {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ declare module 'stripe' {
*/
name: string | null;

/**
* The suffix of the customer's next invoice number, e.g., 0001.
*/
next_invoice_sequence?: number;

/**
* The customer's phone number.
*/
Expand Down Expand Up @@ -248,6 +253,11 @@ declare module 'stripe' {
*/
name?: string;

/**
* The sequence to be used on the customer's next invoice. Defaults to 1.
*/
next_invoice_sequence?: number;

payment_method?: string;

/**
Expand Down Expand Up @@ -432,6 +442,11 @@ declare module 'stripe' {
*/
name?: string;

/**
* The sequence to be used on the customer's next invoice. Defaults to 1.
*/
next_invoice_sequence?: number;

/**
* The customer's phone number.
*/
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ declare module 'stripe' {
account_holder_type: Fpx.AccountHolderType | null;

/**
* The customer's bank, if provided. Can be one of `affin_bank`, `alliance_bank`, `ambank`, `bank_islam`, `bank_muamalat`, `bank_rakyat`, `bsn`, `cimb`, `hong_leong_bank`, `hsbc`, `kfh`, `maybank2u`, `ocbc`, `public_bank`, `rhb`, `standard_chartered`, `uob`, `deutsche_bank`, `maybank2e`, `pb_enterprise`, or `uob_regional`.
* The customer's bank, if provided. Can be one of `affin_bank`, `alliance_bank`, `ambank`, `bank_islam`, `bank_muamalat`, `bank_rakyat`, `bsn`, `cimb`, `hong_leong_bank`, `hsbc`, `kfh`, `maybank2u`, `ocbc`, `public_bank`, `rhb`, `standard_chartered`, `uob`, `deutsche_bank`, `maybank2e`, or `pb_enterprise`.
*/
bank: Fpx.Bank;
}
Expand Down Expand Up @@ -310,8 +310,7 @@ declare module 'stripe' {
| 'public_bank'
| 'rhb'
| 'standard_chartered'
| 'uob'
| 'uob_regional';
| 'uob';
}

interface Ideal {
Expand Down Expand Up @@ -573,8 +572,7 @@ declare module 'stripe' {
| 'public_bank'
| 'rhb'
| 'standard_chartered'
| 'uob'
| 'uob_regional';
| 'uob';
}

interface Ideal {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ declare module 'stripe' {
plan?: string;

/**
* Flag indicating whether to [prorate](https://stripe.com/docs/billing/subscriptions/prorations) switching plans during a billing cycle. This field has been deprecated and will be removed in a future API version. Use `proration_behavior=create_prorations` as a replacement for `prorate=true` and `proration_behavior=none` for `prorate=false`.
* This field has been renamed to `proration_behavior`. `prorate=true` can be replaced with `proration_behavior=create_prorations` and `prorate=false` can be replaced with `proration_behavior=none`.
*/
prorate?: boolean;

Expand Down Expand Up @@ -210,7 +210,7 @@ declare module 'stripe' {
plan?: string;

/**
* Flag indicating whether to [prorate](https://stripe.com/docs/billing/subscriptions/prorations) switching plans during a billing cycle. This field has been deprecated and will be removed in a future API version. Use `proration_behavior=create_prorations` as a replacement for `prorate=true` and `proration_behavior=none` for `prorate=false`.
* This field has been renamed to `proration_behavior`. `prorate=true` can be replaced with `proration_behavior=create_prorations` and `prorate=false` can be replaced with `proration_behavior=none`.
*/
prorate?: boolean;

Expand Down Expand Up @@ -274,16 +274,29 @@ declare module 'stripe' {
clear_usage?: boolean;

/**
* Flag indicating whether to [prorate](https://stripe.com/docs/billing/subscriptions/prorations) switching plans during a billing cycle.
* This field has been renamed to `proration_behavior`. `prorate=true` can be replaced with `proration_behavior=create_prorations` and `prorate=false` can be replaced with `proration_behavior=none`.
*/
prorate?: boolean;

/**
* Determines how to handle [prorations](https://stripe.com/docs/subscriptions/billing-cycle#prorations) when the billing cycle changes (e.g., when switching plans, resetting `billing_cycle_anchor=now`, or starting a trial), or if an item's `quantity` changes. Valid values are `create_prorations`, `none`, or `always_invoice`.
*
* Passing `create_prorations` will cause proration invoice items to be created when applicable. These proration items will only be invoiced immediately under [certain conditions](https://stripe.com/docs/subscriptions/upgrading-downgrading#immediate-payment). In order to always invoice immediately for prorations, pass `always_invoice`.
*
* Prorations can be disabled by passing `none`.
*/
proration_behavior?: SubscriptionItemDeleteParams.ProrationBehavior;

/**
* If set, the proration will be calculated as though the subscription was updated at the given time. This can be used to apply the same proration that was previewed with the [upcoming invoice](https://stripe.com/docs/api#retrieve_customer_invoice) endpoint.
*/
proration_date?: number;
}

namespace SubscriptionItemDeleteParams {
type ProrationBehavior = 'always_invoice' | 'create_prorations' | 'none';
}

class SubscriptionItemsResource {
/**
* Adds a new item to an existing subscription. No existing items will be changed or replaced.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ declare module 'stripe' {
| '2019-10-08'
| '2019-10-17'
| '2019-11-05'
| '2019-12-03';
| '2019-12-03'
| '2020-03-02';

type EnabledEvent =
| '*'
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions types/lib.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Agent} from 'http';

declare module 'stripe' {
namespace Stripe {
export type LatestApiVersion = '2019-12-03';
export type LatestApiVersion = '2020-03-02';
export type HttpAgent = Agent;

export interface StripeConfig {
Expand Down Expand Up @@ -92,7 +92,7 @@ declare module 'stripe' {
stripe_account?: string;

/**
* The [API Version](https://stripe.com/docs/upgrades) to use for a given request (e.g., '2019-12-03').
* The [API Version](https://stripe.com/docs/upgrades) to use for a given request (e.g., '2020-03-02').
*/
apiVersion?: string;
/** @deprecated Please use apiVersion instead. */
Expand Down
8 changes: 4 additions & 4 deletions types/test/typescriptTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
* and to perform a basic sanity check that types are exported as intended.
*/

///<reference types="../2019-12-03" />
///<reference types="../2020-03-02" />
import Stripe from 'stripe';

let stripe = new Stripe('sk_test_123', {
apiVersion: '2019-12-03',
apiVersion: '2020-03-02',
});

// @ts-ignore lazily ignore apiVersion requirement.
Expand All @@ -27,7 +27,7 @@ stripe = new Stripe('sk_test_123', {

// Check config object.
stripe = new Stripe('sk_test_123', {
apiVersion: '2019-12-03',
apiVersion: '2020-03-02',
typescript: true,
maxNetworkRetries: 1,
timeout: 1000,
Expand All @@ -48,7 +48,7 @@ stripe.setHost('host', 'port', 'protocol');
description: 'test',
};
const opts: Stripe.RequestOptions = {
apiVersion: '2019-12-03',
apiVersion: '2020-03-02',
};
const customer: Stripe.Customer = await stripe.customers.create(params, opts);

Expand Down

0 comments on commit 02da7dc

Please sign in to comment.