expo-iap 2.8.3-rc.2 → 2.8.3

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 (62) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/CLAUDE.md +8 -20
  3. package/CONTRIBUTING.md +4 -3
  4. package/build/helpers/subscription.d.ts.map +1 -1
  5. package/build/helpers/subscription.js +6 -3
  6. package/build/helpers/subscription.js.map +1 -1
  7. package/build/index.d.ts.map +1 -1
  8. package/build/index.js +1 -3
  9. package/build/index.js.map +1 -1
  10. package/build/modules/android.d.ts.map +1 -1
  11. package/build/modules/android.js.map +1 -1
  12. package/build/modules/ios.d.ts.map +1 -1
  13. package/build/modules/ios.js.map +1 -1
  14. package/build/types/ExpoIapAndroid.types.d.ts +2 -2
  15. package/build/types/ExpoIapAndroid.types.d.ts.map +1 -1
  16. package/build/types/ExpoIapAndroid.types.js.map +1 -1
  17. package/build/types/ExpoIapIOS.types.d.ts +3 -3
  18. package/build/types/ExpoIapIOS.types.d.ts.map +1 -1
  19. package/build/types/ExpoIapIOS.types.js.map +1 -1
  20. package/build/useIAP.d.ts +4 -0
  21. package/build/useIAP.d.ts.map +1 -1
  22. package/build/useIAP.js +4 -0
  23. package/build/useIAP.js.map +1 -1
  24. package/ios/ExpoIap.podspec +5 -5
  25. package/jest.config.js +17 -14
  26. package/package.json +1 -1
  27. package/plugin/build/withIAP.js +4 -17
  28. package/plugin/src/withIAP.ts +4 -23
  29. package/plugin/tsconfig.tsbuildinfo +1 -1
  30. package/src/helpers/subscription.ts +28 -21
  31. package/src/index.ts +5 -10
  32. package/src/modules/android.ts +7 -7
  33. package/src/modules/ios.ts +2 -7
  34. package/src/types/ExpoIapAndroid.types.ts +4 -3
  35. package/src/types/ExpoIapIOS.types.ts +3 -4
  36. package/src/useIAP.ts +7 -9
  37. package/coverage/clover.xml +0 -601
  38. package/coverage/coverage-final.json +0 -9
  39. package/coverage/lcov-report/base.css +0 -224
  40. package/coverage/lcov-report/block-navigation.js +0 -87
  41. package/coverage/lcov-report/favicon.png +0 -0
  42. package/coverage/lcov-report/index.html +0 -176
  43. package/coverage/lcov-report/prettify.css +0 -1
  44. package/coverage/lcov-report/prettify.js +0 -2
  45. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  46. package/coverage/lcov-report/sorter.js +0 -210
  47. package/coverage/lcov-report/src/ExpoIap.types.ts.html +0 -1243
  48. package/coverage/lcov-report/src/helpers/index.html +0 -116
  49. package/coverage/lcov-report/src/helpers/subscription.ts.html +0 -430
  50. package/coverage/lcov-report/src/index.html +0 -146
  51. package/coverage/lcov-report/src/index.ts.html +0 -2227
  52. package/coverage/lcov-report/src/modules/android.ts.html +0 -469
  53. package/coverage/lcov-report/src/modules/index.html +0 -131
  54. package/coverage/lcov-report/src/modules/ios.ts.html +0 -1411
  55. package/coverage/lcov-report/src/types/ExpoIapAndroid.types.ts.html +0 -487
  56. package/coverage/lcov-report/src/types/index.html +0 -116
  57. package/coverage/lcov-report/src/useIap.ts.html +0 -1483
  58. package/coverage/lcov-report/src/utils/errorMapping.ts.html +0 -349
  59. package/coverage/lcov-report/src/utils/index.html +0 -116
  60. package/coverage/lcov.info +0 -1115
  61. package/ios/expoiap.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  62. package/ios/expoiap.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
@@ -26,7 +26,7 @@ export function isProductAndroid<T extends {platform?: string}>(
26
26
  * @param {string} params.sku - The product's SKU (on Android)
27
27
  * @param {string} params.packageName - The package name of your Android app (e.g., 'com.example.app')
28
28
  * @returns {Promise<void>}
29
- *
29
+ *
30
30
  * @example
31
31
  * ```typescript
32
32
  * await deepLinkToSubscriptionsAndroid({
@@ -43,9 +43,11 @@ export const deepLinkToSubscriptionsAndroid = async ({
43
43
  packageName: string;
44
44
  }): Promise<void> => {
45
45
  if (!packageName) {
46
- throw new Error('packageName is required for deepLinkToSubscriptionsAndroid');
46
+ throw new Error(
47
+ 'packageName is required for deepLinkToSubscriptionsAndroid',
48
+ );
47
49
  }
48
-
50
+
49
51
  return Linking.openURL(
50
52
  `https://play.google.com/store/account/subscriptions?package=${packageName}&sku=${sku}`,
51
53
  );
@@ -118,11 +120,9 @@ export const acknowledgePurchaseAndroid = ({
118
120
  * Open the Google Play Store to redeem offer codes (Android only).
119
121
  * Note: Google Play does not provide a direct API to redeem codes within the app.
120
122
  * This function opens the Play Store where users can manually enter their codes.
121
- *
123
+ *
122
124
  * @returns {Promise<void>}
123
125
  */
124
126
  export const openRedeemOfferCodeAndroid = async (): Promise<void> => {
125
- return Linking.openURL(
126
- `https://play.google.com/redeem?code=`
127
- );
127
+ return Linking.openURL(`https://play.google.com/redeem?code=`);
128
128
  };
@@ -5,10 +5,7 @@ import {purchaseUpdatedListener} from '..';
5
5
  import ExpoIapModule from '../ExpoIapModule';
6
6
 
7
7
  // Types
8
- import {
9
- Purchase,
10
- PurchaseError,
11
- } from '../ExpoIap.types';
8
+ import {Purchase, PurchaseError} from '../ExpoIap.types';
12
9
  import type {
13
10
  ProductStatusIOS,
14
11
  AppTransactionIOS,
@@ -136,9 +133,7 @@ export const subscriptionStatusIOS = (
136
133
  *
137
134
  * @platform iOS
138
135
  */
139
- export const currentEntitlementIOS = (
140
- sku: string,
141
- ): Promise<Purchase> => {
136
+ export const currentEntitlementIOS = (sku: string): Promise<Purchase> => {
142
137
  return ExpoIapModule.currentEntitlement(sku);
143
138
  };
144
139
 
@@ -31,7 +31,7 @@ type ProductSubscriptionAndroidOfferDetail = {
31
31
  export type ProductAndroid = ProductCommon & {
32
32
  nameAndroid: string;
33
33
  oneTimePurchaseOfferDetailsAndroid?: ProductAndroidOneTimePurchaseOfferDetail;
34
- platform: "android";
34
+ platform: 'android';
35
35
  subscriptionOfferDetailsAndroid?: ProductSubscriptionAndroidOfferDetail[];
36
36
  /**
37
37
  * @deprecated Use `nameAndroid` instead. This field will be removed in v2.9.0.
@@ -144,7 +144,7 @@ export const PurchaseStateAndroid = PurchaseAndroidState;
144
144
 
145
145
  // Legacy naming for backward compatibility
146
146
  export type ProductPurchaseAndroid = PurchaseCommon & {
147
- platform: "android";
147
+ platform: 'android';
148
148
  /**
149
149
  * @deprecated Use `purchaseToken` instead. This field will be removed in a future version.
150
150
  */
@@ -167,7 +167,8 @@ export type PurchaseAndroid = ProductPurchaseAndroid;
167
167
  /**
168
168
  * @deprecated Use `ProductAndroidOneTimePurchaseOfferDetail` instead. This type will be removed in v2.9.0.
169
169
  */
170
- export type OneTimePurchaseOfferDetails = ProductAndroidOneTimePurchaseOfferDetail;
170
+ export type OneTimePurchaseOfferDetails =
171
+ ProductAndroidOneTimePurchaseOfferDetail;
171
172
 
172
173
  /**
173
174
  * @deprecated Use `ProductSubscriptionAndroidOfferDetail` instead. This type will be removed in v2.9.0.
@@ -30,7 +30,7 @@ export type ProductIOS = ProductCommon & {
30
30
  displayNameIOS: string;
31
31
  isFamilyShareableIOS: boolean;
32
32
  jsonRepresentationIOS: string;
33
- platform: "ios";
33
+ platform: 'ios';
34
34
  subscriptionInfoIOS?: SubscriptionInfo;
35
35
  /**
36
36
  * @deprecated Use `displayNameIOS` instead. This field will be removed in v2.9.0.
@@ -69,7 +69,7 @@ export type ProductSubscriptionIOS = ProductIOS & {
69
69
  introductoryPricePaymentModeIOS?: PaymentMode;
70
70
  introductoryPriceNumberOfPeriodsIOS?: string;
71
71
  introductoryPriceSubscriptionPeriodIOS?: SubscriptionIosPeriod;
72
- platform: "ios";
72
+ platform: 'ios';
73
73
  subscriptionPeriodNumberIOS?: string;
74
74
  subscriptionPeriodUnitIOS?: SubscriptionIosPeriod;
75
75
  /**
@@ -140,7 +140,7 @@ export type ProductStatusIOS = {
140
140
  // Legacy naming for backward compatibility
141
141
  export type ProductPurchaseIOS = PurchaseCommon & {
142
142
  // iOS basic fields
143
- platform: "ios";
143
+ platform: 'ios';
144
144
  quantityIOS?: number;
145
145
  originalTransactionDateIOS?: number;
146
146
  originalTransactionIdentifierIOS?: string;
@@ -179,7 +179,6 @@ export type ProductPurchaseIOS = PurchaseCommon & {
179
179
  // Preferred naming
180
180
  export type PurchaseIOS = ProductPurchaseIOS;
181
181
 
182
-
183
182
  export type AppTransactionIOS = {
184
183
  appTransactionId?: string; // Only available in iOS 18.4+
185
184
  originalPlatform?: string; // Only available in iOS 18.4+
package/src/useIAP.ts CHANGED
@@ -97,26 +97,24 @@ type UseIap = {
97
97
  };
98
98
 
99
99
  export interface UseIAPOptions {
100
- onPurchaseSuccess?: (
101
- purchase: Purchase,
102
- ) => void;
100
+ onPurchaseSuccess?: (purchase: Purchase) => void;
103
101
  onPurchaseError?: (error: PurchaseError) => void;
104
102
  onSyncError?: (error: Error) => void;
105
103
  shouldAutoSyncPurchases?: boolean; // New option to control auto-syncing
106
104
  onPromotedProductIOS?: (product: Product) => void;
107
105
  }
108
106
 
107
+ /**
108
+ * React Hook for managing In-App Purchases.
109
+ * See documentation at https://expo-iap.hyo.dev/docs/hooks/useIAP
110
+ */
109
111
  export function useIAP(options?: UseIAPOptions): UseIap {
110
112
  const [connected, setConnected] = useState<boolean>(false);
111
113
  const [products, setProducts] = useState<Product[]>([]);
112
114
  const [promotedProductsIOS] = useState<Purchase[]>([]);
113
115
  const [subscriptions, setSubscriptions] = useState<SubscriptionProduct[]>([]);
114
- const [purchaseHistories, setPurchaseHistories] = useState<Purchase[]>(
115
- [],
116
- );
117
- const [availablePurchases, setAvailablePurchases] = useState<
118
- Purchase[]
119
- >([]);
116
+ const [purchaseHistories, setPurchaseHistories] = useState<Purchase[]>([]);
117
+ const [availablePurchases, setAvailablePurchases] = useState<Purchase[]>([]);
120
118
  const [currentPurchase, setCurrentPurchase] = useState<Purchase>();
121
119
  const [promotedProductIOS, setPromotedProductIOS] = useState<Product>();
122
120
  const [currentPurchaseError, setCurrentPurchaseError] =