expo-iap 2.7.13 → 2.8.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/.copilot-instructions.md +5 -5
- package/.cursorrules +31 -13
- package/CHANGELOG.md +16 -1
- package/CLAUDE.md +5 -1
- package/android/src/main/java/expo/modules/iap/ExpoIapModule.kt +2 -0
- package/build/ExpoIap.types.d.ts +24 -11
- package/build/ExpoIap.types.d.ts.map +1 -1
- package/build/ExpoIap.types.js.map +1 -1
- package/build/helpers/subscription.d.ts.map +1 -1
- package/build/helpers/subscription.js +24 -17
- package/build/helpers/subscription.js.map +1 -1
- package/build/index.d.ts +2 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +12 -17
- package/build/index.js.map +1 -1
- package/build/modules/ios.d.ts +10 -23
- package/build/modules/ios.d.ts.map +1 -1
- package/build/modules/ios.js +9 -23
- package/build/modules/ios.js.map +1 -1
- package/build/types/ExpoIapAndroid.types.d.ts +6 -0
- package/build/types/ExpoIapAndroid.types.d.ts.map +1 -1
- package/build/types/ExpoIapAndroid.types.js.map +1 -1
- package/build/types/{ExpoIapIos.types.d.ts → ExpoIapIOS.types.d.ts} +45 -33
- package/build/types/{ExpoIapIos.types.d.ts.map → ExpoIapIOS.types.d.ts.map} +1 -1
- package/build/types/ExpoIapIOS.types.js +2 -0
- package/build/types/ExpoIapIOS.types.js.map +1 -0
- package/build/{useIap.d.ts → useIAP.d.ts} +2 -2
- package/build/{useIap.d.ts.map → useIAP.d.ts.map} +1 -1
- package/build/{useIap.js → useIAP.js} +7 -6
- package/build/useIAP.js.map +1 -0
- package/bun.lock +677 -61
- package/ios/ExpoIapModule.swift +46 -45
- package/jest.config.js +43 -0
- package/package.json +8 -3
- package/src/ExpoIap.types.ts +34 -15
- package/src/helpers/subscription.ts +27 -20
- package/src/index.ts +16 -24
- package/src/modules/ios.ts +13 -40
- package/src/types/ExpoIapAndroid.types.ts +6 -0
- package/src/types/{ExpoIapIos.types.ts → ExpoIapIOS.types.ts} +46 -32
- package/src/{useIap.ts → useIAP.ts} +7 -6
- package/build/types/ExpoIapIos.types.js +0 -2
- package/build/types/ExpoIapIos.types.js.map +0 -1
- package/build/useIap.js.map +0 -1
package/.copilot-instructions.md
CHANGED
|
@@ -20,14 +20,14 @@ When suggesting code for expo-iap, follow these naming conventions:
|
|
|
20
20
|
|
|
21
21
|
Functions that only work on one platform MUST have platform suffixes:
|
|
22
22
|
|
|
23
|
-
- iOS: `
|
|
23
|
+
- iOS: `functionNameIOS()`
|
|
24
24
|
- Android: `functionNameAndroid()`
|
|
25
25
|
|
|
26
26
|
```typescript
|
|
27
27
|
// Correct examples:
|
|
28
|
-
export const
|
|
28
|
+
export const getStorefrontIOS = async (): Promise<string> => { ... }
|
|
29
29
|
export const consumeProductAndroid = async (token: string): Promise<void> => { ... }
|
|
30
|
-
export const
|
|
30
|
+
export const getAppTransactionIOS = async (): Promise<AppTransactionIOS | null> => { ... }
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
### Cross-Platform Functions
|
|
@@ -145,7 +145,7 @@ src/
|
|
|
145
145
|
├── index.ts # Main exports
|
|
146
146
|
├── ExpoIap.types.ts # Core type definitions
|
|
147
147
|
├── ExpoIapModule.ts # Native module interface
|
|
148
|
-
├──
|
|
148
|
+
├── useIAP.ts # React hook (legacy support)
|
|
149
149
|
├── modules/
|
|
150
150
|
│ ├── android.ts # Android-specific utilities
|
|
151
151
|
│ └── ios.ts # iOS-specific utilities
|
|
@@ -195,7 +195,7 @@ const handleSubscription = async (subscriptionId: string) => {
|
|
|
195
195
|
|
|
196
196
|
## Type Naming
|
|
197
197
|
|
|
198
|
-
- Platform-specific types: `
|
|
198
|
+
- Platform-specific types: `ProductIOS`, `ProductAndroid`, `PurchaseErrorIOS`
|
|
199
199
|
- Cross-platform types: `Product`, `Purchase`, `PurchaseError`
|
|
200
200
|
|
|
201
201
|
## Code Suggestions
|
package/.cursorrules
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# GitHub Copilot and Cursor Rules for expo-iap
|
|
2
2
|
|
|
3
3
|
## Package Manager
|
|
4
|
+
|
|
4
5
|
**IMPORTANT: This project uses Bun exclusively. Do not suggest npm, yarn, or pnpm commands.**
|
|
5
6
|
|
|
6
7
|
- Install dependencies: `bun install`
|
|
@@ -16,28 +17,35 @@
|
|
|
16
17
|
When suggesting code for expo-iap, follow these naming conventions:
|
|
17
18
|
|
|
18
19
|
### Platform-Specific Functions
|
|
20
|
+
|
|
19
21
|
Functions that only work on one platform MUST have platform suffixes:
|
|
20
|
-
|
|
22
|
+
|
|
23
|
+
- iOS: `functionNameIOS()`
|
|
21
24
|
- Android: `functionNameAndroid()`
|
|
22
25
|
|
|
23
26
|
```typescript
|
|
24
27
|
// Correct examples:
|
|
25
|
-
export const
|
|
28
|
+
export const getStorefrontIOS = async (): Promise<string> => { ... }
|
|
26
29
|
export const consumeProductAndroid = async (token: string): Promise<void> => { ... }
|
|
27
|
-
export const
|
|
30
|
+
export const getAppTransactionIOS = async (): Promise<AppTransactionIOS | null> => { ... }
|
|
28
31
|
```
|
|
29
32
|
|
|
30
33
|
### Cross-Platform Functions
|
|
34
|
+
|
|
31
35
|
Functions that abstract platform differences don't need suffixes:
|
|
32
36
|
|
|
33
37
|
```typescript
|
|
34
38
|
// Correct cross-platform example:
|
|
35
39
|
export const getProducts = async (skus: string[]): Promise<Product[]> => {
|
|
36
40
|
return Platform.select({
|
|
37
|
-
ios: async () => {
|
|
38
|
-
|
|
41
|
+
ios: async () => {
|
|
42
|
+
/* iOS implementation */
|
|
43
|
+
},
|
|
44
|
+
android: async () => {
|
|
45
|
+
/* Android implementation */
|
|
46
|
+
},
|
|
39
47
|
})();
|
|
40
|
-
}
|
|
48
|
+
};
|
|
41
49
|
```
|
|
42
50
|
|
|
43
51
|
## Project Overview
|
|
@@ -137,7 +145,7 @@ src/
|
|
|
137
145
|
├── index.ts # Main exports
|
|
138
146
|
├── ExpoIap.types.ts # Core type definitions
|
|
139
147
|
├── ExpoIapModule.ts # Native module interface
|
|
140
|
-
├──
|
|
148
|
+
├── useIAP.ts # React hook (legacy support)
|
|
141
149
|
├── modules/
|
|
142
150
|
│ ├── android.ts # Android-specific utilities
|
|
143
151
|
│ └── ios.ts # iOS-specific utilities
|
|
@@ -187,12 +195,13 @@ const handleSubscription = async (subscriptionId: string) => {
|
|
|
187
195
|
|
|
188
196
|
## Type Naming
|
|
189
197
|
|
|
190
|
-
- Platform-specific types: `
|
|
198
|
+
- Platform-specific types: `ProductIOS`, `ProductAndroid`, `PurchaseErrorIOS`
|
|
191
199
|
- Cross-platform types: `Product`, `Purchase`, `PurchaseError`
|
|
192
200
|
|
|
193
201
|
## Code Suggestions
|
|
194
202
|
|
|
195
203
|
When generating code:
|
|
204
|
+
|
|
196
205
|
1. Check if the function is platform-specific
|
|
197
206
|
2. Add appropriate suffix if it only works on one platform
|
|
198
207
|
3. Use Platform.select() for cross-platform implementations
|
|
@@ -201,7 +210,9 @@ When generating code:
|
|
|
201
210
|
6. Add JSDoc comments for public APIs
|
|
202
211
|
|
|
203
212
|
## Testing
|
|
213
|
+
|
|
204
214
|
Suggest tests that:
|
|
215
|
+
|
|
205
216
|
- Cover both iOS and Android paths
|
|
206
217
|
- Use `bun test` commands
|
|
207
218
|
- Include platform mocking when needed
|
|
@@ -210,12 +221,19 @@ Suggest tests that:
|
|
|
210
221
|
## Common Patterns
|
|
211
222
|
|
|
212
223
|
### Platform Selection
|
|
224
|
+
|
|
213
225
|
```typescript
|
|
214
226
|
Platform.select({
|
|
215
|
-
ios: () => {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
227
|
+
ios: () => {
|
|
228
|
+
/* iOS code */
|
|
229
|
+
},
|
|
230
|
+
android: () => {
|
|
231
|
+
/* Android code */
|
|
232
|
+
},
|
|
233
|
+
default: () => {
|
|
234
|
+
/* Fallback */
|
|
235
|
+
},
|
|
236
|
+
});
|
|
219
237
|
```
|
|
220
238
|
|
|
221
239
|
### Receipt Validation (Platform-specific parameters)
|
|
@@ -300,4 +318,4 @@ const result = await requestPurchase({
|
|
|
300
318
|
});
|
|
301
319
|
```
|
|
302
320
|
|
|
303
|
-
While maintaining full power and flexibility for advanced enterprise use cases.
|
|
321
|
+
While maintaining full power and flexibility for advanced enterprise use cases.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## [2.8.0] - 2025-08-18
|
|
4
|
+
|
|
5
|
+
### Breaking Changes
|
|
6
|
+
|
|
7
|
+
- **iOS Field Naming Convention**: All iOS-related field names ending with "Ios" have been renamed to end with "IOS" to follow the convention that acronyms at the end of field names should be uppercase.
|
|
8
|
+
|
|
9
|
+
**Migration Guide**: See the full migration guide at [expo-iap.pages.dev/blog/v2-8-0-migration-guide](https://expo-iap.pages.dev/blog/v2-8-0-migration-guide)
|
|
10
|
+
|
|
11
|
+
Affected fields:
|
|
12
|
+
|
|
13
|
+
- `quantityIos` → `quantityIOS`
|
|
14
|
+
- `expirationDateIos` → `expirationDateIOS`
|
|
15
|
+
- `environmentIos` → `environmentIOS`
|
|
16
|
+
- And all other iOS-suffixed fields
|
|
17
|
+
|
|
18
|
+
For older versions, checkout [Release Notes](https://github.com/hyochan/expo-iap/releases)
|
package/CLAUDE.md
CHANGED
|
@@ -17,9 +17,13 @@ Before committing any changes:
|
|
|
17
17
|
|
|
18
18
|
### Platform-Specific Naming Conventions
|
|
19
19
|
|
|
20
|
-
- **iOS-related code**: Use `
|
|
20
|
+
- **iOS-related code**: Use `IOS` in naming (e.g., `PurchaseIOS`, `SubscriptionOfferIOS`)
|
|
21
|
+
- **Exception**: When an acronym appears at the end of a field name, use uppercase (e.g., `quantityIOS`, `appBundleIdIOS`, not `quantityIos`)
|
|
21
22
|
- **Android-related code**: Use `Android` in naming (e.g., `PurchaseAndroid`, `SubscriptionOfferAndroid`)
|
|
22
23
|
- **IAP-related code**: Use `Iap` in naming (e.g., `IapPurchase`, not `IAPPurchase`)
|
|
24
|
+
- **ID fields**: Use `Id` instead of `ID` in field names (e.g., `productId`, `transactionId`, not `productID`, `transactionID`)
|
|
25
|
+
- This applies across all platforms for consistency
|
|
26
|
+
- Examples: `productId`, `originalTransactionId`, `purchaseId`
|
|
23
27
|
- This applies to both functions, types, and file names
|
|
24
28
|
|
|
25
29
|
### React/JSX Conventions
|
|
@@ -93,6 +93,7 @@ class ExpoIapModule :
|
|
|
93
93
|
"transactionDate" to purchase.purchaseTime.toDouble(),
|
|
94
94
|
"transactionReceipt" to purchase.originalJson,
|
|
95
95
|
"purchaseTokenAndroid" to purchase.purchaseToken,
|
|
96
|
+
"purchaseToken" to purchase.purchaseToken,
|
|
96
97
|
"dataAndroid" to purchase.originalJson,
|
|
97
98
|
"signatureAndroid" to purchase.signature,
|
|
98
99
|
"autoRenewingAndroid" to purchase.isAutoRenewing,
|
|
@@ -269,6 +270,7 @@ class ExpoIapModule :
|
|
|
269
270
|
"transactionReceipt" to purchase.originalJson,
|
|
270
271
|
"orderId" to purchase.orderId,
|
|
271
272
|
"purchaseTokenAndroid" to purchase.purchaseToken,
|
|
273
|
+
"purchaseToken" to purchase.purchaseToken,
|
|
272
274
|
"developerPayloadAndroid" to purchase.developerPayload,
|
|
273
275
|
"signatureAndroid" to purchase.signature,
|
|
274
276
|
"purchaseStateAndroid" to purchase.purchaseState,
|
package/build/ExpoIap.types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProductAndroid, ProductPurchaseAndroid, SubscriptionProductAndroid } from './types/ExpoIapAndroid.types';
|
|
2
|
-
import {
|
|
2
|
+
import { ProductIOS, ProductPurchaseIOS, SubscriptionProductIOS } from './types/ExpoIapIOS.types';
|
|
3
3
|
export type ChangeEventPayload = {
|
|
4
4
|
value: string;
|
|
5
5
|
};
|
|
@@ -20,6 +20,7 @@ export type PurchaseBase = {
|
|
|
20
20
|
transactionId?: string;
|
|
21
21
|
transactionDate: number;
|
|
22
22
|
transactionReceipt: string;
|
|
23
|
+
purchaseToken?: string;
|
|
23
24
|
};
|
|
24
25
|
export type IosPlatform = {
|
|
25
26
|
platform: 'ios';
|
|
@@ -27,21 +28,29 @@ export type IosPlatform = {
|
|
|
27
28
|
export type AndroidPlatform = {
|
|
28
29
|
platform: 'android';
|
|
29
30
|
};
|
|
30
|
-
export type Product = (ProductAndroid & AndroidPlatform) | (
|
|
31
|
-
export type SubscriptionProduct = (SubscriptionProductAndroid & AndroidPlatform) | (
|
|
31
|
+
export type Product = (ProductAndroid & AndroidPlatform) | (ProductIOS & IosPlatform);
|
|
32
|
+
export type SubscriptionProduct = (SubscriptionProductAndroid & AndroidPlatform) | (SubscriptionProductIOS & IosPlatform);
|
|
32
33
|
export type { ProductPurchaseAndroid } from './types/ExpoIapAndroid.types';
|
|
33
|
-
export type {
|
|
34
|
-
|
|
34
|
+
export type { ProductPurchaseIOS } from './types/ExpoIapIOS.types';
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated Use ProductPurchaseIOS instead. This alias will be removed in v3.0.0.
|
|
37
|
+
*/
|
|
38
|
+
export type ProductPurchaseIos = ProductPurchaseIOS;
|
|
39
|
+
export type ProductPurchase = (ProductPurchaseAndroid & AndroidPlatform) | (ProductPurchaseIOS & IosPlatform);
|
|
35
40
|
export type SubscriptionPurchase = (ProductPurchaseAndroid & AndroidPlatform & {
|
|
36
41
|
autoRenewingAndroid: boolean;
|
|
37
|
-
}) | (
|
|
42
|
+
}) | (ProductPurchaseIOS & IosPlatform);
|
|
38
43
|
export type Purchase = ProductPurchase | SubscriptionPurchase;
|
|
39
44
|
export type PurchaseResult = {
|
|
40
45
|
responseCode?: number;
|
|
41
46
|
debugMessage?: string;
|
|
42
47
|
code?: string;
|
|
43
48
|
message?: string;
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated Use `purchaseToken` instead. This field will be removed in a future version.
|
|
51
|
+
*/
|
|
44
52
|
purchaseTokenAndroid?: string;
|
|
53
|
+
purchaseToken?: string;
|
|
45
54
|
};
|
|
46
55
|
/**
|
|
47
56
|
* Centralized error codes for expo-iap
|
|
@@ -195,7 +204,7 @@ export interface UnifiedRequestPurchaseProps {
|
|
|
195
204
|
readonly andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;
|
|
196
205
|
readonly appAccountToken?: string;
|
|
197
206
|
readonly quantity?: number;
|
|
198
|
-
readonly withOffer?: import('./types/
|
|
207
|
+
readonly withOffer?: import('./types/ExpoIapIOS.types').PaymentDiscount;
|
|
199
208
|
readonly obfuscatedAccountIdAndroid?: string;
|
|
200
209
|
readonly obfuscatedProfileIdAndroid?: string;
|
|
201
210
|
readonly isOfferPersonalized?: boolean;
|
|
@@ -203,12 +212,12 @@ export interface UnifiedRequestPurchaseProps {
|
|
|
203
212
|
/**
|
|
204
213
|
* iOS-specific purchase request parameters
|
|
205
214
|
*/
|
|
206
|
-
export interface
|
|
215
|
+
export interface RequestPurchaseIOSProps {
|
|
207
216
|
readonly sku: string;
|
|
208
217
|
readonly andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;
|
|
209
218
|
readonly appAccountToken?: string;
|
|
210
219
|
readonly quantity?: number;
|
|
211
|
-
readonly withOffer?: import('./types/
|
|
220
|
+
readonly withOffer?: import('./types/ExpoIapIOS.types').PaymentDiscount;
|
|
212
221
|
}
|
|
213
222
|
/**
|
|
214
223
|
* Android-specific purchase request parameters
|
|
@@ -235,14 +244,14 @@ export interface RequestSubscriptionAndroidProps extends RequestPurchaseAndroidP
|
|
|
235
244
|
* Allows clear separation of iOS and Android parameters
|
|
236
245
|
*/
|
|
237
246
|
export interface RequestPurchasePropsByPlatforms {
|
|
238
|
-
readonly ios?:
|
|
247
|
+
readonly ios?: RequestPurchaseIOSProps;
|
|
239
248
|
readonly android?: RequestPurchaseAndroidProps;
|
|
240
249
|
}
|
|
241
250
|
/**
|
|
242
251
|
* Modern platform-specific subscription request structure (v2.7.0+)
|
|
243
252
|
*/
|
|
244
253
|
export interface RequestSubscriptionPropsByPlatforms {
|
|
245
|
-
readonly ios?:
|
|
254
|
+
readonly ios?: RequestPurchaseIOSProps;
|
|
246
255
|
readonly android?: RequestSubscriptionAndroidProps;
|
|
247
256
|
}
|
|
248
257
|
/**
|
|
@@ -255,4 +264,8 @@ export type RequestPurchaseProps = RequestPurchasePropsByPlatforms;
|
|
|
255
264
|
* This is the recommended API moving forward
|
|
256
265
|
*/
|
|
257
266
|
export type RequestSubscriptionProps = RequestSubscriptionPropsByPlatforms;
|
|
267
|
+
/**
|
|
268
|
+
* @deprecated Use RequestPurchaseIOSProps instead. This alias will be removed in v3.0.0.
|
|
269
|
+
*/
|
|
270
|
+
export type RequestPurchaseIosProps = RequestPurchaseIOSProps;
|
|
258
271
|
//# sourceMappingURL=ExpoIap.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoIap.types.d.ts","sourceRoot":"","sources":["../src/ExpoIap.types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,0BAA0B,EAC3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAGlC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;AAE3C,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,WAAW,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE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CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CACvC,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,kBAAkB,EAAE,CAClB,SAAoB,EACpB,QAA2B,EAClB,EAAE;QACX,OAAO,SAAS,IAAI,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IACjD,CAAC;CACF,CAAC;AA8FF,2EAA2E","sourcesContent":["import {\n ProductAndroid,\n ProductPurchaseAndroid,\n SubscriptionProductAndroid,\n} from './types/ExpoIapAndroid.types';\nimport {\n ProductIos,\n ProductPurchaseIos,\n SubscriptionProductIos,\n} from './types/ExpoIapIos.types';\nimport {NATIVE_ERROR_CODES} from './ExpoIapModule';\n\nexport type ChangeEventPayload = {\n value: string;\n};\n\nexport type ProductType = 'inapp' | 'subs';\n\nexport type ProductBase = {\n id: string;\n title: string;\n description: string;\n type: ProductType;\n displayName?: string;\n displayPrice: string;\n currency: string;\n price?: number;\n};\n\nexport type PurchaseBase = {\n id: string; // Transaction identifier - used by finishTransaction\n productId: string; // Product identifier - which product was purchased\n transactionId?: string; // @deprecated - use id instead\n transactionDate: number;\n transactionReceipt: string;\n};\n\n// Define literal platform types for better type discrimination\nexport type IosPlatform = {platform: 'ios'};\nexport type AndroidPlatform = {platform: 'android'};\n\n// Platform-agnostic unified product types (public API)\nexport type Product =\n | (ProductAndroid & AndroidPlatform)\n | (ProductIos & IosPlatform);\n\nexport type SubscriptionProduct =\n | (SubscriptionProductAndroid & AndroidPlatform)\n | (SubscriptionProductIos & IosPlatform);\n\n// ============================================================================\n// Legacy Types (For backward compatibility with useIap hook)\n// ============================================================================\n\n// Re-export platform-specific purchase types for legacy compatibility\nexport type {ProductPurchaseAndroid} from './types/ExpoIapAndroid.types';\nexport type {ProductPurchaseIos} from './types/ExpoIapIos.types';\n\n// Union type for platform-specific purchase types (legacy support)\nexport type ProductPurchase =\n | (ProductPurchaseAndroid & AndroidPlatform)\n | (ProductPurchaseIos & IosPlatform);\n\n// Union type for platform-specific subscription purchase types (legacy support)\nexport type SubscriptionPurchase =\n | (ProductPurchaseAndroid & AndroidPlatform & {autoRenewingAndroid: boolean})\n | (ProductPurchaseIos & IosPlatform);\n\nexport type Purchase = ProductPurchase | SubscriptionPurchase;\n\n// Legacy result type\nexport type PurchaseResult = {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n purchaseTokenAndroid?: string;\n};\n/**\n * Centralized error codes for expo-iap\n * These are mapped to platform-specific error codes and provide consistent error handling\n */\nexport enum ErrorCode {\n E_UNKNOWN = 'E_UNKNOWN',\n E_USER_CANCELLED = 'E_USER_CANCELLED',\n E_USER_ERROR = 'E_USER_ERROR',\n E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',\n E_REMOTE_ERROR = 'E_REMOTE_ERROR',\n E_NETWORK_ERROR = 'E_NETWORK_ERROR',\n E_SERVICE_ERROR = 'E_SERVICE_ERROR',\n E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',\n E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',\n E_NOT_PREPARED = 'E_NOT_PREPARED',\n E_NOT_ENDED = 'E_NOT_ENDED',\n E_ALREADY_OWNED = 'E_ALREADY_OWNED',\n E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',\n E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',\n E_INTERRUPTED = 'E_INTERRUPTED',\n E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',\n E_PURCHASE_ERROR = 'E_PURCHASE_ERROR',\n E_SYNC_ERROR = 'E_SYNC_ERROR',\n E_TRANSACTION_VALIDATION_FAILED = 'E_TRANSACTION_VALIDATION_FAILED',\n E_ACTIVITY_UNAVAILABLE = 'E_ACTIVITY_UNAVAILABLE',\n E_ALREADY_PREPARED = 'E_ALREADY_PREPARED',\n E_PENDING = 'E_PENDING',\n E_CONNECTION_CLOSED = 'E_CONNECTION_CLOSED',\n}\n\n/**\n * Platform-specific error code mappings\n * Maps ErrorCode enum values to platform-specific integer codes\n */\nexport const ErrorCodeMapping = {\n ios: {\n [ErrorCode.E_UNKNOWN]: 0,\n [ErrorCode.E_SERVICE_ERROR]: 1,\n [ErrorCode.E_USER_CANCELLED]: 2,\n [ErrorCode.E_USER_ERROR]: 3,\n [ErrorCode.E_ITEM_UNAVAILABLE]: 4,\n [ErrorCode.E_REMOTE_ERROR]: 5,\n [ErrorCode.E_NETWORK_ERROR]: 6,\n [ErrorCode.E_RECEIPT_FAILED]: 7,\n [ErrorCode.E_RECEIPT_FINISHED_FAILED]: 8,\n [ErrorCode.E_DEVELOPER_ERROR]: 9,\n [ErrorCode.E_PURCHASE_ERROR]: 10,\n [ErrorCode.E_SYNC_ERROR]: 11,\n [ErrorCode.E_DEFERRED_PAYMENT]: 12,\n [ErrorCode.E_TRANSACTION_VALIDATION_FAILED]: 13,\n [ErrorCode.E_NOT_PREPARED]: 14,\n [ErrorCode.E_NOT_ENDED]: 15,\n [ErrorCode.E_ALREADY_OWNED]: 16,\n [ErrorCode.E_BILLING_RESPONSE_JSON_PARSE_ERROR]: 17,\n [ErrorCode.E_INTERRUPTED]: 18,\n [ErrorCode.E_IAP_NOT_AVAILABLE]: 19,\n [ErrorCode.E_ACTIVITY_UNAVAILABLE]: 20,\n [ErrorCode.E_ALREADY_PREPARED]: 21,\n [ErrorCode.E_PENDING]: 22,\n [ErrorCode.E_CONNECTION_CLOSED]: 23,\n },\n android: {\n [ErrorCode.E_UNKNOWN]: 'E_UNKNOWN',\n [ErrorCode.E_USER_CANCELLED]: 'E_USER_CANCELLED',\n [ErrorCode.E_USER_ERROR]: 'E_USER_ERROR',\n [ErrorCode.E_ITEM_UNAVAILABLE]: 'E_ITEM_UNAVAILABLE',\n [ErrorCode.E_REMOTE_ERROR]: 'E_REMOTE_ERROR',\n [ErrorCode.E_NETWORK_ERROR]: 'E_NETWORK_ERROR',\n [ErrorCode.E_SERVICE_ERROR]: 'E_SERVICE_ERROR',\n [ErrorCode.E_RECEIPT_FAILED]: 'E_RECEIPT_FAILED',\n [ErrorCode.E_RECEIPT_FINISHED_FAILED]: 'E_RECEIPT_FINISHED_FAILED',\n [ErrorCode.E_NOT_PREPARED]: 'E_NOT_PREPARED',\n [ErrorCode.E_NOT_ENDED]: 'E_NOT_ENDED',\n [ErrorCode.E_ALREADY_OWNED]: 'E_ALREADY_OWNED',\n [ErrorCode.E_DEVELOPER_ERROR]: 'E_DEVELOPER_ERROR',\n [ErrorCode.E_BILLING_RESPONSE_JSON_PARSE_ERROR]:\n 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n [ErrorCode.E_DEFERRED_PAYMENT]: 'E_DEFERRED_PAYMENT',\n [ErrorCode.E_INTERRUPTED]: 'E_INTERRUPTED',\n [ErrorCode.E_IAP_NOT_AVAILABLE]: 'E_IAP_NOT_AVAILABLE',\n [ErrorCode.E_PURCHASE_ERROR]: 'E_PURCHASE_ERROR',\n [ErrorCode.E_SYNC_ERROR]: 'E_SYNC_ERROR',\n [ErrorCode.E_TRANSACTION_VALIDATION_FAILED]:\n 'E_TRANSACTION_VALIDATION_FAILED',\n [ErrorCode.E_ACTIVITY_UNAVAILABLE]: 'E_ACTIVITY_UNAVAILABLE',\n [ErrorCode.E_ALREADY_PREPARED]: 'E_ALREADY_PREPARED',\n [ErrorCode.E_PENDING]: 'E_PENDING',\n [ErrorCode.E_CONNECTION_CLOSED]: 'E_CONNECTION_CLOSED',\n },\n} as const;\n\nexport class PurchaseError implements Error {\n constructor(\n public name: string,\n public message: string,\n public responseCode?: number,\n public debugMessage?: string,\n public code?: ErrorCode,\n public productId?: string,\n public platform?: 'ios' | 'android',\n ) {\n this.name = '[expo-iap]: PurchaseError';\n this.message = message;\n this.responseCode = responseCode;\n this.debugMessage = debugMessage;\n this.code = code;\n this.productId = productId;\n this.platform = platform;\n }\n\n /**\n * Creates a PurchaseError from platform-specific error data\n * @param errorData Raw error data from native modules\n * @param platform Platform where the error occurred\n * @returns Properly typed PurchaseError instance\n */\n static fromPlatformError(\n errorData: any,\n platform: 'ios' | 'android',\n ): PurchaseError {\n const errorCode = errorData.code\n ? ErrorCodeUtils.fromPlatformCode(errorData.code, platform)\n : ErrorCode.E_UNKNOWN;\n\n return new PurchaseError(\n '[expo-iap]: PurchaseError',\n errorData.message || 'Unknown error occurred',\n errorData.responseCode,\n errorData.debugMessage,\n errorCode,\n errorData.productId,\n platform,\n );\n }\n\n /**\n * Gets the platform-specific error code for this error\n * @returns Platform-specific error code\n */\n getPlatformCode(): string | number | undefined {\n if (!this.code || !this.platform) return undefined;\n return ErrorCodeUtils.toPlatformCode(this.code, this.platform);\n }\n}\n\n/**\n * Utility functions for error code mapping and validation\n */\nexport const ErrorCodeUtils = {\n /**\n * Gets the native error code for the current platform\n * @param errorCode ErrorCode enum value\n * @returns Platform-specific error code from native constants\n */\n getNativeErrorCode: (errorCode: ErrorCode): string => {\n return NATIVE_ERROR_CODES[errorCode] || errorCode;\n },\n\n /**\n * Maps a platform-specific error code back to the standardized ErrorCode enum\n * @param platformCode Platform-specific error code (string for Android, number for iOS)\n * @param platform Target platform\n * @returns Corresponding ErrorCode enum value or E_UNKNOWN if not found\n */\n fromPlatformCode: (\n platformCode: string | number,\n platform: 'ios' | 'android',\n ): ErrorCode => {\n const mapping = ErrorCodeMapping[platform];\n\n for (const [errorCode, mappedCode] of Object.entries(mapping)) {\n if (mappedCode === platformCode) {\n return errorCode as ErrorCode;\n }\n }\n\n return ErrorCode.E_UNKNOWN;\n },\n\n /**\n * Maps an ErrorCode enum to platform-specific code\n * @param errorCode ErrorCode enum value\n * @param platform Target platform\n * @returns Platform-specific error code\n */\n toPlatformCode: (\n errorCode: ErrorCode,\n platform: 'ios' | 'android',\n ): string | number => {\n return (\n ErrorCodeMapping[platform][errorCode] ??\n (platform === 'ios' ? 0 : 'E_UNKNOWN')\n );\n },\n\n /**\n * Checks if an error code is valid for the specified platform\n * @param errorCode ErrorCode enum value\n * @param platform Target platform\n * @returns True if the error code is supported on the platform\n */\n isValidForPlatform: (\n errorCode: ErrorCode,\n platform: 'ios' | 'android',\n ): boolean => {\n return errorCode in ErrorCodeMapping[platform];\n },\n};\n\n// ============================================================================\n// Enhanced Unified Request Types\n// ============================================================================\n\n/**\n * Unified request props that work on both iOS and Android platforms\n * iOS will use 'sku', Android will use 'skus' (or convert sku to skus array)\n */\nexport interface UnifiedRequestPurchaseProps {\n // Universal properties - works on both platforms\n readonly sku?: string; // Single SKU (iOS native, Android fallback)\n readonly skus?: string[]; // Multiple SKUs (Android native, iOS uses first item)\n\n // iOS-specific properties (ignored on Android)\n readonly andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n readonly appAccountToken?: string;\n readonly quantity?: number;\n readonly withOffer?: import('./types/ExpoIapIos.types').PaymentDiscount;\n\n // Android-specific properties (ignored on iOS)\n readonly obfuscatedAccountIdAndroid?: string;\n readonly obfuscatedProfileIdAndroid?: string;\n readonly isOfferPersonalized?: boolean;\n}\n\n// ============================================================================\n// New Platform-Specific Request Types (v2.7.0+)\n// ============================================================================\n\n/**\n * iOS-specific purchase request parameters\n */\nexport interface RequestPurchaseIosProps {\n readonly sku: string;\n readonly andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n readonly appAccountToken?: string;\n readonly quantity?: number;\n readonly withOffer?: import('./types/ExpoIapIos.types').PaymentDiscount;\n}\n\n/**\n * Android-specific purchase request parameters\n */\nexport interface RequestPurchaseAndroidProps {\n readonly skus: string[];\n readonly obfuscatedAccountIdAndroid?: string;\n readonly obfuscatedProfileIdAndroid?: string;\n readonly isOfferPersonalized?: boolean;\n}\n\n/**\n * Android-specific subscription request parameters\n */\nexport interface RequestSubscriptionAndroidProps\n extends RequestPurchaseAndroidProps {\n readonly purchaseTokenAndroid?: string;\n readonly replacementModeAndroid?: number;\n readonly subscriptionOffers: {\n sku: string;\n offerToken: string;\n }[];\n}\n\n/**\n * Modern platform-specific request structure (v2.7.0+)\n * Allows clear separation of iOS and Android parameters\n */\nexport interface RequestPurchasePropsByPlatforms {\n readonly ios?: RequestPurchaseIosProps;\n readonly android?: RequestPurchaseAndroidProps;\n}\n\n/**\n * Modern platform-specific subscription request structure (v2.7.0+)\n */\nexport interface RequestSubscriptionPropsByPlatforms {\n readonly ios?: RequestPurchaseIosProps;\n readonly android?: RequestSubscriptionAndroidProps;\n}\n\n/**\n * Modern request purchase parameters (v2.7.0+)\n * This is the recommended API moving forward\n */\nexport type RequestPurchaseProps = RequestPurchasePropsByPlatforms;\n\n/**\n * Modern request subscription parameters (v2.7.0+)\n * This is the recommended API moving forward\n */\nexport type RequestSubscriptionProps = RequestSubscriptionPropsByPlatforms;\n\n// Note: Type guard functions are exported from index.ts to avoid conflicts\n"]}
|
|
1
|
+
{"version":3,"file":"ExpoIap.types.js","sourceRoot":"","sources":["../src/ExpoIap.types.ts"],"names":[],"mappings":"AAUA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AA8EnD;;;GAGG;AACH,MAAM,CAAN,IAAY,SAyBX;AAzBD,WAAY,SAAS;IACnB,oCAAuB,CAAA;IACvB,kDAAqC,CAAA;IACrC,0CAA6B,CAAA;IAC7B,sDAAyC,CAAA;IACzC,8CAAiC,CAAA;IACjC,gDAAmC,CAAA;IACnC,gDAAmC,CAAA;IACnC,kDAAqC,CAAA;IACrC,oEAAuD,CAAA;IACvD,8CAAiC,CAAA;IACjC,wCAA2B,CAAA;IAC3B,gDAAmC,CAAA;IACnC,oDAAuC,CAAA;IACvC,wFAA2E,CAAA;IAC3E,sDAAyC,CAAA;IACzC,4CAA+B,CAAA;IAC/B,wDAA2C,CAAA;IAC3C,kDAAqC,CAAA;IACrC,0CAA6B,CAAA;IAC7B,gFAAmE,CAAA;IACnE,8DAAiD,CAAA;IACjD,sDAAyC,CAAA;IACzC,oCAAuB,CAAA;IACvB,wDAA2C,CAAA;AAC7C,CAAC,EAzBW,SAAS,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ProductAndroid,\n} from './types/ExpoIapAndroid.types';\nimport {\n ProductIOS,\n ProductPurchaseIOS,\n SubscriptionProductIOS,\n} from './types/ExpoIapIOS.types';\nimport {NATIVE_ERROR_CODES} from './ExpoIapModule';\n\nexport type ChangeEventPayload = {\n value: string;\n};\n\nexport type ProductType = 'inapp' | 'subs';\n\nexport type ProductBase = {\n id: string;\n title: string;\n description: string;\n type: ProductType;\n displayName?: string;\n displayPrice: string;\n currency: string;\n price?: number;\n};\n\nexport type PurchaseBase = {\n id: string; // Transaction identifier - used by finishTransaction\n productId: string; // Product identifier - which product was purchased\n transactionId?: string; // @deprecated - use id instead\n transactionDate: number;\n transactionReceipt: string;\n purchaseToken?: string; // Unified purchase token (jwsRepresentation for iOS, purchaseToken for Android)\n};\n\n// Define literal platform types for better type discrimination\nexport type IosPlatform = {platform: 'ios'};\nexport type AndroidPlatform = {platform: 'android'};\n\n// Platform-agnostic unified product types (public API)\nexport type Product =\n | (ProductAndroid & AndroidPlatform)\n | (ProductIOS & IosPlatform);\n\nexport type SubscriptionProduct =\n | (SubscriptionProductAndroid & AndroidPlatform)\n | (SubscriptionProductIOS & IosPlatform);\n\n// ============================================================================\n// Legacy Types (For backward compatibility with useIAP hook)\n// ============================================================================\n\n// Re-export platform-specific purchase types for legacy compatibility\nexport type {ProductPurchaseAndroid} from './types/ExpoIapAndroid.types';\nexport type {ProductPurchaseIOS} from './types/ExpoIapIOS.types';\n\n/**\n * @deprecated Use ProductPurchaseIOS instead. This alias will be removed in v3.0.0.\n */\nexport type ProductPurchaseIos = ProductPurchaseIOS;\n\n// Union type for platform-specific purchase types (legacy support)\nexport type ProductPurchase =\n | (ProductPurchaseAndroid & AndroidPlatform)\n | (ProductPurchaseIOS & IosPlatform);\n\n// Union type for platform-specific subscription purchase types (legacy support)\nexport type SubscriptionPurchase =\n | (ProductPurchaseAndroid & AndroidPlatform & {autoRenewingAndroid: boolean})\n | (ProductPurchaseIOS & IosPlatform);\n\nexport type Purchase = ProductPurchase | SubscriptionPurchase;\n\n// Legacy result type\nexport type PurchaseResult = {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n /**\n * @deprecated Use `purchaseToken` instead. This field will be removed in a future version.\n */\n purchaseTokenAndroid?: string;\n purchaseToken?: string;\n};\n/**\n * Centralized error codes for expo-iap\n * These are mapped to platform-specific error codes and provide consistent error handling\n */\nexport enum ErrorCode {\n E_UNKNOWN = 'E_UNKNOWN',\n E_USER_CANCELLED = 'E_USER_CANCELLED',\n E_USER_ERROR = 'E_USER_ERROR',\n E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',\n E_REMOTE_ERROR = 'E_REMOTE_ERROR',\n E_NETWORK_ERROR = 'E_NETWORK_ERROR',\n E_SERVICE_ERROR = 'E_SERVICE_ERROR',\n E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',\n E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',\n E_NOT_PREPARED = 'E_NOT_PREPARED',\n E_NOT_ENDED = 'E_NOT_ENDED',\n E_ALREADY_OWNED = 'E_ALREADY_OWNED',\n E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',\n E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',\n E_INTERRUPTED = 'E_INTERRUPTED',\n E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',\n E_PURCHASE_ERROR = 'E_PURCHASE_ERROR',\n E_SYNC_ERROR = 'E_SYNC_ERROR',\n E_TRANSACTION_VALIDATION_FAILED = 'E_TRANSACTION_VALIDATION_FAILED',\n E_ACTIVITY_UNAVAILABLE = 'E_ACTIVITY_UNAVAILABLE',\n E_ALREADY_PREPARED = 'E_ALREADY_PREPARED',\n E_PENDING = 'E_PENDING',\n E_CONNECTION_CLOSED = 'E_CONNECTION_CLOSED',\n}\n\n/**\n * Platform-specific error code mappings\n * Maps ErrorCode enum values to platform-specific integer codes\n */\nexport const ErrorCodeMapping = {\n ios: {\n [ErrorCode.E_UNKNOWN]: 0,\n [ErrorCode.E_SERVICE_ERROR]: 1,\n [ErrorCode.E_USER_CANCELLED]: 2,\n [ErrorCode.E_USER_ERROR]: 3,\n [ErrorCode.E_ITEM_UNAVAILABLE]: 4,\n [ErrorCode.E_REMOTE_ERROR]: 5,\n [ErrorCode.E_NETWORK_ERROR]: 6,\n [ErrorCode.E_RECEIPT_FAILED]: 7,\n [ErrorCode.E_RECEIPT_FINISHED_FAILED]: 8,\n [ErrorCode.E_DEVELOPER_ERROR]: 9,\n [ErrorCode.E_PURCHASE_ERROR]: 10,\n [ErrorCode.E_SYNC_ERROR]: 11,\n [ErrorCode.E_DEFERRED_PAYMENT]: 12,\n [ErrorCode.E_TRANSACTION_VALIDATION_FAILED]: 13,\n [ErrorCode.E_NOT_PREPARED]: 14,\n [ErrorCode.E_NOT_ENDED]: 15,\n [ErrorCode.E_ALREADY_OWNED]: 16,\n [ErrorCode.E_BILLING_RESPONSE_JSON_PARSE_ERROR]: 17,\n [ErrorCode.E_INTERRUPTED]: 18,\n [ErrorCode.E_IAP_NOT_AVAILABLE]: 19,\n [ErrorCode.E_ACTIVITY_UNAVAILABLE]: 20,\n [ErrorCode.E_ALREADY_PREPARED]: 21,\n [ErrorCode.E_PENDING]: 22,\n [ErrorCode.E_CONNECTION_CLOSED]: 23,\n },\n android: {\n [ErrorCode.E_UNKNOWN]: 'E_UNKNOWN',\n [ErrorCode.E_USER_CANCELLED]: 'E_USER_CANCELLED',\n [ErrorCode.E_USER_ERROR]: 'E_USER_ERROR',\n [ErrorCode.E_ITEM_UNAVAILABLE]: 'E_ITEM_UNAVAILABLE',\n [ErrorCode.E_REMOTE_ERROR]: 'E_REMOTE_ERROR',\n [ErrorCode.E_NETWORK_ERROR]: 'E_NETWORK_ERROR',\n [ErrorCode.E_SERVICE_ERROR]: 'E_SERVICE_ERROR',\n [ErrorCode.E_RECEIPT_FAILED]: 'E_RECEIPT_FAILED',\n [ErrorCode.E_RECEIPT_FINISHED_FAILED]: 'E_RECEIPT_FINISHED_FAILED',\n [ErrorCode.E_NOT_PREPARED]: 'E_NOT_PREPARED',\n [ErrorCode.E_NOT_ENDED]: 'E_NOT_ENDED',\n [ErrorCode.E_ALREADY_OWNED]: 'E_ALREADY_OWNED',\n [ErrorCode.E_DEVELOPER_ERROR]: 'E_DEVELOPER_ERROR',\n [ErrorCode.E_BILLING_RESPONSE_JSON_PARSE_ERROR]:\n 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n [ErrorCode.E_DEFERRED_PAYMENT]: 'E_DEFERRED_PAYMENT',\n [ErrorCode.E_INTERRUPTED]: 'E_INTERRUPTED',\n [ErrorCode.E_IAP_NOT_AVAILABLE]: 'E_IAP_NOT_AVAILABLE',\n [ErrorCode.E_PURCHASE_ERROR]: 'E_PURCHASE_ERROR',\n [ErrorCode.E_SYNC_ERROR]: 'E_SYNC_ERROR',\n [ErrorCode.E_TRANSACTION_VALIDATION_FAILED]:\n 'E_TRANSACTION_VALIDATION_FAILED',\n [ErrorCode.E_ACTIVITY_UNAVAILABLE]: 'E_ACTIVITY_UNAVAILABLE',\n [ErrorCode.E_ALREADY_PREPARED]: 'E_ALREADY_PREPARED',\n [ErrorCode.E_PENDING]: 'E_PENDING',\n [ErrorCode.E_CONNECTION_CLOSED]: 'E_CONNECTION_CLOSED',\n },\n} as const;\n\nexport class PurchaseError implements Error {\n constructor(\n public name: string,\n public message: string,\n public responseCode?: number,\n public debugMessage?: string,\n public code?: ErrorCode,\n public productId?: string,\n public platform?: 'ios' | 'android',\n ) {\n this.name = '[expo-iap]: PurchaseError';\n this.message = message;\n this.responseCode = responseCode;\n this.debugMessage = debugMessage;\n this.code = code;\n this.productId = productId;\n this.platform = platform;\n }\n\n /**\n * Creates a PurchaseError from platform-specific error data\n * @param errorData Raw error data from native modules\n * @param platform Platform where the error occurred\n * @returns Properly typed PurchaseError instance\n */\n static fromPlatformError(\n errorData: any,\n platform: 'ios' | 'android',\n ): PurchaseError {\n const errorCode = errorData.code\n ? ErrorCodeUtils.fromPlatformCode(errorData.code, platform)\n : ErrorCode.E_UNKNOWN;\n\n return new PurchaseError(\n '[expo-iap]: PurchaseError',\n errorData.message || 'Unknown error occurred',\n errorData.responseCode,\n errorData.debugMessage,\n errorCode,\n errorData.productId,\n platform,\n );\n }\n\n /**\n * Gets the platform-specific error code for this error\n * @returns Platform-specific error code\n */\n getPlatformCode(): string | number | undefined {\n if (!this.code || !this.platform) return undefined;\n return ErrorCodeUtils.toPlatformCode(this.code, this.platform);\n }\n}\n\n/**\n * Utility functions for error code mapping and validation\n */\nexport const ErrorCodeUtils = {\n /**\n * Gets the native error code for the current platform\n * @param errorCode ErrorCode enum value\n * @returns Platform-specific error code from native constants\n */\n getNativeErrorCode: (errorCode: ErrorCode): string => {\n return NATIVE_ERROR_CODES[errorCode] || errorCode;\n },\n\n /**\n * Maps a platform-specific error code back to the standardized ErrorCode enum\n * @param platformCode Platform-specific error code (string for Android, number for iOS)\n * @param platform Target platform\n * @returns Corresponding ErrorCode enum value or E_UNKNOWN if not found\n */\n fromPlatformCode: (\n platformCode: string | number,\n platform: 'ios' | 'android',\n ): ErrorCode => {\n const mapping = ErrorCodeMapping[platform];\n\n for (const [errorCode, mappedCode] of Object.entries(mapping)) {\n if (mappedCode === platformCode) {\n return errorCode as ErrorCode;\n }\n }\n\n return ErrorCode.E_UNKNOWN;\n },\n\n /**\n * Maps an ErrorCode enum to platform-specific code\n * @param errorCode ErrorCode enum value\n * @param platform Target platform\n * @returns Platform-specific error code\n */\n toPlatformCode: (\n errorCode: ErrorCode,\n platform: 'ios' | 'android',\n ): string | number => {\n return (\n ErrorCodeMapping[platform][errorCode] ??\n (platform === 'ios' ? 0 : 'E_UNKNOWN')\n );\n },\n\n /**\n * Checks if an error code is valid for the specified platform\n * @param errorCode ErrorCode enum value\n * @param platform Target platform\n * @returns True if the error code is supported on the platform\n */\n isValidForPlatform: (\n errorCode: ErrorCode,\n platform: 'ios' | 'android',\n ): boolean => {\n return errorCode in ErrorCodeMapping[platform];\n },\n};\n\n// ============================================================================\n// Enhanced Unified Request Types\n// ============================================================================\n\n/**\n * Unified request props that work on both iOS and Android platforms\n * iOS will use 'sku', Android will use 'skus' (or convert sku to skus array)\n */\nexport interface UnifiedRequestPurchaseProps {\n // Universal properties - works on both platforms\n readonly sku?: string; // Single SKU (iOS native, Android fallback)\n readonly skus?: string[]; // Multiple SKUs (Android native, iOS uses first item)\n\n // iOS-specific properties (ignored on Android)\n readonly andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n readonly appAccountToken?: string;\n readonly quantity?: number;\n readonly withOffer?: import('./types/ExpoIapIOS.types').PaymentDiscount;\n\n // Android-specific properties (ignored on iOS)\n readonly obfuscatedAccountIdAndroid?: string;\n readonly obfuscatedProfileIdAndroid?: string;\n readonly isOfferPersonalized?: boolean;\n}\n\n// ============================================================================\n// New Platform-Specific Request Types (v2.7.0+)\n// ============================================================================\n\n/**\n * iOS-specific purchase request parameters\n */\nexport interface RequestPurchaseIOSProps {\n readonly sku: string;\n readonly andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n readonly appAccountToken?: string;\n readonly quantity?: number;\n readonly withOffer?: import('./types/ExpoIapIOS.types').PaymentDiscount;\n}\n\n/**\n * Android-specific purchase request parameters\n */\nexport interface RequestPurchaseAndroidProps {\n readonly skus: string[];\n readonly obfuscatedAccountIdAndroid?: string;\n readonly obfuscatedProfileIdAndroid?: string;\n readonly isOfferPersonalized?: boolean;\n}\n\n/**\n * Android-specific subscription request parameters\n */\nexport interface RequestSubscriptionAndroidProps\n extends RequestPurchaseAndroidProps {\n readonly purchaseTokenAndroid?: string;\n readonly replacementModeAndroid?: number;\n readonly subscriptionOffers: {\n sku: string;\n offerToken: string;\n }[];\n}\n\n/**\n * Modern platform-specific request structure (v2.7.0+)\n * Allows clear separation of iOS and Android parameters\n */\nexport interface RequestPurchasePropsByPlatforms {\n readonly ios?: RequestPurchaseIOSProps;\n readonly android?: RequestPurchaseAndroidProps;\n}\n\n/**\n * Modern platform-specific subscription request structure (v2.7.0+)\n */\nexport interface RequestSubscriptionPropsByPlatforms {\n readonly ios?: RequestPurchaseIOSProps;\n readonly android?: RequestSubscriptionAndroidProps;\n}\n\n/**\n * Modern request purchase parameters (v2.7.0+)\n * This is the recommended API moving forward\n */\nexport type RequestPurchaseProps = RequestPurchasePropsByPlatforms;\n\n/**\n * Modern request subscription parameters (v2.7.0+)\n * This is the recommended API moving forward\n */\nexport type RequestSubscriptionProps = RequestSubscriptionPropsByPlatforms;\n\n// ============================================================================\n// Deprecated Aliases for Backward Compatibility\n// ============================================================================\n\n/**\n * @deprecated Use RequestPurchaseIOSProps instead. This alias will be removed in v3.0.0.\n */\nexport type RequestPurchaseIosProps = RequestPurchaseIOSProps;\n\n// Note: Type guard functions are exported from index.ts to avoid conflicts\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../src/helpers/subscription.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,iBAAiB,CAAC,EAAE,IAAI,CAAC;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,kBAAkB,MAAM,EAAE,KACzB,OAAO,CAAC,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../src/helpers/subscription.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,iBAAiB,CAAC,EAAE,IAAI,CAAC;IACzB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,kBAAkB,MAAM,EAAE,KACzB,OAAO,CAAC,kBAAkB,EAAE,CAgG9B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,kBAAkB,MAAM,EAAE,KACzB,OAAO,CAAC,OAAO,CAGjB,CAAC"}
|
|
@@ -14,27 +14,34 @@ export const getActiveSubscriptions = async (subscriptionIds) => {
|
|
|
14
14
|
const filteredPurchases = purchases.filter((purchase) => {
|
|
15
15
|
// If specific IDs provided, filter by them
|
|
16
16
|
if (subscriptionIds && subscriptionIds.length > 0) {
|
|
17
|
-
if (!subscriptionIds.includes(purchase.
|
|
17
|
+
if (!subscriptionIds.includes(purchase.productId)) {
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
// Check if this purchase has subscription-specific fields
|
|
22
|
-
const hasSubscriptionFields = ('
|
|
23
|
-
'autoRenewingAndroid' in purchase
|
|
22
|
+
const hasSubscriptionFields = ('expirationDateIOS' in purchase && purchase.expirationDateIOS) ||
|
|
23
|
+
'autoRenewingAndroid' in purchase ||
|
|
24
|
+
('environmentIOS' in purchase && purchase.environmentIOS === 'Sandbox');
|
|
24
25
|
if (!hasSubscriptionFields) {
|
|
25
26
|
return false;
|
|
26
27
|
}
|
|
27
28
|
// Check if it's actually active
|
|
28
29
|
if (Platform.OS === 'ios') {
|
|
29
|
-
if ('
|
|
30
|
-
return purchase.
|
|
30
|
+
if ('expirationDateIOS' in purchase && purchase.expirationDateIOS) {
|
|
31
|
+
return purchase.expirationDateIOS > currentTime;
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
// For iOS purchases without expiration date (like Sandbox), we consider them active
|
|
34
|
+
// if they have the environmentIOS field and were created recently
|
|
35
|
+
if ('environmentIOS' in purchase && purchase.environmentIOS) {
|
|
34
36
|
const dayInMs = 24 * 60 * 60 * 1000;
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
// If no expiration date, consider active if transaction is recent (within 24 hours for Sandbox)
|
|
38
|
+
if (!('expirationDateIOS' in purchase) ||
|
|
39
|
+
!purchase.expirationDateIOS) {
|
|
40
|
+
if (purchase.environmentIOS === 'Sandbox' &&
|
|
41
|
+
purchase.transactionDate &&
|
|
42
|
+
currentTime - purchase.transactionDate < dayInMs) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
38
45
|
}
|
|
39
46
|
}
|
|
40
47
|
}
|
|
@@ -47,21 +54,21 @@ export const getActiveSubscriptions = async (subscriptionIds) => {
|
|
|
47
54
|
// Convert to ActiveSubscription format
|
|
48
55
|
for (const purchase of filteredPurchases) {
|
|
49
56
|
const subscription = {
|
|
50
|
-
productId: purchase.
|
|
57
|
+
productId: purchase.productId,
|
|
51
58
|
isActive: true,
|
|
52
59
|
};
|
|
53
60
|
// Add platform-specific details
|
|
54
61
|
if (Platform.OS === 'ios') {
|
|
55
|
-
if ('
|
|
56
|
-
const expirationDate = new Date(purchase.
|
|
62
|
+
if ('expirationDateIOS' in purchase && purchase.expirationDateIOS) {
|
|
63
|
+
const expirationDate = new Date(purchase.expirationDateIOS);
|
|
57
64
|
subscription.expirationDateIOS = expirationDate;
|
|
58
|
-
// Calculate days until expiration
|
|
59
|
-
const daysUntilExpiration = Math.
|
|
65
|
+
// Calculate days until expiration (round to nearest day)
|
|
66
|
+
const daysUntilExpiration = Math.round((purchase.expirationDateIOS - currentTime) / (1000 * 60 * 60 * 24));
|
|
60
67
|
subscription.daysUntilExpirationIOS = daysUntilExpiration;
|
|
61
68
|
subscription.willExpireSoon = daysUntilExpiration <= 7;
|
|
62
69
|
}
|
|
63
|
-
if ('
|
|
64
|
-
subscription.environmentIOS = purchase.
|
|
70
|
+
if ('environmentIOS' in purchase) {
|
|
71
|
+
subscription.environmentIOS = purchase.environmentIOS;
|
|
65
72
|
}
|
|
66
73
|
}
|
|
67
74
|
else if (Platform.OS === 'android') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../src/helpers/subscription.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AACtC,OAAO,EAAC,qBAAqB,EAAC,MAAM,UAAU,CAAC;AAY/C;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EACzC,eAA0B,EACK,EAAE;IACjC,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,MAAM,qBAAqB,EAAE,CAAC;QAChD,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC/B,MAAM,mBAAmB,GAAyB,EAAE,CAAC;QAErD,gDAAgD;QAChD,MAAM,iBAAiB,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE;YACtD,2CAA2C;YAC3C,IAAI,eAAe,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAClD,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../src/helpers/subscription.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,cAAc,CAAC;AACtC,OAAO,EAAC,qBAAqB,EAAC,MAAM,UAAU,CAAC;AAY/C;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EACzC,eAA0B,EACK,EAAE;IACjC,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,MAAM,qBAAqB,EAAE,CAAC;QAChD,MAAM,WAAW,GAAG,IAAI,CA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B,IAAI,QAAQ,EAAE,CAAC;oBACtC,YAAY,CAAC,mBAAmB,GAAG,QAAQ,CAAC,mBAAmB,CAAC;oBAChE,2DAA2D;oBAC3D,YAAY,CAAC,cAAc,GAAG,CAAC,QAAQ,CAAC,mBAAmB,CAAC;gBAC9D,CAAC;YACH,CAAC;YAED,mBAAmB,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACzC,CAAC;QAED,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAC;QAC5D,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EACzC,eAA0B,EACR,EAAE;IACpB,MAAM,aAAa,GAAG,MAAM,sBAAsB,CAAC,eAAe,CAAC,CAAC;IACpE,OAAO,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;AAClC,CAAC,CAAC","sourcesContent":["import {Platform} from 'react-native';\nimport {getAvailablePurchases} from '../index';\n\nexport interface ActiveSubscription {\n productId: string;\n isActive: boolean;\n expirationDateIOS?: Date;\n autoRenewingAndroid?: boolean;\n environmentIOS?: string;\n willExpireSoon?: boolean;\n daysUntilExpirationIOS?: number;\n}\n\n/**\n * Get all active subscriptions with detailed information\n * @param subscriptionIds - Optional array of subscription product IDs to filter. If not provided, returns all active subscriptions.\n * @returns Promise<ActiveSubscription[]> array of active subscriptions with details\n */\nexport const getActiveSubscriptions = async (\n subscriptionIds?: string[],\n): Promise<ActiveSubscription[]> => {\n try {\n const purchases = await getAvailablePurchases();\n const currentTime = Date.now();\n const activeSubscriptions: ActiveSubscription[] = [];\n\n // Filter purchases to find active subscriptions\n const filteredPurchases = purchases.filter((purchase) => {\n // If specific IDs provided, filter by them\n if (subscriptionIds && subscriptionIds.length > 0) {\n if (!subscriptionIds.includes(purchase.productId)) {\n return false;\n }\n }\n\n // Check if this purchase has subscription-specific fields\n const hasSubscriptionFields =\n ('expirationDateIOS' in purchase && purchase.expirationDateIOS) ||\n 'autoRenewingAndroid' in purchase ||\n ('environmentIOS' in purchase && purchase.environmentIOS === 'Sandbox');\n\n if (!hasSubscriptionFields) {\n return false;\n }\n\n // Check if it's actually active\n if (Platform.OS === 'ios') {\n if ('expirationDateIOS' in purchase && purchase.expirationDateIOS) {\n return purchase.expirationDateIOS > currentTime;\n }\n // For iOS purchases without expiration date (like Sandbox), we consider them active\n // if they have the environmentIOS field and were created recently\n if ('environmentIOS' in purchase && purchase.environmentIOS) {\n const dayInMs = 24 * 60 * 60 * 1000;\n // If no expiration date, consider active if transaction is recent (within 24 hours for Sandbox)\n if (\n !('expirationDateIOS' in purchase) ||\n !purchase.expirationDateIOS\n ) {\n if (\n purchase.environmentIOS === 'Sandbox' &&\n purchase.transactionDate &&\n currentTime - purchase.transactionDate < dayInMs\n ) {\n return true;\n }\n }\n }\n } else if (Platform.OS === 'android') {\n // For Android, if it's in the purchases list, it's active\n return true;\n }\n\n return false;\n });\n\n // Convert to ActiveSubscription format\n for (const purchase of filteredPurchases) {\n const subscription: ActiveSubscription = {\n productId: purchase.productId,\n isActive: true,\n };\n\n // Add platform-specific details\n if (Platform.OS === 'ios') {\n if ('expirationDateIOS' in purchase && purchase.expirationDateIOS) {\n const expirationDate = new Date(purchase.expirationDateIOS);\n subscription.expirationDateIOS = expirationDate;\n\n // Calculate days until expiration (round to nearest day)\n const daysUntilExpiration = Math.round(\n (purchase.expirationDateIOS - currentTime) / (1000 * 60 * 60 * 24),\n );\n subscription.daysUntilExpirationIOS = daysUntilExpiration;\n subscription.willExpireSoon = daysUntilExpiration <= 7;\n }\n\n if ('environmentIOS' in purchase) {\n subscription.environmentIOS = purchase.environmentIOS;\n }\n } else if (Platform.OS === 'android') {\n if ('autoRenewingAndroid' in purchase) {\n subscription.autoRenewingAndroid = purchase.autoRenewingAndroid;\n // If auto-renewing is false, subscription will expire soon\n subscription.willExpireSoon = !purchase.autoRenewingAndroid;\n }\n }\n\n activeSubscriptions.push(subscription);\n }\n\n return activeSubscriptions;\n } catch (error) {\n console.error('Error getting active subscriptions:', error);\n return [];\n }\n};\n\n/**\n * Check if user has any active subscriptions\n * @param subscriptionIds - Optional array of subscription product IDs to check. If not provided, checks all subscriptions.\n * @returns Promise<boolean> true if user has at least one active subscription\n */\nexport const hasActiveSubscriptions = async (\n subscriptionIds?: string[],\n): Promise<boolean> => {\n const subscriptions = await getActiveSubscriptions(subscriptionIds);\n return subscriptions.length > 0;\n};\n"]}
|
package/build/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Product, ProductPurchase, Purchase, PurchaseError, PurchaseResult, Requ
|
|
|
2
2
|
export * from './ExpoIap.types';
|
|
3
3
|
export * from './modules/android';
|
|
4
4
|
export * from './modules/ios';
|
|
5
|
-
export type { AppTransactionIOS } from './types/
|
|
5
|
+
export type { AppTransactionIOS } from './types/ExpoIapIOS.types';
|
|
6
6
|
export { getActiveSubscriptions, hasActiveSubscriptions, type ActiveSubscription, } from './helpers/subscription';
|
|
7
7
|
export declare const PI: any;
|
|
8
8
|
export declare enum IapEvent {
|
|
@@ -217,6 +217,6 @@ export declare const deepLinkToSubscriptions: (options: {
|
|
|
217
217
|
skuAndroid?: string;
|
|
218
218
|
packageNameAndroid?: string;
|
|
219
219
|
}) => Promise<void>;
|
|
220
|
-
export * from './
|
|
220
|
+
export * from './useIAP';
|
|
221
221
|
export * from './utils/errorMapping';
|
|
222
222
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,OAAO,EACP,eAAe,EACf,QAAQ,EACR,aAAa,EACb,cAAc,EACd,wBAAwB,EACxB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,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