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