expo-iap 2.8.7 → 2.9.0-rc.2
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/CHANGELOG.md +28 -0
- package/CLAUDE.md +7 -0
- package/CONTRIBUTING.md +3 -4
- package/android/src/main/java/expo/modules/iap/ExpoIapModule.kt +7 -7
- package/android/src/main/java/expo/modules/iap/Types.kt +1 -1
- package/build/ExpoIap.types.d.ts +4 -4
- package/build/ExpoIap.types.d.ts.map +1 -1
- package/build/ExpoIap.types.js +3 -0
- package/build/ExpoIap.types.js.map +1 -1
- package/build/helpers/subscription.d.ts.map +1 -1
- package/build/helpers/subscription.js +3 -6
- package/build/helpers/subscription.js.map +1 -1
- package/build/index.d.ts +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +14 -12
- package/build/index.js.map +1 -1
- package/build/modules/android.d.ts.map +1 -1
- package/build/modules/android.js.map +1 -1
- package/build/modules/ios.d.ts.map +1 -1
- package/build/modules/ios.js.map +1 -1
- package/build/types/ExpoIapAndroid.types.d.ts +2 -2
- 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 +3 -3
- package/build/types/ExpoIapIOS.types.d.ts.map +1 -1
- package/build/types/ExpoIapIOS.types.js.map +1 -1
- package/build/useIAP.d.ts.map +1 -1
- package/build/useIAP.js.map +1 -1
- package/ios/ExpoIap.podspec +1 -0
- package/ios/ExpoIapModule.swift +353 -1180
- package/jest.config.js +14 -17
- package/package.json +5 -3
- package/plugin/build/withIAP.d.ts +7 -1
- package/plugin/build/withIAP.js +16 -2
- package/plugin/build/withLocalOpenIAP.d.ts +9 -0
- package/plugin/build/withLocalOpenIAP.js +85 -0
- package/plugin/src/withIAP.ts +21 -2
- package/plugin/src/withLocalOpenIAP.ts +66 -0
- package/plugin/tsconfig.tsbuildinfo +1 -1
- package/src/ExpoIap.types.ts +5 -11
- package/src/helpers/subscription.ts +21 -28
- package/src/index.ts +27 -25
- package/src/modules/android.ts +7 -7
- package/src/modules/ios.ts +11 -5
- package/src/types/ExpoIapAndroid.types.ts +3 -4
- package/src/types/ExpoIapIOS.types.ts +4 -3
- package/src/useIAP.ts +10 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## [2.9.0] - 2025-09-05
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **iOS**: Integrated [OpenIAP Apple](https://github.com/hyodotdev/openiap-apple) v1.1.5
|
|
8
|
+
- Updated types to match [OpenIAP v1.1.0 specification](https://www.openiap.dev/docs/versions#v1-1-0)
|
|
9
|
+
- Enhanced error handling with `PurchaseError` type and native error code mapping
|
|
10
|
+
- New type system: `ProductRequest`, `RequestPurchaseProps`, `ReceiptValidationProps`
|
|
11
|
+
- Improved receipt validation with `ReceiptValidationResult`
|
|
12
|
+
- Root-level type re-exports to remove deep imports (e.g., `ProductAndroid`, `ProductIOS`, `PaymentDiscount`)
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- Updated `serializePurchase` and `serializeProduct` for new OpenIAP structure
|
|
17
|
+
- Updated listener setup to use new OpenIAP methods (`purchaseUpdatedListener`, `purchaseErrorListener`)
|
|
18
|
+
- Added unified `removeAllListeners()` for cleanup
|
|
19
|
+
- Avoid deep imports: consumers can import all public types from `expo-iap` root
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- Fixed duplicate purchase success alerts
|
|
24
|
+
- Fixed restore purchase alerts on screen entry
|
|
25
|
+
- Improved purchase validation logic
|
|
26
|
+
|
|
27
|
+
### Note
|
|
28
|
+
|
|
29
|
+
- Android native module integration with OpenIAP Android planned for v3.0.0
|
|
30
|
+
|
|
3
31
|
## [2.8.7] - 2025-09-03
|
|
4
32
|
|
|
5
33
|
### Added
|
package/CLAUDE.md
CHANGED
|
@@ -93,3 +93,10 @@ For new feature proposals:
|
|
|
93
93
|
2. Get community feedback and consensus
|
|
94
94
|
3. Ensure alignment with OpenIAP standards
|
|
95
95
|
4. Implement following the agreed specification
|
|
96
|
+
|
|
97
|
+
## Documentation Guidelines
|
|
98
|
+
|
|
99
|
+
### Blog Post Conventions
|
|
100
|
+
|
|
101
|
+
- **Title format**: Use version number only (e.g., `v2.8.7 - Feature Description`, not `Expo IAP v2.8.7 - Feature Description`)
|
|
102
|
+
- **Heading format**: Use version number only in headings (e.g., `# v2.8.7 Release Notes`, not `# Expo IAP v2.8.7 Release Notes`)
|
package/CONTRIBUTING.md
CHANGED
|
@@ -47,7 +47,6 @@ This project includes VSCode configurations for easier development:
|
|
|
47
47
|
1. **Install recommended extensions**: When you open the project in VSCode, you'll be prompted to install recommended extensions. Accept to install them.
|
|
48
48
|
|
|
49
49
|
1. **Use Debug Configurations**: Press `F5` or go to Run → Start Debugging and select:
|
|
50
|
-
|
|
51
50
|
- `Debug iOS (Expo)` - Runs the example app on iOS simulator
|
|
52
51
|
- `Debug Android (Expo)` - Runs the example app on Android emulator
|
|
53
52
|
- `iOS + Metro` - Starts Metro bundler and iOS app together
|
|
@@ -183,7 +182,7 @@ bun start
|
|
|
183
182
|
# Run on iOS simulator
|
|
184
183
|
bun run ios
|
|
185
184
|
|
|
186
|
-
# Run on Android emulator
|
|
185
|
+
# Run on Android emulator
|
|
187
186
|
bun run android
|
|
188
187
|
|
|
189
188
|
# Run tests
|
|
@@ -287,12 +286,12 @@ bun run test:coverage
|
|
|
287
286
|
Example test structure:
|
|
288
287
|
|
|
289
288
|
```typescript
|
|
290
|
-
import {render, fireEvent} from '@testing-library/react-native';
|
|
289
|
+
import { render, fireEvent } from '@testing-library/react-native';
|
|
291
290
|
import MyComponent from '../MyComponent';
|
|
292
291
|
|
|
293
292
|
describe('MyComponent', () => {
|
|
294
293
|
it('should render correctly', () => {
|
|
295
|
-
const {getByText} = render(<MyComponent />);
|
|
294
|
+
const { getByText } = render(<MyComponent />);
|
|
296
295
|
expect(getByText('Expected Text')).toBeTruthy();
|
|
297
296
|
});
|
|
298
297
|
});
|
|
@@ -73,7 +73,7 @@ class ExpoIapModule :
|
|
|
73
73
|
error["code"] = errorData.code
|
|
74
74
|
error["message"] = errorData.message
|
|
75
75
|
try {
|
|
76
|
-
sendEvent(
|
|
76
|
+
sendEvent(OpenIapEvent.PURCHASE_ERROR, error.toMap())
|
|
77
77
|
} catch (e: Exception) {
|
|
78
78
|
Log.e(TAG, "Failed to send PURCHASE_ERROR event: ${e.message}")
|
|
79
79
|
}
|
|
@@ -109,7 +109,7 @@ class ExpoIapModule :
|
|
|
109
109
|
}
|
|
110
110
|
promiseItems.add(item.toMap())
|
|
111
111
|
try {
|
|
112
|
-
sendEvent(
|
|
112
|
+
sendEvent(OpenIapEvent.PURCHASE_UPDATED, item.toMap())
|
|
113
113
|
} catch (e: Exception) {
|
|
114
114
|
Log.e(TAG, "Failed to send PURCHASE_UPDATED event: ${e.message}")
|
|
115
115
|
}
|
|
@@ -125,7 +125,7 @@ class ExpoIapModule :
|
|
|
125
125
|
"The purchases are null. This is a normal behavior if you have requested DEFERRED proration. If not please report an issue.",
|
|
126
126
|
)
|
|
127
127
|
try {
|
|
128
|
-
sendEvent(
|
|
128
|
+
sendEvent(OpenIapEvent.PURCHASE_UPDATED, result.toMap())
|
|
129
129
|
} catch (e: Exception) {
|
|
130
130
|
Log.e(TAG, "Failed to send PURCHASE_UPDATED event: ${e.message}")
|
|
131
131
|
}
|
|
@@ -141,7 +141,7 @@ class ExpoIapModule :
|
|
|
141
141
|
"ERROR_CODES" to IapErrorCode.toMap()
|
|
142
142
|
)
|
|
143
143
|
|
|
144
|
-
Events(
|
|
144
|
+
Events(OpenIapEvent.PURCHASE_UPDATED, OpenIapEvent.PURCHASE_ERROR)
|
|
145
145
|
|
|
146
146
|
AsyncFunction("initConnection") { promise: Promise ->
|
|
147
147
|
initBillingClient(promise) { promise.resolve(true) }
|
|
@@ -450,7 +450,7 @@ class ExpoIapModule :
|
|
|
450
450
|
val debugMessage = "The number of skus (${skuArr.size}) must match: the number of offerTokens (${offerTokenArr.size}) for Subscriptions"
|
|
451
451
|
try {
|
|
452
452
|
sendEvent(
|
|
453
|
-
|
|
453
|
+
OpenIapEvent.PURCHASE_ERROR,
|
|
454
454
|
mapOf(
|
|
455
455
|
"debugMessage" to debugMessage,
|
|
456
456
|
"code" to IapErrorCode.E_SKU_OFFER_MISMATCH,
|
|
@@ -472,7 +472,7 @@ class ExpoIapModule :
|
|
|
472
472
|
"The sku was not found. Please fetch products first by calling getItems"
|
|
473
473
|
try {
|
|
474
474
|
sendEvent(
|
|
475
|
-
|
|
475
|
+
OpenIapEvent.PURCHASE_ERROR,
|
|
476
476
|
mapOf(
|
|
477
477
|
"debugMessage" to debugMessage,
|
|
478
478
|
"code" to IapErrorCode.E_SKU_NOT_FOUND,
|
|
@@ -577,7 +577,7 @@ class ExpoIapModule :
|
|
|
577
577
|
}
|
|
578
578
|
|
|
579
579
|
try {
|
|
580
|
-
sendEvent(
|
|
580
|
+
sendEvent(OpenIapEvent.PURCHASE_ERROR, errorMap.toMap())
|
|
581
581
|
} catch (e: Exception) {
|
|
582
582
|
Log.e(TAG, "Failed to send PURCHASE_ERROR event: ${e.message}")
|
|
583
583
|
}
|
package/build/ExpoIap.types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ProductAndroid, PurchaseAndroid, ProductSubscriptionAndroid } from './types/ExpoIapAndroid.types';
|
|
2
|
-
import { ProductIOS, PurchaseIOS, ProductSubscriptionIOS } from './types/ExpoIapIOS.types';
|
|
1
|
+
import type { ProductAndroid, PurchaseAndroid, ProductSubscriptionAndroid } from './types/ExpoIapAndroid.types';
|
|
2
|
+
import type { ProductIOS, PurchaseIOS, ProductSubscriptionIOS } from './types/ExpoIapIOS.types';
|
|
3
3
|
export type ChangeEventPayload = {
|
|
4
4
|
value: string;
|
|
5
5
|
};
|
|
@@ -37,8 +37,8 @@ export type AndroidPlatform = {
|
|
|
37
37
|
};
|
|
38
38
|
export type Product = (ProductAndroid & AndroidPlatform) | (ProductIOS & IosPlatform);
|
|
39
39
|
export type SubscriptionProduct = (ProductSubscriptionAndroid & AndroidPlatform) | (ProductSubscriptionIOS & IosPlatform);
|
|
40
|
-
export
|
|
41
|
-
export
|
|
40
|
+
export * from './types/ExpoIapAndroid.types';
|
|
41
|
+
export * from './types/ExpoIapIOS.types';
|
|
42
42
|
export type Purchase = (PurchaseAndroid & AndroidPlatform) | (PurchaseIOS & IosPlatform);
|
|
43
43
|
/**
|
|
44
44
|
* @deprecated Use `Purchase` instead. This type alias will be removed in v2.9.0.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoIap.types.d.ts","sourceRoot":"","sources":["../src/ExpoIap.types.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ExpoIap.types.d.ts","sourceRoot":"","sources":["../src/ExpoIap.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,0BAA0B,EAC3B,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,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;AAM3C,MAAM,MAAM,aAAa,GAAG;IAC1B,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;IACf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ERROR_CODES } from './ExpoIapModule';
|
|
2
|
+
// Re-export all platform-specific types to avoid deep imports
|
|
3
|
+
export * from './types/ExpoIapAndroid.types';
|
|
4
|
+
export * from './types/ExpoIapIOS.types';
|
|
2
5
|
/**
|
|
3
6
|
* Centralized error codes for expo-iap
|
|
4
7
|
* These are mapped to platform-specific error codes and provide consistent error handling
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoIap.types.js","sourceRoot":"","sources":["../src/ExpoIap.types.ts"],"names":[],"mappings":"AAUA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AAyFnD;;;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,KAAT,SAAS,QAyBpB;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,GAAG,EAAE;QACH,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC;QACxB,CAAC,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC;QAC9B,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC/B,CAAC,SAAS,CAA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GAAG;IAC5B;;;;OAIG;IACH,kBAAkB,EAAE,CAAC,SAAoB,EAAU,EAAE;QACnD,OAAO,kBAAkB,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC;IACpD,CAAC;IAED;;;;;OAKG;IACH,gBAAgB,EAAE,CAChB,YAA6B,EAC7B,QAA2B,EAChB,EAAE;QACb,MAAM,OAAO,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAE3C,KAAK,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9D,IAAI,UAAU,KAAK,YAAY,EAAE,CAAC;gBAChC,OAAO,SAAsB,CAAC;YAChC,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC,SAAS,CAAC;IAC7B,CAAC;IAED;;;;;OAKG;IACH,cAAc,EAAE,CACd,SAAoB,EACpB,QAA2B,EACV,EAAE;QACnB,OAAO,CACL,gBAAgB,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC;YACrC,CAAC,QAAQ,KAAK,KAAK,CAAC,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","sourcesContent":["import {\n ProductAndroid,\n PurchaseAndroid,\n ProductSubscriptionAndroid,\n} from './types/ExpoIapAndroid.types';\nimport {\n ProductIOS,\n PurchaseIOS,\n ProductSubscriptionIOS,\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\n// =============================================================================\n// COMMON TYPES (Base types shared across all platforms)\n// =============================================================================\n\nexport type ProductCommon = {\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 debugDescription?: string;\n platform?: string;\n};\n\nexport type PurchaseCommon = {\n id: string; // Transaction identifier - used by finishTransaction\n productId: string; // Product identifier - which product was purchased\n ids?: string[]; // Product identifiers for purchases that include multiple products\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 platform?: string;\n};\n\nexport type ProductSubscriptionCommon = ProductCommon & {\n type: 'subs';\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 | (ProductSubscriptionAndroid & AndroidPlatform)\n | (ProductSubscriptionIOS & IosPlatform);\n\n// Re-export platform-specific types\nexport type {\n PurchaseAndroid,\n ProductSubscriptionAndroid,\n} from './types/ExpoIapAndroid.types';\nexport type {\n PurchaseIOS,\n ProductSubscriptionIOS,\n} from './types/ExpoIapIOS.types';\n\n// Unified purchase type for both products and subscriptions\nexport type Purchase =\n | (PurchaseAndroid & AndroidPlatform)\n | (PurchaseIOS & IosPlatform);\n\n// Legacy type aliases - deprecated, use Purchase instead\n/**\n * @deprecated Use `Purchase` instead. This type alias will be removed in v2.9.0.\n */\nexport type ProductPurchase = Purchase;\n/**\n * @deprecated Use `Purchase` instead. This type alias will be removed in v2.9.0.\n */\nexport type SubscriptionPurchase = Purchase;\n\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 andDangerouslyFinishTransactionAutomatically?: 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 andDangerouslyFinishTransactionAutomatically?: 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"]}
|
|
1
|
+
{"version":3,"file":"ExpoIap.types.js","sourceRoot":"","sources":["../src/ExpoIap.types.ts"],"names":[],"mappings":"AAUA,OAAO,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AAqDnD,8DAA8D;AAC9D,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AA4BzC;;;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,KAAT,SAAS,QAyBpB;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,GAAG,EAAE;QACH,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC;QACxB,CAAC,SAAS,CAAC,eAAe,CAAC,EAAE,CAAC;QAC9B,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC/B,CAAC,SAAS,CAAC,YAAY,CAAC,EAAE,CAAC;Q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kBAAkB,EAAE,CAAC,SAAoB,EAAU,EAAE;QACnD,OAAO,kBAAkB,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC;IACpD,CAAC;IAED;;;;;OAKG;IACH,gBAAgB,EAAE,CAChB,YAA6B,EAC7B,QAA2B,EAChB,EAAE;QACb,MAAM,OAAO,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;QAE3C,KAAK,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YAC9D,IAAI,UAAU,KAAK,YAAY,EAAE,CAAC;gBAChC,OAAO,SAAsB,CAAC;YAChC,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC,SAAS,CAAC;IAC7B,CAAC;IAED;;;;;OAKG;IACH,cAAc,EAAE,CACd,SAAoB,EACpB,QAA2B,EACV,EAAE;QACnB,OAAO,CACL,gBAAgB,CAAC,QAAQ,CAAC,CAAC,SAAS,CAAC;YACrC,CAAC,QAAQ,KAAK,KAAK,CAAC,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","sourcesContent":["import type {\n ProductAndroid,\n PurchaseAndroid,\n ProductSubscriptionAndroid,\n} from './types/ExpoIapAndroid.types';\nimport type {\n ProductIOS,\n PurchaseIOS,\n ProductSubscriptionIOS,\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\n// =============================================================================\n// COMMON TYPES (Base types shared across all platforms)\n// =============================================================================\n\nexport type ProductCommon = {\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 debugDescription?: string;\n platform?: string;\n};\n\nexport type PurchaseCommon = {\n id: string; // Transaction identifier - used by finishTransaction\n productId: string; // Product identifier - which product was purchased\n ids?: string[]; // Product identifiers for purchases that include multiple products\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 platform?: string;\n};\n\nexport type ProductSubscriptionCommon = ProductCommon & {\n type: 'subs';\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 | (ProductSubscriptionAndroid & AndroidPlatform)\n | (ProductSubscriptionIOS & IosPlatform);\n\n// Re-export all platform-specific types to avoid deep imports\nexport * from './types/ExpoIapAndroid.types';\nexport * from './types/ExpoIapIOS.types';\n\n// Unified purchase type for both products and subscriptions\nexport type Purchase =\n | (PurchaseAndroid & AndroidPlatform)\n | (PurchaseIOS & IosPlatform);\n\n// Legacy type aliases - deprecated, use Purchase instead\n/**\n * @deprecated Use `Purchase` instead. This type alias will be removed in v2.9.0.\n */\nexport type ProductPurchase = Purchase;\n/**\n * @deprecated Use `Purchase` instead. This type alias will be removed in v2.9.0.\n */\nexport type SubscriptionPurchase = Purchase;\n\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 andDangerouslyFinishTransactionAutomatically?: 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 andDangerouslyFinishTransactionAutomatically?: 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"]}
|
|
@@ -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,CAyF9B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,kBAAkB,MAAM,EAAE,KACzB,OAAO,CAAC,OAAO,CAGjB,CAAC"}
|
|
@@ -20,7 +20,7 @@ export const getActiveSubscriptions = async (subscriptionIds) => {
|
|
|
20
20
|
}
|
|
21
21
|
// Check if this purchase has subscription-specific fields
|
|
22
22
|
const hasSubscriptionFields = ('expirationDateIOS' in purchase && purchase.expirationDateIOS) ||
|
|
23
|
-
'autoRenewingAndroid' in purchase ||
|
|
23
|
+
('autoRenewingAndroid' in purchase) ||
|
|
24
24
|
('environmentIOS' in purchase && purchase.environmentIOS === 'Sandbox');
|
|
25
25
|
if (!hasSubscriptionFields) {
|
|
26
26
|
return false;
|
|
@@ -35,11 +35,8 @@ export const getActiveSubscriptions = async (subscriptionIds) => {
|
|
|
35
35
|
if ('environmentIOS' in purchase && purchase.environmentIOS) {
|
|
36
36
|
const dayInMs = 24 * 60 * 60 * 1000;
|
|
37
37
|
// If no expiration date, consider active if transaction is recent (within 24 hours for Sandbox)
|
|
38
|
-
if (!('expirationDateIOS' in purchase) ||
|
|
39
|
-
|
|
40
|
-
if (purchase.environmentIOS === 'Sandbox' &&
|
|
41
|
-
purchase.transactionDate &&
|
|
42
|
-
currentTime - purchase.transactionDate < dayInMs) {
|
|
38
|
+
if (!('expirationDateIOS' in purchase) || !purchase.expirationDateIOS) {
|
|
39
|
+
if (purchase.environmentIOS === 'Sandbox' && purchase.transactionDate && (currentTime - purchase.transactionDate) < dayInMs) {
|
|
43
40
|
return true;
|
|
44
41
|
}
|
|
45
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../src/helpers/subscription.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../src/helpers/subscription.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAYjD;;;;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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AK,SAAS,EAAE,CAAC;gBACrC,IAAI,qBAAqB,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 (!('expirationDateIOS' in purchase) || !purchase.expirationDateIOS) {\n if (purchase.environmentIOS === 'Sandbox' && purchase.transactionDate && (currentTime - purchase.transactionDate) < dayInMs) {\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};"]}
|
package/build/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export * from './modules/ios';
|
|
|
5
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
|
-
export declare enum
|
|
8
|
+
export declare enum OpenIapEvent {
|
|
9
9
|
PurchaseUpdated = "purchase-updated",
|
|
10
10
|
PurchaseError = "purchase-error",
|
|
11
11
|
/** @deprecated Use PurchaseUpdated instead. This will be removed in a future version. */
|
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,QAAQ,EACR,aAAa,EAEb,cAAc,EACd,wBAAwB,EACxB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,iBAAiB,CAAC;AAKzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,YAAY,EAAC,iBAAiB,EAAC,MAAM,0BAA0B,CAAC;AAGhE,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,KAAK,kBAAkB,GACxB,MAAM,wBAAwB,CAAC;AAGhC,eAAO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AgB,QAAO,OAAO,CAAC,MAAM,CAMjD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,QAAO,OAAO,CAAC,MAAM,CAK9C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAC1B,KAAK,MAAM,EACX,iBAAiB;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,KACA,OAAO,CAAC,GAAG,CAwBb,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,uBAAuB,GAAI,SAAS;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,KAAG,OAAO,CAAC,IAAI,CA2Bf,CAAC;AAEF,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC"}
|
package/build/index.js
CHANGED
|
@@ -15,25 +15,25 @@ export * from './modules/ios';
|
|
|
15
15
|
export { getActiveSubscriptions, hasActiveSubscriptions, } from './helpers/subscription';
|
|
16
16
|
// Get the native constant value
|
|
17
17
|
export const PI = ExpoIapModule.PI;
|
|
18
|
-
export var
|
|
19
|
-
(function (
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
export var OpenIapEvent;
|
|
19
|
+
(function (OpenIapEvent) {
|
|
20
|
+
OpenIapEvent["PurchaseUpdated"] = "purchase-updated";
|
|
21
|
+
OpenIapEvent["PurchaseError"] = "purchase-error";
|
|
22
22
|
/** @deprecated Use PurchaseUpdated instead. This will be removed in a future version. */
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})(
|
|
23
|
+
OpenIapEvent["TransactionIapUpdated"] = "iap-transaction-updated";
|
|
24
|
+
OpenIapEvent["PromotedProductIOS"] = "promoted-product-ios";
|
|
25
|
+
})(OpenIapEvent || (OpenIapEvent = {}));
|
|
26
26
|
export function setValueAsync(value) {
|
|
27
27
|
return ExpoIapModule.setValueAsync(value);
|
|
28
28
|
}
|
|
29
29
|
// Ensure the emitter has proper EventEmitter interface
|
|
30
30
|
export const emitter = (ExpoIapModule || NativeModulesProxy.ExpoIap);
|
|
31
31
|
export const purchaseUpdatedListener = (listener) => {
|
|
32
|
-
const emitterSubscription = emitter.addListener(
|
|
32
|
+
const emitterSubscription = emitter.addListener(OpenIapEvent.PurchaseUpdated, listener);
|
|
33
33
|
return emitterSubscription;
|
|
34
34
|
};
|
|
35
35
|
export const purchaseErrorListener = (listener) => {
|
|
36
|
-
return emitter.addListener(
|
|
36
|
+
return emitter.addListener(OpenIapEvent.PurchaseError, listener);
|
|
37
37
|
};
|
|
38
38
|
/**
|
|
39
39
|
* iOS-only listener for App Store promoted product events.
|
|
@@ -60,7 +60,7 @@ export const promotedProductListenerIOS = (listener) => {
|
|
|
60
60
|
console.warn('promotedProductListenerIOS: This listener is only available on iOS');
|
|
61
61
|
return { remove: () => { } };
|
|
62
62
|
}
|
|
63
|
-
return emitter.addListener(
|
|
63
|
+
return emitter.addListener(OpenIapEvent.PromotedProductIOS, listener);
|
|
64
64
|
};
|
|
65
65
|
export function initConnection() {
|
|
66
66
|
const result = ExpoIapModule.initConnection();
|
|
@@ -305,7 +305,9 @@ export const requestPurchase = (requestObj) => {
|
|
|
305
305
|
return (async () => {
|
|
306
306
|
const offer = offerToRecordIOS(withOffer);
|
|
307
307
|
const purchase = await ExpoIapModule.requestPurchase(sku, andDangerouslyFinishTransactionAutomatically, appAccountToken, quantity ?? -1, offer);
|
|
308
|
-
return type === 'inapp'
|
|
308
|
+
return type === 'inapp'
|
|
309
|
+
? purchase
|
|
310
|
+
: purchase;
|
|
309
311
|
})();
|
|
310
312
|
}
|
|
311
313
|
if (Platform.OS === 'android') {
|
|
@@ -419,7 +421,7 @@ export const getStorefrontIOS = () => {
|
|
|
419
421
|
console.warn('getStorefrontIOS: This method is only available on iOS');
|
|
420
422
|
return Promise.resolve('');
|
|
421
423
|
}
|
|
422
|
-
return ExpoIapModule.
|
|
424
|
+
return ExpoIapModule.getStorefrontIOS();
|
|
423
425
|
};
|
|
424
426
|
/**
|
|
425
427
|
* @deprecated Use `getStorefrontIOS` instead. This function will be removed in version 3.0.0.
|