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