expo-iap 3.1.8 → 3.1.9

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 (51) hide show
  1. package/android/src/main/java/expo/modules/iap/ExpoIapHelper.kt +69 -2
  2. package/android/src/main/java/expo/modules/iap/ExpoIapModule.kt +62 -4
  3. package/build/index.d.ts +32 -2
  4. package/build/index.d.ts.map +1 -1
  5. package/build/index.js +40 -15
  6. package/build/index.js.map +1 -1
  7. package/build/modules/android.d.ts +68 -0
  8. package/build/modules/android.d.ts.map +1 -1
  9. package/build/modules/android.js +74 -0
  10. package/build/modules/android.js.map +1 -1
  11. package/build/modules/ios.d.ts +23 -0
  12. package/build/modules/ios.d.ts.map +1 -1
  13. package/build/modules/ios.js +34 -3
  14. package/build/modules/ios.js.map +1 -1
  15. package/build/types.d.ts +116 -13
  16. package/build/types.d.ts.map +1 -1
  17. package/build/types.js.map +1 -1
  18. package/build/useIAP.d.ts +8 -0
  19. package/build/useIAP.d.ts.map +1 -1
  20. package/build/useIAP.js +11 -1
  21. package/build/useIAP.js.map +1 -1
  22. package/bun.lockb +0 -0
  23. package/coverage/clover.xml +258 -234
  24. package/coverage/coverage-final.json +3 -3
  25. package/coverage/lcov-report/index.html +27 -27
  26. package/coverage/lcov-report/src/helpers/index.html +1 -1
  27. package/coverage/lcov-report/src/helpers/subscription.ts.html +1 -1
  28. package/coverage/lcov-report/src/index.html +19 -19
  29. package/coverage/lcov-report/src/index.ts.html +136 -31
  30. package/coverage/lcov-report/src/modules/android.ts.html +257 -8
  31. package/coverage/lcov-report/src/modules/index.html +23 -23
  32. package/coverage/lcov-report/src/modules/ios.ts.html +137 -11
  33. package/coverage/lcov-report/src/utils/debug.ts.html +1 -1
  34. package/coverage/lcov-report/src/utils/errorMapping.ts.html +1 -1
  35. package/coverage/lcov-report/src/utils/index.html +1 -1
  36. package/coverage/lcov.info +473 -429
  37. package/ios/ExpoIapHelper.swift +4 -0
  38. package/ios/ExpoIapModule.swift +33 -1
  39. package/openiap-versions.json +3 -3
  40. package/package.json +1 -1
  41. package/plugin/build/withIAP.d.ts +26 -0
  42. package/plugin/build/withIAP.js +67 -3
  43. package/plugin/build/withLocalOpenIAP.d.ts +2 -0
  44. package/plugin/build/withLocalOpenIAP.js +7 -0
  45. package/plugin/src/withIAP.ts +141 -3
  46. package/plugin/src/withLocalOpenIAP.ts +14 -4
  47. package/src/index.ts +49 -14
  48. package/src/modules/android.ts +83 -0
  49. package/src/modules/ios.ts +45 -3
  50. package/src/types.ts +124 -13
  51. package/src/useIAP.ts +26 -1
@@ -107,4 +107,78 @@ export const acknowledgePurchaseAndroid = async (purchaseToken) => {
107
107
  export const openRedeemOfferCodeAndroid = async () => {
108
108
  return Linking.openURL(`https://play.google.com/redeem?code=`);
109
109
  };
110
+ /**
111
+ * Check if alternative billing is available for this user/device (Android only).
112
+ * Step 1 of alternative billing flow.
113
+ *
114
+ * Returns true if available, false otherwise.
115
+ * Throws OpenIapError.NotPrepared if billing client not ready.
116
+ *
117
+ * @returns {Promise<boolean>}
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * const isAvailable = await checkAlternativeBillingAvailabilityAndroid();
122
+ * if (isAvailable) {
123
+ * // Proceed with alternative billing flow
124
+ * }
125
+ * ```
126
+ */
127
+ export const checkAlternativeBillingAvailabilityAndroid = async () => {
128
+ return ExpoIapModule.checkAlternativeBillingAvailabilityAndroid();
129
+ };
130
+ /**
131
+ * Show alternative billing information dialog to user (Android only).
132
+ * Step 2 of alternative billing flow.
133
+ * Must be called BEFORE processing payment in your payment system.
134
+ *
135
+ * Returns true if user accepted, false if user canceled.
136
+ * Throws OpenIapError.NotPrepared if billing client not ready.
137
+ *
138
+ * @returns {Promise<boolean>}
139
+ *
140
+ * @example
141
+ * ```typescript
142
+ * const userAccepted = await showAlternativeBillingDialogAndroid();
143
+ * if (userAccepted) {
144
+ * // Process payment in your payment system
145
+ * const success = await processCustomPayment();
146
+ * if (success) {
147
+ * // Create reporting token
148
+ * const token = await createAlternativeBillingTokenAndroid();
149
+ * // Send token to your backend for Google Play reporting
150
+ * }
151
+ * }
152
+ * ```
153
+ */
154
+ export const showAlternativeBillingDialogAndroid = async () => {
155
+ return ExpoIapModule.showAlternativeBillingDialogAndroid();
156
+ };
157
+ /**
158
+ * Create external transaction token for Google Play reporting (Android only).
159
+ * Step 3 of alternative billing flow.
160
+ * Must be called AFTER successful payment in your payment system.
161
+ * Token must be reported to Google Play backend within 24 hours.
162
+ *
163
+ * Returns token string, or null if creation failed.
164
+ * Throws OpenIapError.NotPrepared if billing client not ready.
165
+ *
166
+ * @param {string} sku - The product SKU that was purchased
167
+ * @returns {Promise<string | null>}
168
+ *
169
+ * @example
170
+ * ```typescript
171
+ * const token = await createAlternativeBillingTokenAndroid('premium_subscription');
172
+ * if (token) {
173
+ * // Send token to your backend
174
+ * await fetch('/api/report-transaction', {
175
+ * method: 'POST',
176
+ * body: JSON.stringify({ token, sku: 'premium_subscription' })
177
+ * });
178
+ * }
179
+ * ```
180
+ */
181
+ export const createAlternativeBillingTokenAndroid = async (sku) => {
182
+ return ExpoIapModule.createAlternativeBillingTokenAndroid(sku);
183
+ };
110
184
  //# sourceMappingURL=android.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"android.js","sourceRoot":"","sources":["../../src/modules/android.ts"],"names":[],"mappings":"AAAA,wBAAwB;AACxB,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAErC,mBAAmB;AACnB,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAiB7C,MAAM,mBAAmB,GAAG,aAAoC,CAAC;AAEjE,cAAc;AACd,MAAM,UAAU,gBAAgB,CAC9B,IAAa;IAEb,OAAO,CACL,IAAI,IAAI,IAAI;QACZ,OAAO,IAAI,KAAK,QAAQ;QACxB,UAAU,IAAI,IAAI;QAClB,OAAQ,IAAY,CAAC,QAAQ,KAAK,QAAQ;QACzC,IAAY,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,S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AAE,KAAK;QACb,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,UAAU,WAAW,EAAE;SACvC;KACF,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;YAClD,UAAU,EAAE,QAAQ,CAAC,MAAM;SAC5B,CAAC,CAAC;IACL,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAEnC,KAAK,EAAE,aAAa,EAAE,EAAE;IAC1B,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,0BAA0B,CAAC,aAAa,CAAC,CAAC;IAE7E,IAAI,OAAO,MAAM,KAAK,SAAS,EAAE,CAAC;QAChC,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QACzC,MAAM,MAAM,GAAG,MAAiC,CAAC;QACjD,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YACxC,OAAO,MAAM,CAAC,OAAO,CAAC;QACxB,CAAC;QACD,IAAI,OAAO,MAAM,CAAC,YAAY,KAAK,QAAQ,EAAE,CAAC;YAC5C,OAAO,MAAM,CAAC,YAAY,KAAK,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,IAAmB,EAAE;IAClE,OAAO,OAAO,CAAC,OAAO,CAAC,sCAAsC,CAAC,CAAC;AACjE,CAAC,CAAC","sourcesContent":["// External dependencies\nimport {Linking} from 'react-native';\n\n// Internal modules\nimport ExpoIapModule from '../ExpoIapModule';\n\n// Types\nimport type {\n DeepLinkOptions,\n MutationField,\n ReceiptValidationResultAndroid,\n} from '../types';\n\ntype NativeAndroidModule = {\n deepLinkToSubscriptionsAndroid?: (params: {\n skuAndroid?: string;\n packageNameAndroid?: string;\n }) => Promise<void> | void;\n getStorefront?: () => Promise<string> | string;\n};\n\nconst nativeAndroidModule = ExpoIapModule as NativeAndroidModule;\n\n// Type guards\nexport function isProductAndroid<T extends {platform?: string}>(\n item: unknown,\n): item is T & {platform: 'android'} {\n return (\n item != null &&\n typeof item === 'object' &&\n 'platform' in item &&\n typeof (item as any).platform === 'string' &&\n (item as any).platform.toLowerCase() === 'android'\n );\n}\n\n/**\n * Deep link to subscriptions screen on Android.\n * @param {Object} params - The parameters object\n * @param {string} params.skuAndroid - The product's SKU (on Android)\n * @param {string} params.packageNameAndroid - The package name of your Android app (e.g., 'com.example.app')\n * @returns {Promise<void>}\n *\n * @example\n * ```typescript\n * await deepLinkToSubscriptionsAndroid({\n * skuAndroid: 'subscription_id',\n * packageNameAndroid: 'com.example.app'\n * });\n * ```\n */\nexport const deepLinkToSubscriptionsAndroid = async (\n options?: DeepLinkOptions | null,\n): Promise<void> => {\n const sku = options?.skuAndroid ?? undefined;\n const packageName = options?.packageNameAndroid ?? undefined;\n\n // Prefer native deep link implementation via OpenIAP module\n if (nativeAndroidModule?.deepLinkToSubscriptionsAndroid) {\n return nativeAndroidModule.deepLinkToSubscriptionsAndroid({\n skuAndroid: sku,\n packageNameAndroid: packageName,\n });\n }\n\n // Fallback to Linking if native method unavailable\n if (!packageName) {\n throw new Error(\n 'packageName is required for deepLinkToSubscriptionsAndroid',\n );\n }\n const base = `https://play.google.com/store/account/subscriptions?package=${encodeURIComponent(\n packageName,\n )}`;\n const url = sku ? `${base}&sku=${encodeURIComponent(sku)}` : base;\n return Linking.openURL(url);\n};\n\n/**\n * Validate receipt for Android. NOTE: This method is here for debugging purposes only. Including\n * your access token in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {Object} params - The parameters object\n * @param {string} params.packageName - package name of your app.\n * @param {string} params.productId - product id for your in app product.\n * @param {string} params.productToken - token for your purchase (called 'token' in the API documentation).\n * @param {string} params.accessToken - OAuth access token with androidpublisher scope. Required for authentication.\n * @param {boolean} params.isSub - whether this is subscription or in-app. `true` for subscription.\n * @returns {Promise<ReceiptAndroid>}\n */\nexport const validateReceiptAndroid = async ({\n packageName,\n productId,\n productToken,\n accessToken,\n isSub,\n}: {\n packageName: string;\n productId: string;\n productToken: string;\n accessToken: string;\n isSub?: boolean;\n}): Promise<ReceiptValidationResultAndroid> => {\n const type = isSub ? 'subscriptions' : 'products';\n\n const url =\n 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications' +\n `/${packageName}/purchases/${type}/${productId}` +\n `/tokens/${productToken}`;\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${accessToken}`,\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Acknowledge a product (on Android.) No-op on iOS.\n * @param {Object} params - The parameters object\n * @param {string} params.token - The product's token (on Android)\n * @returns {Promise<VoidResult | void>}\n */\nexport const acknowledgePurchaseAndroid: MutationField<\n 'acknowledgePurchaseAndroid'\n> = async (purchaseToken) => {\n const result = await ExpoIapModule.acknowledgePurchaseAndroid(purchaseToken);\n\n if (typeof result === 'boolean') {\n return result;\n }\n\n if (result && typeof result === 'object') {\n const record = result as Record<string, unknown>;\n if (typeof record.success === 'boolean') {\n return record.success;\n }\n if (typeof record.responseCode === 'number') {\n return record.responseCode === 0;\n }\n }\n\n return true;\n};\n\n/**\n * Open the Google Play Store to redeem offer codes (Android only).\n * Note: Google Play does not provide a direct API to redeem codes within the app.\n * This function opens the Play Store where users can manually enter their codes.\n *\n * @returns {Promise<void>}\n */\nexport const openRedeemOfferCodeAndroid = async (): Promise<void> => {\n return Linking.openURL(`https://play.google.com/redeem?code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AAK,SAAS,EAAE,CAAC;YACxC,OAAO,MAAM,CAAC,OAAO,CAAC;QACxB,CAAC;QACD,IAAI,OAAO,MAAM,CAAC,YAAY,KAAK,QAAQ,EAAE,CAAC;YAC5C,OAAO,MAAM,CAAC,YAAY,KAAK,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,IAAmB,EAAE;IAClE,OAAO,OAAO,CAAC,OAAO,CAAC,sCAAsC,CAAC,CAAC;AACjE,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,0CAA0C,GAEnD,KAAK,IAAI,EAAE;IACb,OAAO,aAAa,CAAC,0CAA0C,EAAE,CAAC;AACpE,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAE5C,KAAK,IAAI,EAAE;IACb,OAAO,aAAa,CAAC,mCAAmC,EAAE,CAAC;AAC7D,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAE7C,KAAK,EAAE,GAAY,EAAE,EAAE;IACzB,OAAO,aAAa,CAAC,oCAAoC,CAAC,GAAG,CAAC,CAAC;AACjE,CAAC,CAAC","sourcesContent":["// External dependencies\nimport {Linking} from 'react-native';\n\n// Internal modules\nimport ExpoIapModule from '../ExpoIapModule';\n\n// Types\nimport type {\n DeepLinkOptions,\n MutationField,\n ReceiptValidationResultAndroid,\n} from '../types';\n\ntype NativeAndroidModule = {\n deepLinkToSubscriptionsAndroid?: (params: {\n skuAndroid?: string;\n packageNameAndroid?: string;\n }) => Promise<void> | void;\n getStorefront?: () => Promise<string> | string;\n};\n\nconst nativeAndroidModule = ExpoIapModule as NativeAndroidModule;\n\n// Type guards\nexport function isProductAndroid<T extends {platform?: string}>(\n item: unknown,\n): item is T & {platform: 'android'} {\n return (\n item != null &&\n typeof item === 'object' &&\n 'platform' in item &&\n typeof (item as any).platform === 'string' &&\n (item as any).platform.toLowerCase() === 'android'\n );\n}\n\n/**\n * Deep link to subscriptions screen on Android.\n * @param {Object} params - The parameters object\n * @param {string} params.skuAndroid - The product's SKU (on Android)\n * @param {string} params.packageNameAndroid - The package name of your Android app (e.g., 'com.example.app')\n * @returns {Promise<void>}\n *\n * @example\n * ```typescript\n * await deepLinkToSubscriptionsAndroid({\n * skuAndroid: 'subscription_id',\n * packageNameAndroid: 'com.example.app'\n * });\n * ```\n */\nexport const deepLinkToSubscriptionsAndroid = async (\n options?: DeepLinkOptions | null,\n): Promise<void> => {\n const sku = options?.skuAndroid ?? undefined;\n const packageName = options?.packageNameAndroid ?? undefined;\n\n // Prefer native deep link implementation via OpenIAP module\n if (nativeAndroidModule?.deepLinkToSubscriptionsAndroid) {\n return nativeAndroidModule.deepLinkToSubscriptionsAndroid({\n skuAndroid: sku,\n packageNameAndroid: packageName,\n });\n }\n\n // Fallback to Linking if native method unavailable\n if (!packageName) {\n throw new Error(\n 'packageName is required for deepLinkToSubscriptionsAndroid',\n );\n }\n const base = `https://play.google.com/store/account/subscriptions?package=${encodeURIComponent(\n packageName,\n )}`;\n const url = sku ? `${base}&sku=${encodeURIComponent(sku)}` : base;\n return Linking.openURL(url);\n};\n\n/**\n * Validate receipt for Android. NOTE: This method is here for debugging purposes only. Including\n * your access token in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {Object} params - The parameters object\n * @param {string} params.packageName - package name of your app.\n * @param {string} params.productId - product id for your in app product.\n * @param {string} params.productToken - token for your purchase (called 'token' in the API documentation).\n * @param {string} params.accessToken - OAuth access token with androidpublisher scope. Required for authentication.\n * @param {boolean} params.isSub - whether this is subscription or in-app. `true` for subscription.\n * @returns {Promise<ReceiptAndroid>}\n */\nexport const validateReceiptAndroid = async ({\n packageName,\n productId,\n productToken,\n accessToken,\n isSub,\n}: {\n packageName: string;\n productId: string;\n productToken: string;\n accessToken: string;\n isSub?: boolean;\n}): Promise<ReceiptValidationResultAndroid> => {\n const type = isSub ? 'subscriptions' : 'products';\n\n const url =\n 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications' +\n `/${packageName}/purchases/${type}/${productId}` +\n `/tokens/${productToken}`;\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${accessToken}`,\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Acknowledge a product (on Android.) No-op on iOS.\n * @param {Object} params - The parameters object\n * @param {string} params.token - The product's token (on Android)\n * @returns {Promise<VoidResult | void>}\n */\nexport const acknowledgePurchaseAndroid: MutationField<\n 'acknowledgePurchaseAndroid'\n> = async (purchaseToken) => {\n const result = await ExpoIapModule.acknowledgePurchaseAndroid(purchaseToken);\n\n if (typeof result === 'boolean') {\n return result;\n }\n\n if (result && typeof result === 'object') {\n const record = result as Record<string, unknown>;\n if (typeof record.success === 'boolean') {\n return record.success;\n }\n if (typeof record.responseCode === 'number') {\n return record.responseCode === 0;\n }\n }\n\n return true;\n};\n\n/**\n * Open the Google Play Store to redeem offer codes (Android only).\n * Note: Google Play does not provide a direct API to redeem codes within the app.\n * This function opens the Play Store where users can manually enter their codes.\n *\n * @returns {Promise<void>}\n */\nexport const openRedeemOfferCodeAndroid = async (): Promise<void> => {\n return Linking.openURL(`https://play.google.com/redeem?code=`);\n};\n\n/**\n * Check if alternative billing is available for this user/device (Android only).\n * Step 1 of alternative billing flow.\n *\n * Returns true if available, false otherwise.\n * Throws OpenIapError.NotPrepared if billing client not ready.\n *\n * @returns {Promise<boolean>}\n *\n * @example\n * ```typescript\n * const isAvailable = await checkAlternativeBillingAvailabilityAndroid();\n * if (isAvailable) {\n * // Proceed with alternative billing flow\n * }\n * ```\n */\nexport const checkAlternativeBillingAvailabilityAndroid: MutationField<\n 'checkAlternativeBillingAvailabilityAndroid'\n> = async () => {\n return ExpoIapModule.checkAlternativeBillingAvailabilityAndroid();\n};\n\n/**\n * Show alternative billing information dialog to user (Android only).\n * Step 2 of alternative billing flow.\n * Must be called BEFORE processing payment in your payment system.\n *\n * Returns true if user accepted, false if user canceled.\n * Throws OpenIapError.NotPrepared if billing client not ready.\n *\n * @returns {Promise<boolean>}\n *\n * @example\n * ```typescript\n * const userAccepted = await showAlternativeBillingDialogAndroid();\n * if (userAccepted) {\n * // Process payment in your payment system\n * const success = await processCustomPayment();\n * if (success) {\n * // Create reporting token\n * const token = await createAlternativeBillingTokenAndroid();\n * // Send token to your backend for Google Play reporting\n * }\n * }\n * ```\n */\nexport const showAlternativeBillingDialogAndroid: MutationField<\n 'showAlternativeBillingDialogAndroid'\n> = async () => {\n return ExpoIapModule.showAlternativeBillingDialogAndroid();\n};\n\n/**\n * Create external transaction token for Google Play reporting (Android only).\n * Step 3 of alternative billing flow.\n * Must be called AFTER successful payment in your payment system.\n * Token must be reported to Google Play backend within 24 hours.\n *\n * Returns token string, or null if creation failed.\n * Throws OpenIapError.NotPrepared if billing client not ready.\n *\n * @param {string} sku - The product SKU that was purchased\n * @returns {Promise<string | null>}\n *\n * @example\n * ```typescript\n * const token = await createAlternativeBillingTokenAndroid('premium_subscription');\n * if (token) {\n * // Send token to your backend\n * await fetch('/api/report-transaction', {\n * method: 'POST',\n * body: JSON.stringify({ token, sku: 'premium_subscription' })\n * });\n * }\n * ```\n */\nexport const createAlternativeBillingTokenAndroid: MutationField<\n 'createAlternativeBillingTokenAndroid'\n> = async (sku?: string) => {\n return ExpoIapModule.createAlternativeBillingTokenAndroid(sku);\n};\n"]}
@@ -183,4 +183,27 @@ export declare const clearTransactionIOS: MutationField<'clearTransactionIOS'>;
183
183
  * @platform iOS
184
184
  */
185
185
  export declare const deepLinkToSubscriptionsIOS: () => Promise<void>;
186
+ /**
187
+ * Check if the device can present an external purchase notice sheet (iOS 18.2+).
188
+ *
189
+ * @returns Promise resolving to true if the notice sheet can be presented
190
+ * @platform iOS
191
+ */
192
+ export declare const canPresentExternalPurchaseNoticeIOS: QueryField<'canPresentExternalPurchaseNoticeIOS'>;
193
+ /**
194
+ * Present an external purchase notice sheet to inform users about external purchases (iOS 18.2+).
195
+ * This must be called before opening an external purchase link.
196
+ *
197
+ * @returns Promise resolving to the result with action and error if any
198
+ * @platform iOS
199
+ */
200
+ export declare const presentExternalPurchaseNoticeSheetIOS: MutationField<'presentExternalPurchaseNoticeSheetIOS'>;
201
+ /**
202
+ * Present an external purchase link to redirect users to your website (iOS 16.0+).
203
+ *
204
+ * @param url - The external purchase URL to open
205
+ * @returns Promise resolving to the result with success status and error if any
206
+ * @platform iOS
207
+ */
208
+ export declare const presentExternalPurchaseLinkIOS: MutationField<'presentExternalPurchaseLinkIOS'>;
186
209
  //# sourceMappingURL=ios.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../src/modules/ios.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,aAAa,EAEb,QAAQ,EAER,UAAU,EAIX,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AAGzD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,WAAW,CAAC,EAAE,QAAQ,CAAC;IACvB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,CAAC;AAKF,wBAAgB,YAAY,CAAC,CAAC,SAAS;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAC,EACxD,IAAI,EAAE,OAAO,GACZ,IAAI,IAAI,CAAC,GAAG;IAAC,QAAQ,EAAE,KAAK,CAAA;CAAC,CAQ/B;AAGD;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,SAAS,CAE5C,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B,EAAE,UAAU,CACj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AAa,CACxD,gCAAgC,CAIjC,CAAC"}
@@ -23,7 +23,7 @@ export function isProductIOS(item) {
23
23
  * @platform iOS
24
24
  */
25
25
  export const syncIOS = async () => {
26
- return Boolean(await ExpoIapModule.syncIOS());
26
+ return !!(await ExpoIapModule.syncIOS());
27
27
  };
28
28
  /**
29
29
  * Check if user is eligible for introductory offer
@@ -199,7 +199,7 @@ export const validateReceiptIOS = validateReceiptIOSImpl;
199
199
  * @platform iOS
200
200
  */
201
201
  export const presentCodeRedemptionSheetIOS = async () => {
202
- return Boolean(await ExpoIapModule.presentCodeRedemptionSheetIOS());
202
+ return !!(await ExpoIapModule.presentCodeRedemptionSheetIOS());
203
203
  };
204
204
  /**
205
205
  * Get app transaction information (iOS 16.0+).
@@ -262,7 +262,7 @@ export const getPendingTransactionsIOS = async () => {
262
262
  * @platform iOS
263
263
  */
264
264
  export const clearTransactionIOS = async () => {
265
- return Boolean(await ExpoIapModule.clearTransactionIOS());
265
+ return !!(await ExpoIapModule.clearTransactionIOS());
266
266
  };
267
267
  /**
268
268
  * Deep link to subscriptions screen on iOS.
@@ -271,5 +271,36 @@ export const clearTransactionIOS = async () => {
271
271
  * @platform iOS
272
272
  */
273
273
  export const deepLinkToSubscriptionsIOS = () => Linking.openURL('https://apps.apple.com/account/subscriptions');
274
+ /**
275
+ * Check if the device can present an external purchase notice sheet (iOS 18.2+).
276
+ *
277
+ * @returns Promise resolving to true if the notice sheet can be presented
278
+ * @platform iOS
279
+ */
280
+ export const canPresentExternalPurchaseNoticeIOS = async () => {
281
+ return !!(await ExpoIapModule.canPresentExternalPurchaseNoticeIOS());
282
+ };
283
+ /**
284
+ * Present an external purchase notice sheet to inform users about external purchases (iOS 18.2+).
285
+ * This must be called before opening an external purchase link.
286
+ *
287
+ * @returns Promise resolving to the result with action and error if any
288
+ * @platform iOS
289
+ */
290
+ export const presentExternalPurchaseNoticeSheetIOS = async () => {
291
+ const result = await ExpoIapModule.presentExternalPurchaseNoticeSheetIOS();
292
+ return result;
293
+ };
294
+ /**
295
+ * Present an external purchase link to redirect users to your website (iOS 16.0+).
296
+ *
297
+ * @param url - The external purchase URL to open
298
+ * @returns Promise resolving to the result with success status and error if any
299
+ * @platform iOS
300
+ */
301
+ export const presentExternalPurchaseLinkIOS = async (url) => {
302
+ const result = await ExpoIapModule.presentExternalPurchaseLinkIOS(url);
303
+ return result;
304
+ };
274
305
  // iOS-specific APIs only; cross-platform wrappers live in src/index.ts
275
306
  //# sourceMappingURL=ios.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ios.js","sourceRoot":"","sources":["../../src/modules/ios.ts"],"names":[],"mappings":"AAAA,wBAAwB;AAExB,mBAAmB;AACnB,mEAAmE;AACnE,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAc7C,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAOrC,YAAY;AAEZ,cAAc;AACd,MAAM,UAAU,YAAY,CAC1B,IAAa;IAEb,OAAO,CACL,IAAI,IAAI,IAAI;QACZ,OAAO,IAAI,KAAK,QAAQ;QACxB,UAAU,IAAI,IAAI;QAClB,OAAQ,IAAY,CAAC,QAAQ,KAAK,QAAQ;QACzC,IAAY,CAAC,QAAQ,CAAC,WAAW,EAAE,KAAK,KAAK,CAC/C,CAAC;AACJ,CAAC;AAED,YAAY;AACZ;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,OAAO,GAA6B,KAAK,IAAI,EAAE;IAC1D,OAAO,OAAO,CAAC,MAAM,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC;AAChD,CAAC,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAEnC,KAAK,EAAE,OAAO,EAAE,EAAE;IACpB,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,aAAa,CAAC,0BAA0B,CAAC,OAAO,CAAC,CAAC;AAC3D,CAAC,CAAC;A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,IAAI,EAAE;IACb,OAAO,OAAO,CAAC,MAAM,aAAa,CAAC,mBAAmB,EAAE,CAAC,CAAC;AAC5D,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAkB,EAAE,CAC5D,OAAO,CAAC,OAAO,CAAC,8CAA8C,CAAC,CAAC;AAElE,uEAAuE","sourcesContent":["// External dependencies\n\n// Internal modules\n// import removed: use purchaseUpdatedListener directly in app code\nimport ExpoIapModule from '../ExpoIapModule';\n\n// Types\nimport type {\n MutationField,\n ProductIOS,\n Purchase,\n PurchaseIOS,\n QueryField,\n ReceiptValidationProps,\n ReceiptValidationResultIOS,\n SubscriptionStatusIOS,\n} from '../types';\nimport type {PurchaseError} from '../utils/errorMapping';\nimport {Linking} from 'react-native';\n\nexport type TransactionEvent = {\n transaction?: Purchase;\n error?: PurchaseError;\n};\n\n// Listeners\n\n// Type guards\nexport function isProductIOS<T extends {platform?: string}>(\n item: unknown,\n): item is T & {platform: 'ios'} {\n return (\n item != null &&\n typeof item === 'object' &&\n 'platform' in item &&\n typeof (item as any).platform === 'string' &&\n (item as any).platform.toLowerCase() === 'ios'\n );\n}\n\n// Functions\n/**\n * Sync state with Appstore (iOS only)\n * https://developer.apple.com/documentation/storekit/appstore/3791906-sync\n *\n * @returns Promise resolving to null on success\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const syncIOS: MutationField<'syncIOS'> = async () => {\n return Boolean(await ExpoIapModule.syncIOS());\n};\n\n/**\n * Check if user is eligible for introductory offer\n *\n * @param groupId The subscription group ID\n * @returns Promise resolving to true if eligible\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const isEligibleForIntroOfferIOS: QueryField<\n 'isEligibleForIntroOfferIOS'\n> = async (groupID) => {\n if (!groupID) {\n throw new Error('isEligibleForIntroOfferIOS requires a groupID');\n }\n return ExpoIapModule.isEligibleForIntroOfferIOS(groupID);\n};\n\n/**\n * Get subscription status for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to array of subscription status\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const subscriptionStatusIOS: QueryField<\n 'subscriptionStatusIOS'\n> = async (sku) => {\n if (!sku) {\n throw new Error('subscriptionStatusIOS requires a SKU');\n }\n const status = await ExpoIapModule.subscriptionStatusIOS(sku);\n return (status ?? []) as SubscriptionStatusIOS[];\n};\n\n/**\n * Get current entitlement for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to current entitlement\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const currentEntitlementIOS: QueryField<\n 'currentEntitlementIOS'\n> = async (sku) => {\n if (!sku) {\n throw new Error('currentEntitlementIOS requires a SKU');\n }\n const purchase = await ExpoIapModule.currentEntitlementIOS(sku);\n return (purchase ?? null) as PurchaseIOS | null;\n};\n\n/**\n * Get latest transaction for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to latest transaction\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const latestTransactionIOS: QueryField<'latestTransactionIOS'> = async (\n sku,\n) => {\n if (!sku) {\n throw new Error('latestTransactionIOS requires a SKU');\n }\n const transaction = await ExpoIapModule.latestTransactionIOS(sku);\n return (transaction ?? null) as PurchaseIOS | null;\n};\n\n/**\n * Begin refund request for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to refund request status\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const beginRefundRequestIOS: MutationField<\n 'beginRefundRequestIOS'\n> = async (sku) => {\n if (!sku) {\n throw new Error('beginRefundRequestIOS requires a SKU');\n }\n const status = await ExpoIapModule.beginRefundRequestIOS(sku);\n return status ?? null;\n};\n\n/**\n * Shows the system UI for managing subscriptions.\n * Returns an array of subscriptions that had status changes after the UI is closed.\n *\n * @returns Promise<Purchase[]> - Array of subscriptions with status changes (e.g., auto-renewal toggled)\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const showManageSubscriptionsIOS: MutationField<\n 'showManageSubscriptionsIOS'\n> = async () => {\n const purchases = await ExpoIapModule.showManageSubscriptionsIOS();\n return (purchases ?? []) as PurchaseIOS[];\n};\n\n/**\n * Get the receipt data from the iOS device.\n * This returns the base64 encoded receipt data which can be sent to your server\n * for verification with Apple's server.\n *\n * NOTE: For proper security, always verify receipts on your server using\n * Apple's verifyReceipt endpoint, not directly from the app.\n *\n * @returns {Promise<string>} Base64 encoded receipt data\n */\nexport const getReceiptDataIOS: QueryField<'getReceiptDataIOS'> = async () => {\n return ExpoIapModule.getReceiptDataIOS();\n};\n\nexport const getReceiptIOS = getReceiptDataIOS;\n\n/**\n * Check if a transaction is verified through StoreKit 2.\n * StoreKit 2 performs local verification of transaction JWS signatures.\n *\n * @param sku The product's SKU (on iOS)\n * @returns Promise resolving to true if the transaction is verified\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const isTransactionVerifiedIOS: QueryField<\n 'isTransactionVerifiedIOS'\n> = async (sku) => {\n if (!sku) {\n throw new Error('isTransactionVerifiedIOS requires a SKU');\n }\n return ExpoIapModule.isTransactionVerifiedIOS(sku);\n};\n\n/**\n * Get the JWS representation of a purchase for server-side verification.\n * The JWS (JSON Web Signature) can be verified on your server using Apple's public keys.\n *\n * @param sku The product's SKU (on iOS)\n * @returns Promise resolving to JWS representation of the transaction\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const getTransactionJwsIOS: QueryField<'getTransactionJwsIOS'> = async (\n sku,\n) => {\n if (!sku) {\n throw new Error('getTransactionJwsIOS requires a SKU');\n }\n const jws = await ExpoIapModule.getTransactionJwsIOS(sku);\n return jws ?? '';\n};\n\n/**\n * Validate receipt for iOS using StoreKit 2's built-in verification.\n * Returns receipt data and verification information to help with server-side validation.\n *\n * NOTE: For proper security, Apple recommends verifying receipts on your server using\n * the verifyReceipt endpoint rather than relying solely on client-side verification.\n *\n * @param {string} sku The product's SKU (on iOS)\n * @returns {Promise<{\n * isValid: boolean;\n * receiptData: string;\n * jwsRepresentation: string;\n * latestTransaction?: Purchase;\n * }>}\n */\nconst validateReceiptIOSImpl = async (\n props: ReceiptValidationProps | string,\n) => {\n const sku =\n typeof props === 'string' ? props : (props as ReceiptValidationProps)?.sku;\n\n if (!sku) {\n throw new Error('validateReceiptIOS requires a SKU');\n }\n\n return (await ExpoIapModule.validateReceiptIOS(\n sku,\n )) as ReceiptValidationResultIOS;\n};\n\nexport const validateReceiptIOS =\n validateReceiptIOSImpl as QueryField<'validateReceiptIOS'>;\n\n/**\n * Present the code redemption sheet for offer codes (iOS only).\n * This allows users to redeem promotional codes for in-app purchases and subscriptions.\n *\n * Note: This only works on real devices, not simulators.\n *\n * @returns Promise resolving to true if the sheet was presented successfully\n * @throws Error if called on non-iOS platform or tvOS\n *\n * @platform iOS\n */\nexport const presentCodeRedemptionSheetIOS: MutationField<\n 'presentCodeRedemptionSheetIOS'\n> = async () => {\n return Boolean(await ExpoIapModule.presentCodeRedemptionSheetIOS());\n};\n\n/**\n * Get app transaction information (iOS 16.0+).\n * AppTransaction represents the initial purchase that unlocked the app.\n *\n * NOTE: This function requires:\n * - iOS 16.0 or later at runtime\n * - Xcode 15.0+ with iOS 16.0 SDK for compilation\n *\n * @returns Promise resolving to the app transaction information or null if not available\n * @throws Error if called on non-iOS platform, iOS version < 16.0, or compiled with older SDK\n *\n * @platform iOS\n * @since iOS 16.0\n */\nexport const getAppTransactionIOS: QueryField<\n 'getAppTransactionIOS'\n> = async () => {\n return (await ExpoIapModule.getAppTransactionIOS()) ?? null;\n};\n\n/**\n * Get information about a promoted product if one is available (iOS only).\n * Promoted products are products that the App Store promotes on your behalf.\n * This is called after a promoted product event is received from the App Store.\n *\n * @returns Promise resolving to the promoted product information or null if none available\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const getPromotedProductIOS: QueryField<\n 'getPromotedProductIOS'\n> = async () => {\n const product = await ExpoIapModule.getPromotedProductIOS();\n return (product ?? null) as ProductIOS | null;\n};\n\n/**\n * Complete the purchase of a promoted product (iOS only).\n * This should be called after showing your purchase UI for a promoted product.\n *\n * @returns Promise resolving when the purchase is initiated\n * @throws Error if called on non-iOS platform or no promoted product is available\n *\n * @platform iOS\n */\nexport const requestPurchaseOnPromotedProductIOS: MutationField<\n 'requestPurchaseOnPromotedProductIOS'\n> = async () => {\n await ExpoIapModule.requestPurchaseOnPromotedProductIOS();\n return true;\n};\n\n/**\n * Get pending transactions that haven't been finished yet (iOS only).\n *\n * @returns Promise resolving to array of pending transactions\n * @platform iOS\n */\nexport const getPendingTransactionsIOS: QueryField<\n 'getPendingTransactionsIOS'\n> = async () => {\n const transactions = await ExpoIapModule.getPendingTransactionsIOS();\n return (transactions ?? []) as PurchaseIOS[];\n};\n\n/**\n * Clear a specific transaction (iOS only).\n *\n * @returns Promise resolving when transaction is cleared\n * @platform iOS\n */\nexport const clearTransactionIOS: MutationField<\n 'clearTransactionIOS'\n> = async () => {\n return Boolean(await ExpoIapModule.clearTransactionIOS());\n};\n\n/**\n * Deep link to subscriptions screen on iOS.\n * @returns {Promise<void>}\n *\n * @platform iOS\n */\nexport const deepLinkToSubscriptionsIOS = (): Promise<void> =>\n Linking.openURL('https://apps.apple.com/account/subscriptions');\n\n// iOS-specific APIs only; cross-platform wrappers live in src/index.ts\n"]}
1
+ {"version":3,"file":"ios.js","sourceRoot":"","sources":["../../src/modules/ios.ts"],"names":[],"mappings":"AAAA,wBAAwB;AAExB,mBAAmB;AACnB,mEAAmE;AACnE,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAgB7C,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAOrC,YAAY;AAEZ,cAAc;AACd,MAAM,UAAU,YAAY,CAC1B,IAAa;IAEb,OAAO,CACL,IAAI,IAAI,IAAI;QACZ,OAAO,IAAI,KAAK,QAAQ;QACxB,UAAU,IAAI,IAAI;QAClB,OAAQ,IAAY,CAAC,QAAQ,KAAK,QAAQ;QACzC,IAAY,C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CAAC,CAAC;IACvE,OAAO,MAAuC,CAAC;AACjD,CAAC,CAAC;AAEF,uEAAuE","sourcesContent":["// External dependencies\n\n// Internal modules\n// import removed: use purchaseUpdatedListener directly in app code\nimport ExpoIapModule from '../ExpoIapModule';\n\n// Types\nimport type {\n ExternalPurchaseLinkResultIOS,\n ExternalPurchaseNoticeResultIOS,\n MutationField,\n ProductIOS,\n Purchase,\n PurchaseIOS,\n QueryField,\n ReceiptValidationProps,\n ReceiptValidationResultIOS,\n SubscriptionStatusIOS,\n} from '../types';\nimport type {PurchaseError} from '../utils/errorMapping';\nimport {Linking} from 'react-native';\n\nexport type TransactionEvent = {\n transaction?: Purchase;\n error?: PurchaseError;\n};\n\n// Listeners\n\n// Type guards\nexport function isProductIOS<T extends {platform?: string}>(\n item: unknown,\n): item is T & {platform: 'ios'} {\n return (\n item != null &&\n typeof item === 'object' &&\n 'platform' in item &&\n typeof (item as any).platform === 'string' &&\n (item as any).platform.toLowerCase() === 'ios'\n );\n}\n\n// Functions\n/**\n * Sync state with Appstore (iOS only)\n * https://developer.apple.com/documentation/storekit/appstore/3791906-sync\n *\n * @returns Promise resolving to null on success\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const syncIOS: MutationField<'syncIOS'> = async () => {\n return !!(await ExpoIapModule.syncIOS());\n};\n\n/**\n * Check if user is eligible for introductory offer\n *\n * @param groupId The subscription group ID\n * @returns Promise resolving to true if eligible\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const isEligibleForIntroOfferIOS: QueryField<\n 'isEligibleForIntroOfferIOS'\n> = async (groupID) => {\n if (!groupID) {\n throw new Error('isEligibleForIntroOfferIOS requires a groupID');\n }\n return ExpoIapModule.isEligibleForIntroOfferIOS(groupID);\n};\n\n/**\n * Get subscription status for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to array of subscription status\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const subscriptionStatusIOS: QueryField<\n 'subscriptionStatusIOS'\n> = async (sku) => {\n if (!sku) {\n throw new Error('subscriptionStatusIOS requires a SKU');\n }\n const status = await ExpoIapModule.subscriptionStatusIOS(sku);\n return (status ?? []) as SubscriptionStatusIOS[];\n};\n\n/**\n * Get current entitlement for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to current entitlement\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const currentEntitlementIOS: QueryField<\n 'currentEntitlementIOS'\n> = async (sku) => {\n if (!sku) {\n throw new Error('currentEntitlementIOS requires a SKU');\n }\n const purchase = await ExpoIapModule.currentEntitlementIOS(sku);\n return (purchase ?? null) as PurchaseIOS | null;\n};\n\n/**\n * Get latest transaction for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to latest transaction\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const latestTransactionIOS: QueryField<'latestTransactionIOS'> = async (\n sku,\n) => {\n if (!sku) {\n throw new Error('latestTransactionIOS requires a SKU');\n }\n const transaction = await ExpoIapModule.latestTransactionIOS(sku);\n return (transaction ?? null) as PurchaseIOS | null;\n};\n\n/**\n * Begin refund request for a specific SKU\n *\n * @param sku The product SKU\n * @returns Promise resolving to refund request status\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const beginRefundRequestIOS: MutationField<\n 'beginRefundRequestIOS'\n> = async (sku) => {\n if (!sku) {\n throw new Error('beginRefundRequestIOS requires a SKU');\n }\n const status = await ExpoIapModule.beginRefundRequestIOS(sku);\n return status ?? null;\n};\n\n/**\n * Shows the system UI for managing subscriptions.\n * Returns an array of subscriptions that had status changes after the UI is closed.\n *\n * @returns Promise<Purchase[]> - Array of subscriptions with status changes (e.g., auto-renewal toggled)\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const showManageSubscriptionsIOS: MutationField<\n 'showManageSubscriptionsIOS'\n> = async () => {\n const purchases = await ExpoIapModule.showManageSubscriptionsIOS();\n return (purchases ?? []) as PurchaseIOS[];\n};\n\n/**\n * Get the receipt data from the iOS device.\n * This returns the base64 encoded receipt data which can be sent to your server\n * for verification with Apple's server.\n *\n * NOTE: For proper security, always verify receipts on your server using\n * Apple's verifyReceipt endpoint, not directly from the app.\n *\n * @returns {Promise<string>} Base64 encoded receipt data\n */\nexport const getReceiptDataIOS: QueryField<'getReceiptDataIOS'> = async () => {\n return ExpoIapModule.getReceiptDataIOS();\n};\n\nexport const getReceiptIOS = getReceiptDataIOS;\n\n/**\n * Check if a transaction is verified through StoreKit 2.\n * StoreKit 2 performs local verification of transaction JWS signatures.\n *\n * @param sku The product's SKU (on iOS)\n * @returns Promise resolving to true if the transaction is verified\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const isTransactionVerifiedIOS: QueryField<\n 'isTransactionVerifiedIOS'\n> = async (sku) => {\n if (!sku) {\n throw new Error('isTransactionVerifiedIOS requires a SKU');\n }\n return ExpoIapModule.isTransactionVerifiedIOS(sku);\n};\n\n/**\n * Get the JWS representation of a purchase for server-side verification.\n * The JWS (JSON Web Signature) can be verified on your server using Apple's public keys.\n *\n * @param sku The product's SKU (on iOS)\n * @returns Promise resolving to JWS representation of the transaction\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const getTransactionJwsIOS: QueryField<'getTransactionJwsIOS'> = async (\n sku,\n) => {\n if (!sku) {\n throw new Error('getTransactionJwsIOS requires a SKU');\n }\n const jws = await ExpoIapModule.getTransactionJwsIOS(sku);\n return jws ?? '';\n};\n\n/**\n * Validate receipt for iOS using StoreKit 2's built-in verification.\n * Returns receipt data and verification information to help with server-side validation.\n *\n * NOTE: For proper security, Apple recommends verifying receipts on your server using\n * the verifyReceipt endpoint rather than relying solely on client-side verification.\n *\n * @param {string} sku The product's SKU (on iOS)\n * @returns {Promise<{\n * isValid: boolean;\n * receiptData: string;\n * jwsRepresentation: string;\n * latestTransaction?: Purchase;\n * }>}\n */\nconst validateReceiptIOSImpl = async (\n props: ReceiptValidationProps | string,\n) => {\n const sku =\n typeof props === 'string' ? props : (props as ReceiptValidationProps)?.sku;\n\n if (!sku) {\n throw new Error('validateReceiptIOS requires a SKU');\n }\n\n return (await ExpoIapModule.validateReceiptIOS(\n sku,\n )) as ReceiptValidationResultIOS;\n};\n\nexport const validateReceiptIOS =\n validateReceiptIOSImpl as QueryField<'validateReceiptIOS'>;\n\n/**\n * Present the code redemption sheet for offer codes (iOS only).\n * This allows users to redeem promotional codes for in-app purchases and subscriptions.\n *\n * Note: This only works on real devices, not simulators.\n *\n * @returns Promise resolving to true if the sheet was presented successfully\n * @throws Error if called on non-iOS platform or tvOS\n *\n * @platform iOS\n */\nexport const presentCodeRedemptionSheetIOS: MutationField<\n 'presentCodeRedemptionSheetIOS'\n> = async () => {\n return !!(await ExpoIapModule.presentCodeRedemptionSheetIOS());\n};\n\n/**\n * Get app transaction information (iOS 16.0+).\n * AppTransaction represents the initial purchase that unlocked the app.\n *\n * NOTE: This function requires:\n * - iOS 16.0 or later at runtime\n * - Xcode 15.0+ with iOS 16.0 SDK for compilation\n *\n * @returns Promise resolving to the app transaction information or null if not available\n * @throws Error if called on non-iOS platform, iOS version < 16.0, or compiled with older SDK\n *\n * @platform iOS\n * @since iOS 16.0\n */\nexport const getAppTransactionIOS: QueryField<\n 'getAppTransactionIOS'\n> = async () => {\n return (await ExpoIapModule.getAppTransactionIOS()) ?? null;\n};\n\n/**\n * Get information about a promoted product if one is available (iOS only).\n * Promoted products are products that the App Store promotes on your behalf.\n * This is called after a promoted product event is received from the App Store.\n *\n * @returns Promise resolving to the promoted product information or null if none available\n * @throws Error if called on non-iOS platform\n *\n * @platform iOS\n */\nexport const getPromotedProductIOS: QueryField<\n 'getPromotedProductIOS'\n> = async () => {\n const product = await ExpoIapModule.getPromotedProductIOS();\n return (product ?? null) as ProductIOS | null;\n};\n\n/**\n * Complete the purchase of a promoted product (iOS only).\n * This should be called after showing your purchase UI for a promoted product.\n *\n * @returns Promise resolving when the purchase is initiated\n * @throws Error if called on non-iOS platform or no promoted product is available\n *\n * @platform iOS\n */\nexport const requestPurchaseOnPromotedProductIOS: MutationField<\n 'requestPurchaseOnPromotedProductIOS'\n> = async () => {\n await ExpoIapModule.requestPurchaseOnPromotedProductIOS();\n return true;\n};\n\n/**\n * Get pending transactions that haven't been finished yet (iOS only).\n *\n * @returns Promise resolving to array of pending transactions\n * @platform iOS\n */\nexport const getPendingTransactionsIOS: QueryField<\n 'getPendingTransactionsIOS'\n> = async () => {\n const transactions = await ExpoIapModule.getPendingTransactionsIOS();\n return (transactions ?? []) as PurchaseIOS[];\n};\n\n/**\n * Clear a specific transaction (iOS only).\n *\n * @returns Promise resolving when transaction is cleared\n * @platform iOS\n */\nexport const clearTransactionIOS: MutationField<\n 'clearTransactionIOS'\n> = async () => {\n return !!(await ExpoIapModule.clearTransactionIOS());\n};\n\n/**\n * Deep link to subscriptions screen on iOS.\n * @returns {Promise<void>}\n *\n * @platform iOS\n */\nexport const deepLinkToSubscriptionsIOS = (): Promise<void> =>\n Linking.openURL('https://apps.apple.com/account/subscriptions');\n\n/**\n * Check if the device can present an external purchase notice sheet (iOS 18.2+).\n *\n * @returns Promise resolving to true if the notice sheet can be presented\n * @platform iOS\n */\nexport const canPresentExternalPurchaseNoticeIOS: QueryField<\n 'canPresentExternalPurchaseNoticeIOS'\n> = async () => {\n return !!(await ExpoIapModule.canPresentExternalPurchaseNoticeIOS());\n};\n\n/**\n * Present an external purchase notice sheet to inform users about external purchases (iOS 18.2+).\n * This must be called before opening an external purchase link.\n *\n * @returns Promise resolving to the result with action and error if any\n * @platform iOS\n */\nexport const presentExternalPurchaseNoticeSheetIOS: MutationField<\n 'presentExternalPurchaseNoticeSheetIOS'\n> = async () => {\n const result = await ExpoIapModule.presentExternalPurchaseNoticeSheetIOS();\n return result as ExternalPurchaseNoticeResultIOS;\n};\n\n/**\n * Present an external purchase link to redirect users to your website (iOS 16.0+).\n *\n * @param url - The external purchase URL to open\n * @returns Promise resolving to the result with success status and error if any\n * @platform iOS\n */\nexport const presentExternalPurchaseLinkIOS: MutationField<\n 'presentExternalPurchaseLinkIOS'\n> = async (url: string) => {\n const result = await ExpoIapModule.presentExternalPurchaseLinkIOS(url);\n return result as ExternalPurchaseLinkResultIOS;\n};\n\n// iOS-specific APIs only; cross-platform wrappers live in src/index.ts\n"]}
package/build/types.d.ts CHANGED
@@ -1,15 +1,30 @@
1
1
  export interface ActiveSubscription {
2
2
  autoRenewingAndroid?: (boolean | null);
3
+ basePlanIdAndroid?: (string | null);
4
+ /**
5
+ * The current plan identifier. This is:
6
+ * - On Android: the basePlanId (e.g., "premium", "premium-year")
7
+ * - On iOS: the productId (e.g., "com.example.premium_monthly", "com.example.premium_yearly")
8
+ * This provides a unified way to identify which specific plan/tier the user is subscribed to.
9
+ */
10
+ currentPlanId?: (string | null);
3
11
  daysUntilExpirationIOS?: (number | null);
4
12
  environmentIOS?: (string | null);
5
13
  expirationDateIOS?: (number | null);
6
14
  isActive: boolean;
7
15
  productId: string;
8
16
  purchaseToken?: (string | null);
17
+ /** Required for subscription upgrade/downgrade on Android */
18
+ purchaseTokenAndroid?: (string | null);
9
19
  transactionDate: number;
10
20
  transactionId: string;
11
21
  willExpireSoon?: (boolean | null);
12
22
  }
23
+ /**
24
+ * Alternative billing mode for Android
25
+ * Controls which billing system is used
26
+ */
27
+ export type AlternativeBillingModeAndroid = 'none' | 'user-choice' | 'alternative-only';
13
28
  export interface AndroidSubscriptionOfferInput {
14
29
  /** Offer token */
15
30
  offerToken: string;
@@ -112,18 +127,60 @@ export declare enum ErrorCode {
112
127
  UserCancelled = "user-cancelled",
113
128
  UserError = "user-error"
114
129
  }
130
+ /** Result of presenting an external purchase link (iOS 18.2+) */
131
+ export interface ExternalPurchaseLinkResultIOS {
132
+ /** Optional error message if the presentation failed */
133
+ error?: (string | null);
134
+ /** Whether the user completed the external purchase flow */
135
+ success: boolean;
136
+ }
137
+ /** User actions on external purchase notice sheet (iOS 18.2+) */
138
+ export type ExternalPurchaseNoticeAction = 'continue' | 'dismissed';
139
+ /** Result of presenting external purchase notice sheet (iOS 18.2+) */
140
+ export interface ExternalPurchaseNoticeResultIOS {
141
+ /** Optional error message if the presentation failed */
142
+ error?: (string | null);
143
+ /** Notice result indicating user action */
144
+ result: ExternalPurchaseNoticeAction;
145
+ }
115
146
  export type FetchProductsResult = Product[] | ProductSubscription[] | null;
116
- export type IapEvent = 'purchase-updated' | 'purchase-error' | 'promoted-product-ios';
147
+ export type IapEvent = 'purchase-updated' | 'purchase-error' | 'promoted-product-ios' | 'user-choice-billing-android';
117
148
  export type IapPlatform = 'ios' | 'android';
149
+ /** Connection initialization configuration */
150
+ export interface InitConnectionConfig {
151
+ /**
152
+ * Alternative billing mode for Android
153
+ * If not specified, defaults to NONE (standard Google Play billing)
154
+ */
155
+ alternativeBillingModeAndroid?: (AlternativeBillingModeAndroid | null);
156
+ }
118
157
  export interface Mutation {
119
158
  /** Acknowledge a non-consumable purchase or subscription */
120
159
  acknowledgePurchaseAndroid: Promise<boolean>;
121
160
  /** Initiate a refund request for a product (iOS 15+) */
122
161
  beginRefundRequestIOS?: Promise<(string | null)>;
162
+ /**
163
+ * Check if alternative billing is available for this user/device
164
+ * Step 1 of alternative billing flow
165
+ *
166
+ * Returns true if available, false otherwise
167
+ * Throws OpenIapError.NotPrepared if billing client not ready
168
+ */
169
+ checkAlternativeBillingAvailabilityAndroid: Promise<boolean>;
123
170
  /** Clear pending transactions from the StoreKit payment queue */
124
171
  clearTransactionIOS: Promise<boolean>;
125
172
  /** Consume a purchase token so it can be repurchased */
126
173
  consumePurchaseAndroid: Promise<boolean>;
174
+ /**
175
+ * Create external transaction token for Google Play reporting
176
+ * Step 3 of alternative billing flow
177
+ * Must be called AFTER successful payment in your payment system
178
+ * Token must be reported to Google Play backend within 24 hours
179
+ *
180
+ * Returns token string, or null if creation failed
181
+ * Throws OpenIapError.NotPrepared if billing client not ready
182
+ */
183
+ createAlternativeBillingTokenAndroid?: Promise<(string | null)>;
127
184
  /** Open the native subscription management surface */
128
185
  deepLinkToSubscriptions: Promise<void>;
129
186
  /** Close the platform billing connection */
@@ -134,12 +191,25 @@ export interface Mutation {
134
191
  initConnection: Promise<boolean>;
135
192
  /** Present the App Store code redemption sheet */
136
193
  presentCodeRedemptionSheetIOS: Promise<boolean>;
194
+ /** Present external purchase custom link with StoreKit UI (iOS 18.2+) */
195
+ presentExternalPurchaseLinkIOS: Promise<ExternalPurchaseLinkResultIOS>;
196
+ /** Present external purchase notice sheet (iOS 18.2+) */
197
+ presentExternalPurchaseNoticeSheetIOS: Promise<ExternalPurchaseNoticeResultIOS>;
137
198
  /** Initiate a purchase flow; rely on events for final state */
138
199
  requestPurchase?: Promise<(Purchase | Purchase[] | null)>;
139
200
  /** Purchase the promoted product surfaced by the App Store */
140
201
  requestPurchaseOnPromotedProductIOS: Promise<boolean>;
141
202
  /** Restore completed purchases across platforms */
142
203
  restorePurchases: Promise<void>;
204
+ /**
205
+ * Show alternative billing information dialog to user
206
+ * Step 2 of alternative billing flow
207
+ * Must be called BEFORE processing payment in your payment system
208
+ *
209
+ * Returns true if user accepted, false if user canceled
210
+ * Throws OpenIapError.NotPrepared if billing client not ready
211
+ */
212
+ showAlternativeBillingDialogAndroid: Promise<boolean>;
143
213
  /** Open subscription management UI and return changed purchases (iOS 15+) */
144
214
  showManageSubscriptionsIOS: Promise<PurchaseIOS[]>;
145
215
  /** Force a StoreKit sync for transactions (iOS 15+) */
@@ -155,14 +225,20 @@ export interface MutationFinishTransactionArgs {
155
225
  isConsumable?: (boolean | null);
156
226
  purchase: PurchaseInput;
157
227
  }
228
+ export type MutationInitConnectionArgs = (InitConnectionConfig | null) | undefined;
229
+ export type MutationPresentExternalPurchaseLinkIosArgs = string;
158
230
  export type MutationRequestPurchaseArgs = {
159
231
  /** Per-platform purchase request props */
160
232
  request: RequestPurchasePropsByPlatforms;
161
233
  type: 'in-app';
234
+ /** Use alternative billing (Google Play alternative billing, Apple external purchase link) */
235
+ useAlternativeBilling?: boolean | null;
162
236
  } | {
163
237
  /** Per-platform subscription request props */
164
238
  request: RequestSubscriptionPropsByPlatforms;
165
239
  type: 'subs';
240
+ /** Use alternative billing (Google Play alternative billing, Apple external purchase link) */
241
+ useAlternativeBilling?: boolean | null;
166
242
  };
167
243
  export type MutationValidateReceiptArgs = ReceiptValidationProps;
168
244
  export type PaymentModeIOS = 'empty' | 'free-trial' | 'pay-as-you-go' | 'pay-up-front';
@@ -285,6 +361,7 @@ export type ProductTypeIOS = 'consumable' | 'non-consumable' | 'auto-renewable-s
285
361
  export type Purchase = PurchaseAndroid | PurchaseIOS;
286
362
  export interface PurchaseAndroid extends PurchaseCommon {
287
363
  autoRenewingAndroid?: (boolean | null);
364
+ currentPlanId?: (string | null);
288
365
  dataAndroid?: (string | null);
289
366
  developerPayloadAndroid?: (string | null);
290
367
  id: string;
@@ -304,6 +381,13 @@ export interface PurchaseAndroid extends PurchaseCommon {
304
381
  transactionId?: (string | null);
305
382
  }
306
383
  export interface PurchaseCommon {
384
+ /**
385
+ * The current plan identifier. This is:
386
+ * - On Android: the basePlanId (e.g., "premium", "premium-year")
387
+ * - On iOS: the productId (e.g., "com.example.premium_monthly", "com.example.premium_yearly")
388
+ * This provides a unified way to identify which specific plan/tier the user is subscribed to.
389
+ */
390
+ currentPlanId?: (string | null);
307
391
  id: string;
308
392
  ids?: (string[] | null);
309
393
  isAutoRenewing: boolean;
@@ -326,6 +410,7 @@ export interface PurchaseIOS extends PurchaseCommon {
326
410
  countryCodeIOS?: (string | null);
327
411
  currencyCodeIOS?: (string | null);
328
412
  currencySymbolIOS?: (string | null);
413
+ currentPlanId?: (string | null);
329
414
  environmentIOS?: (string | null);
330
415
  expirationDateIOS?: (number | null);
331
416
  id: string;
@@ -353,17 +438,7 @@ export interface PurchaseIOS extends PurchaseCommon {
353
438
  transactionReasonIOS?: (string | null);
354
439
  webOrderLineItemIdIOS?: (string | null);
355
440
  }
356
- export interface PurchaseInput {
357
- id: string;
358
- ids?: (string[] | null);
359
- isAutoRenewing: boolean;
360
- platform: IapPlatform;
361
- productId: string;
362
- purchaseState: PurchaseState;
363
- purchaseToken?: (string | null);
364
- quantity: number;
365
- transactionDate: number;
366
- }
441
+ export type PurchaseInput = Purchase;
367
442
  export interface PurchaseOfferIOS {
368
443
  id: string;
369
444
  paymentMode: string;
@@ -377,6 +452,8 @@ export interface PurchaseOptions {
377
452
  }
378
453
  export type PurchaseState = 'pending' | 'purchased' | 'failed' | 'restored' | 'deferred' | 'unknown';
379
454
  export interface Query {
455
+ /** Check if external purchase notice sheet can be presented (iOS 18.2+) */
456
+ canPresentExternalPurchaseNoticeIOS: Promise<boolean>;
380
457
  /** Get current StoreKit 2 entitlements (iOS 15+) */
381
458
  currentEntitlementIOS?: Promise<(PurchaseIOS | null)>;
382
459
  /** Retrieve products or subscriptions from the store */
@@ -504,10 +581,14 @@ export type RequestPurchaseProps = {
504
581
  /** Per-platform purchase request props */
505
582
  request: RequestPurchasePropsByPlatforms;
506
583
  type: 'in-app';
584
+ /** Use alternative billing (Google Play alternative billing, Apple external purchase link) */
585
+ useAlternativeBilling?: boolean | null;
507
586
  } | {
508
587
  /** Per-platform subscription request props */
509
588
  request: RequestSubscriptionPropsByPlatforms;
510
589
  type: 'subs';
590
+ /** Use alternative billing (Google Play alternative billing, Apple external purchase link) */
591
+ useAlternativeBilling?: boolean | null;
511
592
  };
512
593
  export interface RequestPurchasePropsByPlatforms {
513
594
  /** Android-specific purchase parameters */
@@ -552,6 +633,11 @@ export interface Subscription {
552
633
  purchaseError: PurchaseError;
553
634
  /** Fires when a purchase completes successfully or a pending purchase resolves */
554
635
  purchaseUpdated: Purchase;
636
+ /**
637
+ * Fires when a user selects alternative billing in the User Choice Billing dialog (Android only)
638
+ * Only triggered when the user selects alternative billing instead of Google Play billing
639
+ */
640
+ userChoiceBillingAndroid: UserChoiceBillingDetails;
555
641
  }
556
642
  export interface SubscriptionInfoIOS {
557
643
  introductoryOffer?: (SubscriptionOfferIOS | null);
@@ -578,8 +664,19 @@ export interface SubscriptionStatusIOS {
578
664
  renewalInfo?: (RenewalInfoIOS | null);
579
665
  state: string;
580
666
  }
667
+ /**
668
+ * User Choice Billing event details (Android)
669
+ * Fired when a user selects alternative billing in the User Choice Billing dialog
670
+ */
671
+ export interface UserChoiceBillingDetails {
672
+ /** Token that must be reported to Google Play within 24 hours */
673
+ externalTransactionToken: string;
674
+ /** List of product IDs selected by the user */
675
+ products: string[];
676
+ }
581
677
  export type VoidResult = void;
582
678
  export type QueryArgsMap = {
679
+ canPresentExternalPurchaseNoticeIOS: never;
583
680
  currentEntitlementIOS: QueryCurrentEntitlementIosArgs;
584
681
  fetchProducts: QueryFetchProductsArgs;
585
682
  getActiveSubscriptions: QueryGetActiveSubscriptionsArgs;
@@ -605,16 +702,21 @@ export type QueryFieldMap = {
605
702
  export type MutationArgsMap = {
606
703
  acknowledgePurchaseAndroid: MutationAcknowledgePurchaseAndroidArgs;
607
704
  beginRefundRequestIOS: MutationBeginRefundRequestIosArgs;
705
+ checkAlternativeBillingAvailabilityAndroid: never;
608
706
  clearTransactionIOS: never;
609
707
  consumePurchaseAndroid: MutationConsumePurchaseAndroidArgs;
708
+ createAlternativeBillingTokenAndroid: never;
610
709
  deepLinkToSubscriptions: MutationDeepLinkToSubscriptionsArgs;
611
710
  endConnection: never;
612
711
  finishTransaction: MutationFinishTransactionArgs;
613
- initConnection: never;
712
+ initConnection: MutationInitConnectionArgs;
614
713
  presentCodeRedemptionSheetIOS: never;
714
+ presentExternalPurchaseLinkIOS: MutationPresentExternalPurchaseLinkIosArgs;
715
+ presentExternalPurchaseNoticeSheetIOS: never;
615
716
  requestPurchase: MutationRequestPurchaseArgs;
616
717
  requestPurchaseOnPromotedProductIOS: never;
617
718
  restorePurchases: never;
719
+ showAlternativeBillingDialogAndroid: never;
618
720
  showManageSubscriptionsIOS: never;
619
721
  syncIOS: never;
620
722
  validateReceipt: MutationValidateReceiptArgs;
@@ -627,6 +729,7 @@ export type SubscriptionArgsMap = {
627
729
  promotedProductIOS: never;
628
730
  purchaseError: never;
629
731
  purchaseUpdated: never;
732
+ userChoiceBillingAndroid: never;
630
733
  };
631
734
  export type SubscriptionField<K extends keyof Subscription> = SubscriptionArgsMap[K] extends never ? () => NonNullable<Subscription[K]> : undefined extends SubscriptionArgsMap[K] ? (args?: SubscriptionArgsMap[K]) => NonNullable<Subscription[K]> : (args: SubscriptionArgsMap[K]) => NonNullable<Subscription[K]>;
632
735
  export type SubscriptionFieldMap = {