expo-iap 2.8.6 → 2.8.8
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 +38 -0
- package/CLAUDE.md +7 -0
- package/android/src/main/java/expo/modules/iap/ExpoIapModule.kt +113 -0
- package/build/helpers/subscription.d.ts +3 -0
- package/build/helpers/subscription.d.ts.map +1 -1
- package/build/helpers/subscription.js +3 -0
- package/build/helpers/subscription.js.map +1 -1
- package/build/index.d.ts +30 -4
- package/build/index.d.ts.map +1 -1
- package/build/index.js +39 -13
- package/build/index.js.map +1 -1
- package/build/modules/ios.d.ts +4 -5
- package/build/modules/ios.d.ts.map +1 -1
- package/build/modules/ios.js +2 -3
- package/build/modules/ios.js.map +1 -1
- package/build/useIAP.d.ts +12 -4
- package/build/useIAP.d.ts.map +1 -1
- package/build/useIAP.js +14 -6
- package/build/useIAP.js.map +1 -1
- package/build/utils/constants.d.ts +4 -0
- package/build/utils/constants.d.ts.map +1 -0
- package/build/utils/constants.js +12 -0
- package/build/utils/constants.js.map +1 -0
- package/ios/ExpoIapModule.swift +102 -150
- package/package.json +3 -2
- package/src/helpers/subscription.ts +6 -0
- package/src/index.ts +48 -13
- package/src/modules/ios.ts +4 -5
- package/src/useIAP.ts +35 -10
- package/src/utils/constants.ts +14 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,43 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
+
## [2.8.8] - 2025-09-05
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Enhanced `ActiveSubscription` interface with backend validation fields:
|
|
8
|
+
- `transactionId` - Transaction identifier for backend validation
|
|
9
|
+
- `purchaseToken` - JWT token (iOS) or purchase token (Android) for backend validation
|
|
10
|
+
- `transactionDate` - Transaction timestamp
|
|
11
|
+
- Return subscription changes from `showManageSubscriptionsIOS()` as Promise data
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- Fixed iOS `getAvailablePurchases({ onlyIncludeActiveItemsIOS: true })` returning expired subscriptions
|
|
16
|
+
- Now correctly uses `Transaction.currentEntitlements` for better performance and accuracy
|
|
17
|
+
- Fixed subscription status matching to specific SKU in `showManageSubscriptionsIOS()`
|
|
18
|
+
- Prevents picking wrong status when multiple statuses exist in a subscription group
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- Removed unnecessary event sending from `getAvailableItems()` - events are only sent from `requestPurchase()`
|
|
23
|
+
- Removed polling logic from subscription status monitoring for cleaner code
|
|
24
|
+
- Updated to comply with OpenIAP v1.1.1 specification
|
|
25
|
+
|
|
26
|
+
## [2.8.7] - 2025-09-03
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
|
|
30
|
+
- `fetchProducts` function following OpenIAP terminology (replaces `requestProducts`)
|
|
31
|
+
|
|
32
|
+
### Deprecated
|
|
33
|
+
|
|
34
|
+
- `requestProducts` - Use `fetchProducts` instead (will be removed in v3.0.0)
|
|
35
|
+
|
|
36
|
+
### Changed
|
|
37
|
+
|
|
38
|
+
- Internal useIAP hook now uses `fetchProducts`
|
|
39
|
+
- Updated documentation and deprecation messages
|
|
40
|
+
|
|
3
41
|
## [2.8.6]
|
|
4
42
|
|
|
5
43
|
### Changed
|
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`)
|
|
@@ -154,7 +154,120 @@ class ExpoIapModule :
|
|
|
154
154
|
promise.resolve(true)
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
AsyncFunction("fetchProducts") { type: String, skuArr: Array<String>, promise: Promise ->
|
|
158
|
+
ensureConnection(promise) { billingClient ->
|
|
159
|
+
val skuList =
|
|
160
|
+
skuArr.map { sku ->
|
|
161
|
+
QueryProductDetailsParams.Product
|
|
162
|
+
.newBuilder()
|
|
163
|
+
.setProductId(sku)
|
|
164
|
+
.setProductType(type)
|
|
165
|
+
.build()
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (skuList.isEmpty()) {
|
|
169
|
+
promise.reject(IapErrorCode.E_EMPTY_SKU_LIST, "The SKU list is empty.", null)
|
|
170
|
+
return@ensureConnection
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
val params =
|
|
174
|
+
QueryProductDetailsParams
|
|
175
|
+
.newBuilder()
|
|
176
|
+
.setProductList(skuList)
|
|
177
|
+
.build()
|
|
178
|
+
|
|
179
|
+
billingClient.queryProductDetailsAsync(params) { billingResult: BillingResult, productDetailsResult: QueryProductDetailsResult ->
|
|
180
|
+
if (billingResult.responseCode != BillingClient.BillingResponseCode.OK) {
|
|
181
|
+
promise.reject(
|
|
182
|
+
IapErrorCode.E_QUERY_PRODUCT,
|
|
183
|
+
"Error querying product details: ${billingResult.debugMessage}",
|
|
184
|
+
null,
|
|
185
|
+
)
|
|
186
|
+
return@queryProductDetailsAsync
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
val productDetailsList = productDetailsResult.productDetailsList ?: emptyList()
|
|
190
|
+
|
|
191
|
+
val items =
|
|
192
|
+
productDetailsList.map { productDetails ->
|
|
193
|
+
skus[productDetails.productId] = productDetails
|
|
194
|
+
|
|
195
|
+
val currency = productDetails.oneTimePurchaseOfferDetails?.priceCurrencyCode
|
|
196
|
+
?: productDetails.subscriptionOfferDetails?.firstOrNull()?.pricingPhases?.pricingPhaseList?.firstOrNull()?.priceCurrencyCode
|
|
197
|
+
?: "Unknown"
|
|
198
|
+
val displayPrice = productDetails.oneTimePurchaseOfferDetails?.formattedPrice
|
|
199
|
+
?: productDetails.subscriptionOfferDetails?.firstOrNull()?.pricingPhases?.pricingPhaseList?.firstOrNull()?.formattedPrice
|
|
200
|
+
?: "N/A"
|
|
201
|
+
|
|
202
|
+
// Prepare reusable data
|
|
203
|
+
val oneTimePurchaseData = productDetails.oneTimePurchaseOfferDetails?.let {
|
|
204
|
+
mapOf(
|
|
205
|
+
"priceCurrencyCode" to it.priceCurrencyCode,
|
|
206
|
+
"formattedPrice" to it.formattedPrice,
|
|
207
|
+
"priceAmountMicros" to it.priceAmountMicros.toString(),
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
val subscriptionOfferData = productDetails.subscriptionOfferDetails?.map { subscriptionOfferDetailsItem ->
|
|
212
|
+
mapOf(
|
|
213
|
+
"basePlanId" to subscriptionOfferDetailsItem.basePlanId,
|
|
214
|
+
"offerId" to subscriptionOfferDetailsItem.offerId,
|
|
215
|
+
"offerToken" to subscriptionOfferDetailsItem.offerToken,
|
|
216
|
+
"offerTags" to subscriptionOfferDetailsItem.offerTags,
|
|
217
|
+
"pricingPhases" to
|
|
218
|
+
mapOf(
|
|
219
|
+
"pricingPhaseList" to
|
|
220
|
+
subscriptionOfferDetailsItem.pricingPhases.pricingPhaseList.map
|
|
221
|
+
{ pricingPhaseItem ->
|
|
222
|
+
mapOf(
|
|
223
|
+
"formattedPrice" to pricingPhaseItem.formattedPrice,
|
|
224
|
+
"priceCurrencyCode" to pricingPhaseItem.priceCurrencyCode,
|
|
225
|
+
"billingPeriod" to pricingPhaseItem.billingPeriod,
|
|
226
|
+
"billingCycleCount" to pricingPhaseItem.billingCycleCount,
|
|
227
|
+
"priceAmountMicros" to
|
|
228
|
+
pricingPhaseItem.priceAmountMicros.toString(),
|
|
229
|
+
"recurrenceMode" to pricingPhaseItem.recurrenceMode,
|
|
230
|
+
)
|
|
231
|
+
},
|
|
232
|
+
),
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Convert Android productType to our expected 'inapp' or 'subs'
|
|
237
|
+
val productType = if (productDetails.productType == BillingClient.ProductType.SUBS) "subs" else "inapp"
|
|
238
|
+
|
|
239
|
+
mapOf(
|
|
240
|
+
"id" to productDetails.productId,
|
|
241
|
+
"title" to productDetails.title,
|
|
242
|
+
"description" to productDetails.description,
|
|
243
|
+
"type" to productType,
|
|
244
|
+
// New field names with Android suffix
|
|
245
|
+
"nameAndroid" to productDetails.name,
|
|
246
|
+
"oneTimePurchaseOfferDetailsAndroid" to oneTimePurchaseData,
|
|
247
|
+
"subscriptionOfferDetailsAndroid" to subscriptionOfferData,
|
|
248
|
+
"platform" to "android",
|
|
249
|
+
"currency" to currency,
|
|
250
|
+
"displayPrice" to displayPrice,
|
|
251
|
+
// START: Deprecated - will be removed in v2.9.0
|
|
252
|
+
// Use nameAndroid instead of displayName
|
|
253
|
+
"displayName" to productDetails.name,
|
|
254
|
+
// Use nameAndroid instead of name
|
|
255
|
+
"name" to productDetails.name,
|
|
256
|
+
// Use oneTimePurchaseOfferDetailsAndroid instead of oneTimePurchaseOfferDetails
|
|
257
|
+
"oneTimePurchaseOfferDetails" to oneTimePurchaseData,
|
|
258
|
+
// Use subscriptionOfferDetailsAndroid instead of subscriptionOfferDetails
|
|
259
|
+
"subscriptionOfferDetails" to subscriptionOfferData,
|
|
260
|
+
// END: Deprecated - will be removed in v2.9.0
|
|
261
|
+
)
|
|
262
|
+
}
|
|
263
|
+
promise.resolve(items)
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
157
268
|
AsyncFunction("requestProducts") { type: String, skuArr: Array<String>, promise: Promise ->
|
|
269
|
+
Log.w("ExpoIap", "WARNING: requestProducts is deprecated. Use fetchProducts instead. The 'request' prefix should only be used for event-based operations. This method will be removed in version 3.0.0.")
|
|
270
|
+
|
|
158
271
|
ensureConnection(promise) { billingClient ->
|
|
159
272
|
val skuList =
|
|
160
273
|
skuArr.map { sku ->
|
|
@@ -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,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,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,CAmG9B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,kBAAkB,MAAM,EAAE,KACzB,OAAO,CAAC,OAAO,CAGjB,CAAC"}
|
|
@@ -56,6 +56,9 @@ export const getActiveSubscriptions = async (subscriptionIds) => {
|
|
|
56
56
|
const subscription = {
|
|
57
57
|
productId: purchase.productId,
|
|
58
58
|
isActive: true,
|
|
59
|
+
transactionId: purchase.transactionId || purchase.id,
|
|
60
|
+
purchaseToken: purchase.purchaseToken,
|
|
61
|
+
transactionDate: purchase.transactionDate,
|
|
59
62
|
};
|
|
60
63
|
// Add platform-specific details
|
|
61
64
|
if (Platform.OS === 'ios') {
|
|
@@ -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;
|
|
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;AAe/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,SAAS,CAAC,EAAE,CAAC;oBAClD,OAAO,KAAK,CAAC;gBACf,CAAC;YACH,CAAC;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AAC,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 transactionId: string; // Transaction identifier for backend validation\n purchaseToken?: string; // JWT token (iOS) or purchase token (Android) for backend validation\n transactionDate: number; // Transaction timestamp\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 transactionId: purchase.transactionId || purchase.id,\n purchaseToken: purchase.purchaseToken,\n transactionDate: purchase.transactionDate,\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
|
@@ -53,27 +53,53 @@ export declare const getProducts: (skus: string[]) => Promise<Product[]>;
|
|
|
53
53
|
export declare const getSubscriptions: (skus: string[]) => Promise<SubscriptionProduct[]>;
|
|
54
54
|
export declare function endConnection(): Promise<boolean>;
|
|
55
55
|
/**
|
|
56
|
-
*
|
|
56
|
+
* Fetch products with unified API (v2.7.0+)
|
|
57
57
|
*
|
|
58
|
-
* @param params - Product
|
|
58
|
+
* @param params - Product fetch configuration
|
|
59
59
|
* @param params.skus - Array of product SKUs to fetch
|
|
60
60
|
* @param params.type - Type of products: 'inapp' for regular products (default) or 'subs' for subscriptions
|
|
61
61
|
*
|
|
62
62
|
* @example
|
|
63
63
|
* ```typescript
|
|
64
64
|
* // Regular products
|
|
65
|
-
* const products = await
|
|
65
|
+
* const products = await fetchProducts({
|
|
66
66
|
* skus: ['product1', 'product2'],
|
|
67
67
|
* type: 'inapp'
|
|
68
68
|
* });
|
|
69
69
|
*
|
|
70
70
|
* // Subscriptions
|
|
71
|
-
* const subscriptions = await
|
|
71
|
+
* const subscriptions = await fetchProducts({
|
|
72
72
|
* skus: ['sub1', 'sub2'],
|
|
73
73
|
* type: 'subs'
|
|
74
74
|
* });
|
|
75
75
|
* ```
|
|
76
76
|
*/
|
|
77
|
+
export declare const fetchProducts: ({ skus, type, }: {
|
|
78
|
+
skus: string[];
|
|
79
|
+
type?: "inapp" | "subs";
|
|
80
|
+
}) => Promise<Product[] | SubscriptionProduct[]>;
|
|
81
|
+
/**
|
|
82
|
+
* @deprecated Use `fetchProducts` instead. This method will be removed in version 3.0.0.
|
|
83
|
+
*
|
|
84
|
+
* The 'request' prefix should only be used for event-based operations that trigger
|
|
85
|
+
* purchase flows. Since this function simply fetches product information, it has been
|
|
86
|
+
* renamed to `fetchProducts` to follow OpenIAP terminology guidelines.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* // Old way (deprecated)
|
|
91
|
+
* const products = await requestProducts({
|
|
92
|
+
* skus: ['com.example.product1'],
|
|
93
|
+
* type: 'inapp'
|
|
94
|
+
* });
|
|
95
|
+
*
|
|
96
|
+
* // New way (recommended)
|
|
97
|
+
* const products = await fetchProducts({
|
|
98
|
+
* skus: ['com.example.product1'],
|
|
99
|
+
* type: 'inapp'
|
|
100
|
+
* });
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
77
103
|
export declare const requestProducts: ({ skus, type, }: {
|
|
78
104
|
skus: string[];
|
|
79
105
|
type?: "inapp" | "subs";
|
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,MAAM,EAAE,KAAmB,CAAC;AAEnC,oBAAY,QAAQ;IAClB,eAAe,qBAAqB;IACpC,aAAa,mBAAmB;IAChC,yFAAyF;IACz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F;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,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
|
@@ -67,13 +67,13 @@ export function initConnection() {
|
|
|
67
67
|
return Promise.resolve(result);
|
|
68
68
|
}
|
|
69
69
|
export const getProducts = async (skus) => {
|
|
70
|
-
console.warn("`getProducts` is deprecated. Use `
|
|
70
|
+
console.warn("`getProducts` is deprecated. Use `fetchProducts({ skus, type: 'inapp' })` instead. This function will be removed in version 3.0.0.");
|
|
71
71
|
if (!skus?.length) {
|
|
72
72
|
return Promise.reject(new Error('"skus" is required'));
|
|
73
73
|
}
|
|
74
74
|
return Platform.select({
|
|
75
75
|
ios: async () => {
|
|
76
|
-
const rawItems = await ExpoIapModule.
|
|
76
|
+
const rawItems = await ExpoIapModule.fetchProducts(skus);
|
|
77
77
|
return rawItems.filter((item) => {
|
|
78
78
|
if (!isProductIOS(item))
|
|
79
79
|
return false;
|
|
@@ -85,20 +85,20 @@ export const getProducts = async (skus) => {
|
|
|
85
85
|
});
|
|
86
86
|
},
|
|
87
87
|
android: async () => {
|
|
88
|
-
const products = await ExpoIapModule.
|
|
88
|
+
const products = await ExpoIapModule.fetchProducts('inapp', skus);
|
|
89
89
|
return products.filter((product) => isProductAndroid(product));
|
|
90
90
|
},
|
|
91
91
|
default: () => Promise.reject(new Error('Unsupported Platform')),
|
|
92
92
|
})();
|
|
93
93
|
};
|
|
94
94
|
export const getSubscriptions = async (skus) => {
|
|
95
|
-
console.warn("`getSubscriptions` is deprecated. Use `
|
|
95
|
+
console.warn("`getSubscriptions` is deprecated. Use `fetchProducts({ skus, type: 'subs' })` instead. This function will be removed in version 3.0.0.");
|
|
96
96
|
if (!skus?.length) {
|
|
97
97
|
return Promise.reject(new Error('"skus" is required'));
|
|
98
98
|
}
|
|
99
99
|
return Platform.select({
|
|
100
100
|
ios: async () => {
|
|
101
|
-
const rawItems = await ExpoIapModule.
|
|
101
|
+
const rawItems = await ExpoIapModule.fetchProducts(skus);
|
|
102
102
|
return rawItems.filter((item) => {
|
|
103
103
|
if (!isProductIOS(item))
|
|
104
104
|
return false;
|
|
@@ -110,7 +110,7 @@ export const getSubscriptions = async (skus) => {
|
|
|
110
110
|
});
|
|
111
111
|
},
|
|
112
112
|
android: async () => {
|
|
113
|
-
const rawItems = await ExpoIapModule.
|
|
113
|
+
const rawItems = await ExpoIapModule.fetchProducts('subs', skus);
|
|
114
114
|
return rawItems.filter((item) => {
|
|
115
115
|
if (!isProductAndroid(item))
|
|
116
116
|
return false;
|
|
@@ -128,33 +128,33 @@ export async function endConnection() {
|
|
|
128
128
|
return ExpoIapModule.endConnection();
|
|
129
129
|
}
|
|
130
130
|
/**
|
|
131
|
-
*
|
|
131
|
+
* Fetch products with unified API (v2.7.0+)
|
|
132
132
|
*
|
|
133
|
-
* @param params - Product
|
|
133
|
+
* @param params - Product fetch configuration
|
|
134
134
|
* @param params.skus - Array of product SKUs to fetch
|
|
135
135
|
* @param params.type - Type of products: 'inapp' for regular products (default) or 'subs' for subscriptions
|
|
136
136
|
*
|
|
137
137
|
* @example
|
|
138
138
|
* ```typescript
|
|
139
139
|
* // Regular products
|
|
140
|
-
* const products = await
|
|
140
|
+
* const products = await fetchProducts({
|
|
141
141
|
* skus: ['product1', 'product2'],
|
|
142
142
|
* type: 'inapp'
|
|
143
143
|
* });
|
|
144
144
|
*
|
|
145
145
|
* // Subscriptions
|
|
146
|
-
* const subscriptions = await
|
|
146
|
+
* const subscriptions = await fetchProducts({
|
|
147
147
|
* skus: ['sub1', 'sub2'],
|
|
148
148
|
* type: 'subs'
|
|
149
149
|
* });
|
|
150
150
|
* ```
|
|
151
151
|
*/
|
|
152
|
-
export const
|
|
152
|
+
export const fetchProducts = async ({ skus, type = 'inapp', }) => {
|
|
153
153
|
if (!skus?.length) {
|
|
154
154
|
throw new Error('No SKUs provided');
|
|
155
155
|
}
|
|
156
156
|
if (Platform.OS === 'ios') {
|
|
157
|
-
const rawItems = await ExpoIapModule.
|
|
157
|
+
const rawItems = await ExpoIapModule.fetchProducts(skus);
|
|
158
158
|
const filteredItems = rawItems.filter((item) => {
|
|
159
159
|
if (!isProductIOS(item))
|
|
160
160
|
return false;
|
|
@@ -169,7 +169,7 @@ export const requestProducts = async ({ skus, type = 'inapp', }) => {
|
|
|
169
169
|
: filteredItems;
|
|
170
170
|
}
|
|
171
171
|
if (Platform.OS === 'android') {
|
|
172
|
-
const items = await ExpoIapModule.
|
|
172
|
+
const items = await ExpoIapModule.fetchProducts(type, skus);
|
|
173
173
|
const filteredItems = items.filter((item) => {
|
|
174
174
|
if (!isProductAndroid(item))
|
|
175
175
|
return false;
|
|
@@ -185,6 +185,32 @@ export const requestProducts = async ({ skus, type = 'inapp', }) => {
|
|
|
185
185
|
}
|
|
186
186
|
throw new Error('Unsupported platform');
|
|
187
187
|
};
|
|
188
|
+
/**
|
|
189
|
+
* @deprecated Use `fetchProducts` instead. This method will be removed in version 3.0.0.
|
|
190
|
+
*
|
|
191
|
+
* The 'request' prefix should only be used for event-based operations that trigger
|
|
192
|
+
* purchase flows. Since this function simply fetches product information, it has been
|
|
193
|
+
* renamed to `fetchProducts` to follow OpenIAP terminology guidelines.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* // Old way (deprecated)
|
|
198
|
+
* const products = await requestProducts({
|
|
199
|
+
* skus: ['com.example.product1'],
|
|
200
|
+
* type: 'inapp'
|
|
201
|
+
* });
|
|
202
|
+
*
|
|
203
|
+
* // New way (recommended)
|
|
204
|
+
* const products = await fetchProducts({
|
|
205
|
+
* skus: ['com.example.product1'],
|
|
206
|
+
* type: 'inapp'
|
|
207
|
+
* });
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
export const requestProducts = async ({ skus, type = 'inapp', }) => {
|
|
211
|
+
console.warn("`requestProducts` is deprecated. Use `fetchProducts` instead. The 'request' prefix should only be used for event-based operations. This method will be removed in version 3.0.0.");
|
|
212
|
+
return fetchProducts({ skus, type });
|
|
213
|
+
};
|
|
188
214
|
/**
|
|
189
215
|
* @deprecated Use `getPurchaseHistories` instead. This function will be removed in version 3.0.0.
|
|
190
216
|
*/
|