react-native-iap 15.6.0 → 15.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +28 -4
  2. package/android/src/main/java/com/margelo/nitro/iap/RnIapLog.kt +13 -0
  3. package/ios/HybridRnIap.swift +25 -4
  4. package/ios/RnIapHelper.swift +3 -2
  5. package/ios/RnIapLog.swift +14 -0
  6. package/lib/module/hooks/useIAP.js.map +1 -1
  7. package/lib/module/index.js +72 -30
  8. package/lib/module/index.js.map +1 -1
  9. package/lib/module/index.kepler.js +71 -5
  10. package/lib/module/index.kepler.js.map +1 -1
  11. package/lib/module/kit-api.js +78 -3
  12. package/lib/module/kit-api.js.map +1 -1
  13. package/lib/module/types.js +29 -25
  14. package/lib/module/types.js.map +1 -1
  15. package/lib/module/utils/deprecation.js +15 -0
  16. package/lib/module/utils/deprecation.js.map +1 -0
  17. package/lib/module/utils/platform-request.js +28 -0
  18. package/lib/module/utils/platform-request.js.map +1 -0
  19. package/lib/module/utils/type-bridge.js +9 -4
  20. package/lib/module/utils/type-bridge.js.map +1 -1
  21. package/lib/module/vega-adapter.js +31 -22
  22. package/lib/module/vega-adapter.js.map +1 -1
  23. package/lib/typescript/src/hooks/useIAP.d.ts +14 -2
  24. package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -1
  25. package/lib/typescript/src/index.d.ts +37 -12
  26. package/lib/typescript/src/index.d.ts.map +1 -1
  27. package/lib/typescript/src/index.kepler.d.ts +49 -4
  28. package/lib/typescript/src/index.kepler.d.ts.map +1 -1
  29. package/lib/typescript/src/kit-api.d.ts +18 -8
  30. package/lib/typescript/src/kit-api.d.ts.map +1 -1
  31. package/lib/typescript/src/specs/RnIap.nitro.d.ts +24 -6
  32. package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
  33. package/lib/typescript/src/types.d.ts +105 -176
  34. package/lib/typescript/src/types.d.ts.map +1 -1
  35. package/lib/typescript/src/utils/deprecation.d.ts +3 -0
  36. package/lib/typescript/src/utils/deprecation.d.ts.map +1 -0
  37. package/lib/typescript/src/utils/platform-request.d.ts +12 -0
  38. package/lib/typescript/src/utils/platform-request.d.ts.map +1 -0
  39. package/lib/typescript/src/utils/type-bridge.d.ts.map +1 -1
  40. package/lib/typescript/src/vega-adapter.d.ts +1 -0
  41. package/lib/typescript/src/vega-adapter.d.ts.map +1 -1
  42. package/nitrogen/generated/android/c++/JNitroPurchase.hpp +5 -1
  43. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroPurchase.kt +7 -2
  44. package/nitrogen/generated/ios/swift/NitroPurchase.swift +39 -2
  45. package/nitrogen/generated/shared/c++/NitroPurchase.hpp +5 -1
  46. package/openiap-versions.json +3 -3
  47. package/package.json +1 -1
  48. package/src/hooks/useIAP.ts +14 -2
  49. package/src/index.kepler.ts +82 -8
  50. package/src/index.ts +104 -47
  51. package/src/kit-api.ts +136 -13
  52. package/src/specs/RnIap.nitro.ts +24 -6
  53. package/src/types.ts +116 -204
  54. package/src/utils/deprecation.ts +16 -0
  55. package/src/utils/platform-request.ts +37 -0
  56. package/src/utils/type-bridge.ts +20 -4
  57. package/src/vega-adapter.ts +46 -24
  58. package/lib/module/hooks/useWebhookEvents.js +0 -113
  59. package/lib/module/hooks/useWebhookEvents.js.map +0 -1
  60. package/lib/module/webhook-client.js +0 -164
  61. package/lib/module/webhook-client.js.map +0 -1
  62. package/lib/typescript/src/hooks/useWebhookEvents.d.ts +0 -55
  63. package/lib/typescript/src/hooks/useWebhookEvents.d.ts.map +0 -1
  64. package/lib/typescript/src/webhook-client.d.ts +0 -82
  65. package/lib/typescript/src/webhook-client.d.ts.map +0 -1
  66. package/src/hooks/useWebhookEvents.ts +0 -180
  67. package/src/webhook-client.ts +0 -312
@@ -3,6 +3,7 @@ import type {
3
3
  MutationField,
4
4
  Product,
5
5
  ProductQueryType,
6
+ ProductRequest,
6
7
  ProductSubscription,
7
8
  Purchase,
8
9
  PurchaseError,
@@ -25,16 +26,19 @@ import {
25
26
  validateNitroProduct,
26
27
  validateNitroPurchase,
27
28
  } from './utils/type-bridge';
29
+ import {warnLegacyOnce} from './utils/deprecation';
30
+ import {selectCanonicalPlatformRequest} from './utils/platform-request';
28
31
 
29
32
  export * from './types';
30
33
  export * from './utils/error';
31
34
  export * from './vega';
32
35
  export {useIAP, type UseIapOptions} from './hooks/useIAP';
33
- export {connectWebhookStream, parseWebhookEventData} from './webhook-client';
34
36
  export {kitApi, KitApiError} from './kit-api';
35
37
  export type {
36
38
  EntitlementsResponse,
37
39
  KitApiOptions,
40
+ KitClientPayloadCache,
41
+ KitClientPayloadOptions,
38
42
  KitClientPayloadResponse,
39
43
  KitProduct,
40
44
  KitProductClientPayload,
@@ -46,8 +50,17 @@ export type {
46
50
  StatusResponse,
47
51
  } from './kit-api';
48
52
 
53
+ /**
54
+ * Product type accepted by the Amazon Vega entry point.
55
+ *
56
+ * Compatibility note: the `'inapp'` member is deprecated. Use `'in-app'`
57
+ * instead; the alias will be removed in react-native-iap 16.0.0.
58
+ */
49
59
  export type ProductTypeInput = 'inapp' | 'in-app' | 'subs';
50
60
 
61
+ const LEGACY_INAPP_WARNING =
62
+ "[react-native-iap] `type: 'inapp'` is deprecated and will be removed in react-native-iap 16.0.0. Use 'in-app' instead.";
63
+
51
64
  export interface EventSubscription {
52
65
  remove(): void;
53
66
  }
@@ -80,7 +93,10 @@ const normalizeProductQueryType = (
80
93
  ): ProductTypeInput | 'all' => {
81
94
  if (type === 'subs') return 'subs';
82
95
  if (type === 'all') return 'all';
83
- return 'inapp';
96
+ if (type === 'inapp') {
97
+ warnLegacyOnce('product-type.inapp', LEGACY_INAPP_WARNING);
98
+ }
99
+ return 'in-app';
84
100
  };
85
101
 
86
102
  const mapProducts = (
@@ -113,13 +129,16 @@ export const endConnection: MutationField<'endConnection'> = async () => {
113
129
  return getModule().endConnection();
114
130
  };
115
131
 
116
- export const fetchProducts: QueryField<'fetchProducts'> = async (request) => {
132
+ export const fetchProducts = async (
133
+ request: Omit<ProductRequest, 'type'> & {
134
+ type?: ProductQueryType | ProductTypeInput | null;
135
+ },
136
+ ): ReturnType<QueryField<'fetchProducts'>> => {
117
137
  const {skus, type} = request;
118
138
  const normalizedType = normalizeProductQueryType(type);
119
139
  const nitroProducts = await getModule().fetchProducts(skus, normalizedType);
120
140
  return mapProducts(nitroProducts, normalizedType) as
121
- | Product[]
122
- | ProductSubscription[];
141
+ Product[] | ProductSubscription[];
123
142
  };
124
143
 
125
144
  export const requestPurchase: MutationField<'requestPurchase'> = async (
@@ -129,8 +148,19 @@ export const requestPurchase: MutationField<'requestPurchase'> = async (
129
148
  | RequestPurchasePropsByPlatforms
130
149
  | RequestSubscriptionPropsByPlatforms
131
150
  | undefined;
132
- const androidRequest =
133
- perPlatformRequest?.google ?? perPlatformRequest?.android;
151
+ const selection = perPlatformRequest
152
+ ? selectCanonicalPlatformRequest<
153
+ | RequestPurchasePropsByPlatforms['google']
154
+ | RequestSubscriptionPropsByPlatforms['google']
155
+ >(perPlatformRequest, 'google', 'android')
156
+ : {usesLegacyKey: false, value: undefined};
157
+ if (selection.usesLegacyKey && selection.value != null) {
158
+ warnLegacyOnce(
159
+ 'request-purchase.android',
160
+ '[react-native-iap] `request.android` is deprecated and will be removed in react-native-iap 16.0.0. Use `request.google` instead.',
161
+ );
162
+ }
163
+ const androidRequest = selection.value;
134
164
 
135
165
  if (!androidRequest?.skus?.length) {
136
166
  throw new Error(
@@ -140,7 +170,6 @@ export const requestPurchase: MutationField<'requestPurchase'> = async (
140
170
 
141
171
  const nitroRequest: NitroPurchaseRequest = {
142
172
  google: androidRequest,
143
- android: androidRequest,
144
173
  };
145
174
  const result = await getModule().requestPurchase(nitroRequest);
146
175
  if (!Array.isArray(result)) return null;
@@ -247,11 +276,20 @@ export const verifyPurchaseWithProvider: MutationField<
247
276
  >;
248
277
  };
249
278
 
279
+ /**
280
+ * @deprecated Use `verifyPurchase` instead. This compatibility operation will
281
+ * be removed in react-native-iap 16.0.0.
282
+ */
250
283
  export const validateReceipt: MutationField<'validateReceipt'> = async () => {
251
284
  return unsupported('validateReceipt');
252
285
  };
253
286
 
254
287
  export const verifyPurchase: MutationField<'verifyPurchase'> = validateReceipt;
288
+
289
+ /**
290
+ * @deprecated Use `verifyPurchase` instead. This iOS compatibility operation
291
+ * will be removed in react-native-iap 16.0.0.
292
+ */
255
293
  export const validateReceiptIOS: QueryField<'validateReceiptIOS'> = async () =>
256
294
  unsupported('validateReceiptIOS');
257
295
  export const syncIOS: MutationField<'syncIOS'> = async () =>
@@ -262,7 +300,18 @@ export const getAppTransactionIOS: QueryField<
262
300
  export const getPromotedProductIOS: QueryField<
263
301
  'getPromotedProductIOS'
264
302
  > = async () => null;
303
+
304
+ /**
305
+ * @deprecated Use `getPromotedProductIOS` instead. This compatibility alias
306
+ * will be removed in react-native-iap 16.0.0.
307
+ */
265
308
  export const requestPromotedProductIOS = getPromotedProductIOS;
309
+
310
+ /**
311
+ * @deprecated Use `promotedProductListenerIOS` followed by `requestPurchase`
312
+ * instead. This compatibility operation will be removed in react-native-iap
313
+ * 16.0.0.
314
+ */
266
315
  export const requestPurchaseOnPromotedProductIOS = async (): Promise<void> =>
267
316
  unsupported('requestPurchaseOnPromotedProductIOS');
268
317
  export const showManageSubscriptionsIOS: MutationField<
@@ -291,19 +340,44 @@ export const consumePurchaseAndroid: MutationField<
291
340
  > = async (purchaseToken) => {
292
341
  return getVegaModule().consumePurchaseAndroid(purchaseToken);
293
342
  };
343
+
344
+ /**
345
+ * @deprecated Use `acknowledgePurchaseAndroid` instead. This alias will be
346
+ * removed in react-native-iap 16.0.0.
347
+ */
294
348
  export const acknowledgePurchase = acknowledgePurchaseAndroid;
349
+
350
+ /**
351
+ * @deprecated Use `consumePurchaseAndroid` instead. This alias will be removed
352
+ * in react-native-iap 16.0.0.
353
+ */
295
354
  export const consumePurchase = consumePurchaseAndroid;
296
355
 
297
356
  export const openRedeemOfferCodeAndroid: MutationField<
298
357
  'openRedeemOfferCodeAndroid'
299
358
  > = async () => false;
300
359
 
360
+ /**
361
+ * @deprecated Use `isBillingProgramAvailableAndroid('external-offer')`
362
+ * instead. Scheduled for removal in react-native-iap 16.0.0.
363
+ */
301
364
  export const checkAlternativeBillingAvailabilityAndroid: MutationField<
302
365
  'checkAlternativeBillingAvailabilityAndroid'
303
366
  > = async () => unsupported('checkAlternativeBillingAvailabilityAndroid');
367
+
368
+ /**
369
+ * @deprecated Use `launchExternalLinkAndroid` instead. Scheduled for removal
370
+ * in react-native-iap 16.0.0.
371
+ */
304
372
  export const showAlternativeBillingDialogAndroid: MutationField<
305
373
  'showAlternativeBillingDialogAndroid'
306
374
  > = async () => unsupported('showAlternativeBillingDialogAndroid');
375
+
376
+ /**
377
+ * @deprecated Use `createBillingProgramReportingDetailsAndroid` with the
378
+ * external-offer program instead. Scheduled for removal in react-native-iap
379
+ * 16.0.0.
380
+ */
307
381
  export const createAlternativeBillingTokenAndroid: MutationField<
308
382
  'createAlternativeBillingTokenAndroid'
309
383
  > = async () => unsupported('createAlternativeBillingTokenAndroid');
package/src/index.ts CHANGED
@@ -57,6 +57,8 @@ import {
57
57
  DUPLICATE_PURCHASE_CODE,
58
58
  } from './utils/errorMapping';
59
59
  import {RnIapConsole} from './utils/debug';
60
+ import {warnLegacyOnce} from './utils/deprecation';
61
+ import {selectCanonicalPlatformRequest} from './utils/platform-request';
60
62
  import {getSuccessFromPurchaseVariant} from './utils/purchase';
61
63
  import {parseAppTransactionPayload} from './utils';
62
64
  import {getVegaIapModule, isVegaOS} from './vega';
@@ -91,10 +93,16 @@ export * from './types';
91
93
  export * from './utils/error';
92
94
  export * from './vega';
93
95
 
96
+ /**
97
+ * Product type accepted by public query and purchase helpers.
98
+ *
99
+ * Compatibility note: the `'inapp'` member is deprecated. Use `'in-app'`
100
+ * instead; the alias will be removed in react-native-iap 16.0.0.
101
+ */
94
102
  export type ProductTypeInput = 'inapp' | 'in-app' | 'subs';
95
103
 
96
104
  const LEGACY_INAPP_WARNING =
97
- "[react-native-iap] `type: 'inapp'` is deprecated and will be removed in a future major version. Use 'in-app' instead.";
105
+ "[react-native-iap] `type: 'inapp'` is deprecated and will be removed in react-native-iap 16.0.0. Use 'in-app' instead.";
98
106
 
99
107
  type NitroPurchaseRequest = Parameters<RnIap['requestPurchase']>[0];
100
108
  type NitroAvailablePurchasesOptions = NonNullable<
@@ -148,23 +156,11 @@ export interface EventSubscription {
148
156
 
149
157
  // Export hooks
150
158
  export {useIAP} from './hooks/useIAP';
151
- export {useWebhookEvents} from './hooks/useWebhookEvents';
152
- export type {
153
- UseWebhookEventsOptions,
154
- UseWebhookEventsResult,
155
- } from './hooks/useWebhookEvents';
156
- export {connectWebhookStream, parseWebhookEventData} from './webhook-client';
157
- export type {
158
- WebhookEventPayload,
159
- WebhookEventStream,
160
- WebhookEventType as WebhookEventTypeName,
161
- WebhookListener,
162
- WebhookListenerError,
163
- WebhookListenerOptions,
164
- } from './webhook-client';
165
159
  export {kitApi, KitApiError} from './kit-api';
166
160
  export type {
167
161
  KitApiOptions,
162
+ KitClientPayloadCache,
163
+ KitClientPayloadOptions,
168
164
  KitClientPayloadResponse,
169
165
  KitProduct,
170
166
  KitProductClientPayload,
@@ -879,8 +875,7 @@ export const fetchProducts: QueryField<'fetchProducts'> = async (request) => {
879
875
 
880
876
  if (normalizedType === 'all') {
881
877
  const converted = (await fetchAndConvert('all')) as (
882
- | Product
883
- | ProductSubscription
878
+ Product | ProductSubscription
884
879
  )[];
885
880
 
886
881
  RnIapConsole.debug(
@@ -1112,6 +1107,10 @@ export const getPromotedProductIOS: QueryField<
1112
1107
  }
1113
1108
  };
1114
1109
 
1110
+ /**
1111
+ * @deprecated Use `getPromotedProductIOS` instead. This compatibility alias
1112
+ * will be removed in react-native-iap 16.0.0.
1113
+ */
1115
1114
  export const requestPromotedProductIOS = getPromotedProductIOS;
1116
1115
 
1117
1116
  /**
@@ -1126,6 +1125,8 @@ export const requestPromotedProductIOS = getPromotedProductIOS;
1126
1125
  * ```
1127
1126
  *
1128
1127
  * @see {@link https://openiap.dev/docs/apis/ios/get-storefront-ios}
1128
+ * @deprecated Use `getStorefront` instead. Scheduled for removal in
1129
+ * react-native-iap 16.0.0.
1129
1130
  */
1130
1131
  export const getStorefrontIOS: QueryField<'getStorefrontIOS'> = async () => {
1131
1132
  if (Platform.OS !== 'ios') {
@@ -1529,13 +1530,21 @@ export const getReceiptDataIOS: QueryField<'getReceiptDataIOS'> = async () => {
1529
1530
  }
1530
1531
  };
1531
1532
 
1533
+ /**
1534
+ * Legacy alias for `getReceiptDataIOS`.
1535
+ *
1536
+ * @deprecated Use `getReceiptDataIOS` for the cumulative App Store receipt or
1537
+ * `getTransactionJwsIOS(productId)` for one transaction. This alias will be
1538
+ * removed in react-native-iap 16.0.0.
1539
+ */
1532
1540
  export const getReceiptIOS = async (): Promise<string> => {
1533
1541
  if (Platform.OS !== 'ios') {
1534
1542
  throw new Error('getReceiptIOS is only available on iOS');
1535
1543
  }
1536
1544
 
1537
1545
  RnIapConsole.warn(
1538
- '[getReceiptIOS] ⚠️ iOS receipts contain ALL transactions, not just the latest one. ' +
1546
+ '[getReceiptIOS] is deprecated and will be removed in react-native-iap 16.0.0. ' +
1547
+ 'Use getReceiptDataIOS() for the cumulative receipt. iOS receipts contain ALL transactions, not just the latest one. ' +
1539
1548
  'For individual purchase validation, use getTransactionJwsIOS(productId) instead. ' +
1540
1549
  'See: https://react-native-iap.hyo.dev/docs/guides/receipt-validation',
1541
1550
  );
@@ -1799,19 +1808,22 @@ export const requestPurchase: MutationField<'requestPurchase'> = async (
1799
1808
  throw new Error('Missing purchase request configuration');
1800
1809
  }
1801
1810
 
1811
+ const iosRequestSource =
1812
+ Platform.OS === 'ios'
1813
+ ? selectApplePurchaseRequest(perPlatformRequest)
1814
+ : undefined;
1815
+ const androidRequestSource = isAndroidStoreRuntime()
1816
+ ? selectGooglePurchaseRequest(perPlatformRequest)
1817
+ : undefined;
1818
+
1802
1819
  if (Platform.OS === 'ios') {
1803
- // Support both 'apple' (recommended) and 'ios' (deprecated) fields
1804
- const iosRequest = perPlatformRequest.apple ?? perPlatformRequest.ios;
1805
- if (!iosRequest?.sku) {
1820
+ if (!iosRequestSource?.sku) {
1806
1821
  throw new Error(
1807
1822
  'Invalid request for iOS. The `sku` property is required.',
1808
1823
  );
1809
1824
  }
1810
1825
  } else if (isAndroidStoreRuntime()) {
1811
- // Support both 'google' (recommended) and 'android' (deprecated) fields
1812
- const androidRequest =
1813
- perPlatformRequest.google ?? perPlatformRequest.android;
1814
- if (!androidRequest?.skus?.length) {
1826
+ if (!androidRequestSource?.skus?.length) {
1815
1827
  throw new Error(
1816
1828
  'Invalid request for Android. The `skus` property is required and must be a non-empty array.',
1817
1829
  );
@@ -1822,14 +1834,12 @@ export const requestPurchase: MutationField<'requestPurchase'> = async (
1822
1834
 
1823
1835
  const unifiedRequest: NitroPurchaseRequest = {};
1824
1836
 
1825
- // Support both 'apple' (recommended) and 'ios' (deprecated) fields
1826
- const iosRequestSource = perPlatformRequest.apple ?? perPlatformRequest.ios;
1827
1837
  if (Platform.OS === 'ios' && iosRequestSource) {
1828
1838
  const iosRequest = isSubs
1829
1839
  ? (iosRequestSource as RequestSubscriptionIosProps)
1830
1840
  : (iosRequestSource as RequestPurchaseIosProps);
1831
1841
 
1832
- const iosPayload: NonNullable<NitroPurchaseRequest['ios']> = {
1842
+ const iosPayload: NonNullable<NitroPurchaseRequest['apple']> = {
1833
1843
  sku: iosRequest.sku,
1834
1844
  };
1835
1845
 
@@ -1869,18 +1879,15 @@ export const requestPurchase: MutationField<'requestPurchase'> = async (
1869
1879
  }
1870
1880
  }
1871
1881
 
1872
- unifiedRequest.ios = iosPayload;
1882
+ unifiedRequest.apple = iosPayload;
1873
1883
  }
1874
1884
 
1875
- // Support both 'google' (recommended) and 'android' (deprecated) fields
1876
- const androidRequestSource =
1877
- perPlatformRequest.google ?? perPlatformRequest.android;
1878
1885
  if (isAndroidStoreRuntime() && androidRequestSource) {
1879
1886
  const androidRequest = isSubs
1880
1887
  ? (androidRequestSource as RequestSubscriptionAndroidProps)
1881
1888
  : (androidRequestSource as RequestPurchaseAndroidProps);
1882
1889
 
1883
- const androidPayload: NonNullable<NitroPurchaseRequest['android']> = {
1890
+ const androidPayload: NonNullable<NitroPurchaseRequest['google']> = {
1884
1891
  skus: androidRequest.skus,
1885
1892
  };
1886
1893
 
@@ -1934,7 +1941,7 @@ export const requestPurchase: MutationField<'requestPurchase'> = async (
1934
1941
  }));
1935
1942
  }
1936
1943
 
1937
- unifiedRequest.android = androidPayload;
1944
+ unifiedRequest.google = androidPayload;
1938
1945
  }
1939
1946
 
1940
1947
  return await IAP.instance.requestPurchase(unifiedRequest);
@@ -2153,7 +2160,7 @@ export const openRedeemOfferCodeAndroid: MutationField<
2153
2160
 
2154
2161
  /**
2155
2162
  * Validate receipt on both iOS and Android platforms
2156
- * @deprecated Use `verifyPurchase` instead. This function will be removed in a future version.
2163
+ * @deprecated Use `verifyPurchase` instead. This function will be removed in react-native-iap 16.0.0.
2157
2164
  * @param options - Platform-specific verification options
2158
2165
  * @param options.apple - Apple App Store verification options (iOS)
2159
2166
  * @param options.google - Google Play verification options (Android)
@@ -2315,9 +2322,8 @@ export const verifyPurchase: MutationField<'verifyPurchase'> = validateReceipt;
2315
2322
  /**
2316
2323
  * iOS-only receipt validation alias.
2317
2324
  *
2318
- * @deprecated Use `verifyPurchase` (or `validateReceipt`) instead. Kept so
2319
- * consumers who imported `validateReceiptIOS` which is still declared on the
2320
- * OpenIAP Query interface — keep working. Throws on non-iOS platforms.
2325
+ * @deprecated Use `verifyPurchase` instead. This compatibility alias will be
2326
+ * removed in react-native-iap 16.0.0. Throws on non-iOS platforms.
2321
2327
  *
2322
2328
  * @see {@link https://openiap.dev/docs/apis/ios/validate-receipt-ios}
2323
2329
  */
@@ -2465,7 +2471,9 @@ export const presentCodeRedemptionSheetIOS: MutationField<
2465
2471
 
2466
2472
  /**
2467
2473
  * Buy promoted product on iOS
2468
- * @deprecated In StoreKit 2, promoted products can be purchased directly via the standard `requestPurchase()` flow.
2474
+ * @deprecated In StoreKit 2, promoted products can be purchased directly via
2475
+ * the standard `requestPurchase()` flow. This alias will be removed in
2476
+ * react-native-iap 16.0.0.
2469
2477
  * Use `promotedProductListenerIOS` to receive the product ID when a user taps a promoted product,
2470
2478
  * then call `requestPurchase()` with the received SKU directly.
2471
2479
  *
@@ -2673,6 +2681,7 @@ export const getActiveSubscriptions: QueryField<
2673
2681
  willAutoRenew: sub.renewalInfoIOS.willAutoRenew ?? false,
2674
2682
  autoRenewPreference:
2675
2683
  sub.renewalInfoIOS.autoRenewPreference ?? null,
2684
+ commitmentInfo: sub.renewalInfoIOS.commitmentInfo ?? null,
2676
2685
  pendingUpgradeProductId:
2677
2686
  sub.renewalInfoIOS.pendingUpgradeProductId ?? null,
2678
2687
  renewalDate: sub.renewalInfoIOS.renewalDate ?? null,
@@ -2682,8 +2691,11 @@ export const getActiveSubscriptions: QueryField<
2682
2691
  sub.renewalInfoIOS.gracePeriodExpirationDate ?? null,
2683
2692
  priceIncreaseStatus:
2684
2693
  sub.renewalInfoIOS.priceIncreaseStatus ?? null,
2694
+ renewalBillingPlanType:
2695
+ sub.renewalInfoIOS.renewalBillingPlanType ?? null,
2685
2696
  renewalOfferType: sub.renewalInfoIOS.renewalOfferType ?? null,
2686
2697
  renewalOfferId: sub.renewalInfoIOS.renewalOfferId ?? null,
2698
+ jsonRepresentation: sub.renewalInfoIOS.jsonRepresentation ?? null,
2687
2699
  }
2688
2700
  : null,
2689
2701
  // Android specific fields
@@ -2747,12 +2759,14 @@ export {
2747
2759
 
2748
2760
  // Deprecated exports for backward compatibility
2749
2761
  /**
2750
- * @deprecated Use acknowledgePurchaseAndroid instead
2762
+ * @deprecated Use acknowledgePurchaseAndroid instead. This alias will be
2763
+ * removed in react-native-iap 16.0.0.
2751
2764
  */
2752
2765
  export const acknowledgePurchase = acknowledgePurchaseAndroid;
2753
2766
 
2754
2767
  /**
2755
- * @deprecated Use consumePurchaseAndroid instead
2768
+ * @deprecated Use consumePurchaseAndroid instead. This alias will be removed
2769
+ * in react-native-iap 16.0.0.
2756
2770
  */
2757
2771
  export const consumePurchase = consumePurchaseAndroid;
2758
2772
 
@@ -2761,9 +2775,45 @@ export const consumePurchase = consumePurchaseAndroid;
2761
2775
  // ============================================================================
2762
2776
 
2763
2777
  type NitroDiscountOfferRecord = NonNullable<
2764
- NonNullable<NitroPurchaseRequest['ios']>['withOffer']
2778
+ NonNullable<NitroPurchaseRequest['apple']>['withOffer']
2765
2779
  >;
2766
2780
 
2781
+ const selectApplePurchaseRequest = (
2782
+ request:
2783
+ RequestPurchasePropsByPlatforms | RequestSubscriptionPropsByPlatforms,
2784
+ ): RequestPurchaseIosProps | RequestSubscriptionIosProps | null | undefined => {
2785
+ const selection = selectCanonicalPlatformRequest<
2786
+ RequestPurchaseIosProps | RequestSubscriptionIosProps
2787
+ >(request, 'apple', 'ios');
2788
+ if (selection.usesLegacyKey && selection.value != null) {
2789
+ warnLegacyOnce(
2790
+ 'request-purchase.ios',
2791
+ '[react-native-iap] `request.ios` is deprecated and will be removed in react-native-iap 16.0.0. Use `request.apple` instead.',
2792
+ );
2793
+ }
2794
+ return selection.value;
2795
+ };
2796
+
2797
+ const selectGooglePurchaseRequest = (
2798
+ request:
2799
+ RequestPurchasePropsByPlatforms | RequestSubscriptionPropsByPlatforms,
2800
+ ):
2801
+ | RequestPurchaseAndroidProps
2802
+ | RequestSubscriptionAndroidProps
2803
+ | null
2804
+ | undefined => {
2805
+ const selection = selectCanonicalPlatformRequest<
2806
+ RequestPurchaseAndroidProps | RequestSubscriptionAndroidProps
2807
+ >(request, 'google', 'android');
2808
+ if (selection.usesLegacyKey && selection.value != null) {
2809
+ warnLegacyOnce(
2810
+ 'request-purchase.android',
2811
+ '[react-native-iap] `request.android` is deprecated and will be removed in react-native-iap 16.0.0. Use `request.google` instead.',
2812
+ );
2813
+ }
2814
+ return selection.value;
2815
+ };
2816
+
2767
2817
  const toDiscountOfferRecordIOS = (
2768
2818
  offer: DiscountOfferInputIOS | null | undefined,
2769
2819
  ): NitroDiscountOfferRecord | undefined => {
@@ -2781,7 +2831,7 @@ const toDiscountOfferRecordIOS = (
2781
2831
 
2782
2832
  const toNitroProductType = (
2783
2833
  type?: ProductTypeInput | ProductQueryType | null,
2784
- ): 'inapp' | 'subs' | 'all' => {
2834
+ ): 'in-app' | 'subs' | 'all' => {
2785
2835
  if (type === 'subs') {
2786
2836
  return 'subs';
2787
2837
  }
@@ -2789,10 +2839,10 @@ const toNitroProductType = (
2789
2839
  return 'all';
2790
2840
  }
2791
2841
  if (type === 'inapp') {
2792
- RnIapConsole.warn(LEGACY_INAPP_WARNING);
2793
- return 'inapp';
2842
+ warnLegacyOnce('product-type.inapp', LEGACY_INAPP_WARNING);
2843
+ return 'in-app';
2794
2844
  }
2795
- return 'inapp';
2845
+ return 'in-app';
2796
2846
  };
2797
2847
 
2798
2848
  const isSubscriptionQuery = (type?: ProductQueryType | null): boolean =>
@@ -2815,7 +2865,7 @@ const normalizeProductQueryType = (
2815
2865
  return 'subs';
2816
2866
  }
2817
2867
  if (normalized === 'inapp') {
2818
- RnIapConsole.warn(LEGACY_INAPP_WARNING);
2868
+ warnLegacyOnce('product-type.inapp', LEGACY_INAPP_WARNING);
2819
2869
  return 'in-app';
2820
2870
  }
2821
2871
  if (normalized === 'in-app') {
@@ -2850,6 +2900,8 @@ const normalizeProductQueryType = (
2850
2900
  * ```
2851
2901
  *
2852
2902
  * @see {@link https://openiap.dev/docs/apis/android/check-alternative-billing-availability-android}
2903
+ * @deprecated Use `isBillingProgramAvailableAndroid('external-offer')`
2904
+ * instead. Scheduled for removal in react-native-iap 16.0.0.
2853
2905
  */
2854
2906
  export const checkAlternativeBillingAvailabilityAndroid: MutationField<
2855
2907
  'checkAlternativeBillingAvailabilityAndroid'
@@ -2892,6 +2944,8 @@ export const checkAlternativeBillingAvailabilityAndroid: MutationField<
2892
2944
  * ```
2893
2945
  *
2894
2946
  * @see {@link https://openiap.dev/docs/apis/android/show-alternative-billing-dialog-android}
2947
+ * @deprecated Use `launchExternalLinkAndroid` instead. Scheduled for removal in
2948
+ * react-native-iap 16.0.0.
2895
2949
  */
2896
2950
  export const showAlternativeBillingDialogAndroid: MutationField<
2897
2951
  'showAlternativeBillingDialogAndroid'
@@ -2931,6 +2985,9 @@ export const showAlternativeBillingDialogAndroid: MutationField<
2931
2985
  * ```
2932
2986
  *
2933
2987
  * @see {@link https://openiap.dev/docs/apis/android/create-alternative-billing-token-android}
2988
+ * @deprecated Use
2989
+ * `createBillingProgramReportingDetailsAndroid('external-offer')` instead.
2990
+ * Scheduled for removal in react-native-iap 16.0.0.
2934
2991
  */
2935
2992
  export const createAlternativeBillingTokenAndroid: MutationField<
2936
2993
  'createAlternativeBillingTokenAndroid'