@shware/purchase 1.8.9 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +23 -0
  2. package/dist/app-store/config.cjs +105 -128
  3. package/dist/app-store/config.cjs.map +1 -1
  4. package/dist/app-store/config.d.cts +36 -33
  5. package/dist/app-store/config.d.cts.map +1 -0
  6. package/dist/app-store/config.d.mts +42 -0
  7. package/dist/app-store/config.d.mts.map +1 -0
  8. package/dist/app-store/config.mjs +100 -91
  9. package/dist/app-store/config.mjs.map +1 -1
  10. package/dist/app-store/index.cjs +3 -31
  11. package/dist/app-store/index.d.cts +2 -3
  12. package/dist/app-store/index.d.mts +2 -0
  13. package/dist/app-store/index.mjs +1 -5
  14. package/dist/google-play/config.cjs +108 -123
  15. package/dist/google-play/config.cjs.map +1 -1
  16. package/dist/google-play/config.d.cts +35 -33
  17. package/dist/google-play/config.d.cts.map +1 -0
  18. package/dist/google-play/config.d.mts +41 -0
  19. package/dist/google-play/config.d.mts.map +1 -0
  20. package/dist/google-play/config.mjs +103 -86
  21. package/dist/google-play/config.mjs.map +1 -1
  22. package/dist/google-play/index.cjs +9 -42
  23. package/dist/google-play/index.d.cts +3 -4
  24. package/dist/google-play/index.d.mts +3 -0
  25. package/dist/google-play/index.mjs +2 -17
  26. package/dist/google-play/real-time-developer-notification.cjs +122 -81
  27. package/dist/google-play/real-time-developer-notification.cjs.map +1 -1
  28. package/dist/google-play/real-time-developer-notification.d.cts +119 -117
  29. package/dist/google-play/real-time-developer-notification.d.cts.map +1 -0
  30. package/dist/google-play/real-time-developer-notification.d.mts +150 -0
  31. package/dist/google-play/real-time-developer-notification.d.mts.map +1 -0
  32. package/dist/google-play/real-time-developer-notification.mjs +118 -53
  33. package/dist/google-play/real-time-developer-notification.mjs.map +1 -1
  34. package/dist/index.cjs +13 -48
  35. package/dist/index.d.cts +5 -6
  36. package/dist/index.d.mts +5 -0
  37. package/dist/index.mjs +2 -19
  38. package/dist/stripe/config.cjs +114 -133
  39. package/dist/stripe/config.cjs.map +1 -1
  40. package/dist/stripe/config.d.cts +46 -37
  41. package/dist/stripe/config.d.cts.map +1 -0
  42. package/dist/stripe/config.d.mts +52 -0
  43. package/dist/stripe/config.d.mts.map +1 -0
  44. package/dist/stripe/config.mjs +109 -96
  45. package/dist/stripe/config.mjs.map +1 -1
  46. package/dist/stripe/handler.cjs +25 -53
  47. package/dist/stripe/handler.cjs.map +1 -1
  48. package/dist/stripe/handler.d.cts +10 -9
  49. package/dist/stripe/handler.d.cts.map +1 -0
  50. package/dist/stripe/handler.d.mts +16 -0
  51. package/dist/stripe/handler.d.mts.map +1 -0
  52. package/dist/stripe/handler.mjs +25 -29
  53. package/dist/stripe/handler.mjs.map +1 -1
  54. package/dist/stripe/index.cjs +27 -74
  55. package/dist/stripe/index.d.cts +8 -12
  56. package/dist/stripe/index.d.mts +8 -0
  57. package/dist/stripe/index.mjs +5 -44
  58. package/dist/stripe/mapper.cjs +168 -219
  59. package/dist/stripe/mapper.cjs.map +1 -1
  60. package/dist/stripe/mapper.d.cts +115 -114
  61. package/dist/stripe/mapper.d.cts.map +1 -0
  62. package/dist/stripe/mapper.d.mts +158 -0
  63. package/dist/stripe/mapper.d.mts.map +1 -0
  64. package/dist/stripe/mapper.mjs +155 -182
  65. package/dist/stripe/mapper.mjs.map +1 -1
  66. package/dist/stripe/metadata.cjs +11 -35
  67. package/dist/stripe/metadata.cjs.map +1 -1
  68. package/dist/stripe/metadata.d.cts +9 -7
  69. package/dist/stripe/metadata.d.cts.map +1 -0
  70. package/dist/stripe/metadata.d.mts +12 -0
  71. package/dist/stripe/metadata.d.mts.map +1 -0
  72. package/dist/stripe/metadata.mjs +11 -11
  73. package/dist/stripe/metadata.mjs.map +1 -1
  74. package/dist/stripe/pending-checkout.cjs +55 -61
  75. package/dist/stripe/pending-checkout.cjs.map +1 -1
  76. package/dist/stripe/pending-checkout.d.cts +3 -1
  77. package/dist/stripe/pending-checkout.d.cts.map +1 -0
  78. package/dist/stripe/{pending-checkout.d.ts → pending-checkout.d.mts} +3 -1
  79. package/dist/stripe/pending-checkout.d.mts.map +1 -0
  80. package/dist/stripe/pending-checkout.mjs +52 -34
  81. package/dist/stripe/pending-checkout.mjs.map +1 -1
  82. package/dist/stripe/schema.cjs +30 -55
  83. package/dist/stripe/schema.cjs.map +1 -1
  84. package/dist/stripe/schema.d.cts +36 -37
  85. package/dist/stripe/schema.d.cts.map +1 -0
  86. package/dist/stripe/schema.d.mts +40 -0
  87. package/dist/stripe/schema.d.mts.map +1 -0
  88. package/dist/stripe/schema.mjs +28 -40
  89. package/dist/stripe/schema.mjs.map +1 -1
  90. package/dist/subscription/index.cjs +178 -80
  91. package/dist/subscription/index.cjs.map +1 -1
  92. package/dist/subscription/index.d.cts +136 -134
  93. package/dist/subscription/index.d.cts.map +1 -0
  94. package/dist/subscription/index.d.mts +150 -0
  95. package/dist/subscription/index.d.mts.map +1 -0
  96. package/dist/subscription/index.mjs +173 -51
  97. package/dist/subscription/index.mjs.map +1 -1
  98. package/dist/types.cjs +0 -19
  99. package/dist/types.d.cts +7 -6
  100. package/dist/types.d.cts.map +1 -0
  101. package/dist/types.d.mts +10 -0
  102. package/dist/types.d.mts.map +1 -0
  103. package/dist/types.mjs +1 -1
  104. package/package.json +40 -25
  105. package/dist/app-store/config.d.ts +0 -39
  106. package/dist/app-store/index.cjs.map +0 -1
  107. package/dist/app-store/index.d.ts +0 -3
  108. package/dist/app-store/index.mjs.map +0 -1
  109. package/dist/google-play/config.d.ts +0 -39
  110. package/dist/google-play/index.cjs.map +0 -1
  111. package/dist/google-play/index.d.ts +0 -4
  112. package/dist/google-play/index.mjs.map +0 -1
  113. package/dist/google-play/real-time-developer-notification.d.ts +0 -148
  114. package/dist/index.cjs.map +0 -1
  115. package/dist/index.d.ts +0 -6
  116. package/dist/index.mjs.map +0 -1
  117. package/dist/stripe/config.d.ts +0 -43
  118. package/dist/stripe/handler.d.ts +0 -15
  119. package/dist/stripe/index.cjs.map +0 -1
  120. package/dist/stripe/index.d.ts +0 -12
  121. package/dist/stripe/index.mjs.map +0 -1
  122. package/dist/stripe/mapper.d.ts +0 -157
  123. package/dist/stripe/metadata.d.ts +0 -10
  124. package/dist/stripe/schema.d.ts +0 -41
  125. package/dist/subscription/index.d.ts +0 -148
  126. package/dist/types.cjs.map +0 -1
  127. package/dist/types.d.ts +0 -9
  128. package/dist/types.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/stripe/schema.ts"],"sourcesContent":["import type { Stripe } from 'stripe';\nimport {\n _default,\n enum as _enum,\n gte,\n int,\n maxLength,\n nullable,\n object,\n optional,\n type output,\n string,\n url,\n} from 'zod/mini';\n\nexport const cancellationDetailsSchema = object({\n comment: optional(nullable(string().check(maxLength(1024)))),\n feedback: optional(\n nullable(\n _enum([\n 'customer_service',\n 'low_quality',\n 'missing_features',\n 'switched_service',\n 'too_complex',\n 'too_expensive',\n 'unused',\n 'other',\n ])\n )\n ),\n resubscribeIntent: optional(nullable(_enum(['maybe', 'no', 'yes']))),\n});\n\nexport function createCheckoutSessionSchema(productIds: string[]) {\n return object({\n quantity: _default(int().check(gte(1)), 1),\n productId: _enum(productIds),\n cancelUrl: optional(url()),\n successUrl: optional(url()),\n });\n}\n\nexport interface CancellationDetails extends output<typeof cancellationDetailsSchema> {\n reason?: Stripe.Subscription.CancellationDetails.Reason | null;\n}\n\nexport interface CreateCheckoutSessionDTO {\n productId: string;\n cancelUrl?: string;\n successUrl?: `${string}session_id={CHECKOUT_SESSION_ID}${string}`;\n}\n"],"mappings":";AACA;AAAA,EACE;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AAEA,IAAM,4BAA4B,OAAO;AAAA,EAC9C,SAAS,SAAS,SAAS,OAAO,EAAE,MAAM,UAAU,IAAI,CAAC,CAAC,CAAC;AAAA,EAC3D,UAAU;AAAA,IACR;AAAA,MACE,MAAM;AAAA,QACJ;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EACA,mBAAmB,SAAS,SAAS,MAAM,CAAC,SAAS,MAAM,KAAK,CAAC,CAAC,CAAC;AACrE,CAAC;AAEM,SAAS,4BAA4B,YAAsB;AAChE,SAAO,OAAO;AAAA,IACZ,UAAU,SAAS,IAAI,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC;AAAA,IACzC,WAAW,MAAM,UAAU;AAAA,IAC3B,WAAW,SAAS,IAAI,CAAC;AAAA,IACzB,YAAY,SAAS,IAAI,CAAC;AAAA,EAC5B,CAAC;AACH;","names":[]}
1
+ {"version":3,"file":"schema.mjs","names":["_enum"],"sources":["../../src/stripe/schema.ts"],"sourcesContent":["import type { Stripe } from 'stripe';\nimport {\n _default,\n enum as _enum,\n gte,\n int,\n maxLength,\n nullable,\n object,\n optional,\n type output,\n string,\n url,\n} from 'zod/mini';\n\nexport const cancellationDetailsSchema = object({\n comment: optional(nullable(string().check(maxLength(1024)))),\n feedback: optional(\n nullable(\n _enum([\n 'customer_service',\n 'low_quality',\n 'missing_features',\n 'switched_service',\n 'too_complex',\n 'too_expensive',\n 'unused',\n 'other',\n ])\n )\n ),\n resubscribeIntent: optional(nullable(_enum(['maybe', 'no', 'yes']))),\n});\n\nexport function createCheckoutSessionSchema(productIds: string[]) {\n return object({\n quantity: _default(int().check(gte(1)), 1),\n productId: _enum(productIds),\n cancelUrl: optional(url()),\n successUrl: optional(url()),\n });\n}\n\nexport interface CancellationDetails extends output<typeof cancellationDetailsSchema> {\n reason?: Stripe.Subscription.CancellationDetails.Reason | null;\n}\n\nexport interface CreateCheckoutSessionDTO {\n productId: string;\n cancelUrl?: string;\n successUrl?: `${string}session_id={CHECKOUT_SESSION_ID}${string}`;\n}\n"],"mappings":";;AAeA,MAAa,4BAA4B,OAAO;CAC9C,SAAS,SAAS,SAAS,OAAO,CAAC,CAAC,MAAM,UAAU,IAAI,CAAC,CAAC,CAAC;CAC3D,UAAU,SACR,SACEA,OAAM;EACJ;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,CACH,CACF;CACA,mBAAmB,SAAS,SAASA,OAAM;EAAC;EAAS;EAAM;CAAK,CAAC,CAAC,CAAC;AACrE,CAAC;AAED,SAAgB,4BAA4B,YAAsB;CAChE,OAAO,OAAO;EACZ,UAAU,SAAS,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC;EACzC,WAAWA,OAAM,UAAU;EAC3B,WAAW,SAAS,IAAI,CAAC;EACzB,YAAY,SAAS,IAAI,CAAC;CAC5B,CAAC;AACH"}
@@ -1,83 +1,181 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/subscription/index.ts
21
- var subscription_exports = {};
22
- __export(subscription_exports, {
23
- ALL_PLATFORMS: () => ALL_PLATFORMS,
24
- ALL_SUBSCRIPTION_STATUS: () => ALL_SUBSCRIPTION_STATUS,
25
- AVAILABLE_STATUS: () => AVAILABLE_STATUS,
26
- Platform: () => Platform,
27
- SubscriptionStatus: () => SubscriptionStatus
28
- });
29
- module.exports = __toCommonJS(subscription_exports);
30
- var Platform = /* @__PURE__ */ ((Platform2) => {
31
- Platform2["APPLE"] = "APPLE";
32
- Platform2["GOOGLE"] = "GOOGLE";
33
- Platform2["STRIPE"] = "STRIPE";
34
- return Platform2;
35
- })(Platform || {});
36
- var ALL_PLATFORMS = ["APPLE" /* APPLE */, "GOOGLE" /* GOOGLE */, "STRIPE" /* STRIPE */];
37
- var SubscriptionStatus = /* @__PURE__ */ ((SubscriptionStatus2) => {
38
- SubscriptionStatus2["TRIALING"] = "TRIALING";
39
- SubscriptionStatus2["ACTIVE"] = "ACTIVE";
40
- SubscriptionStatus2["IN_GRACE_PERIOD"] = "IN_GRACE_PERIOD";
41
- SubscriptionStatus2["INCOMPLETE"] = "INCOMPLETE";
42
- SubscriptionStatus2["INCOMPLETE_EXPIRED"] = "INCOMPLETE_EXPIRED";
43
- SubscriptionStatus2["PENDING"] = "PENDING";
44
- SubscriptionStatus2["PENDING_PURCHASE_CANCELED"] = "PENDING_PURCHASE_CANCELED";
45
- SubscriptionStatus2["PAST_DUE"] = "PAST_DUE";
46
- SubscriptionStatus2["ON_HOLD"] = "ON_HOLD";
47
- SubscriptionStatus2["CANCELED"] = "CANCELED";
48
- SubscriptionStatus2["UNPAID"] = "UNPAID";
49
- SubscriptionStatus2["PAUSED"] = "PAUSED";
50
- SubscriptionStatus2["REPLACED"] = "REPLACED";
51
- SubscriptionStatus2["EXPIRED"] = "EXPIRED";
52
- return SubscriptionStatus2;
53
- })(SubscriptionStatus || {});
54
- var AVAILABLE_STATUS = [
55
- "ACTIVE" /* ACTIVE */,
56
- "TRIALING" /* TRIALING */,
57
- "IN_GRACE_PERIOD" /* IN_GRACE_PERIOD */
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/subscription/index.ts
3
+ let Platform = /* @__PURE__ */ function(Platform) {
4
+ Platform["APPLE"] = "APPLE";
5
+ Platform["GOOGLE"] = "GOOGLE";
6
+ Platform["STRIPE"] = "STRIPE";
7
+ return Platform;
8
+ }({});
9
+ const ALL_PLATFORMS = [
10
+ "APPLE",
11
+ "GOOGLE",
12
+ "STRIPE"
13
+ ];
14
+ /**
15
+ * [Stripe Subscription Status](https://stripe.com/docs/api/subscriptions/object#subscription_object-status)
16
+ * [Stripe Subscription Lifecycle](https://docs.stripe.com/billing/subscriptions/overview)
17
+ *
18
+ * provision product for customer when Status = TRIALING, ACTIVE, IN_GRACE_PERIOD
19
+ */
20
+ let SubscriptionStatus = /* @__PURE__ */ function(SubscriptionStatus) {
21
+ /**
22
+ * The subscription is currently in a trial period and it’s safe to provision your product for
23
+ * your customer. The subscription transitions automatically to active when the first payment
24
+ * is made.
25
+ *
26
+ * Google: play(LineItems[0].OfferDetails.OfferId == 'xx')
27
+ *
28
+ * Platform: Apple, Google, Stripe
29
+ * */
30
+ SubscriptionStatus["TRIALING"] = "TRIALING";
31
+ /**
32
+ * The subscription is in good standing and the most recent payment is successful. It’s safe to
33
+ * provision your product for your customer.
34
+ *
35
+ * Platform: Apple, Google, Stripe
36
+ * */
37
+ SubscriptionStatus["ACTIVE"] = "ACTIVE";
38
+ /**
39
+ * Apple: The subscription enters the billing retry period. If the subtype is GRACE_PERIOD,
40
+ * continue to provide service through the grace period. If the subtype is empty, the
41
+ * subscription isn’t in a grace period and you can stop providing the subscription service.
42
+ *
43
+ * Google: Subscription is in grace period. The state is only available when the subscription
44
+ * is an auto renewing plan. In this state, all items are in grace period.
45
+ *
46
+ * Platform: Apple, Google
47
+ * */
48
+ SubscriptionStatus["IN_GRACE_PERIOD"] = "IN_GRACE_PERIOD";
49
+ /**
50
+ * A successful payment needs to be made within 23 hours to activate the subscription. Or the
51
+ * payment requires action, like customer authentication. Subscriptions can also be incomplete
52
+ * if there’s a pending payment and the PaymentIntent status would be processing.
53
+ *
54
+ * Platform: Stripe
55
+ * */
56
+ SubscriptionStatus["INCOMPLETE"] = "INCOMPLETE";
57
+ /**
58
+ * The initial payment on the subscription failed and no successful payment was made within 23
59
+ * hours of creating the subscription. These subscriptions don’t bill customers. This status
60
+ * exists so you can track customers that failed to activate their subscriptions.
61
+ *
62
+ * Platform: Stripe
63
+ * */
64
+ SubscriptionStatus["INCOMPLETE_EXPIRED"] = "INCOMPLETE_EXPIRED";
65
+ /**
66
+ * Subscription was created but awaiting payment during signup. In this state, all items are
67
+ * awaiting payment.
68
+ *
69
+ * Platform: Google
70
+ * */
71
+ SubscriptionStatus["PENDING"] = "PENDING";
72
+ /**
73
+ * Pending transaction for subscription is canceled. If this pending purchase was for an
74
+ * existing subscription, use linkedPurchaseToken to get the current state of that subscription.
75
+ *
76
+ * Platform: Google
77
+ * */
78
+ SubscriptionStatus["PENDING_PURCHASE_CANCELED"] = "PENDING_PURCHASE_CANCELED";
79
+ /**
80
+ * Payment on the latest finalized invoice either failed or wasn’t attempted. The subscription
81
+ * continues to create invoices. Your subscription settings determine the subscription’s next
82
+ * state. If the invoice is still unpaid after all Smart Retries have been attempted, you can
83
+ * configure the subscription to move to canceled, unpaid, or leave it as past_due. To move the
84
+ * subscription to active, pay the most recent invoice before its due date.
85
+ *
86
+ * Platform: Stripe
87
+ * */
88
+ SubscriptionStatus["PAST_DUE"] = "PAST_DUE";
89
+ /**
90
+ * Subscription is on hold (suspended). The state is only available when the subscription is an
91
+ * auto renewing plan. In this state, all items are on hold. Grace period ends or Active period
92
+ * ends but not grace period
93
+ *
94
+ * Platform: Google
95
+ * */
96
+ SubscriptionStatus["ON_HOLD"] = "ON_HOLD";
97
+ /**
98
+ * The subscription has been canceled. During cancellation, automatic collection for all unpaid
99
+ * invoices is disabled (auto_advance=false). This is a terminal state that can’t be updated.
100
+ *
101
+ * Platform: Apple, Google, Stripe
102
+ * */
103
+ SubscriptionStatus["CANCELED"] = "CANCELED";
104
+ /**
105
+ * The latest invoice hasn’t been paid but the subscription remains in place. The latest invoice
106
+ * remains open and invoices continue to be generated but payments aren’t attempted. You should
107
+ * revoke access to your product when the subscription is unpaid since payments were already
108
+ * attempted and retried when it was past_due. To move the subscription to active, pay the most
109
+ * recent invoice before its due date.
110
+ *
111
+ * Platform: Stripe
112
+ * */
113
+ SubscriptionStatus["UNPAID"] = "UNPAID";
114
+ /**
115
+ * Google: Subscription is paused. The state is only available when the subscription is an auto
116
+ * renewing plan. In this state, all items are in paused state.
117
+ *
118
+ * Stripe: The subscription has ended its trial period without a default payment method and the
119
+ * trial_settings.end_behavior.missing_payment_method is set to pause. Invoices will no longer
120
+ * be created for the subscription. After a default payment method has been attached to the
121
+ * customer, you can resume the subscription.
122
+ *
123
+ * Platform: Google, Stripe
124
+ * */
125
+ SubscriptionStatus["PAUSED"] = "PAUSED";
126
+ /**
127
+ * For example, a user buys a subscription and receives a purchase token A. The
128
+ * linkedPurchaseToken field will not be set in the API response because the purchase token
129
+ * belongs to a brand new subscription.
130
+ *
131
+ * If the user upgrades their subscription, a new purchase token B will be generated. Since the
132
+ * upgrade is replacing the subscription from purchase token A, the linkedPurchaseToken field
133
+ * for token B will be set to point to token A. Notice it points backwards in time to the
134
+ * original purchase token.
135
+ *
136
+ * +---------------------------+ +------------------------+ +------------------------+
137
+ * | Step 1 first purchase | | Step 2 upgrades | | Step 3 downgrades |
138
+ * | purchaseToken: A |->| purchaseToken: B |->| purchaseToken: C |
139
+ * | linkedPurchaseToken: null | | linkedPurchaseToken: A | | linkedPurchaseToken: B |
140
+ * +---------------------------+ +------------------------+ +------------------------+
141
+ *
142
+ * Platform: Google
143
+ * */
144
+ SubscriptionStatus["REPLACED"] = "REPLACED";
145
+ /**
146
+ * Google: Subscription is expired. All items have expiryTime in the past.
147
+ *
148
+ * Platform: Apple, Google
149
+ * */
150
+ SubscriptionStatus["EXPIRED"] = "EXPIRED";
151
+ return SubscriptionStatus;
152
+ }({});
153
+ const AVAILABLE_STATUS = [
154
+ "ACTIVE",
155
+ "TRIALING",
156
+ "IN_GRACE_PERIOD"
58
157
  ];
59
- var ALL_SUBSCRIPTION_STATUS = [
60
- "TRIALING" /* TRIALING */,
61
- "ACTIVE" /* ACTIVE */,
62
- "IN_GRACE_PERIOD" /* IN_GRACE_PERIOD */,
63
- "INCOMPLETE" /* INCOMPLETE */,
64
- "INCOMPLETE_EXPIRED" /* INCOMPLETE_EXPIRED */,
65
- "PENDING" /* PENDING */,
66
- "PENDING_PURCHASE_CANCELED" /* PENDING_PURCHASE_CANCELED */,
67
- "PAST_DUE" /* PAST_DUE */,
68
- "ON_HOLD" /* ON_HOLD */,
69
- "CANCELED" /* CANCELED */,
70
- "UNPAID" /* UNPAID */,
71
- "PAUSED" /* PAUSED */,
72
- "REPLACED" /* REPLACED */,
73
- "EXPIRED" /* EXPIRED */
158
+ const ALL_SUBSCRIPTION_STATUS = [
159
+ "TRIALING",
160
+ "ACTIVE",
161
+ "IN_GRACE_PERIOD",
162
+ "INCOMPLETE",
163
+ "INCOMPLETE_EXPIRED",
164
+ "PENDING",
165
+ "PENDING_PURCHASE_CANCELED",
166
+ "PAST_DUE",
167
+ "ON_HOLD",
168
+ "CANCELED",
169
+ "UNPAID",
170
+ "PAUSED",
171
+ "REPLACED",
172
+ "EXPIRED"
74
173
  ];
75
- // Annotate the CommonJS export names for ESM import in node:
76
- 0 && (module.exports = {
77
- ALL_PLATFORMS,
78
- ALL_SUBSCRIPTION_STATUS,
79
- AVAILABLE_STATUS,
80
- Platform,
81
- SubscriptionStatus
82
- });
174
+ //#endregion
175
+ exports.ALL_PLATFORMS = ALL_PLATFORMS;
176
+ exports.ALL_SUBSCRIPTION_STATUS = ALL_SUBSCRIPTION_STATUS;
177
+ exports.AVAILABLE_STATUS = AVAILABLE_STATUS;
178
+ exports.Platform = Platform;
179
+ exports.SubscriptionStatus = SubscriptionStatus;
180
+
83
181
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/subscription/index.ts"],"sourcesContent":["export enum Platform {\n APPLE = 'APPLE',\n GOOGLE = 'GOOGLE',\n STRIPE = 'STRIPE',\n}\n\nexport const ALL_PLATFORMS = [Platform.APPLE, Platform.GOOGLE, Platform.STRIPE] as const;\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 enum SubscriptionStatus {\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 = '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 = '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 = '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 = '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 = '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 = '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 = '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 = '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 = '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 = '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 = '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 = '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 = 'REPLACED',\n\n /**\n * Google: \tSubscription is expired. All items have expiryTime in the past.\n *\n * Platform: Apple, Google\n * */\n EXPIRED = 'EXPIRED',\n}\n\nexport const AVAILABLE_STATUS = [\n SubscriptionStatus.ACTIVE,\n SubscriptionStatus.TRIALING,\n SubscriptionStatus.IN_GRACE_PERIOD,\n];\n\nexport const ALL_SUBSCRIPTION_STATUS = [\n SubscriptionStatus.TRIALING,\n SubscriptionStatus.ACTIVE,\n SubscriptionStatus.IN_GRACE_PERIOD,\n SubscriptionStatus.INCOMPLETE,\n SubscriptionStatus.INCOMPLETE_EXPIRED,\n SubscriptionStatus.PENDING,\n SubscriptionStatus.PENDING_PURCHASE_CANCELED,\n SubscriptionStatus.PAST_DUE,\n SubscriptionStatus.ON_HOLD,\n SubscriptionStatus.CANCELED,\n SubscriptionStatus.UNPAID,\n SubscriptionStatus.PAUSED,\n SubscriptionStatus.REPLACED,\n SubscriptionStatus.EXPIRED,\n] as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAK,WAAL,kBAAKA,cAAL;AACL,EAAAA,UAAA,WAAQ;AACR,EAAAA,UAAA,YAAS;AACT,EAAAA,UAAA,YAAS;AAHC,SAAAA;AAAA,GAAA;AAML,IAAM,gBAAgB,CAAC,qBAAgB,uBAAiB,qBAAe;AAQvE,IAAK,qBAAL,kBAAKC,wBAAL;AAUL,EAAAA,oBAAA,cAAW;AAQX,EAAAA,oBAAA,YAAS;AAYT,EAAAA,oBAAA,qBAAkB;AASlB,EAAAA,oBAAA,gBAAa;AASb,EAAAA,oBAAA,wBAAqB;AAQrB,EAAAA,oBAAA,aAAU;AAQV,EAAAA,oBAAA,+BAA4B;AAW5B,EAAAA,oBAAA,cAAW;AASX,EAAAA,oBAAA,aAAU;AAQV,EAAAA,oBAAA,cAAW;AAWX,EAAAA,oBAAA,YAAS;AAaT,EAAAA,oBAAA,YAAS;AAoBT,EAAAA,oBAAA,cAAW;AAOX,EAAAA,oBAAA,aAAU;AA/IA,SAAAA;AAAA,GAAA;AAkJL,IAAM,mBAAmB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AACF;AAEO,IAAM,0BAA0B;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;","names":["Platform","SubscriptionStatus"]}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../src/subscription/index.ts"],"sourcesContent":["export enum Platform {\n APPLE = 'APPLE',\n GOOGLE = 'GOOGLE',\n STRIPE = 'STRIPE',\n}\n\nexport const ALL_PLATFORMS = [Platform.APPLE, Platform.GOOGLE, Platform.STRIPE] as const;\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 enum SubscriptionStatus {\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 = '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 = '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 = '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 = '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 = '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 = '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 = '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 = '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 = '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 = '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 = '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 = '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 = 'REPLACED',\n\n /**\n * Google: \tSubscription is expired. All items have expiryTime in the past.\n *\n * Platform: Apple, Google\n * */\n EXPIRED = 'EXPIRED',\n}\n\nexport const AVAILABLE_STATUS = [\n SubscriptionStatus.ACTIVE,\n SubscriptionStatus.TRIALING,\n SubscriptionStatus.IN_GRACE_PERIOD,\n];\n\nexport const ALL_SUBSCRIPTION_STATUS = [\n SubscriptionStatus.TRIALING,\n SubscriptionStatus.ACTIVE,\n SubscriptionStatus.IN_GRACE_PERIOD,\n SubscriptionStatus.INCOMPLETE,\n SubscriptionStatus.INCOMPLETE_EXPIRED,\n SubscriptionStatus.PENDING,\n SubscriptionStatus.PENDING_PURCHASE_CANCELED,\n SubscriptionStatus.PAST_DUE,\n SubscriptionStatus.ON_HOLD,\n SubscriptionStatus.CANCELED,\n SubscriptionStatus.UNPAID,\n SubscriptionStatus.PAUSED,\n SubscriptionStatus.REPLACED,\n SubscriptionStatus.EXPIRED,\n] as const;\n"],"mappings":";;AAAA,IAAY,WAAL,yBAAA,UAAA;CACL,SAAA,WAAA;CACA,SAAA,YAAA;CACA,SAAA,YAAA;;AACF,EAAA,CAAA,CAAA;AAEA,MAAa,gBAAgB;;;;AAAiD;;;;;;;AAQ9E,IAAY,qBAAL,yBAAA,oBAAA;;;;;;;;;;CAUL,mBAAA,cAAA;;;;;;;CAQA,mBAAA,YAAA;;;;;;;;;;;CAYA,mBAAA,qBAAA;;;;;;;;CASA,mBAAA,gBAAA;;;;;;;;CASA,mBAAA,wBAAA;;;;;;;CAQA,mBAAA,aAAA;;;;;;;CAQA,mBAAA,+BAAA;;;;;;;;;;CAWA,mBAAA,cAAA;;;;;;;;CASA,mBAAA,aAAA;;;;;;;CAQA,mBAAA,cAAA;;;;;;;;;;CAWA,mBAAA,YAAA;;;;;;;;;;;;CAaA,mBAAA,YAAA;;;;;;;;;;;;;;;;;;;CAoBA,mBAAA,cAAA;;;;;;CAOA,mBAAA,aAAA;;AACF,EAAA,CAAA,CAAA;AAEA,MAAa,mBAAmB;;;;AAIhC;AAEA,MAAa,0BAA0B;;;;;;;;;;;;;;;AAevC"}
@@ -1,7 +1,8 @@
1
+ //#region src/subscription/index.d.ts
1
2
  declare enum Platform {
2
- APPLE = "APPLE",
3
- GOOGLE = "GOOGLE",
4
- STRIPE = "STRIPE"
3
+ APPLE = "APPLE",
4
+ GOOGLE = "GOOGLE",
5
+ STRIPE = "STRIPE"
5
6
  }
6
7
  declare const ALL_PLATFORMS: readonly [Platform.APPLE, Platform.GOOGLE, Platform.STRIPE];
7
8
  /**
@@ -11,138 +12,139 @@ declare const ALL_PLATFORMS: readonly [Platform.APPLE, Platform.GOOGLE, Platform
11
12
  * provision product for customer when Status = TRIALING, ACTIVE, IN_GRACE_PERIOD
12
13
  */
13
14
  declare enum SubscriptionStatus {
14
- /**
15
- * The subscription is currently in a trial period and it’s safe to provision your product for
16
- * your customer. The subscription transitions automatically to active when the first payment
17
- * is made.
18
- *
19
- * Google: play(LineItems[0].OfferDetails.OfferId == 'xx')
20
- *
21
- * Platform: Apple, Google, Stripe
22
- * */
23
- TRIALING = "TRIALING",
24
- /**
25
- * The subscription is in good standing and the most recent payment is successful. It’s safe to
26
- * provision your product for your customer.
27
- *
28
- * Platform: Apple, Google, Stripe
29
- * */
30
- ACTIVE = "ACTIVE",
31
- /**
32
- * Apple: The subscription enters the billing retry period. If the subtype is GRACE_PERIOD,
33
- * continue to provide service through the grace period. If the subtype is empty, the
34
- * subscription isn’t in a grace period and you can stop providing the subscription service.
35
- *
36
- * Google: Subscription is in grace period. The state is only available when the subscription
37
- * is an auto renewing plan. In this state, all items are in grace period.
38
- *
39
- * Platform: Apple, Google
40
- * */
41
- IN_GRACE_PERIOD = "IN_GRACE_PERIOD",
42
- /**
43
- * A successful payment needs to be made within 23 hours to activate the subscription. Or the
44
- * payment requires action, like customer authentication. Subscriptions can also be incomplete
45
- * if there’s a pending payment and the PaymentIntent status would be processing.
46
- *
47
- * Platform: Stripe
48
- * */
49
- INCOMPLETE = "INCOMPLETE",
50
- /**
51
- * The initial payment on the subscription failed and no successful payment was made within 23
52
- * hours of creating the subscription. These subscriptions don’t bill customers. This status
53
- * exists so you can track customers that failed to activate their subscriptions.
54
- *
55
- * Platform: Stripe
56
- * */
57
- INCOMPLETE_EXPIRED = "INCOMPLETE_EXPIRED",
58
- /**
59
- * Subscription was created but awaiting payment during signup. In this state, all items are
60
- * awaiting payment.
61
- *
62
- * Platform: Google
63
- * */
64
- PENDING = "PENDING",
65
- /**
66
- * Pending transaction for subscription is canceled. If this pending purchase was for an
67
- * existing subscription, use linkedPurchaseToken to get the current state of that subscription.
68
- *
69
- * Platform: Google
70
- * */
71
- PENDING_PURCHASE_CANCELED = "PENDING_PURCHASE_CANCELED",
72
- /**
73
- * Payment on the latest finalized invoice either failed or wasn’t attempted. The subscription
74
- * continues to create invoices. Your subscription settings determine the subscription’s next
75
- * state. If the invoice is still unpaid after all Smart Retries have been attempted, you can
76
- * configure the subscription to move to canceled, unpaid, or leave it as past_due. To move the
77
- * subscription to active, pay the most recent invoice before its due date.
78
- *
79
- * Platform: Stripe
80
- * */
81
- PAST_DUE = "PAST_DUE",
82
- /**
83
- * Subscription is on hold (suspended). The state is only available when the subscription is an
84
- * auto renewing plan. In this state, all items are on hold. Grace period ends or Active period
85
- * ends but not grace period
86
- *
87
- * Platform: Google
88
- * */
89
- ON_HOLD = "ON_HOLD",
90
- /**
91
- * The subscription has been canceled. During cancellation, automatic collection for all unpaid
92
- * invoices is disabled (auto_advance=false). This is a terminal state that can’t be updated.
93
- *
94
- * Platform: Apple, Google, Stripe
95
- * */
96
- CANCELED = "CANCELED",
97
- /**
98
- * The latest invoice hasn’t been paid but the subscription remains in place. The latest invoice
99
- * remains open and invoices continue to be generated but payments aren’t attempted. You should
100
- * revoke access to your product when the subscription is unpaid since payments were already
101
- * attempted and retried when it was past_due. To move the subscription to active, pay the most
102
- * recent invoice before its due date.
103
- *
104
- * Platform: Stripe
105
- * */
106
- UNPAID = "UNPAID",
107
- /**
108
- * Google: Subscription is paused. The state is only available when the subscription is an auto
109
- * renewing plan. In this state, all items are in paused state.
110
- *
111
- * Stripe: The subscription has ended its trial period without a default payment method and the
112
- * trial_settings.end_behavior.missing_payment_method is set to pause. Invoices will no longer
113
- * be created for the subscription. After a default payment method has been attached to the
114
- * customer, you can resume the subscription.
115
- *
116
- * Platform: Google, Stripe
117
- * */
118
- PAUSED = "PAUSED",
119
- /**
120
- * For example, a user buys a subscription and receives a purchase token A. The
121
- * linkedPurchaseToken field will not be set in the API response because the purchase token
122
- * belongs to a brand new subscription.
123
- *
124
- * If the user upgrades their subscription, a new purchase token B will be generated. Since the
125
- * upgrade is replacing the subscription from purchase token A, the linkedPurchaseToken field
126
- * for token B will be set to point to token A. Notice it points backwards in time to the
127
- * original purchase token.
128
- *
129
- * +---------------------------+ +------------------------+ +------------------------+
130
- * | Step 1 first purchase | | Step 2 upgrades | | Step 3 downgrades |
131
- * | purchaseToken: A |->| purchaseToken: B |->| purchaseToken: C |
132
- * | linkedPurchaseToken: null | | linkedPurchaseToken: A | | linkedPurchaseToken: B |
133
- * +---------------------------+ +------------------------+ +------------------------+
134
- *
135
- * Platform: Google
136
- * */
137
- REPLACED = "REPLACED",
138
- /**
139
- * Google: Subscription is expired. All items have expiryTime in the past.
140
- *
141
- * Platform: Apple, Google
142
- * */
143
- EXPIRED = "EXPIRED"
15
+ /**
16
+ * The subscription is currently in a trial period and it’s safe to provision your product for
17
+ * your customer. The subscription transitions automatically to active when the first payment
18
+ * is made.
19
+ *
20
+ * Google: play(LineItems[0].OfferDetails.OfferId == 'xx')
21
+ *
22
+ * Platform: Apple, Google, Stripe
23
+ * */
24
+ TRIALING = "TRIALING",
25
+ /**
26
+ * The subscription is in good standing and the most recent payment is successful. It’s safe to
27
+ * provision your product for your customer.
28
+ *
29
+ * Platform: Apple, Google, Stripe
30
+ * */
31
+ ACTIVE = "ACTIVE",
32
+ /**
33
+ * Apple: The subscription enters the billing retry period. If the subtype is GRACE_PERIOD,
34
+ * continue to provide service through the grace period. If the subtype is empty, the
35
+ * subscription isn’t in a grace period and you can stop providing the subscription service.
36
+ *
37
+ * Google: Subscription is in grace period. The state is only available when the subscription
38
+ * is an auto renewing plan. In this state, all items are in grace period.
39
+ *
40
+ * Platform: Apple, Google
41
+ * */
42
+ IN_GRACE_PERIOD = "IN_GRACE_PERIOD",
43
+ /**
44
+ * A successful payment needs to be made within 23 hours to activate the subscription. Or the
45
+ * payment requires action, like customer authentication. Subscriptions can also be incomplete
46
+ * if there’s a pending payment and the PaymentIntent status would be processing.
47
+ *
48
+ * Platform: Stripe
49
+ * */
50
+ INCOMPLETE = "INCOMPLETE",
51
+ /**
52
+ * The initial payment on the subscription failed and no successful payment was made within 23
53
+ * hours of creating the subscription. These subscriptions don’t bill customers. This status
54
+ * exists so you can track customers that failed to activate their subscriptions.
55
+ *
56
+ * Platform: Stripe
57
+ * */
58
+ INCOMPLETE_EXPIRED = "INCOMPLETE_EXPIRED",
59
+ /**
60
+ * Subscription was created but awaiting payment during signup. In this state, all items are
61
+ * awaiting payment.
62
+ *
63
+ * Platform: Google
64
+ * */
65
+ PENDING = "PENDING",
66
+ /**
67
+ * Pending transaction for subscription is canceled. If this pending purchase was for an
68
+ * existing subscription, use linkedPurchaseToken to get the current state of that subscription.
69
+ *
70
+ * Platform: Google
71
+ * */
72
+ PENDING_PURCHASE_CANCELED = "PENDING_PURCHASE_CANCELED",
73
+ /**
74
+ * Payment on the latest finalized invoice either failed or wasn’t attempted. The subscription
75
+ * continues to create invoices. Your subscription settings determine the subscription’s next
76
+ * state. If the invoice is still unpaid after all Smart Retries have been attempted, you can
77
+ * configure the subscription to move to canceled, unpaid, or leave it as past_due. To move the
78
+ * subscription to active, pay the most recent invoice before its due date.
79
+ *
80
+ * Platform: Stripe
81
+ * */
82
+ PAST_DUE = "PAST_DUE",
83
+ /**
84
+ * Subscription is on hold (suspended). The state is only available when the subscription is an
85
+ * auto renewing plan. In this state, all items are on hold. Grace period ends or Active period
86
+ * ends but not grace period
87
+ *
88
+ * Platform: Google
89
+ * */
90
+ ON_HOLD = "ON_HOLD",
91
+ /**
92
+ * The subscription has been canceled. During cancellation, automatic collection for all unpaid
93
+ * invoices is disabled (auto_advance=false). This is a terminal state that can’t be updated.
94
+ *
95
+ * Platform: Apple, Google, Stripe
96
+ * */
97
+ CANCELED = "CANCELED",
98
+ /**
99
+ * The latest invoice hasn’t been paid but the subscription remains in place. The latest invoice
100
+ * remains open and invoices continue to be generated but payments aren’t attempted. You should
101
+ * revoke access to your product when the subscription is unpaid since payments were already
102
+ * attempted and retried when it was past_due. To move the subscription to active, pay the most
103
+ * recent invoice before its due date.
104
+ *
105
+ * Platform: Stripe
106
+ * */
107
+ UNPAID = "UNPAID",
108
+ /**
109
+ * Google: Subscription is paused. The state is only available when the subscription is an auto
110
+ * renewing plan. In this state, all items are in paused state.
111
+ *
112
+ * Stripe: The subscription has ended its trial period without a default payment method and the
113
+ * trial_settings.end_behavior.missing_payment_method is set to pause. Invoices will no longer
114
+ * be created for the subscription. After a default payment method has been attached to the
115
+ * customer, you can resume the subscription.
116
+ *
117
+ * Platform: Google, Stripe
118
+ * */
119
+ PAUSED = "PAUSED",
120
+ /**
121
+ * For example, a user buys a subscription and receives a purchase token A. The
122
+ * linkedPurchaseToken field will not be set in the API response because the purchase token
123
+ * belongs to a brand new subscription.
124
+ *
125
+ * If the user upgrades their subscription, a new purchase token B will be generated. Since the
126
+ * upgrade is replacing the subscription from purchase token A, the linkedPurchaseToken field
127
+ * for token B will be set to point to token A. Notice it points backwards in time to the
128
+ * original purchase token.
129
+ *
130
+ * +---------------------------+ +------------------------+ +------------------------+
131
+ * | Step 1 first purchase | | Step 2 upgrades | | Step 3 downgrades |
132
+ * | purchaseToken: A |->| purchaseToken: B |->| purchaseToken: C |
133
+ * | linkedPurchaseToken: null | | linkedPurchaseToken: A | | linkedPurchaseToken: B |
134
+ * +---------------------------+ +------------------------+ +------------------------+
135
+ *
136
+ * Platform: Google
137
+ * */
138
+ REPLACED = "REPLACED",
139
+ /**
140
+ * Google: Subscription is expired. All items have expiryTime in the past.
141
+ *
142
+ * Platform: Apple, Google
143
+ * */
144
+ EXPIRED = "EXPIRED"
144
145
  }
145
146
  declare const AVAILABLE_STATUS: SubscriptionStatus[];
146
147
  declare const ALL_SUBSCRIPTION_STATUS: readonly [SubscriptionStatus.TRIALING, SubscriptionStatus.ACTIVE, SubscriptionStatus.IN_GRACE_PERIOD, SubscriptionStatus.INCOMPLETE, SubscriptionStatus.INCOMPLETE_EXPIRED, SubscriptionStatus.PENDING, SubscriptionStatus.PENDING_PURCHASE_CANCELED, SubscriptionStatus.PAST_DUE, SubscriptionStatus.ON_HOLD, SubscriptionStatus.CANCELED, SubscriptionStatus.UNPAID, SubscriptionStatus.PAUSED, SubscriptionStatus.REPLACED, SubscriptionStatus.EXPIRED];
147
-
148
+ //#endregion
148
149
  export { ALL_PLATFORMS, ALL_SUBSCRIPTION_STATUS, AVAILABLE_STATUS, Platform, SubscriptionStatus };
150
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/subscription/index.ts"],"mappings":";aAAY;EACV;EACA;EACA;;cAGW,yBAAa,SAAA,OAAA,SAAA,QAAA,SAAA;;;;;;;aAQd;;;;;;;;;;EAUV;;;;;;;EAQA;;;;;;;;;;;EAYA;;;;;;;;EASA;;;;;;;;EASA;;;;;;;EAQA;;;;;;;EAQA;;;;;;;;;;EAWA;;;;;;;;EASA;;;;;;;EAQA;;;;;;;;;;EAWA;;;;;;;;;;;;EAaA;;;;;;;;;;;;;;;;;;;EAoBA;;;;;;EAOA;;cAGW,kBAAgB;cAMhB,mCAAuB,mBAAA,UAAA,mBAAA,QAAA,mBAAA,iBAAA,mBAAA,YAAA,mBAAA,oBAAA,mBAAA,SAAA,mBAAA,2BAAA,mBAAA,UAAA,mBAAA,SAAA,mBAAA,UAAA,mBAAA,QAAA,mBAAA,QAAA,mBAAA,UAAA,mBAAA"}