Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for pending_update on Subscription #765

Merged
merged 1 commit into from
Jan 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions types/2019-12-03/InvoiceLineItems.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ declare module 'stripe' {
*/
subscription_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. The value defaults to `create_prorations`, indicating that proration invoice items should be created. Prorations can be disabled by setting the value to `none`.
*/
subscription_proration_behavior?: InvoiceLineItemListUpcomingParams.SubscriptionProrationBehavior;

/**
* If previewing an update to a subscription, and doing proration, `subscription_proration_date` forces the proration to be calculated as though the update was done at the specified time. The time given must be within the current subscription period, and cannot be before the subscription was on its current plan. If set, `subscription`, and one of `subscription_items`, or `subscription_trial_end` are required. Also, `subscription_proration` cannot be set to false.
*/
Expand Down Expand Up @@ -351,6 +356,11 @@ declare module 'stripe' {
usage_gte: number;
}
}

type SubscriptionProrationBehavior =
| 'always_invoice'
| 'create_prorations'
| 'none';
}
}
}
10 changes: 10 additions & 0 deletions types/2019-12-03/Invoices.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,11 @@ declare module 'stripe' {
*/
subscription_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. The value defaults to `create_prorations`, indicating that proration invoice items should be created. Prorations can be disabled by setting the value to `none`.
*/
subscription_proration_behavior?: InvoiceRetrieveUpcomingParams.SubscriptionProrationBehavior;

/**
* If previewing an update to a subscription, and doing proration, `subscription_proration_date` forces the proration to be calculated as though the update was done at the specified time. The time given must be within the current subscription period, and cannot be before the subscription was on its current plan. If set, `subscription`, and one of `subscription_items`, or `subscription_trial_end` are required. Also, `subscription_proration` cannot be set to false.
*/
Expand Down Expand Up @@ -1005,6 +1010,11 @@ declare module 'stripe' {
usage_gte: number;
}
}

type SubscriptionProrationBehavior =
| 'always_invoice'
| 'create_prorations'
| 'none';
}

interface InvoiceSendInvoiceParams {
Expand Down
14 changes: 14 additions & 0 deletions types/2019-12-03/SubscriptionItems.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ declare module 'stripe' {
*/
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. The value defaults to `create_prorations`, indicating that proration invoice items should be created. Prorations can be disabled by setting the value to `none`.
*/
proration_behavior?: SubscriptionItemCreateParams.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.
*/
Expand Down Expand Up @@ -144,6 +149,8 @@ declare module 'stripe' {
| 'allow_incomplete'
| 'error_if_incomplete'
| 'pending_if_incomplete';

type ProrationBehavior = 'always_invoice' | 'create_prorations' | 'none';
}

interface SubscriptionItemRetrieveParams {
Expand Down Expand Up @@ -188,6 +195,11 @@ declare module 'stripe' {
*/
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. The value defaults to `create_prorations`, indicating that proration invoice items should be created. Prorations can be disabled by setting the value to `none`.
*/
proration_behavior?: SubscriptionItemUpdateParams.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.
*/
Expand Down Expand Up @@ -216,6 +228,8 @@ declare module 'stripe' {
| 'allow_incomplete'
| 'error_if_incomplete'
| 'pending_if_incomplete';

type ProrationBehavior = 'always_invoice' | 'create_prorations' | 'none';
}

interface SubscriptionItemListParams extends PaginationParams {
Expand Down
46 changes: 46 additions & 0 deletions types/2019-12-03/Subscriptions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ declare module 'stripe' {
*/
pending_setup_intent: string | Stripe.SetupIntent | null;

/**
* If specified, [deferred upgrade](https://stripe.com/docs/billing/subscriptions/upgrading-downgrading#deferred) changes that will be applied to the subscription once the `latest_invoice` has been paid.
*/
pending_update?: Subscription.PendingUpdate | null;

/**
* Hash describing the plan the customer is subscribed to. Only set if the subscription contains a single plan.
*/
Expand Down Expand Up @@ -219,6 +224,33 @@ declare module 'stripe' {
type Interval = 'day' | 'month' | 'week' | 'year';
}

interface PendingUpdate {
/**
* If the update is applied, determines the date of the first full invoice, and, for plans with `month` or `year` intervals, the day of the month for subsequent invoices.
*/
billing_cycle_anchor: number | null;

/**
* The point after which the changes reflected by this update will be discarded and no longer applied.
*/
expires_at: number;

/**
* List of subscription items, each with an attached plan, that will be set if the update is applied.
*/
subscription_items: Array<Stripe.SubscriptionItem> | null;

/**
* Unix timestamp representing the end of the trial period the customer will get before being charged for the first time, if the update is applied.
*/
trial_end: number | null;

/**
* Indicates if a plan's `trial_period_days` should be applied to the subscription. Setting `trial_end` per subscription is preferred, and this defaults to `false`. Setting this flag to `true` together with `trial_end` is not allowed.
*/
trial_from_plan: boolean | null;
}

type Status =
| 'active'
| 'canceled'
Expand Down Expand Up @@ -339,6 +371,11 @@ declare module 'stripe' {
*/
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. The value defaults to `create_prorations`, indicating that proration invoice items should be created. Prorations can be disabled by setting the value to `none`.
*/
proration_behavior?: SubscriptionCreateParams.ProrationBehavior;

/**
* A non-negative decimal (with at most four decimal places) between 0 and 100. This represents the percentage of the subscription invoice subtotal that will be calculated and added as tax to the final amount in each billing period. For example, a plan which charges $10/month with a `tax_percent` of `20.0` will charge $12 per invoice. To unset a previously-set value, pass an empty string. This field has been deprecated and will be removed in a future API version, for further information view the [migration docs](https://stripe.com/docs/billing/migration/taxes) for `tax_rates`.
*/
Expand Down Expand Up @@ -437,6 +474,8 @@ declare module 'stripe' {
type Interval = 'day' | 'month' | 'week' | 'year';
}

type ProrationBehavior = 'always_invoice' | 'create_prorations' | 'none';

interface TransferData {
/**
* ID of an existing, connected Stripe account.
Expand Down Expand Up @@ -545,6 +584,11 @@ declare module 'stripe' {
*/
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. The value defaults to `create_prorations`, indicating that proration invoice items should be created. Prorations can be disabled by setting the value to `none`.
*/
proration_behavior?: SubscriptionUpdateParams.ProrationBehavior;

/**
* If set, the proration will be calculated as though the subscription was updated at the given time. This can be used to apply exactly the same proration that was previewed with [upcoming invoice](https://stripe.com/docs/api#retrieve_customer_invoice) endpoint. It can also be used to implement custom proration logic, such as prorating by day instead of by second, by providing the time that you wish to use for proration calculations.
*/
Expand Down Expand Up @@ -660,6 +704,8 @@ declare module 'stripe' {
type Interval = 'day' | 'month' | 'week' | 'year';
}

type ProrationBehavior = 'always_invoice' | 'create_prorations' | 'none';

interface TransferData {
/**
* ID of an existing, connected Stripe account.
Expand Down