@shware/purchase 2.0.1 → 4.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 (37) hide show
  1. package/dist/google-play/index.cjs +3 -1
  2. package/dist/google-play/index.d.cts +3 -2
  3. package/dist/google-play/index.d.mts +3 -2
  4. package/dist/google-play/index.mjs +3 -2
  5. package/dist/google-play/mapper.cjs +19 -0
  6. package/dist/google-play/mapper.cjs.map +1 -0
  7. package/dist/google-play/mapper.d.cts +7 -0
  8. package/dist/google-play/mapper.d.cts.map +1 -0
  9. package/dist/google-play/mapper.d.mts +7 -0
  10. package/dist/google-play/mapper.d.mts.map +1 -0
  11. package/dist/google-play/mapper.mjs +18 -0
  12. package/dist/google-play/mapper.mjs.map +1 -0
  13. package/dist/google-play/real-time-developer-notification.cjs +41 -77
  14. package/dist/google-play/real-time-developer-notification.cjs.map +1 -1
  15. package/dist/google-play/real-time-developer-notification.d.cts +76 -72
  16. package/dist/google-play/real-time-developer-notification.d.cts.map +1 -1
  17. package/dist/google-play/real-time-developer-notification.d.mts +76 -72
  18. package/dist/google-play/real-time-developer-notification.d.mts.map +1 -1
  19. package/dist/google-play/real-time-developer-notification.mjs +41 -77
  20. package/dist/google-play/real-time-developer-notification.mjs.map +1 -1
  21. package/dist/index.cjs +3 -5
  22. package/dist/index.d.cts +2 -2
  23. package/dist/index.d.mts +2 -2
  24. package/dist/index.mjs +2 -2
  25. package/dist/stripe/mapper.cjs +0 -1
  26. package/dist/stripe/mapper.cjs.map +1 -1
  27. package/dist/stripe/mapper.mjs +0 -1
  28. package/dist/stripe/mapper.mjs.map +1 -1
  29. package/dist/subscription/index.cjs +11 -151
  30. package/dist/subscription/index.cjs.map +1 -1
  31. package/dist/subscription/index.d.cts +137 -141
  32. package/dist/subscription/index.d.cts.map +1 -1
  33. package/dist/subscription/index.d.mts +137 -141
  34. package/dist/subscription/index.d.mts.map +1 -1
  35. package/dist/subscription/index.mjs +9 -147
  36. package/dist/subscription/index.mjs.map +1 -1
  37. package/package.json +1 -1
@@ -1,12 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
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 = [
3
+ const PLATFORMS = [
10
4
  "APPLE",
11
5
  "GOOGLE",
12
6
  "STRIPE"
@@ -17,145 +11,7 @@ const ALL_PLATFORMS = [
17
11
  *
18
12
  * provision product for customer when Status = TRIALING, ACTIVE, IN_GRACE_PERIOD
19
13
  */
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"
157
- ];
158
- const ALL_SUBSCRIPTION_STATUS = [
14
+ const SUBSCRIPTION_STATUSES = [
159
15
  "TRIALING",
160
16
  "ACTIVE",
161
17
  "IN_GRACE_PERIOD",
@@ -171,11 +27,15 @@ const ALL_SUBSCRIPTION_STATUS = [
171
27
  "REPLACED",
172
28
  "EXPIRED"
173
29
  ];
30
+ /** statuses where it is safe to provision your product for the customer */
31
+ const AVAILABLE_STATUSES = [
32
+ "ACTIVE",
33
+ "TRIALING",
34
+ "IN_GRACE_PERIOD"
35
+ ];
174
36
  //#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;
37
+ exports.AVAILABLE_STATUSES = AVAILABLE_STATUSES;
38
+ exports.PLATFORMS = PLATFORMS;
39
+ exports.SUBSCRIPTION_STATUSES = SUBSCRIPTION_STATUSES;
180
40
 
181
41
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
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
+ {"version":3,"file":"index.cjs","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"}
@@ -1,150 +1,146 @@
1
1
  //#region src/subscription/index.d.ts
2
- declare enum Platform {
3
- APPLE = "APPLE",
4
- GOOGLE = "GOOGLE",
5
- STRIPE = "STRIPE"
6
- }
7
- declare const ALL_PLATFORMS: readonly [Platform.APPLE, Platform.GOOGLE, Platform.STRIPE];
2
+ declare const PLATFORMS: readonly ['APPLE', 'GOOGLE', 'STRIPE'];
3
+ type Platform = (typeof PLATFORMS)[number];
8
4
  /**
9
5
  * [Stripe Subscription Status](https://stripe.com/docs/api/subscriptions/object#subscription_object-status)
10
6
  * [Stripe Subscription Lifecycle](https://docs.stripe.com/billing/subscriptions/overview)
11
7
  *
12
8
  * provision product for customer when Status = TRIALING, ACTIVE, IN_GRACE_PERIOD
13
9
  */
14
- declare enum SubscriptionStatus {
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"
145
- }
146
- declare const AVAILABLE_STATUS: SubscriptionStatus[];
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];
10
+ declare const SUBSCRIPTION_STATUSES: readonly [
11
+ /**
12
+ * The subscription is currently in a trial period and it’s safe to provision your product for
13
+ * your customer. The subscription transitions automatically to active when the first payment
14
+ * is made.
15
+ *
16
+ * Google: play(LineItems[0].OfferDetails.OfferId == 'xx')
17
+ *
18
+ * Platform: Apple, Google, Stripe
19
+ * */
20
+ 'TRIALING',
21
+ /**
22
+ * The subscription is in good standing and the most recent payment is successful. It’s safe to
23
+ * provision your product for your customer.
24
+ *
25
+ * Platform: Apple, Google, Stripe
26
+ * */
27
+ 'ACTIVE',
28
+ /**
29
+ * Apple: The subscription enters the billing retry period. If the subtype is GRACE_PERIOD,
30
+ * continue to provide service through the grace period. If the subtype is empty, the
31
+ * subscription isn’t in a grace period and you can stop providing the subscription service.
32
+ *
33
+ * Google: Subscription is in grace period. The state is only available when the subscription
34
+ * is an auto renewing plan. In this state, all items are in grace period.
35
+ *
36
+ * Platform: Apple, Google
37
+ * */
38
+ 'IN_GRACE_PERIOD',
39
+ /**
40
+ * A successful payment needs to be made within 23 hours to activate the subscription. Or the
41
+ * payment requires action, like customer authentication. Subscriptions can also be incomplete
42
+ * if there’s a pending payment and the PaymentIntent status would be processing.
43
+ *
44
+ * Platform: Stripe
45
+ * */
46
+ 'INCOMPLETE',
47
+ /**
48
+ * The initial payment on the subscription failed and no successful payment was made within 23
49
+ * hours of creating the subscription. These subscriptions don’t bill customers. This status
50
+ * exists so you can track customers that failed to activate their subscriptions.
51
+ *
52
+ * Platform: Stripe
53
+ * */
54
+ 'INCOMPLETE_EXPIRED',
55
+ /**
56
+ * Subscription was created but awaiting payment during signup. In this state, all items are
57
+ * awaiting payment.
58
+ *
59
+ * Platform: Google
60
+ * */
61
+ 'PENDING',
62
+ /**
63
+ * Pending transaction for subscription is canceled. If this pending purchase was for an
64
+ * existing subscription, use linkedPurchaseToken to get the current state of that subscription.
65
+ *
66
+ * Platform: Google
67
+ * */
68
+ 'PENDING_PURCHASE_CANCELED',
69
+ /**
70
+ * Payment on the latest finalized invoice either failed or wasn’t attempted. The subscription
71
+ * continues to create invoices. Your subscription settings determine the subscription’s next
72
+ * state. If the invoice is still unpaid after all Smart Retries have been attempted, you can
73
+ * configure the subscription to move to canceled, unpaid, or leave it as past_due. To move the
74
+ * subscription to active, pay the most recent invoice before its due date.
75
+ *
76
+ * Platform: Stripe
77
+ * */
78
+ 'PAST_DUE',
79
+ /**
80
+ * Subscription is on hold (suspended). The state is only available when the subscription is an
81
+ * auto renewing plan. In this state, all items are on hold. Grace period ends or Active period
82
+ * ends but not grace period
83
+ *
84
+ * Platform: Google
85
+ * */
86
+ 'ON_HOLD',
87
+ /**
88
+ * The subscription has been canceled. During cancellation, automatic collection for all unpaid
89
+ * invoices is disabled (auto_advance=false). This is a terminal state that can’t be updated.
90
+ *
91
+ * Platform: Apple, Google, Stripe
92
+ * */
93
+ 'CANCELED',
94
+ /**
95
+ * The latest invoice hasn’t been paid but the subscription remains in place. The latest invoice
96
+ * remains open and invoices continue to be generated but payments aren’t attempted. You should
97
+ * revoke access to your product when the subscription is unpaid since payments were already
98
+ * attempted and retried when it was past_due. To move the subscription to active, pay the most
99
+ * recent invoice before its due date.
100
+ *
101
+ * Platform: Stripe
102
+ * */
103
+ 'UNPAID',
104
+ /**
105
+ * Google: Subscription is paused. The state is only available when the subscription is an auto
106
+ * renewing plan. In this state, all items are in paused state.
107
+ *
108
+ * Stripe: The subscription has ended its trial period without a default payment method and the
109
+ * trial_settings.end_behavior.missing_payment_method is set to pause. Invoices will no longer
110
+ * be created for the subscription. After a default payment method has been attached to the
111
+ * customer, you can resume the subscription.
112
+ *
113
+ * Platform: Google, Stripe
114
+ * */
115
+ 'PAUSED',
116
+ /**
117
+ * For example, a user buys a subscription and receives a purchase token A. The
118
+ * linkedPurchaseToken field will not be set in the API response because the purchase token
119
+ * belongs to a brand new subscription.
120
+ *
121
+ * If the user upgrades their subscription, a new purchase token B will be generated. Since the
122
+ * upgrade is replacing the subscription from purchase token A, the linkedPurchaseToken field
123
+ * for token B will be set to point to token A. Notice it points backwards in time to the
124
+ * original purchase token.
125
+ *
126
+ * +---------------------------+ +------------------------+ +------------------------+
127
+ * | Step 1 first purchase | | Step 2 upgrades | | Step 3 downgrades |
128
+ * | purchaseToken: A |->| purchaseToken: B |->| purchaseToken: C |
129
+ * | linkedPurchaseToken: null | | linkedPurchaseToken: A | | linkedPurchaseToken: B |
130
+ * +---------------------------+ +------------------------+ +------------------------+
131
+ *
132
+ * Platform: Google
133
+ * */
134
+ 'REPLACED',
135
+ /**
136
+ * Google: Subscription is expired. All items have expiryTime in the past.
137
+ *
138
+ * Platform: Apple, Google
139
+ * */
140
+ 'EXPIRED'];
141
+ type SubscriptionStatus = (typeof SUBSCRIPTION_STATUSES)[number];
142
+ /** statuses where it is safe to provision your product for the customer */
143
+ declare const AVAILABLE_STATUSES: readonly ["ACTIVE", "TRIALING", "IN_GRACE_PERIOD"];
148
144
  //#endregion
149
- export { ALL_PLATFORMS, ALL_SUBSCRIPTION_STATUS, AVAILABLE_STATUS, Platform, SubscriptionStatus };
145
+ export { AVAILABLE_STATUSES, PLATFORMS, Platform, SUBSCRIPTION_STATUSES, SubscriptionStatus };
150
146
  //# sourceMappingURL=index.d.cts.map
@@ -1 +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"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/subscription/index.ts"],"mappings":";cAAa;KAED,mBAAmB;;;;;;;cAQlB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkJD,6BAA6B;;cAG5B"}