expo-iap 3.0.2 → 3.0.4

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 (59) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/CLAUDE.md +2 -0
  3. package/build/helpers/subscription.d.ts +1 -12
  4. package/build/helpers/subscription.d.ts.map +1 -1
  5. package/build/helpers/subscription.js +12 -7
  6. package/build/helpers/subscription.js.map +1 -1
  7. package/build/index.d.ts +9 -7
  8. package/build/index.d.ts.map +1 -1
  9. package/build/index.js +6 -4
  10. package/build/index.js.map +1 -1
  11. package/build/modules/android.d.ts +7 -6
  12. package/build/modules/android.d.ts.map +1 -1
  13. package/build/modules/android.js +19 -4
  14. package/build/modules/android.js.map +1 -1
  15. package/build/modules/ios.d.ts +7 -10
  16. package/build/modules/ios.d.ts.map +1 -1
  17. package/build/modules/ios.js +3 -1
  18. package/build/modules/ios.js.map +1 -1
  19. package/build/purchase-error.d.ts +69 -0
  20. package/build/purchase-error.d.ts.map +1 -0
  21. package/build/purchase-error.js +164 -0
  22. package/build/purchase-error.js.map +1 -0
  23. package/build/types.d.ts +649 -0
  24. package/build/types.d.ts.map +1 -0
  25. package/build/types.js +100 -0
  26. package/build/types.js.map +1 -0
  27. package/build/useIAP.d.ts +6 -5
  28. package/build/useIAP.d.ts.map +1 -1
  29. package/build/useIAP.js +2 -3
  30. package/build/useIAP.js.map +1 -1
  31. package/build/utils/errorMapping.d.ts +10 -4
  32. package/build/utils/errorMapping.d.ts.map +1 -1
  33. package/build/utils/errorMapping.js +71 -47
  34. package/build/utils/errorMapping.js.map +1 -1
  35. package/jest.config.js +1 -1
  36. package/package.json +1 -1
  37. package/src/helpers/subscription.ts +12 -20
  38. package/src/index.ts +20 -20
  39. package/src/modules/android.ts +28 -10
  40. package/src/modules/ios.ts +11 -13
  41. package/src/purchase-error.ts +268 -0
  42. package/src/types.ts +738 -0
  43. package/src/useIAP.ts +15 -18
  44. package/src/utils/errorMapping.ts +89 -55
  45. package/build/ExpoIap.types.d.ts +0 -294
  46. package/build/ExpoIap.types.d.ts.map +0 -1
  47. package/build/ExpoIap.types.js +0 -226
  48. package/build/ExpoIap.types.js.map +0 -1
  49. package/build/types/ExpoIapAndroid.types.d.ts +0 -115
  50. package/build/types/ExpoIapAndroid.types.d.ts.map +0 -1
  51. package/build/types/ExpoIapAndroid.types.js +0 -29
  52. package/build/types/ExpoIapAndroid.types.js.map +0 -1
  53. package/build/types/ExpoIapIOS.types.d.ts +0 -143
  54. package/build/types/ExpoIapIOS.types.d.ts.map +0 -1
  55. package/build/types/ExpoIapIOS.types.js +0 -2
  56. package/build/types/ExpoIapIOS.types.js.map +0 -1
  57. package/src/ExpoIap.types.ts +0 -429
  58. package/src/types/ExpoIapAndroid.types.ts +0 -136
  59. package/src/types/ExpoIapIOS.types.ts +0 -167
@@ -1,429 +0,0 @@
1
- import type {
2
- ProductAndroid,
3
- PurchaseAndroid,
4
- ProductSubscriptionAndroid,
5
- } from './types/ExpoIapAndroid.types';
6
- import type {
7
- ProductIOS,
8
- PurchaseIOS,
9
- ProductSubscriptionIOS,
10
- } from './types/ExpoIapIOS.types';
11
- import {NATIVE_ERROR_CODES} from './ExpoIapModule';
12
-
13
- export type ChangeEventPayload = {
14
- value: string;
15
- };
16
-
17
- export type ProductType = 'inapp' | 'subs';
18
-
19
- // =============================================================================
20
- // COMMON TYPES (Base types shared across all platforms)
21
- // =============================================================================
22
-
23
- export type ProductCommon = {
24
- id: string;
25
- title: string;
26
- description: string;
27
- type: ProductType;
28
- displayName?: string;
29
- displayPrice: string;
30
- currency: string;
31
- price?: number;
32
- debugDescription?: string;
33
- platform?: string;
34
- };
35
-
36
- export type PurchaseCommon = {
37
- id: string; // Transaction identifier - used by finishTransaction
38
- productId: string; // Product identifier - which product was purchased
39
- ids?: string[]; // Product identifiers for purchases that include multiple products
40
- transactionDate: number;
41
- transactionReceipt: string;
42
- purchaseToken?: string; // Unified purchase token (jwsRepresentation for iOS, purchaseToken for Android)
43
- platform?: string;
44
- };
45
-
46
- export type ProductSubscriptionCommon = ProductCommon & {
47
- type: 'subs';
48
- };
49
-
50
- // Define literal platform types for better type discrimination
51
- export type IosPlatform = {platform: 'ios'};
52
- export type AndroidPlatform = {platform: 'android'};
53
-
54
- // Platform-agnostic unified product types (public API)
55
- export type Product =
56
- | (ProductAndroid & AndroidPlatform)
57
- | (ProductIOS & IosPlatform);
58
-
59
- export type SubscriptionProduct =
60
- | (ProductSubscriptionAndroid & AndroidPlatform)
61
- | (ProductSubscriptionIOS & IosPlatform);
62
-
63
- // Re-export all platform-specific types to avoid deep imports
64
- export * from './types/ExpoIapAndroid.types';
65
- export * from './types/ExpoIapIOS.types';
66
-
67
- // Unified purchase type for both products and subscriptions
68
- export type Purchase =
69
- | (PurchaseAndroid & AndroidPlatform)
70
- | (PurchaseIOS & IosPlatform);
71
-
72
- export type PurchaseResult = {
73
- responseCode?: number;
74
- debugMessage?: string;
75
- code?: string;
76
- message?: string;
77
- purchaseToken?: string;
78
- };
79
- /**
80
- * Centralized error codes for expo-iap
81
- * These are mapped to platform-specific error codes and provide consistent error handling
82
- */
83
- export enum ErrorCode {
84
- E_UNKNOWN = 'E_UNKNOWN',
85
- E_USER_CANCELLED = 'E_USER_CANCELLED',
86
- E_USER_ERROR = 'E_USER_ERROR',
87
- E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',
88
- E_REMOTE_ERROR = 'E_REMOTE_ERROR',
89
- E_NETWORK_ERROR = 'E_NETWORK_ERROR',
90
- E_SERVICE_ERROR = 'E_SERVICE_ERROR',
91
- E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',
92
- E_RECEIPT_FINISHED = 'E_RECEIPT_FINISHED',
93
- E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',
94
- E_NOT_PREPARED = 'E_NOT_PREPARED',
95
- E_NOT_ENDED = 'E_NOT_ENDED',
96
- E_ALREADY_OWNED = 'E_ALREADY_OWNED',
97
- E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',
98
- E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',
99
- E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',
100
- E_INTERRUPTED = 'E_INTERRUPTED',
101
- E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',
102
- E_PURCHASE_ERROR = 'E_PURCHASE_ERROR',
103
- E_SYNC_ERROR = 'E_SYNC_ERROR',
104
- E_TRANSACTION_VALIDATION_FAILED = 'E_TRANSACTION_VALIDATION_FAILED',
105
- E_ACTIVITY_UNAVAILABLE = 'E_ACTIVITY_UNAVAILABLE',
106
- E_ALREADY_PREPARED = 'E_ALREADY_PREPARED',
107
- E_PENDING = 'E_PENDING',
108
- E_CONNECTION_CLOSED = 'E_CONNECTION_CLOSED',
109
- // Additional detailed errors (Android-focused, kept cross-platform)
110
- E_INIT_CONNECTION = 'E_INIT_CONNECTION',
111
- E_SERVICE_DISCONNECTED = 'E_SERVICE_DISCONNECTED',
112
- E_QUERY_PRODUCT = 'E_QUERY_PRODUCT',
113
- E_SKU_NOT_FOUND = 'E_SKU_NOT_FOUND',
114
- E_SKU_OFFER_MISMATCH = 'E_SKU_OFFER_MISMATCH',
115
- E_ITEM_NOT_OWNED = 'E_ITEM_NOT_OWNED',
116
- E_BILLING_UNAVAILABLE = 'E_BILLING_UNAVAILABLE',
117
- E_FEATURE_NOT_SUPPORTED = 'E_FEATURE_NOT_SUPPORTED',
118
- E_EMPTY_SKU_LIST = 'E_EMPTY_SKU_LIST',
119
- }
120
-
121
- // Fast lookup set for validating standardized error code strings
122
- const OPENIAP_ERROR_CODE_SET: Set<string> = new Set(
123
- Object.values(ErrorCode) as string[],
124
- );
125
-
126
- /**
127
- * Platform-specific error code mappings
128
- * Maps ErrorCode enum values to platform-specific integer codes
129
- */
130
- // Shared OpenIAP string code mapping for both platforms
131
- const COMMON_ERROR_CODE_MAP = {
132
- [ErrorCode.E_UNKNOWN]: 'E_UNKNOWN',
133
- [ErrorCode.E_USER_CANCELLED]: 'E_USER_CANCELLED',
134
- [ErrorCode.E_USER_ERROR]: 'E_USER_ERROR',
135
- [ErrorCode.E_ITEM_UNAVAILABLE]: 'E_ITEM_UNAVAILABLE',
136
- [ErrorCode.E_REMOTE_ERROR]: 'E_REMOTE_ERROR',
137
- [ErrorCode.E_NETWORK_ERROR]: 'E_NETWORK_ERROR',
138
- [ErrorCode.E_SERVICE_ERROR]: 'E_SERVICE_ERROR',
139
- [ErrorCode.E_RECEIPT_FAILED]: 'E_RECEIPT_FAILED',
140
- [ErrorCode.E_RECEIPT_FINISHED]: 'E_RECEIPT_FINISHED',
141
- [ErrorCode.E_RECEIPT_FINISHED_FAILED]: 'E_RECEIPT_FINISHED_FAILED',
142
- [ErrorCode.E_NOT_PREPARED]: 'E_NOT_PREPARED',
143
- [ErrorCode.E_NOT_ENDED]: 'E_NOT_ENDED',
144
- [ErrorCode.E_ALREADY_OWNED]: 'E_ALREADY_OWNED',
145
- [ErrorCode.E_DEVELOPER_ERROR]: 'E_DEVELOPER_ERROR',
146
- [ErrorCode.E_BILLING_RESPONSE_JSON_PARSE_ERROR]:
147
- 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',
148
- [ErrorCode.E_DEFERRED_PAYMENT]: 'E_DEFERRED_PAYMENT',
149
- [ErrorCode.E_INTERRUPTED]: 'E_INTERRUPTED',
150
- [ErrorCode.E_IAP_NOT_AVAILABLE]: 'E_IAP_NOT_AVAILABLE',
151
- [ErrorCode.E_PURCHASE_ERROR]: 'E_PURCHASE_ERROR',
152
- [ErrorCode.E_SYNC_ERROR]: 'E_SYNC_ERROR',
153
- [ErrorCode.E_TRANSACTION_VALIDATION_FAILED]:
154
- 'E_TRANSACTION_VALIDATION_FAILED',
155
- [ErrorCode.E_ACTIVITY_UNAVAILABLE]: 'E_ACTIVITY_UNAVAILABLE',
156
- [ErrorCode.E_ALREADY_PREPARED]: 'E_ALREADY_PREPARED',
157
- [ErrorCode.E_PENDING]: 'E_PENDING',
158
- [ErrorCode.E_CONNECTION_CLOSED]: 'E_CONNECTION_CLOSED',
159
- [ErrorCode.E_INIT_CONNECTION]: 'E_INIT_CONNECTION',
160
- [ErrorCode.E_SERVICE_DISCONNECTED]: 'E_SERVICE_DISCONNECTED',
161
- [ErrorCode.E_QUERY_PRODUCT]: 'E_QUERY_PRODUCT',
162
- [ErrorCode.E_SKU_NOT_FOUND]: 'E_SKU_NOT_FOUND',
163
- [ErrorCode.E_SKU_OFFER_MISMATCH]: 'E_SKU_OFFER_MISMATCH',
164
- [ErrorCode.E_ITEM_NOT_OWNED]: 'E_ITEM_NOT_OWNED',
165
- [ErrorCode.E_BILLING_UNAVAILABLE]: 'E_BILLING_UNAVAILABLE',
166
- [ErrorCode.E_FEATURE_NOT_SUPPORTED]: 'E_FEATURE_NOT_SUPPORTED',
167
- [ErrorCode.E_EMPTY_SKU_LIST]: 'E_EMPTY_SKU_LIST',
168
- } as const;
169
-
170
- export const ErrorCodeMapping = {
171
- // iOS: standardized OpenIAP string codes
172
- ios: COMMON_ERROR_CODE_MAP,
173
- // Android: standardized OpenIAP string codes
174
- android: COMMON_ERROR_CODE_MAP,
175
- } as const;
176
-
177
- export type PurchaseErrorProps = {
178
- message: string;
179
- responseCode?: number;
180
- debugMessage?: string;
181
- code?: ErrorCode;
182
- productId?: string;
183
- platform?: 'ios' | 'android';
184
- };
185
-
186
- export class PurchaseError implements Error {
187
- public name: string;
188
- public message: string;
189
- public responseCode?: number;
190
- public debugMessage?: string;
191
- public code?: ErrorCode;
192
- public productId?: string;
193
- public platform?: 'ios' | 'android';
194
-
195
- // Backwards-compatible constructor: accepts either props object or legacy positional args
196
- constructor(messageOrProps: string | PurchaseErrorProps, ...rest: any[]) {
197
- this.name = '[expo-iap]: PurchaseError';
198
-
199
- if (typeof messageOrProps === 'string') {
200
- // Legacy signature: (name, message, responseCode?, debugMessage?, code?, productId?, platform?)
201
- // The first legacy argument was a name which we always override, so treat it as message here
202
- const message = messageOrProps;
203
- this.message = message;
204
- this.responseCode = rest[0];
205
- this.debugMessage = rest[1];
206
- this.code = rest[2];
207
- this.productId = rest[3];
208
- this.platform = rest[4];
209
- } else {
210
- const props = messageOrProps;
211
- this.message = props.message;
212
- this.responseCode = props.responseCode;
213
- this.debugMessage = props.debugMessage;
214
- this.code = props.code;
215
- this.productId = props.productId;
216
- this.platform = props.platform;
217
- }
218
- }
219
-
220
- /**
221
- * Creates a PurchaseError from platform-specific error data
222
- * @param errorData Raw error data from native modules
223
- * @param platform Platform where the error occurred
224
- * @returns Properly typed PurchaseError instance
225
- */
226
- static fromPlatformError(
227
- errorData: any,
228
- platform: 'ios' | 'android',
229
- ): PurchaseError {
230
- const errorCode = errorData.code
231
- ? ErrorCodeUtils.fromPlatformCode(errorData.code, platform)
232
- : ErrorCode.E_UNKNOWN;
233
-
234
- return new PurchaseError({
235
- message: errorData.message || 'Unknown error occurred',
236
- responseCode: errorData.responseCode,
237
- debugMessage: errorData.debugMessage,
238
- code: errorCode,
239
- productId: errorData.productId,
240
- platform,
241
- });
242
- }
243
-
244
- /**
245
- * Gets the platform-specific error code for this error
246
- * @returns Platform-specific error code
247
- */
248
- getPlatformCode(): string | number | undefined {
249
- if (!this.code || !this.platform) return undefined;
250
- return ErrorCodeUtils.toPlatformCode(this.code, this.platform);
251
- }
252
- }
253
-
254
- /**
255
- * Utility functions for error code mapping and validation
256
- */
257
- export const ErrorCodeUtils = {
258
- /**
259
- * Gets the native error code for the current platform
260
- * @param errorCode ErrorCode enum value
261
- * @returns Platform-specific error code from native constants
262
- */
263
- getNativeErrorCode: (errorCode: ErrorCode): string => {
264
- return NATIVE_ERROR_CODES[errorCode] || errorCode;
265
- },
266
-
267
- /**
268
- * Maps a platform-specific error code back to the standardized ErrorCode enum
269
- * @param platformCode Platform-specific error code (string for Android, number for iOS)
270
- * @param platform Target platform
271
- * @returns Corresponding ErrorCode enum value or E_UNKNOWN if not found
272
- */
273
- fromPlatformCode: (
274
- platformCode: string | number,
275
- platform: 'ios' | 'android',
276
- ): ErrorCode => {
277
- // If native sent standardized string code, accept it directly
278
- if (typeof platformCode === 'string' && platformCode.startsWith('E_')) {
279
- if (OPENIAP_ERROR_CODE_SET.has(platformCode)) {
280
- return platformCode as ErrorCode;
281
- }
282
- }
283
- // Prefer dynamic native mapping for iOS to avoid drift
284
- if (platform === 'ios') {
285
- for (const [, value] of Object.entries(NATIVE_ERROR_CODES || {})) {
286
- if (value === platformCode) {
287
- // Native maps friendly keys to standardized 'E_*' codes
288
- if (typeof value === 'string' && OPENIAP_ERROR_CODE_SET.has(value)) {
289
- return value as ErrorCode;
290
- }
291
- }
292
- }
293
- }
294
-
295
- const mapping = ErrorCodeMapping[platform];
296
- for (const [errorCode, mappedCode] of Object.entries(mapping)) {
297
- if (mappedCode === platformCode) {
298
- return errorCode as ErrorCode;
299
- }
300
- }
301
-
302
- return ErrorCode.E_UNKNOWN;
303
- },
304
-
305
- /**
306
- * Maps an ErrorCode enum to platform-specific code
307
- * @param errorCode ErrorCode enum value
308
- * @param platform Target platform
309
- * @returns Platform-specific error code
310
- */
311
- toPlatformCode: (
312
- errorCode: ErrorCode,
313
- platform: 'ios' | 'android',
314
- ): string | number => {
315
- if (platform === 'ios') {
316
- const native = (NATIVE_ERROR_CODES as any)?.[errorCode];
317
- if (native !== undefined) return native;
318
- }
319
- const mapping = ErrorCodeMapping[platform] as Record<
320
- ErrorCode,
321
- string | number
322
- >;
323
- return mapping[errorCode] ?? 'E_UNKNOWN';
324
- },
325
-
326
- /**
327
- * Checks if an error code is valid for the specified platform
328
- * @param errorCode ErrorCode enum value
329
- * @param platform Target platform
330
- * @returns True if the error code is supported on the platform
331
- */
332
- isValidForPlatform: (
333
- errorCode: ErrorCode,
334
- platform: 'ios' | 'android',
335
- ): boolean => {
336
- return errorCode in ErrorCodeMapping[platform];
337
- },
338
- };
339
-
340
- // ============================================================================
341
- // Enhanced Unified Request Types
342
- // ============================================================================
343
-
344
- /**
345
- * Unified request props that work on both iOS and Android platforms
346
- * iOS will use 'sku', Android will use 'skus' (or convert sku to skus array)
347
- */
348
- export interface UnifiedRequestPurchaseProps {
349
- // Universal properties - works on both platforms
350
- readonly sku?: string; // Single SKU (iOS native, Android fallback)
351
- readonly skus?: string[]; // Multiple SKUs (Android native, iOS uses first item)
352
-
353
- // iOS-specific properties (ignored on Android)
354
- readonly andDangerouslyFinishTransactionAutomatically?: boolean;
355
- readonly appAccountToken?: string;
356
- readonly quantity?: number;
357
- readonly withOffer?: import('./types/ExpoIapIOS.types').PaymentDiscount;
358
-
359
- // Android-specific properties (ignored on iOS)
360
- readonly obfuscatedAccountIdAndroid?: string;
361
- readonly obfuscatedProfileIdAndroid?: string;
362
- readonly isOfferPersonalized?: boolean;
363
- }
364
-
365
- // ============================================================================
366
- // New Platform-Specific Request Types (v2.7.0+)
367
- // ============================================================================
368
-
369
- /**
370
- * iOS-specific purchase request parameters
371
- */
372
- export interface RequestPurchaseIosProps {
373
- readonly sku: string;
374
- readonly andDangerouslyFinishTransactionAutomatically?: boolean;
375
- readonly appAccountToken?: string;
376
- readonly quantity?: number;
377
- readonly withOffer?: import('./types/ExpoIapIOS.types').PaymentDiscount;
378
- }
379
-
380
- /**
381
- * Android-specific purchase request parameters
382
- */
383
- export interface RequestPurchaseAndroidProps {
384
- readonly skus: string[];
385
- readonly obfuscatedAccountIdAndroid?: string;
386
- readonly obfuscatedProfileIdAndroid?: string;
387
- readonly isOfferPersonalized?: boolean;
388
- }
389
-
390
- /**
391
- * Android-specific subscription request parameters
392
- */
393
- export interface RequestSubscriptionAndroidProps
394
- extends RequestPurchaseAndroidProps {
395
- readonly replacementModeAndroid?: number;
396
- readonly subscriptionOffers: {
397
- sku: string;
398
- offerToken: string;
399
- }[];
400
- }
401
-
402
- /**
403
- * Modern platform-specific request structure (v2.7.0+)
404
- * Allows clear separation of iOS and Android parameters
405
- */
406
- export interface RequestPurchasePropsByPlatforms {
407
- readonly ios?: RequestPurchaseIosProps;
408
- readonly android?: RequestPurchaseAndroidProps;
409
- }
410
-
411
- /**
412
- * Modern platform-specific subscription request structure (v2.7.0+)
413
- */
414
- export interface RequestSubscriptionPropsByPlatforms {
415
- readonly ios?: RequestPurchaseIosProps;
416
- readonly android?: RequestSubscriptionAndroidProps;
417
- }
418
-
419
- /**
420
- * Modern request purchase parameters (v2.7.0+)
421
- * This is the recommended API moving forward
422
- */
423
- export type RequestPurchaseProps = RequestPurchasePropsByPlatforms;
424
-
425
- /**
426
- * Modern request subscription parameters (v2.7.0+)
427
- * This is the recommended API moving forward
428
- */
429
- export type RequestSubscriptionProps = RequestSubscriptionPropsByPlatforms;
@@ -1,136 +0,0 @@
1
- import {PurchaseCommon, ProductCommon} from '../ExpoIap.types';
2
-
3
- type ProductAndroidOneTimePurchaseOfferDetail = {
4
- priceCurrencyCode: string;
5
- formattedPrice: string;
6
- priceAmountMicros: string;
7
- };
8
-
9
- type PricingPhaseAndroid = {
10
- formattedPrice: string;
11
- priceCurrencyCode: string;
12
- // P1W, P1M, P1Y
13
- billingPeriod: string;
14
- billingCycleCount: number;
15
- priceAmountMicros: string;
16
- recurrenceMode: number;
17
- };
18
-
19
- type PricingPhasesAndroid = {
20
- pricingPhaseList: PricingPhaseAndroid[];
21
- };
22
-
23
- type ProductSubscriptionAndroidOfferDetail = {
24
- basePlanId: string;
25
- offerId: string | null;
26
- offerToken: string;
27
- offerTags: string[];
28
- pricingPhases: PricingPhasesAndroid;
29
- };
30
-
31
- export type ProductAndroid = ProductCommon & {
32
- nameAndroid: string;
33
- oneTimePurchaseOfferDetailsAndroid?: ProductAndroidOneTimePurchaseOfferDetail;
34
- platform: 'android';
35
- subscriptionOfferDetailsAndroid?: ProductSubscriptionAndroidOfferDetail[];
36
- };
37
-
38
- type ProductSubscriptionAndroidOfferDetails = {
39
- basePlanId: string;
40
- offerId: string | null;
41
- offerToken: string;
42
- pricingPhases: PricingPhasesAndroid;
43
- offerTags: string[];
44
- };
45
-
46
- export type ProductSubscriptionAndroid = ProductAndroid & {
47
- subscriptionOfferDetailsAndroid: ProductSubscriptionAndroidOfferDetails[];
48
- };
49
-
50
- // Legacy naming for backward compatibility
51
- export type SubscriptionProductAndroid = ProductSubscriptionAndroid;
52
-
53
- export type RequestPurchaseAndroidProps = {
54
- skus: string[];
55
- obfuscatedAccountIdAndroid?: string;
56
- obfuscatedProfileIdAndroid?: string;
57
- isOfferPersonalized?: boolean; // For AndroidBilling V5 https://developer.android.com/google/play/billing/integrate#personalized-price
58
- };
59
-
60
- enum ReplacementModesAndroid {
61
- UNKNOWN_REPLACEMENT_MODE = 0,
62
- WITH_TIME_PRORATION = 1,
63
- CHARGE_PRORATED_PRICE = 2,
64
- WITHOUT_PRORATION = 3,
65
- CHARGE_FULL_PRICE = 5,
66
- DEFERRED = 6,
67
- }
68
-
69
- type SubscriptionOffer = {
70
- sku: string;
71
- offerToken: string;
72
- };
73
-
74
- export type RequestSubscriptionAndroidProps = RequestPurchaseAndroidProps & {
75
- replacementModeAndroid?: ReplacementModesAndroid;
76
- subscriptionOffers: SubscriptionOffer[];
77
- };
78
-
79
- export type ReceiptAndroid = {
80
- autoRenewing: boolean;
81
- betaProduct: boolean;
82
- cancelDate: number | null;
83
- cancelReason: string;
84
- deferredDate: number | null;
85
- deferredSku: number | null;
86
- freeTrialEndDate: number;
87
- gracePeriodEndDate: number;
88
- parentProductId: string;
89
- productId: string;
90
- productType: string;
91
- purchaseDate: number;
92
- quantity: number;
93
- receiptId: string;
94
- renewalDate: number;
95
- term: string;
96
- termSku: string;
97
- testTransaction: boolean;
98
- };
99
-
100
- export enum FeatureTypeAndroid {
101
- /** Show in-app messages. Included in documentation by the annotations: */
102
- IN_APP_MESSAGING = 'IN_APP_MESSAGING',
103
- /** Launch a price change confirmation flow. */
104
- PRICE_CHANGE_CONFIRMATION = 'PRICE_CHANGE_CONFIRMATION',
105
- /** Play billing library support for querying and purchasing with ProductDetails. */
106
- PRODUCT_DETAILS = 'PRODUCT_DETAILS',
107
- /** Purchase/query for subscriptions. */
108
- SUBSCRIPTIONS = 'SUBSCRIPTIONS',
109
- /** Subscriptions update/replace. */
110
- SUBSCRIPTIONS_UPDATE = 'SUBSCRIPTIONS_UPDATE',
111
- }
112
-
113
- export enum PurchaseAndroidState {
114
- UNSPECIFIED_STATE = 0,
115
- PURCHASED = 1,
116
- PENDING = 2,
117
- }
118
-
119
- // Legacy naming for backward compatibility
120
-
121
- // Legacy naming for backward compatibility
122
- export type ProductPurchaseAndroid = PurchaseCommon & {
123
- platform: 'android';
124
- dataAndroid?: string;
125
- signatureAndroid?: string;
126
- autoRenewingAndroid?: boolean;
127
- purchaseStateAndroid?: PurchaseAndroidState;
128
- isAcknowledgedAndroid?: boolean;
129
- packageNameAndroid?: string;
130
- developerPayloadAndroid?: string;
131
- obfuscatedAccountIdAndroid?: string;
132
- obfuscatedProfileIdAndroid?: string;
133
- };
134
-
135
- // Preferred naming
136
- export type PurchaseAndroid = ProductPurchaseAndroid;