import { Discount } from './Discount'; import { Payment } from './Payment'; export interface Subscription { /** * ID of the Subscription object. String starting with **sub_**. */ id: `sub_${string}`; /** * Determines the method of billing at the end of the billing cycle. Set to **pay_automatically** - Rapyd generates a 'payment' object, then attempts to pay it using the designated payment method. * See [Invoice Object](ref:invoice-object). */ billing: string; /** * Determines the start of the next full billing cycle, as defined in the plan described in the 'items'. One of the following values: * - **now** - The present day. The next billing cycle starts right now. * *Timestamp* in [*Unix time*](ref:glossary) - A time in the future, at or after the end of the free trial period, not more than the length of the billing cycle. The current billing cycle will be shorter than all other billing cycles. Relevant to creation of the subscription. * - **unchanged** - The original billing cycle anchor is unchanged. Relevant to updating a subscription. * * **Note:** If you update `trial_end`, this parameter will be reset to the end of the new trial period. If you want a different billing cycle anchor, you must update the subscription again at the moment you want, and set this parameter to **now**. */ billing_cycle_anchor: 'now' | 'unchanged' | number; /** * Determines the last date that charges accrue. * * - **true** - Charges accrue until the end of the current billing period, then the subscription is canceled. * - **false** * > * When the subscription is created, no end is defined. * > * When [Cancel Subscription](ref:cancel-subscription) is run, charges stop immediately and the subscription is canceled. */ cancel_at_period_end: boolean; /** * Date and time that the subscription is canceled by the customer or by the client. [*Unix time*](ref:glossary). Response only. */ canceled_at: number; /** * The ID of a discount coupon that applies to all invoice lines associated with this subscription. If the coupon defines a fixed monetary discount, it must use the same currency as the subscription's plan. * * See also: * * ** [Coupon Object](ref:coupon-object). * ** [Plan Object](ref:plan-object). */ coupon: string; /** * Time of creation of this subscription, in [*Unix time*](ref:glossary). Response only. */ created_at: number; /** * End of the current billing cycle, in [*Unix time*](ref:glossary). Response only. */ current_period_end: number; /** * Start of the current billing cycle, in [*Unix time*](ref:glossary). Response only. */ current_period_start: number; /** * ID of the customer who pays for this subscription. String starting with **cus_**. * Required. * * For more information, see [Customer Object](ref:customer-object). */ customer: `cus_${string}`; /** * Number of days between the date of issuance of an invoice and the date payment is due. Integer. Relevant when `billing` is **send_invoice**. */ days_until_due: number; /** * Contains information about the coupon that applies to the subscription. Response only. * * Adding a discount is a 2-step process: * 1. [Create Coupon](ref:create-coupon), which returns a coupon ID. * 2. Add the coupon ID to the `coupon` field of the subscription with [Create Subscription](ref:create-subscription-object) or [Update Subscription](ref:update-subscription). * * For more information, see [Discount Object](ref:discount-object). */ discount: Partial; /** * Date that the subscription was canceled or otherwise terminated. [*Unix time*](ref:glossary). Response only. */ ended_at: number; /** * A JSON object defined by the client. */ metadata: object; /** * Object containing fields of the Payment object. * * For more information, see [Payment Object](ref:payment-object). */ payment_fields: Partial; /** * Payment method ID or Payment Method object. If not specified in this field, the payment method is the default payment method specified for the customer. * * To create a payment method ID, use the [Add Payment Method](ref:add-payment-method) method. The ID is a string starting with **card_** or **other_**. * * For more information, see [Payment Method Object](#payment-method-object). */ payment_method: `card_${string}`; /** * Date and time that the subscription began, in [*Unix time*](ref:glossary). Response only. */ start: number; /** * Status of the subscription. One of the following: * - **active** - The customer is currently paying for this subscription. * - **canceled** - The customer has canceled this subscription, but it remains in the Rapyd database. * - **past_due** - Payment for this subscription was not received by the end of the billing period. * - **trialing** - The subscription is in its free trial period. * - **unpaid** - An error occurred in the payment for this subscription. */ status: 'active' | 'canceled' | 'past_due' | 'trialing' | 'unpaid'; /** * In requests, an array of objects containing the following fields: * - `plan` - ID of a plan that describes the service and pricing structure. String. * - `quantity` - Number of units of the service described in `plan`. * * In responses, an object containing the following fields: * - `data` - A list of up to three subscription items. * - `has_more` - Indicates whether there are more than three items in this subscription. * - `total_count` - Total number of items in this subscription. * - `url` - URL for requesting all of the items in this subscription. * * **NOTE:** All subscription items must have plans with identical values for `interval` and `interval_count`. */ subscription_items: { plan: unknown; quantity: unknown; data: unknown; has_more: unknown; total_count: unknown; url: unknown; } | any[]; /** * The percentage tax rate that is applied to the subtotal of the invoice, after subtracting all discounts. Decimal. * * Range: 0-100, with up to four decimal places. */ tax_percent: number; /** * Total amount of subscription items that are not displayed. */ total_count: number; /** * The date and time of the end of the customer's free trial period, in [*Unix time*](ref:glossary), or the string **now**. Takes precedence over `trial_period_days`. If `trial_end` is not set by the client, Rapyd calculates this date by adding `trial_period_days` to the date in `created_at`. Relevant when `trial_period_days` is not defined. */ trial_end: number; /** * Determines whether a free trial period can be defined in a 'plan' object attached to the subscription. * * - **True** - Free trials can be defined in plans that are attached to the subscription. This is the default. * - **False** - Definitions of free trial in plans are ignored. */ trial_from_plan: boolean; /** * The number of days in the customer's free trial period. Integer. Range: 0-730. This value takes precedence over trial periods that are defined in a plan. Relevant when `trial_end` is not defined. */ trial_period_days: number; /** * Date and time of the start of the customer's free trial period, in [*Unix time*](ref:glossary). Response only. */ trial_start: number; /** * The type of the subscription. One of the following values: * - **payment** * - **payout** */ type: 'payment' | 'payout'; } //# sourceMappingURL=Subscription.d.ts.map