{"version":3,"file":"index.mjs","names":[],"sources":["../../src/subscription/index.ts"],"sourcesContent":["export const PLATFORMS = ['APPLE', 'GOOGLE', 'STRIPE'] as const;\n\nexport type Platform = (typeof PLATFORMS)[number];\n\n/**\n * [Stripe Subscription Status](https://stripe.com/docs/api/subscriptions/object#subscription_object-status)\n * [Stripe Subscription Lifecycle](https://docs.stripe.com/billing/subscriptions/overview)\n *\n * provision product for customer when Status = TRIALING, ACTIVE, IN_GRACE_PERIOD\n */\nexport const SUBSCRIPTION_STATUSES = [\n  /**\n   * The subscription is currently in a trial period and it’s safe to provision your product for\n   * your customer. The subscription transitions automatically to active when the first payment\n   * is made.\n   *\n   * Google: play(LineItems[0].OfferDetails.OfferId == 'xx')\n   *\n   * Platform: Apple, Google, Stripe\n   * */\n  'TRIALING',\n\n  /**\n   * The subscription is in good standing and the most recent payment is successful. It’s safe to\n   * provision your product for your customer.\n   *\n   * Platform: Apple, Google, Stripe\n   * */\n  'ACTIVE',\n\n  /**\n   * Apple: The subscription enters the billing retry period. If the subtype is GRACE_PERIOD,\n   * continue to provide service through the grace period. If the subtype is empty, the\n   * subscription isn’t in a grace period and you can stop providing the subscription service.\n   *\n   * Google: Subscription is in grace period. The state is only available when the subscription\n   * is an auto renewing plan. In this state, all items are in grace period.\n   *\n   * Platform: Apple, Google\n   * */\n  'IN_GRACE_PERIOD',\n\n  /**\n   * A successful payment needs to be made within 23 hours to activate the subscription. Or the\n   * payment requires action, like customer authentication. Subscriptions can also be incomplete\n   * if there’s a pending payment and the PaymentIntent status would be processing.\n   *\n   * Platform: Stripe\n   * */\n  'INCOMPLETE',\n\n  /**\n   * The initial payment on the subscription failed and no successful payment was made within 23\n   * hours of creating the subscription. These subscriptions don’t bill customers. This status\n   * exists so you can track customers that failed to activate their subscriptions.\n   *\n   * Platform: Stripe\n   * */\n  'INCOMPLETE_EXPIRED',\n\n  /**\n   * Subscription was created but awaiting payment during signup. In this state, all items are\n   * awaiting payment.\n   *\n   * Platform: Google\n   * */\n  'PENDING',\n\n  /**\n   * Pending transaction for subscription is canceled. If this pending purchase was for an\n   * existing subscription, use linkedPurchaseToken to get the current state of that subscription.\n   *\n   * Platform: Google\n   * */\n  'PENDING_PURCHASE_CANCELED',\n\n  /**\n   * Payment on the latest finalized invoice either failed or wasn’t attempted. The subscription\n   * continues to create invoices. Your subscription settings determine the subscription’s next\n   * state. If the invoice is still unpaid after all Smart Retries have been attempted, you can\n   * configure the subscription to move to canceled, unpaid, or leave it as past_due. To move the\n   * subscription to active, pay the most recent invoice before its due date.\n   *\n   * Platform: Stripe\n   * */\n  'PAST_DUE',\n\n  /**\n   * Subscription is on hold (suspended). The state is only available when the subscription is an\n   * auto renewing plan. In this state, all items are on hold. Grace period ends or Active period\n   * ends but not grace period\n   *\n   * Platform: Google\n   * */\n  'ON_HOLD',\n\n  /**\n   * The subscription has been canceled. During cancellation, automatic collection for all unpaid\n   * invoices is disabled (auto_advance=false). This is a terminal state that can’t be updated.\n   *\n   * Platform: Apple, Google, Stripe\n   * */\n  'CANCELED',\n\n  /**\n   * The latest invoice hasn’t been paid but the subscription remains in place. The latest invoice\n   * remains open and invoices continue to be generated but payments aren’t attempted. You should\n   * revoke access to your product when the subscription is unpaid since payments were already\n   * attempted and retried when it was past_due. To move the subscription to active, pay the most\n   * recent invoice before its due date.\n   *\n   * Platform: Stripe\n   * */\n  'UNPAID',\n\n  /**\n   * Google: Subscription is paused. The state is only available when the subscription is an auto\n   * renewing plan. In this state, all items are in paused state.\n   *\n   * Stripe: The subscription has ended its trial period without a default payment method and the\n   * trial_settings.end_behavior.missing_payment_method is set to pause. Invoices will no longer\n   * be created for the subscription. After a default payment method has been attached to the\n   * customer, you can resume the subscription.\n   *\n   * Platform: Google, Stripe\n   * */\n  'PAUSED',\n\n  /**\n   * For example, a user buys a subscription and receives a purchase token A. The\n   * linkedPurchaseToken field will not be set in the API response because the purchase token\n   * belongs to a brand new subscription.\n   *\n   * If the user upgrades their subscription, a new purchase token B will be generated. Since the\n   * upgrade is replacing the subscription from purchase token A, the linkedPurchaseToken field\n   * for token B will be set to point to token A. Notice it points backwards in time to the\n   * original purchase token.\n   *\n   * +---------------------------+  +------------------------+  +------------------------+\n   * | Step 1 first purchase     |  | Step 2 upgrades        |  | Step 3 downgrades      |\n   * | purchaseToken: A          |->| purchaseToken: B       |->| purchaseToken: C       |\n   * | linkedPurchaseToken: null |  | linkedPurchaseToken: A |  | linkedPurchaseToken: B |\n   * +---------------------------+  +------------------------+  +------------------------+\n   *\n   * Platform: Google\n   * */\n  'REPLACED',\n\n  /**\n   * Google: Subscription is expired. All items have expiryTime in the past.\n   *\n   * Platform: Apple, Google\n   * */\n  'EXPIRED',\n] as const;\n\nexport type SubscriptionStatus = (typeof SUBSCRIPTION_STATUSES)[number];\n\n/** statuses where it is safe to provision your product for the customer */\nexport const AVAILABLE_STATUSES = [\n  'ACTIVE',\n  'TRIALING',\n  'IN_GRACE_PERIOD',\n] as const satisfies readonly SubscriptionStatus[];\n"],"mappings":";AAAA,MAAa,YAAY;CAAC;CAAS;CAAU;AAAQ;;;;;;;AAUrD,MAAa,wBAAwB;CAUnC;CAQA;CAYA;CASA;CASA;CAQA;CAQA;CAWA;CASA;CAQA;CAWA;CAaA;CAoBA;CAOA;AACF;;AAKA,MAAa,qBAAqB;CAChC;CACA;CACA;AACF"}