import type { BelongsTo, HasMany } from '@adonisjs/lucid/types/relations'; import { DateTime } from 'luxon'; import Stripe from 'stripe'; import { type BillableModel } from '../contracts.js'; import { Invoice } from '../invoice.js'; import { Payment } from '../payment.js'; import { Discount } from '../discount.js'; import SubscriptionItem from './subscription_item.js'; type SwapPricesParam = string | string[] | Stripe.SubscriptionUpdateParams.Item[] | Record; declare const Subscription_base: { new (...args: any[]): { "__#private@#prorationBehaviour": Stripe.SubscriptionCreateParams.ProrationBehavior; noProrate(): /*elided*/ any; prorate(): /*elided*/ any; alwaysInvoice(): /*elided*/ any; setProrationBehavior(prorationBehaviour: Stripe.SubscriptionCreateParams.ProrationBehavior): /*elided*/ any; prorateBehavior(): Stripe.SubscriptionCreateParams.ProrationBehavior; }; } & { new (...args: any[]): { "__#private@#paymentBehavior": Stripe.SubscriptionCreateParams.PaymentBehavior; defaultIncomplete(): /*elided*/ any; allowPaymentFailures(): /*elided*/ any; pendingIfPaymentFails(): /*elided*/ any; errorIfPaymentFails(): /*elided*/ any; paymentBehavior(): Stripe.SubscriptionCreateParams.PaymentBehavior; setPaymentBehavior(paymentBehavior: Stripe.SubscriptionCreateParams.PaymentBehavior): /*elided*/ any; }; } & { new (...args: any[]): { confirmIncompletePayment: boolean; paymentConfirmationOptions: Stripe.PaymentIntentConfirmParams; handlePaymentFailure(subscription: Subscription, paymentMethod?: Stripe.PaymentMethod | string): Promise; ignoreIncompletePayments(): /*elided*/ any; withPaymentConfirmationOptions(params: Stripe.PaymentIntentConfirmParams): /*elided*/ any; }; } & import("@adonisjs/lucid/types/model").LucidModel & (new (...args: any[]) => import("../contracts.js").ManagesStripeContract) & (new (...args: any[]) => import("../contracts.js").AllowsCouponContract); export default class Subscription extends Subscription_base { id: number; userId: string; user: BelongsTo; type: string; stripeStatus: Stripe.Subscription.Status; stripePrice: string | null; quantity: number | null; items: HasMany; trialEndsAt: DateTime | null; endsAt: DateTime | null; updatedAt: DateTime | null; createdAt: DateTime; billingCycleAnchor?: Stripe.SubscriptionUpdateParams.BillingCycleAnchor; /** * Determine if the subscription has a single price. */ hasMultiplePrices(): boolean; /** * Determine if the subscription has a single price. */ hasSinglePrice(): boolean; /** * Determine if the subscription has a specific product. */ hasProduct(this: Subscription, product: string): Promise; /** * Determine if the subscription has a specific price. */ hasPrice(this: Subscription, price: string): Promise; /** * Get the subscription item for the given price. */ findItemOrFail(this: Subscription, price: string): Promise; /** * Determine if the subscription is active, on trial, or within its grace period. */ valid(): boolean; /** * Determine if the subscription is incomplete. */ incomplete(): boolean; /** * Determine if the subscription is past due. */ pastDue(): boolean; /** * Determine if the subscription is active. */ active(): boolean; /** * Sync the Stripe status of the subscription. */ syncStripeStatus(): Promise; /** * Determine if the subscription is recurring and not on trial. */ recurring(): boolean; /** * Determine if the subscription is no longer active. */ canceled(): boolean; /** * Determine if the subscription has ended and the grace period has expired. */ ended(): boolean; /** * Determine if the subscription is within its trial period. */ onTrial(): boolean; /** * Determine if the subscription's trial has expired. */ hasExpiredTrial(): boolean; /** * Determine if the subscription is within its grace period after cancellation. */ onGracePeriod(): boolean; /** * Increment the quantity of the subscription. */ incrementQuantity(count?: number, price?: string): Promise; /** * Increment the quantity of the subscription, and invoice immediately. */ incrementAndInvoice(count?: number, price?: string): Promise; /** * Decrement the quantity of the subscription. */ decrementQuantity(count?: number, price?: string): Promise; /** * Update the quantity of the subscription. */ updateQuantity(quantity: number, price?: string): Promise; /** * Report a meter event for a metered product. */ reportUsage(eventName: string, value?: string, price?: string, params?: Partial): Promise; /** * Report a meter event for a specific price of a metered product. */ reportUsageFor(price: string, eventName: string, value?: string, params?: Partial): Promise; /** * Get the meter event summaries for a metered product. */ usageRecords(meterId: string, params: Omit, price?: string): Promise; /** * Get the meter event summaries for a specific price of a metered product. */ usageRecordsFor(price: string, meterId: string, params: Omit): Promise; /** * Change the billing cycle anchor on a price change. */ anchorBillingCycleOn(date?: Stripe.SubscriptionUpdateParams.BillingCycleAnchor): this; /** * Force the trial to end immediately. * * This method must be combined with swap, resume, etc. */ skipTrial(): this; /** * Force the subscription's trial to end immediately. */ endTrial(): Promise; /** * Extend an existing subscription's trial period. */ extendTrial(date: DateTime): Promise; /** * Swap the subscription to new Stripe prices. */ swap(this: Subscription, prices: SwapPricesParam, params?: Stripe.SubscriptionUpdateParams): Promise; /** * Swap the subscription to new Stripe prices, and invoice immediately. */ swapAndInvoice(prices: string | string[], params?: Stripe.SubscriptionUpdateParams): Promise; /** * Add a new Stripe price to the subscription. */ addPrice(this: Subscription, price: string, quantity?: number | null, params?: Partial): Promise; /** * Add a new Stripe price to the subscription, and invoice immediately. */ addPriceAndInvoice(price: string, quantity?: number | null, params?: Partial): Promise; /** * Add a new Stripe metered price to the subscription. */ addMeteredPrice(price: string, params?: Partial): Promise; /** * Add a new Stripe metered price to the subscription, and invoice immediately. */ addMeteredPriceAndInvoice(price: string, params?: Partial): Promise; /** * Remove a Stripe price from the subscription. */ removePrice(price: string): Promise; /** * Cancel the subscription at the end of the billing period. */ cancel(): Promise; /** * Cancel the subscription at a specific moment in time. */ cancelAt(date: DateTime | number): Promise; /** * Cancel the subscription immediately without invoicing. */ cancelNow(): Promise; /** * Cancel the subscription immediately and invoice. */ cancelNowAndInvoice(): Promise; /** * Mark the subscription as canceled. */ markAsCanceled(): Promise; /** * Resume the canceled subscription. */ resume(): Promise; /** * Determine if the subscription has pending updates. */ pending(): Promise; /** * Invoice the subscription outside of the regular billing cycle. */ invoice(this: Subscription, params?: Stripe.InvoiceCreateParams & Stripe.InvoicePayParams): Promise; /** * Get the latest invoice for the subscription. */ latestInvoice(expand?: string[]): Promise; /** * Fetches upcoming invoice for this subscription. */ upcomingInvoice(params?: Stripe.InvoiceCreatePreviewParams): Promise; /** * Preview the upcoming invoice with new Stripe prices. */ previewInvoice(prices: string[] | string, params?: Stripe.InvoiceCreatePreviewParams): Promise; /** * Get a collection of the subscription's invoices. */ invoices(this: Subscription, includePending?: boolean, params?: Stripe.InvoiceListParams): Promise; /** * Get an array of the subscription's invoices, including pending invoices. */ invoicesIncludingPending(params?: Stripe.InvoiceListParams): Promise; /** * Sync the tax rates of the user to the subscription. */ syncTaxRates(): Promise; /** * Get the price tax rates for the Stripe payload. */ getPriceTaxRatesForPayload(this: Subscription, price: string): Promise; /** * Determine if the subscription has an incomplete payment. */ hasIncompletePayment(): boolean; /** * Get the latest payment for a Subscription. */ latestPayment(): Promise; /** * The discount that applies to the subscription, if applicable. */ discount(): Promise; /** * Apply a coupon to the subscription. */ applyCoupon(coupon: string): Promise; /** * Apply a promotion code to the subscription. */ applyPromotionCode(promotionCode: string): Promise; /** * Make sure a subscription is not incomplete when performing changes. */ guardAgainstIncomplete(): void; /** * Make sure a price argument is provided when the subscription is a subscription with multiple prices. */ guardAgainstMultiplePrices(): void; /** * Update the underlying Stripe subscription information for the model. */ updateStripeSubscription(params: Stripe.SubscriptionUpdateParams): Promise; /** * Get the subscription as a Stripe subscription object. */ asStripeSubscription(expand?: string[]): Promise; /** * Parse the given prices for a swap operation. */ protected parseSwapPrices(prices: SwapPricesParam): Promise>; /** * Merge the items that should be deleted during swap into the given items collection. */ protected mergeItemsThatShouldBeDeletedDuringSwap(items: Map): Promise>; /** * Get the options array for a swap operation. */ protected getSwapOptions(items: Map, params?: Stripe.SubscriptionUpdateParams): Stripe.SubscriptionUpdateParams; } export {};