{"version":3,"file":"real-time-developer-notification.cjs","names":[],"sources":["../../src/google-play/real-time-developer-notification.ts"],"sourcesContent":["// ref: https://cloud.google.com/pubsub/docs/reference/rest/v1/PubsubMessage\nexport type PubsubMessage = {\n  data: string;\n  attributes: Record<string, string>;\n  messageId: string;\n  publishTime: string;\n  orderingKey: string;\n};\n\n/** https://developer.android.com/google/play/billing/rtdn-reference */\nexport interface DeveloperNotification {\n  version: string;\n  packageName: string;\n  eventTimeMillis: number;\n  subscriptionNotification: SubscriptionNotification;\n  oneTimeProductNotification: OneTimeProductNotification;\n  voidedPurchaseNotification: VoidedPurchaseNotification;\n  testNotification: TestNotification;\n}\n\n/**\n * [Real-time developer notifications reference guide](https://developer.android.com/google/play/billing/rtdn-reference)\n * */\nexport const SubscriptionNotificationType = {\n  /** A subscription was recovered from account hold. */\n  SUBSCRIPTION_RECOVERED: 1,\n\n  /** An active subscription was renewed. */\n  SUBSCRIPTION_RENEWED: 2,\n\n  /**\n   * A subscription was either voluntarily or involuntarily cancelled. For voluntary cancellation,\n   * sent when the user cancels.\n   */\n  SUBSCRIPTION_CANCELED: 3,\n\n  /** A new subscription was purchased. */\n  SUBSCRIPTION_PURCHASED: 4,\n\n  /** A subscription has entered account hold (if enabled). */\n  SUBSCRIPTION_ON_HOLD: 5,\n\n  /** A subscription has entered grace period (if enabled). */\n  SUBSCRIPTION_IN_GRACE_PERIOD: 6,\n\n  /**\n   * User has restored their subscription from Play > Account > Subscriptions. The subscription was\n   * canceled but had not expired yet when the user restores. For more information, see Restorations.\n   */\n  SUBSCRIPTION_RESTARTED: 7,\n\n  /** (DEPRECATED) A subscription price change has successfully been confirmed by the user. */\n  SUBSCRIPTION_PRICE_CHANGE_CONFIRMED: 8,\n\n  /** A subscription's recurrence time has been extended. */\n  SUBSCRIPTION_DEFERRED: 9,\n\n  /** A subscription has been paused. */\n  SUBSCRIPTION_PAUSED: 10,\n\n  /** A subscription pause schedule has been changed. */\n  SUBSCRIPTION_PAUSE_SCHEDULE_CHANGED: 11,\n\n  /** A subscription has been revoked from the user before the expiration time. */\n  SUBSCRIPTION_REVOKED: 12,\n\n  /** A subscription has expired. */\n  SUBSCRIPTION_EXPIRED: 13,\n\n  /** A subscription item's price change details are updated. */\n  SUBSCRIPTION_PRICE_CHANGE_UPDATED: 19,\n\n  /** A pending transaction of a subscription has been canceled. */\n  SUBSCRIPTION_PENDING_PURCHASE_CANCELED: 20,\n} as const;\n\nexport type SubscriptionNotificationType =\n  (typeof SubscriptionNotificationType)[keyof typeof SubscriptionNotificationType];\n\nexport interface SubscriptionNotification {\n  version: string;\n  purchaseToken: string;\n  notificationType: SubscriptionNotificationType;\n}\n\nexport const OneTimeProductNotificationType = {\n  /** A one-time product was successfully purchased by a user. */\n  ONE_TIME_PRODUCT_PURCHASED: 1,\n\n  /** A pending one-time product purchase has been canceled by the user. */\n  ONE_TIME_PRODUCT_CANCELED: 2,\n} as const;\n\nexport type OneTimeProductNotificationType =\n  (typeof OneTimeProductNotificationType)[keyof typeof OneTimeProductNotificationType];\n\nexport interface OneTimeProductNotification {\n  version: string;\n  sku: string;\n  purchaseToken: string;\n  notificationType: OneTimeProductNotificationType;\n}\n\nexport const VoidedPurchaseProductType = {\n  /** A subscription purchase has been voided. */\n  PRODUCT_TYPE_SUBSCRIPTION: 1,\n\n  /** A one-time purchase has been voided. */\n  PRODUCT_TYPE_ONE_TIME: 2,\n} as const;\n\nexport type VoidedPurchaseProductType =\n  (typeof VoidedPurchaseProductType)[keyof typeof VoidedPurchaseProductType];\n\n/**\n * Note when the remaining total quantity of a multi-quantity purchase is refunded, the refundType\n * will be REFUND_TYPE_FULL_REFUND.\n */\nexport const VoidedPurchaseRefundType = {\n  /** The purchase has been fully voided. */\n  REFUND_TYPE_FULL_REFUND: 1,\n\n  /**\n   * The purchase has been partially voided by a quantity-based partial refund, applicable only to\n   * multi-quantity purchases. A purchase can be partially voided multiple times.\n   */\n  REFUND_TYPE_QUANTITY_BASED_PARTIAL_REFUND: 2,\n} as const;\n\nexport type VoidedPurchaseRefundType =\n  (typeof VoidedPurchaseRefundType)[keyof typeof VoidedPurchaseRefundType];\n\nexport interface VoidedPurchaseNotification {\n  purchaseToken: string;\n  orderId: string;\n  productType: VoidedPurchaseProductType;\n  refundType: VoidedPurchaseRefundType;\n}\n\nexport interface TestNotification {\n  version: string;\n}\n\n/** ref: https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptionsv2#SubscriptionState */\nexport const GOOGLE_PLAY_SUBSCRIPTION_STATES = [\n  /** Unspecified subscription state. */\n  'SUBSCRIPTION_STATE_UNSPECIFIED',\n\n  /**\n   * Subscription was created but awaiting payment during signup. In this state, all items are\n   * awaiting payment.\n   */\n  'SUBSCRIPTION_STATE_PENDING',\n\n  /**\n   * Subscription is active.\n   * (1) If the subscription is an auto renewing plan, at least one item is autoRenewEnabled and not expired.\n   * (2) If the subscription is a prepaid plan, at least one item is not expired.\n   */\n  'SUBSCRIPTION_STATE_ACTIVE',\n\n  /**\n   * Subscription is paused. The state is only available when the subscription is an auto renewing\n   * plan. In this state, all items are in paused state.\n   */\n  'SUBSCRIPTION_STATE_PAUSED',\n\n  /**\n   * Subscription is in grace period. The state is only available when the subscription is an auto\n   * renewing plan. In this state, all items are in grace period.\n   */\n  'SUBSCRIPTION_STATE_IN_GRACE_PERIOD',\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.\n   */\n  'SUBSCRIPTION_STATE_ON_HOLD',\n\n  /**\n   * Subscription is canceled but not expired yet. The state is only available when the subscription\n   * is an auto renewing plan. All items have autoRenewEnabled set to false.\n   */\n  'SUBSCRIPTION_STATE_CANCELED',\n\n  /** Subscription is expired. All items have expiryTime in the past. */\n  'SUBSCRIPTION_STATE_EXPIRED',\n\n  /**\n   * Pending transaction for subscription is canceled. If this pending purchase was for an existing\n   * subscription, use linkedPurchaseToken to get the current state of that subscription.\n   */\n  'SUBSCRIPTION_STATE_PENDING_PURCHASE_CANCELED',\n] as const;\n\nexport type GooglePlaySubscriptionState = (typeof GOOGLE_PLAY_SUBSCRIPTION_STATES)[number];\n"],"mappings":";;;;;AAuBA,MAAa,+BAA+B;;CAE1C,wBAAwB;;CAGxB,sBAAsB;;;;;CAMtB,uBAAuB;;CAGvB,wBAAwB;;CAGxB,sBAAsB;;CAGtB,8BAA8B;;;;;CAM9B,wBAAwB;;CAGxB,qCAAqC;;CAGrC,uBAAuB;;CAGvB,qBAAqB;;CAGrB,qCAAqC;;CAGrC,sBAAsB;;CAGtB,sBAAsB;;CAGtB,mCAAmC;;CAGnC,wCAAwC;AAC1C;AAWA,MAAa,iCAAiC;;CAE5C,4BAA4B;;CAG5B,2BAA2B;AAC7B;AAYA,MAAa,4BAA4B;;CAEvC,2BAA2B;;CAG3B,uBAAuB;AACzB;;;;;AASA,MAAa,2BAA2B;;CAEtC,yBAAyB;;;;;CAMzB,2CAA2C;AAC7C;;AAiBA,MAAa,kCAAkC;CAE7C;CAMA;CAOA;CAMA;CAMA;CAMA;CAMA;CAGA;CAMA;AACF"}