/
offerings.ts
327 lines (299 loc) · 8.9 KB
/
offerings.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
export enum PACKAGE_TYPE {
/**
* A package that was defined with a custom identifier.
*/
UNKNOWN = "UNKNOWN",
/**
* A package that was defined with a custom identifier.
*/
CUSTOM = "CUSTOM",
/**
* A package configured with the predefined lifetime identifier.
*/
LIFETIME = "LIFETIME",
/**
* A package configured with the predefined annual identifier.
*/
ANNUAL = "ANNUAL",
/**
* A package configured with the predefined six month identifier.
*/
SIX_MONTH = "SIX_MONTH",
/**
* A package configured with the predefined three month identifier.
*/
THREE_MONTH = "THREE_MONTH",
/**
* A package configured with the predefined two month identifier.
*/
TWO_MONTH = "TWO_MONTH",
/**
* A package configured with the predefined monthly identifier.
*/
MONTHLY = "MONTHLY",
/**
* A package configured with the predefined weekly identifier.
*/
WEEKLY = "WEEKLY",
}
export enum INTRO_ELIGIBILITY_STATUS {
/**
* RevenueCat doesn't have enough information to determine eligibility.
*/
INTRO_ELIGIBILITY_STATUS_UNKNOWN = 0,
/**
* The user is not eligible for a free trial or intro pricing for this product.
*/
INTRO_ELIGIBILITY_STATUS_INELIGIBLE,
/**
* The user is eligible for a free trial or intro pricing for this product.
*/
INTRO_ELIGIBILITY_STATUS_ELIGIBLE,
/**
* There is no free trial or intro pricing for this product.
*/
INTRO_ELIGIBILITY_STATUS_NO_INTRO_OFFER_EXISTS
}
export interface PurchasesStoreProduct {
/**
* Product Id.
*/
readonly identifier: string;
/**
* Description of the product.
*/
readonly description: string;
/**
* Title of the product.
*/
readonly title: string;
/**
* Price of the product in the local currency.
*/
readonly price: number;
/**
* Formatted price of the item, including its currency sign.
*/
readonly priceString: string;
/**
* Currency code for price and original price.
*/
readonly currencyCode: string;
/**
* Introductory price.
*/
readonly introPrice: PurchasesIntroPrice | null;
/**
* Collection of discount offers for a product. Null for Android.
*/
readonly discounts: PurchasesStoreProductDiscount[] | null;
/**
* Subscription period, specified in ISO 8601 format. For example,
* P1W equates to one week, P1M equates to one month,
* P3M equates to three months, P6M equates to six months,
* and P1Y equates to one year.
* Note: Not available for Amazon.
*/
readonly subscriptionPeriod: string | null;
}
export interface PurchasesStoreProductDiscount {
/**
* Identifier of the discount.
*/
readonly identifier: string;
/**
* Price in the local currency.
*/
readonly price: number;
/**
* Formatted price, including its currency sign, such as €3.99.
*/
readonly priceString: string;
/**
* Number of subscription billing periods for which the user will be given the discount, such as 3.
*/
readonly cycles: number;
/**
* Billing period of the discount, specified in ISO 8601 format.
*/
readonly period: string;
/**
* Unit for the billing period of the discount, can be DAY, WEEK, MONTH or YEAR.
*/
readonly periodUnit: string;
/**
* Number of units for the billing period of the discount.
*/
readonly periodNumberOfUnits: number;
}
export interface PurchasesIntroPrice {
/**
* Price in the local currency.
*/
readonly price: number;
/**
* Formatted price, including its currency sign, such as €3.99.
*/
readonly priceString: string;
/**
* Number of subscription billing periods for which the user will be given the discount, such as 3.
*/
readonly cycles: number;
/**
* Billing period of the discount, specified in ISO 8601 format.
*/
readonly period: string;
/**
* Unit for the billing period of the discount, can be DAY, WEEK, MONTH or YEAR.
*/
readonly periodUnit: string;
/**
* Number of units for the billing period of the discount.
*/
readonly periodNumberOfUnits: number;
}
/**
* Contains information about the product available for the user to purchase.
* For more info see https://docs.revenuecat.com/docs/entitlements
*/
export interface PurchasesPackage {
/**
* Unique identifier for this package. Can be one a predefined package type or a custom one.
*/
readonly identifier: string;
/**
* Package type for the product. Will be one of [PACKAGE_TYPE].
*/
readonly packageType: PACKAGE_TYPE;
/**
* Product assigned to this package.
*/
readonly product: PurchasesStoreProduct;
/**
* Offering this package belongs to.
*/
readonly offeringIdentifier: string;
}
/**
* An offering is a collection of Packages (`PurchasesPackage`) available for the user to purchase.
* For more info see https://docs.revenuecat.com/docs/entitlements
*/
export interface PurchasesOffering {
/**
* Unique identifier defined in RevenueCat dashboard.
*/
readonly identifier: string;
/**
* Offering description defined in RevenueCat dashboard.
*/
readonly serverDescription: string;
/**
* Array of `Package` objects available for purchase.
*/
readonly availablePackages: PurchasesPackage[];
/**
* Lifetime package type configured in the RevenueCat dashboard, if available.
*/
readonly lifetime: PurchasesPackage | null;
/**
* Annual package type configured in the RevenueCat dashboard, if available.
*/
readonly annual: PurchasesPackage | null;
/**
* Six month package type configured in the RevenueCat dashboard, if available.
*/
readonly sixMonth: PurchasesPackage | null;
/**
* Three month package type configured in the RevenueCat dashboard, if available.
*/
readonly threeMonth: PurchasesPackage | null;
/**
* Two month package type configured in the RevenueCat dashboard, if available.
*/
readonly twoMonth: PurchasesPackage | null;
/**
* Monthly package type configured in the RevenueCat dashboard, if available.
*/
readonly monthly: PurchasesPackage | null;
/**
* Weekly package type configured in the RevenueCat dashboard, if available.
*/
readonly weekly: PurchasesPackage | null;
}
/**
* Contains all the offerings configured in RevenueCat dashboard.
* For more info see https://docs.revenuecat.com/docs/entitlements
*/
export interface PurchasesOfferings {
/**
* Map of all Offerings [PurchasesOffering] objects keyed by their identifier.
*/
readonly all: { [key: string]: PurchasesOffering };
/**
* Current offering configured in the RevenueCat dashboard.
*/
readonly current: PurchasesOffering | null;
}
/**
* Holds the information used when upgrading from another sku. For Android use only.
*/
export interface UpgradeInfo {
/**
* The oldSKU to upgrade from.
*/
readonly oldSKU: string;
/**
* The [PRORATION_MODE] to use when upgrading the given oldSKU.
*/
readonly prorationMode?: PRORATION_MODE;
}
/**
* Holds the introductory price status
*/
export interface IntroEligibility {
/**
* The introductory price eligibility status
*/
readonly status: INTRO_ELIGIBILITY_STATUS;
/**
* Description of the status
*/
readonly description: string;
}
export interface PurchasesPromotionalOffer {
readonly identifier: string;
readonly keyIdentifier: string;
readonly nonce: string;
readonly signature: string;
readonly timestamp: number;
}
export enum PRORATION_MODE {
UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,
/**
* Replacement takes effect immediately, and the remaining time will be
* prorated and credited to the user. This is the current default behavior.
*/
IMMEDIATE_WITH_TIME_PRORATION = 1,
/**
* Replacement takes effect immediately, and the billing cycle remains the
* same. The price for the remaining period will be charged. This option is
* only available for subscription upgrade.
*/
IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,
/**
* Replacement takes effect immediately, and the new price will be charged on
* next recurrence time. The billing cycle stays the same.
*/
IMMEDIATE_WITHOUT_PRORATION = 3,
/**
* Replacement takes effect when the old plan expires, and the new price will
* be charged at the same time.
*/
DEFERRED = 4,
/**
* Replacement takes effect immediately, and the user is charged full price
* of new plan and is given a full billing cycle of subscription,
* plus remaining prorated time from the old plan.
*/
IMMEDIATE_AND_CHARGE_FULL_PRICE = 5,
}