Update Subscription related objects to support billing thresholds and initial invoice (#35549)

This commit is contained in:
Christopher Eck
2019-05-24 13:50:22 -07:00
committed by Ryan Cavanaugh
parent d1ed9f29c6
commit 5aeb745474
+105 -18
View File
@@ -22,6 +22,7 @@
// Andrew Delianides <https://github.com/delianides>
// Gokul Chandrasekaran <https://github.com/gokulchandra>
// Jamie Davies <https://github.com/viralpickaxe>
// Christopher Eck <https://github.com/chrisleck>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
@@ -2405,6 +2406,12 @@ declare namespace Stripe {
*/
paid: boolean;
/**
* The PaymentIntent associated with this invoice. The PaymentIntent is generated when the invoice is finalized,
* and can then be used to pay the invoice. Note that voiding an invoice will cancel the PaymentIntent. [Expandable]
*/
payment_intent: paymentIntents.IPaymentIntent | null;
/**
* End of the usage period during which invoice items were added to this invoice
*/
@@ -5604,6 +5611,41 @@ declare namespace Stripe {
*/
application_fee_percent: number;
/**
* Either "charge_automatically", or "send_invoice". When charging automatically, Stripe will attempt to pay this subscription at the
* end of the cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an
* invoice with payment instructions.
*/
billing: SubscriptionBilling;
/**
* 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;
/**
* Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period.
*/
billing_thresholds: null | {
/**
* Monetary threshold that triggers the subscription to create an invoice.
*/
amount_gte: number;
/**
* Indicates if the billing_cycle_anchor should be reset when a threshold is reached. If true, billing_cycle_anchor
* will be updated to the date/time the threshold was last reached; otherwise, the value will remain unchanged.
* This value may not be true if the subscription contains items with plans that have aggregate_usage=last_ever.
*/
reset_billing_cycle_anchor: boolean;
};
/**
* A date in the future at which the subscription will automatically get canceled.
*/
cancel_at: number;
/**
* If the subscription has been canceled with the at_period_end flag set to true, cancel_at_period_end on the
* subscription will be true. You can use this attribute to determine whether a subscription that has a status
@@ -5618,6 +5660,9 @@ declare namespace Stripe {
*/
canceled_at: number | null;
/**
* Time at which the object was created. Measured in seconds since the Unix epoch.
*/
created: number;
/**
@@ -5635,6 +5680,25 @@ declare namespace Stripe {
*/
customer: string | customers.ICustomer;
/**
* Number of days a customer has to pay invoices generated by this subscription. This value will be null for
* subscriptions where billing=charge_automatically.
*/
days_until_due: number | null;
/**
* ID of the default payment method for the subscription. It must belong to the customer associated with the subscription.
* If not set, invoices will use the default payment method in the customer’s invoice settings. [Expandable]
*/
default_payment_method: string | null;
/**
* ID of the default payment source for the subscription.
* It must belong to the customer associated with the subscription and be in a chargeable state.
* If not set, defaults to the customer’s default source. [Expandable]
*/
default_source: string;
/**
* Describes the current discount applied to this subscription, if there is one. When billing, a discount applied to a
* subscription overrides a discount applied on a customer-wide basis.
@@ -5647,10 +5711,27 @@ declare namespace Stripe {
*/
ended_at: number | null;
metadata: IMetadata;
/**
* List of subscription items, each with an attached plan.
*/
items: IList<subscriptionItems.ISubscriptionItem>;
/**
* The most recent invoice this subscription has generated. [Expandable]
*/
latest_invoice: null | invoices.IInvoice;
/**
* Has the value true if the object exists in live mode or the value false if the object exists in test mode.
*/
livemode: boolean;
/**
* Set of key-value pairs that you can attach to an object. This can be useful for storing additional information
* about the object in a structured format.
*/
metadata: IMetadata;
/**
* Hash describing the plan the customer is subscribed to. Only set if the subscription
* contains a single plan.
@@ -5658,9 +5739,11 @@ declare namespace Stripe {
plan?: plans.IPlan | null;
/**
* The number of subscriptions for the associated plan
* The quantity of the plan to which the customer is subscribed. For example, if your plan is $10/user/month,
* and your customer has 5 users, you could pass 5 as the quantity to have the customer charged $50 (5 x $10) monthly.
* Only set if the subscription contains a single plan.
*/
quantity: number;
quantity?: number;
/**
* Date the subscription started
@@ -5708,20 +5791,6 @@ declare namespace Stripe {
* If the subscription has a trial, the beginning of that trial.
*/
trial_start: number | null;
/**
* Either "charge_automatically", or "send_invoice". When charging automatically, Stripe will attempt to pay this subscription at the
* end of the cycle using the default source attached to the customer. When sending an invoice, Stripe will email your customer an
* invoice with payment instructions.
*/
billing: SubscriptionBilling;
/**
* ID of the default payment source for the subscription.
* It must belong to the customer associated with the subscription and be in a chargeable state.
* If not set, defaults to the customer’s default source. [Expandable]
*/
default_source: string;
}
interface ISubscriptionCustCreationOptions extends IDataOptionsWithMetadata {
@@ -6000,6 +6069,19 @@ declare namespace Stripe {
*/
object: "subscription_item";
/**
* Define thresholds at which an invoice will be sent, and the related subscription advanced to a new billing period.
*/
billing_thresholds: null | {
/**
* Usage threshold that triggers the subscription to create an invoice
*/
usage_gte: number;
};
/**
* Time at which the object was created. Measured in seconds since the Unix epoch.
*/
created: number;
/**
@@ -6017,6 +6099,11 @@ declare namespace Stripe {
* The quantity of the plan to which the customer should be subscribed.
*/
quantity: number;
/**
* The subscription this subscription_item belongs to.
*/
subscription: string;
}
interface ISubscriptionItemCreationOptions extends IDataOptionsWithMetadata {