expo-iap 4.2.2 → 4.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.d.ts +126 -33
- package/build/index.d.ts.map +1 -1
- package/build/index.js +123 -33
- package/build/index.js.map +1 -1
- package/build/kit-api.d.ts +54 -0
- package/build/kit-api.d.ts.map +1 -0
- package/build/kit-api.js +156 -0
- package/build/kit-api.js.map +1 -0
- package/build/modules/android.d.ts +22 -0
- package/build/modules/android.d.ts.map +1 -1
- package/build/modules/android.js +37 -0
- package/build/modules/android.js.map +1 -1
- package/build/modules/ios.d.ts +69 -1
- package/build/modules/ios.d.ts.map +1 -1
- package/build/modules/ios.js +73 -1
- package/build/modules/ios.js.map +1 -1
- package/build/types.d.ts +241 -75
- package/build/types.d.ts.map +1 -1
- package/build/types.js.map +1 -1
- package/build/useIAP.d.ts.map +1 -1
- package/build/useIAP.js +125 -3
- package/build/useIAP.js.map +1 -1
- package/build/useWebhookEvents.d.ts +26 -0
- package/build/useWebhookEvents.d.ts.map +1 -0
- package/build/useWebhookEvents.js +105 -0
- package/build/useWebhookEvents.js.map +1 -0
- package/build/webhook-client.d.ts +82 -0
- package/build/webhook-client.d.ts.map +1 -0
- package/build/webhook-client.js +176 -0
- package/build/webhook-client.js.map +1 -0
- package/openiap-versions.json +2 -2
- package/package.json +1 -1
- package/src/index.ts +141 -33
- package/src/kit-api.ts +229 -0
- package/src/modules/android.ts +47 -0
- package/src/modules/ios.ts +74 -1
- package/src/types.ts +247 -75
- package/src/useIAP.ts +125 -3
- package/src/useWebhookEvents.ts +155 -0
- package/src/webhook-client.ts +314 -0
package/build/modules/android.js
CHANGED
|
@@ -77,11 +77,36 @@ export const validateReceiptAndroid = async ({ packageName, productId, productTo
|
|
|
77
77
|
}
|
|
78
78
|
return response.json();
|
|
79
79
|
};
|
|
80
|
+
/**
|
|
81
|
+
* Consume a purchase token so the user can purchase the same product again
|
|
82
|
+
* (Android consumable products). Prefer using `finishTransaction` with
|
|
83
|
+
* `isConsumable: true`, which dispatches to this under the hood.
|
|
84
|
+
*
|
|
85
|
+
* @see {@link https://www.openiap.dev/docs/apis/android/consume-purchase-android}
|
|
86
|
+
*/
|
|
87
|
+
export const consumePurchaseAndroid = async (purchaseToken) => {
|
|
88
|
+
const result = await ExpoIapModule.consumePurchaseAndroid(purchaseToken);
|
|
89
|
+
if (typeof result === 'boolean') {
|
|
90
|
+
return result;
|
|
91
|
+
}
|
|
92
|
+
if (result && typeof result === 'object') {
|
|
93
|
+
const record = result;
|
|
94
|
+
if (typeof record.success === 'boolean') {
|
|
95
|
+
return record.success;
|
|
96
|
+
}
|
|
97
|
+
if (typeof record.responseCode === 'number') {
|
|
98
|
+
return record.responseCode === 0;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
throw new Error(`consumePurchaseAndroid returned an unexpected response payload: ${JSON.stringify(result)}`);
|
|
102
|
+
};
|
|
80
103
|
/**
|
|
81
104
|
* Acknowledge a product (on Android.) No-op on iOS.
|
|
82
105
|
* @param {Object} params - The parameters object
|
|
83
106
|
* @param {string} params.token - The product's token (on Android)
|
|
84
107
|
* @returns {Promise<VoidResult | void>}
|
|
108
|
+
*
|
|
109
|
+
* @see {@link https://www.openiap.dev/docs/apis/android/acknowledge-purchase-android}
|
|
85
110
|
*/
|
|
86
111
|
export const acknowledgePurchaseAndroid = async (purchaseToken) => {
|
|
87
112
|
const result = await ExpoIapModule.acknowledgePurchaseAndroid(purchaseToken);
|
|
@@ -125,6 +150,8 @@ export const openRedeemOfferCodeAndroid = async () => {
|
|
|
125
150
|
* // Proceed with alternative billing flow
|
|
126
151
|
* }
|
|
127
152
|
* ```
|
|
153
|
+
*
|
|
154
|
+
* @see {@link https://www.openiap.dev/docs/apis/android/check-alternative-billing-availability-android}
|
|
128
155
|
*/
|
|
129
156
|
export const checkAlternativeBillingAvailabilityAndroid = async () => {
|
|
130
157
|
return ExpoIapModule.checkAlternativeBillingAvailabilityAndroid();
|
|
@@ -152,6 +179,8 @@ export const checkAlternativeBillingAvailabilityAndroid = async () => {
|
|
|
152
179
|
* }
|
|
153
180
|
* }
|
|
154
181
|
* ```
|
|
182
|
+
*
|
|
183
|
+
* @see {@link https://www.openiap.dev/docs/apis/android/show-alternative-billing-dialog-android}
|
|
155
184
|
*/
|
|
156
185
|
export const showAlternativeBillingDialogAndroid = async () => {
|
|
157
186
|
return ExpoIapModule.showAlternativeBillingDialogAndroid();
|
|
@@ -179,6 +208,8 @@ export const showAlternativeBillingDialogAndroid = async () => {
|
|
|
179
208
|
* });
|
|
180
209
|
* }
|
|
181
210
|
* ```
|
|
211
|
+
*
|
|
212
|
+
* @see {@link https://www.openiap.dev/docs/apis/android/create-alternative-billing-token-android}
|
|
182
213
|
*/
|
|
183
214
|
export const createAlternativeBillingTokenAndroid = async (sku) => {
|
|
184
215
|
return ExpoIapModule.createAlternativeBillingTokenAndroid(sku);
|
|
@@ -200,6 +231,8 @@ export const createAlternativeBillingTokenAndroid = async (sku) => {
|
|
|
200
231
|
* // Proceed with billing program flow
|
|
201
232
|
* }
|
|
202
233
|
* ```
|
|
234
|
+
*
|
|
235
|
+
* @see {@link https://www.openiap.dev/docs/apis/android/is-billing-program-available-android}
|
|
203
236
|
*/
|
|
204
237
|
export const isBillingProgramAvailableAndroid = async (program) => {
|
|
205
238
|
return ExpoIapModule.isBillingProgramAvailableAndroid(program);
|
|
@@ -220,6 +253,8 @@ export const isBillingProgramAvailableAndroid = async (program) => {
|
|
|
220
253
|
* linkUri: 'https://your-payment-site.com',
|
|
221
254
|
* });
|
|
222
255
|
* ```
|
|
256
|
+
*
|
|
257
|
+
* @see {@link https://www.openiap.dev/docs/apis/android/launch-external-link-android}
|
|
223
258
|
*/
|
|
224
259
|
export const launchExternalLinkAndroid = async (params) => {
|
|
225
260
|
return ExpoIapModule.launchExternalLinkAndroid(params);
|
|
@@ -240,6 +275,8 @@ export const launchExternalLinkAndroid = async (params) => {
|
|
|
240
275
|
* // Report details.externalTransactionToken to Google Play within 24 hours
|
|
241
276
|
* await reportToGooglePlay(details.externalTransactionToken);
|
|
242
277
|
* ```
|
|
278
|
+
*
|
|
279
|
+
* @see {@link https://www.openiap.dev/docs/apis/android/create-billing-program-reporting-details-android}
|
|
243
280
|
*/
|
|
244
281
|
export const createBillingProgramReportingDetailsAndroid = async (program) => {
|
|
245
282
|
return ExpoIapModule.createBillingProgramReportingDetailsAndroid(program);
|
|
@@ -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,SAAS,CACnD,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,KAAK,EACjD,OAAgC,EACjB,EAAE;IACjB,MAAM,GAAG,GAAG,OAAO,EAAE,UAAU,IAAI,SAAS,CAAC;IAC7C,MAAM,WAAW,GAAG,OAAO,EAAE,kBAAkB,IAAI,SAAS,CAAC;IAE7D,4DAA4D;IAC5D,IAAI,mBAAmB,EAAE,8BAA8B,EAAE,CAAC;QACxD,OAAO,mBAAmB,CAAC,8BAA8B,CAAC;YACxD,UAAU,EAAE,GAAG;YACf,kBAAkB,EAAE,WAAW;SAChC,CAAC,CAAC;IACL,CAAC;IAED,mDAAmD;IACnD,IAAI,CAAC,WAAW,EAAE,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;;GAcG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAEzC,KAAK,EAAE,OAAO,EAAE,EAAE;IACpB,OAAO,aAAa,CAAC,gCAAgC,CAAC,OAAO,CAAC,CAAC;AACjE,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAElC,KAAK,EAAE,MAAM,EAAE,EAAE;IACnB,OAAO,aAAa,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC;AACzD,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,2CAA2C,GAEpD,KAAK,EAAE,OAAO,EAAE,EAAE;IACpB,OAAO,aAAa,CAAC,2CAA2C,CAAC,OAAO,CAAC,CAAC;AAC5E,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 VerifyPurchaseResultAndroid,\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 *\n * @deprecated Use verifyPurchase instead\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<VerifyPurchaseResultAndroid> => {\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\n// ============================================================================\n// Billing Programs API (Google Play Billing Library 8.2.0+)\n// ============================================================================\n\n/**\n * Check if a specific billing program is available for this user/device (Android only).\n * Available in Google Play Billing Library 8.2.0+.\n *\n * @param program - The billing program to check ('external-offer' or 'external-content-link')\n * @returns Promise resolving to availability result\n *\n * @example\n * ```typescript\n * const result = await isBillingProgramAvailableAndroid('external-offer');\n * if (result.isAvailable) {\n * // Proceed with billing program flow\n * }\n * ```\n */\nexport const isBillingProgramAvailableAndroid: MutationField<\n 'isBillingProgramAvailableAndroid'\n> = async (program) => {\n return ExpoIapModule.isBillingProgramAvailableAndroid(program);\n};\n\n/**\n * Launch an external link for the specified billing program (Android only).\n * Available in Google Play Billing Library 8.2.0+.\n *\n * @param params - The external link parameters\n * @returns Promise resolving to true if the link was launched successfully\n *\n * @example\n * ```typescript\n * await launchExternalLinkAndroid({\n * billingProgram: 'external-offer',\n * launchMode: 'launch-in-external-browser-or-app',\n * linkType: 'link-to-digital-content-offer',\n * linkUri: 'https://your-payment-site.com',\n * });\n * ```\n */\nexport const launchExternalLinkAndroid: MutationField<\n 'launchExternalLinkAndroid'\n> = async (params) => {\n return ExpoIapModule.launchExternalLinkAndroid(params);\n};\n\n/**\n * Create billing program reporting details for Google Play reporting (Android only).\n * Available in Google Play Billing Library 8.2.0+.\n *\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 * @param program - The billing program type\n * @returns Promise resolving to reporting details including the external transaction token\n *\n * @example\n * ```typescript\n * const details = await createBillingProgramReportingDetailsAndroid('external-offer');\n * // Report details.externalTransactionToken to Google Play within 24 hours\n * await reportToGooglePlay(details.externalTransactionToken);\n * ```\n */\nexport const createBillingProgramReportingDetailsAndroid: MutationField<\n 'createBillingProgramReportingDetailsAndroid'\n> = async (program) => {\n return ExpoIapModule.createBillingProgramReportingDetailsAndroid(program);\n};\n"]}
|
|
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,SAAS,CACnD,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,KAAK,EACjD,OAAgC,EACjB,EAA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;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAElC,KAAK,EAAE,MAAM,EAAE,EAAE;IACnB,OAAO,aAAa,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC;AACzD,CAAC,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,2CAA2C,GAEpD,KAAK,EAAE,OAAO,EAAE,EAAE;IACpB,OAAO,aAAa,CAAC,2CAA2C,CAAC,OAAO,CAAC,CAAC;AAC5E,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 VerifyPurchaseResultAndroid,\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 *\n * @deprecated Use verifyPurchase instead\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<VerifyPurchaseResultAndroid> => {\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 * Consume a purchase token so the user can purchase the same product again\n * (Android consumable products). Prefer using `finishTransaction` with\n * `isConsumable: true`, which dispatches to this under the hood.\n *\n * @see {@link https://www.openiap.dev/docs/apis/android/consume-purchase-android}\n */\nexport const consumePurchaseAndroid: MutationField<\n 'consumePurchaseAndroid'\n> = async (purchaseToken) => {\n const result = await ExpoIapModule.consumePurchaseAndroid(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 throw new Error(\n `consumePurchaseAndroid returned an unexpected response payload: ${JSON.stringify(\n result,\n )}`,\n );\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 *\n * @see {@link https://www.openiap.dev/docs/apis/android/acknowledge-purchase-android}\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 *\n * @see {@link https://www.openiap.dev/docs/apis/android/check-alternative-billing-availability-android}\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 *\n * @see {@link https://www.openiap.dev/docs/apis/android/show-alternative-billing-dialog-android}\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 *\n * @see {@link https://www.openiap.dev/docs/apis/android/create-alternative-billing-token-android}\n */\nexport const createAlternativeBillingTokenAndroid: MutationField<\n 'createAlternativeBillingTokenAndroid'\n> = async (sku?: string) => {\n return ExpoIapModule.createAlternativeBillingTokenAndroid(sku);\n};\n\n// ============================================================================\n// Billing Programs API (Google Play Billing Library 8.2.0+)\n// ============================================================================\n\n/**\n * Check if a specific billing program is available for this user/device (Android only).\n * Available in Google Play Billing Library 8.2.0+.\n *\n * @param program - The billing program to check ('external-offer' or 'external-content-link')\n * @returns Promise resolving to availability result\n *\n * @example\n * ```typescript\n * const result = await isBillingProgramAvailableAndroid('external-offer');\n * if (result.isAvailable) {\n * // Proceed with billing program flow\n * }\n * ```\n *\n * @see {@link https://www.openiap.dev/docs/apis/android/is-billing-program-available-android}\n */\nexport const isBillingProgramAvailableAndroid: MutationField<\n 'isBillingProgramAvailableAndroid'\n> = async (program) => {\n return ExpoIapModule.isBillingProgramAvailableAndroid(program);\n};\n\n/**\n * Launch an external link for the specified billing program (Android only).\n * Available in Google Play Billing Library 8.2.0+.\n *\n * @param params - The external link parameters\n * @returns Promise resolving to true if the link was launched successfully\n *\n * @example\n * ```typescript\n * await launchExternalLinkAndroid({\n * billingProgram: 'external-offer',\n * launchMode: 'launch-in-external-browser-or-app',\n * linkType: 'link-to-digital-content-offer',\n * linkUri: 'https://your-payment-site.com',\n * });\n * ```\n *\n * @see {@link https://www.openiap.dev/docs/apis/android/launch-external-link-android}\n */\nexport const launchExternalLinkAndroid: MutationField<\n 'launchExternalLinkAndroid'\n> = async (params) => {\n return ExpoIapModule.launchExternalLinkAndroid(params);\n};\n\n/**\n * Create billing program reporting details for Google Play reporting (Android only).\n * Available in Google Play Billing Library 8.2.0+.\n *\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 * @param program - The billing program type\n * @returns Promise resolving to reporting details including the external transaction token\n *\n * @example\n * ```typescript\n * const details = await createBillingProgramReportingDetailsAndroid('external-offer');\n * // Report details.externalTransactionToken to Google Play within 24 hours\n * await reportToGooglePlay(details.externalTransactionToken);\n * ```\n *\n * @see {@link https://www.openiap.dev/docs/apis/android/create-billing-program-reporting-details-android}\n */\nexport const createBillingProgramReportingDetailsAndroid: MutationField<\n 'createBillingProgramReportingDetailsAndroid'\n> = async (program) => {\n return ExpoIapModule.createBillingProgramReportingDetailsAndroid(program);\n};\n"]}
|
package/build/modules/ios.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ export declare function isProductIOS<T extends {
|
|
|
17
17
|
* @throws Error if called on non-iOS platform
|
|
18
18
|
*
|
|
19
19
|
* @platform iOS
|
|
20
|
+
*
|
|
21
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/sync-ios}
|
|
20
22
|
*/
|
|
21
23
|
export declare const syncIOS: MutationField<'syncIOS'>;
|
|
22
24
|
/**
|
|
@@ -27,6 +29,8 @@ export declare const syncIOS: MutationField<'syncIOS'>;
|
|
|
27
29
|
* @throws Error if called on non-iOS platform
|
|
28
30
|
*
|
|
29
31
|
* @platform iOS
|
|
32
|
+
*
|
|
33
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/is-eligible-for-intro-offer-ios}
|
|
30
34
|
*/
|
|
31
35
|
export declare const isEligibleForIntroOfferIOS: QueryField<'isEligibleForIntroOfferIOS'>;
|
|
32
36
|
/**
|
|
@@ -37,6 +41,8 @@ export declare const isEligibleForIntroOfferIOS: QueryField<'isEligibleForIntroO
|
|
|
37
41
|
* @throws Error if called on non-iOS platform
|
|
38
42
|
*
|
|
39
43
|
* @platform iOS
|
|
44
|
+
*
|
|
45
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/subscription-status-ios}
|
|
40
46
|
*/
|
|
41
47
|
export declare const subscriptionStatusIOS: QueryField<'subscriptionStatusIOS'>;
|
|
42
48
|
/**
|
|
@@ -47,6 +53,8 @@ export declare const subscriptionStatusIOS: QueryField<'subscriptionStatusIOS'>;
|
|
|
47
53
|
* @throws Error if called on non-iOS platform
|
|
48
54
|
*
|
|
49
55
|
* @platform iOS
|
|
56
|
+
*
|
|
57
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/current-entitlement-ios}
|
|
50
58
|
*/
|
|
51
59
|
export declare const currentEntitlementIOS: QueryField<'currentEntitlementIOS'>;
|
|
52
60
|
/**
|
|
@@ -57,6 +65,8 @@ export declare const currentEntitlementIOS: QueryField<'currentEntitlementIOS'>;
|
|
|
57
65
|
* @throws Error if called on non-iOS platform
|
|
58
66
|
*
|
|
59
67
|
* @platform iOS
|
|
68
|
+
*
|
|
69
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/latest-transaction-ios}
|
|
60
70
|
*/
|
|
61
71
|
export declare const latestTransactionIOS: QueryField<'latestTransactionIOS'>;
|
|
62
72
|
/**
|
|
@@ -67,6 +77,8 @@ export declare const latestTransactionIOS: QueryField<'latestTransactionIOS'>;
|
|
|
67
77
|
* @throws Error if called on non-iOS platform
|
|
68
78
|
*
|
|
69
79
|
* @platform iOS
|
|
80
|
+
*
|
|
81
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/begin-refund-request-ios}
|
|
70
82
|
*/
|
|
71
83
|
export declare const beginRefundRequestIOS: MutationField<'beginRefundRequestIOS'>;
|
|
72
84
|
/**
|
|
@@ -77,6 +89,8 @@ export declare const beginRefundRequestIOS: MutationField<'beginRefundRequestIOS
|
|
|
77
89
|
* @throws Error if called on non-iOS platform
|
|
78
90
|
*
|
|
79
91
|
* @platform iOS
|
|
92
|
+
*
|
|
93
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/show-manage-subscriptions-ios}
|
|
80
94
|
*/
|
|
81
95
|
export declare const showManageSubscriptionsIOS: MutationField<'showManageSubscriptionsIOS'>;
|
|
82
96
|
/**
|
|
@@ -88,9 +102,26 @@ export declare const showManageSubscriptionsIOS: MutationField<'showManageSubscr
|
|
|
88
102
|
* Apple's verifyReceipt endpoint, not directly from the app.
|
|
89
103
|
*
|
|
90
104
|
* @returns {Promise<string>} Base64 encoded receipt data
|
|
105
|
+
*
|
|
106
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/get-receipt-data-ios}
|
|
91
107
|
*/
|
|
92
108
|
export declare const getReceiptDataIOS: QueryField<'getReceiptDataIOS'>;
|
|
93
109
|
export declare const getReceiptIOS: () => Promise<string | null>;
|
|
110
|
+
/**
|
|
111
|
+
* Get the current App Store storefront country code on iOS.
|
|
112
|
+
*
|
|
113
|
+
* @deprecated Use cross-platform `getStorefront` from the main index instead.
|
|
114
|
+
* The native module exposes a single `getStorefront` AsyncFunction that already
|
|
115
|
+
* resolves to the iOS storefront on iOS. This helper is kept as an iOS-only
|
|
116
|
+
* alias so consumers who previously imported `getStorefrontIOS` do not break.
|
|
117
|
+
*
|
|
118
|
+
* @returns {Promise<string>} ISO 3166-1 alpha-2 country code (e.g. "US")
|
|
119
|
+
*
|
|
120
|
+
* @platform iOS
|
|
121
|
+
*
|
|
122
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/get-storefront-ios}
|
|
123
|
+
*/
|
|
124
|
+
export declare const getStorefrontIOS: QueryField<'getStorefrontIOS'>;
|
|
94
125
|
/**
|
|
95
126
|
* Refresh the receipt data from Apple's servers and return the updated receipt.
|
|
96
127
|
* This calls AppStore.sync() before reading the receipt, ensuring the latest
|
|
@@ -112,6 +143,8 @@ export declare const requestReceiptRefreshIOS: () => Promise<string>;
|
|
|
112
143
|
* @throws Error if called on non-iOS platform
|
|
113
144
|
*
|
|
114
145
|
* @platform iOS
|
|
146
|
+
*
|
|
147
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/is-transaction-verified-ios}
|
|
115
148
|
*/
|
|
116
149
|
export declare const isTransactionVerifiedIOS: QueryField<'isTransactionVerifiedIOS'>;
|
|
117
150
|
/**
|
|
@@ -123,6 +156,8 @@ export declare const isTransactionVerifiedIOS: QueryField<'isTransactionVerified
|
|
|
123
156
|
* @throws Error if called on non-iOS platform
|
|
124
157
|
*
|
|
125
158
|
* @platform iOS
|
|
159
|
+
*
|
|
160
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/get-transaction-jws-ios}
|
|
126
161
|
*/
|
|
127
162
|
export declare const getTransactionJwsIOS: QueryField<'getTransactionJwsIOS'>;
|
|
128
163
|
export declare const validateReceiptIOS: QueryField<"validateReceiptIOS">;
|
|
@@ -136,6 +171,8 @@ export declare const validateReceiptIOS: QueryField<"validateReceiptIOS">;
|
|
|
136
171
|
* @throws Error if called on non-iOS platform or tvOS
|
|
137
172
|
*
|
|
138
173
|
* @platform iOS
|
|
174
|
+
*
|
|
175
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/present-code-redemption-sheet-ios}
|
|
139
176
|
*/
|
|
140
177
|
export declare const presentCodeRedemptionSheetIOS: MutationField<'presentCodeRedemptionSheetIOS'>;
|
|
141
178
|
/**
|
|
@@ -151,6 +188,8 @@ export declare const presentCodeRedemptionSheetIOS: MutationField<'presentCodeRe
|
|
|
151
188
|
*
|
|
152
189
|
* @platform iOS
|
|
153
190
|
* @since iOS 16.0
|
|
191
|
+
*
|
|
192
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/get-app-transaction-ios}
|
|
154
193
|
*/
|
|
155
194
|
export declare const getAppTransactionIOS: QueryField<'getAppTransactionIOS'>;
|
|
156
195
|
/**
|
|
@@ -162,6 +201,8 @@ export declare const getAppTransactionIOS: QueryField<'getAppTransactionIOS'>;
|
|
|
162
201
|
* @throws Error if called on non-iOS platform
|
|
163
202
|
*
|
|
164
203
|
* @platform iOS
|
|
204
|
+
*
|
|
205
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/get-promoted-product-ios}
|
|
165
206
|
*/
|
|
166
207
|
export declare const getPromotedProductIOS: QueryField<'getPromotedProductIOS'>;
|
|
167
208
|
/**
|
|
@@ -175,6 +216,8 @@ export declare const getPromotedProductIOS: QueryField<'getPromotedProductIOS'>;
|
|
|
175
216
|
* @throws Error if called on non-iOS platform or no promoted product is available
|
|
176
217
|
*
|
|
177
218
|
* @platform iOS
|
|
219
|
+
*
|
|
220
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/request-purchase-on-promoted-product-ios}
|
|
178
221
|
*/
|
|
179
222
|
export declare const requestPurchaseOnPromotedProductIOS: () => Promise<boolean>;
|
|
180
223
|
/**
|
|
@@ -182,14 +225,23 @@ export declare const requestPurchaseOnPromotedProductIOS: () => Promise<boolean>
|
|
|
182
225
|
*
|
|
183
226
|
* @returns Promise resolving to array of pending transactions
|
|
184
227
|
* @platform iOS
|
|
228
|
+
*
|
|
229
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/get-pending-transactions-ios}
|
|
185
230
|
*/
|
|
186
231
|
export declare const getPendingTransactionsIOS: QueryField<'getPendingTransactionsIOS'>;
|
|
232
|
+
/**
|
|
233
|
+
* List every StoreKit transaction (finished + unfinished) for the current user.
|
|
234
|
+
*
|
|
235
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/get-all-transactions-ios}
|
|
236
|
+
*/
|
|
187
237
|
export declare const getAllTransactionsIOS: QueryField<'getAllTransactionsIOS'>;
|
|
188
238
|
/**
|
|
189
239
|
* Clear a specific transaction (iOS only).
|
|
190
240
|
*
|
|
191
241
|
* @returns Promise resolving when transaction is cleared
|
|
192
242
|
* @platform iOS
|
|
243
|
+
*
|
|
244
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/clear-transaction-ios}
|
|
193
245
|
*/
|
|
194
246
|
export declare const clearTransactionIOS: MutationField<'clearTransactionIOS'>;
|
|
195
247
|
/**
|
|
@@ -200,10 +252,16 @@ export declare const clearTransactionIOS: MutationField<'clearTransactionIOS'>;
|
|
|
200
252
|
*/
|
|
201
253
|
export declare const deepLinkToSubscriptionsIOS: () => Promise<void>;
|
|
202
254
|
/**
|
|
203
|
-
* Check if the device can present an external purchase notice sheet (iOS
|
|
255
|
+
* Check if the device can present an external purchase notice sheet (iOS 17.4+).
|
|
256
|
+
*
|
|
257
|
+
* Wraps `ExternalPurchase.canPresent`, which Apple introduced in iOS 17.4.
|
|
258
|
+
* Note: the notice sheet itself (`presentExternalPurchaseNoticeSheetIOS`)
|
|
259
|
+
* still requires iOS 18.2+; only the eligibility check is available earlier.
|
|
204
260
|
*
|
|
205
261
|
* @returns Promise resolving to true if the notice sheet can be presented
|
|
206
262
|
* @platform iOS
|
|
263
|
+
*
|
|
264
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/can-present-external-purchase-notice-ios}
|
|
207
265
|
*/
|
|
208
266
|
export declare const canPresentExternalPurchaseNoticeIOS: QueryField<'canPresentExternalPurchaseNoticeIOS'>;
|
|
209
267
|
/**
|
|
@@ -213,6 +271,8 @@ export declare const canPresentExternalPurchaseNoticeIOS: QueryField<'canPresent
|
|
|
213
271
|
*
|
|
214
272
|
* @returns Promise resolving to the result with action, token, and error if any
|
|
215
273
|
* @platform iOS
|
|
274
|
+
*
|
|
275
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/present-external-purchase-notice-sheet-ios}
|
|
216
276
|
*/
|
|
217
277
|
export declare const presentExternalPurchaseNoticeSheetIOS: () => Promise<ExternalPurchaseNoticeResultIOS>;
|
|
218
278
|
/**
|
|
@@ -221,6 +281,8 @@ export declare const presentExternalPurchaseNoticeSheetIOS: () => Promise<Extern
|
|
|
221
281
|
* @param url - The external purchase URL to open
|
|
222
282
|
* @returns Promise resolving to the result with success status and error if any
|
|
223
283
|
* @platform iOS
|
|
284
|
+
*
|
|
285
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/present-external-purchase-link-ios}
|
|
224
286
|
*/
|
|
225
287
|
export declare const presentExternalPurchaseLinkIOS: MutationField<'presentExternalPurchaseLinkIOS'>;
|
|
226
288
|
/**
|
|
@@ -230,6 +292,8 @@ export declare const presentExternalPurchaseLinkIOS: MutationField<'presentExter
|
|
|
230
292
|
* @returns Promise resolving to true if eligible
|
|
231
293
|
* @platform iOS
|
|
232
294
|
* @see https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/iseligible
|
|
295
|
+
*
|
|
296
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/is-eligible-for-external-purchase-custom-link-ios}
|
|
233
297
|
*/
|
|
234
298
|
export declare const isEligibleForExternalPurchaseCustomLinkIOS: () => Promise<boolean>;
|
|
235
299
|
/**
|
|
@@ -240,6 +304,8 @@ export declare const isEligibleForExternalPurchaseCustomLinkIOS: () => Promise<b
|
|
|
240
304
|
* @returns Promise resolving to the token result with token string or error
|
|
241
305
|
* @platform iOS
|
|
242
306
|
* @see https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/token(for:)
|
|
307
|
+
*
|
|
308
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/get-external-purchase-custom-link-token-ios}
|
|
243
309
|
*/
|
|
244
310
|
export declare const getExternalPurchaseCustomLinkTokenIOS: (tokenType: ExternalPurchaseCustomLinkTokenTypeIOS) => Promise<ExternalPurchaseCustomLinkTokenResultIOS>;
|
|
245
311
|
/**
|
|
@@ -251,6 +317,8 @@ export declare const getExternalPurchaseCustomLinkTokenIOS: (tokenType: External
|
|
|
251
317
|
* @returns Promise resolving to the result with continued status and error if any
|
|
252
318
|
* @platform iOS
|
|
253
319
|
* @see https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/shownotice(type:)
|
|
320
|
+
*
|
|
321
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/show-external-purchase-custom-link-notice-ios}
|
|
254
322
|
*/
|
|
255
323
|
export declare const showExternalPurchaseCustomLinkNoticeIOS: (noticeType: ExternalPurchaseCustomLinkNoticeTypeIOS) => Promise<ExternalPurchaseCustomLinkNoticeResultIOS>;
|
|
256
324
|
//# 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,yCAAyC,EACzC,wCAAwC,EACxC,sCAAsC,EACtC,uCAAuC,EAEvC,+BAA+B,EAC/B,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,K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,qBAAqB,EAAE,UAAU,CAC5C,uBAAuB,CAIxB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,EAAE,aAAa,CAC7C,qBAAqB,CAGtB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,QAAO,OAAO,CAAC,IAAI,CACO,CAAC;AAElE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mCAAmC,EAAE,UAAU,CAC1D,qCAAqC,CAGtC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,qCAAqC,QACtC,OAAO,CAAC,+BAA+B,CAGhD,CAAC;AAEJ;;;;;;;;GAQG;AACH,eAAO,MAAM,8BAA8B,EAAE,aAAa,CACxD,gCAAgC,CAIjC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,0CAA0C,QAC3C,OAAO,CAAC,OAAO,CAExB,CAAC;AAEJ;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qCAAqC,GAChD,WAAW,sCAAsC,KAChD,OAAO,CAAC,wCAAwC,CAUlD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,uCAAuC,GAClD,YAAY,uCAAuC,KAClD,OAAO,CAAC,yCAAyC,CAUnD,CAAC"}
|
package/build/modules/ios.js
CHANGED
|
@@ -21,6 +21,8 @@ export function isProductIOS(item) {
|
|
|
21
21
|
* @throws Error if called on non-iOS platform
|
|
22
22
|
*
|
|
23
23
|
* @platform iOS
|
|
24
|
+
*
|
|
25
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/sync-ios}
|
|
24
26
|
*/
|
|
25
27
|
export const syncIOS = async () => {
|
|
26
28
|
return !!(await ExpoIapModule.syncIOS());
|
|
@@ -33,6 +35,8 @@ export const syncIOS = async () => {
|
|
|
33
35
|
* @throws Error if called on non-iOS platform
|
|
34
36
|
*
|
|
35
37
|
* @platform iOS
|
|
38
|
+
*
|
|
39
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/is-eligible-for-intro-offer-ios}
|
|
36
40
|
*/
|
|
37
41
|
export const isEligibleForIntroOfferIOS = async (groupId) => {
|
|
38
42
|
if (!groupId) {
|
|
@@ -48,6 +52,8 @@ export const isEligibleForIntroOfferIOS = async (groupId) => {
|
|
|
48
52
|
* @throws Error if called on non-iOS platform
|
|
49
53
|
*
|
|
50
54
|
* @platform iOS
|
|
55
|
+
*
|
|
56
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/subscription-status-ios}
|
|
51
57
|
*/
|
|
52
58
|
export const subscriptionStatusIOS = async (sku) => {
|
|
53
59
|
if (!sku) {
|
|
@@ -64,6 +70,8 @@ export const subscriptionStatusIOS = async (sku) => {
|
|
|
64
70
|
* @throws Error if called on non-iOS platform
|
|
65
71
|
*
|
|
66
72
|
* @platform iOS
|
|
73
|
+
*
|
|
74
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/current-entitlement-ios}
|
|
67
75
|
*/
|
|
68
76
|
export const currentEntitlementIOS = async (sku) => {
|
|
69
77
|
if (!sku) {
|
|
@@ -80,6 +88,8 @@ export const currentEntitlementIOS = async (sku) => {
|
|
|
80
88
|
* @throws Error if called on non-iOS platform
|
|
81
89
|
*
|
|
82
90
|
* @platform iOS
|
|
91
|
+
*
|
|
92
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/latest-transaction-ios}
|
|
83
93
|
*/
|
|
84
94
|
export const latestTransactionIOS = async (sku) => {
|
|
85
95
|
if (!sku) {
|
|
@@ -96,6 +106,8 @@ export const latestTransactionIOS = async (sku) => {
|
|
|
96
106
|
* @throws Error if called on non-iOS platform
|
|
97
107
|
*
|
|
98
108
|
* @platform iOS
|
|
109
|
+
*
|
|
110
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/begin-refund-request-ios}
|
|
99
111
|
*/
|
|
100
112
|
export const beginRefundRequestIOS = async (sku) => {
|
|
101
113
|
if (!sku) {
|
|
@@ -112,6 +124,8 @@ export const beginRefundRequestIOS = async (sku) => {
|
|
|
112
124
|
* @throws Error if called on non-iOS platform
|
|
113
125
|
*
|
|
114
126
|
* @platform iOS
|
|
127
|
+
*
|
|
128
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/show-manage-subscriptions-ios}
|
|
115
129
|
*/
|
|
116
130
|
export const showManageSubscriptionsIOS = async () => {
|
|
117
131
|
const purchases = await ExpoIapModule.showManageSubscriptionsIOS();
|
|
@@ -126,11 +140,30 @@ export const showManageSubscriptionsIOS = async () => {
|
|
|
126
140
|
* Apple's verifyReceipt endpoint, not directly from the app.
|
|
127
141
|
*
|
|
128
142
|
* @returns {Promise<string>} Base64 encoded receipt data
|
|
143
|
+
*
|
|
144
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/get-receipt-data-ios}
|
|
129
145
|
*/
|
|
130
146
|
export const getReceiptDataIOS = async () => {
|
|
131
147
|
return ExpoIapModule.getReceiptDataIOS();
|
|
132
148
|
};
|
|
133
149
|
export const getReceiptIOS = getReceiptDataIOS;
|
|
150
|
+
/**
|
|
151
|
+
* Get the current App Store storefront country code on iOS.
|
|
152
|
+
*
|
|
153
|
+
* @deprecated Use cross-platform `getStorefront` from the main index instead.
|
|
154
|
+
* The native module exposes a single `getStorefront` AsyncFunction that already
|
|
155
|
+
* resolves to the iOS storefront on iOS. This helper is kept as an iOS-only
|
|
156
|
+
* alias so consumers who previously imported `getStorefrontIOS` do not break.
|
|
157
|
+
*
|
|
158
|
+
* @returns {Promise<string>} ISO 3166-1 alpha-2 country code (e.g. "US")
|
|
159
|
+
*
|
|
160
|
+
* @platform iOS
|
|
161
|
+
*
|
|
162
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/get-storefront-ios}
|
|
163
|
+
*/
|
|
164
|
+
export const getStorefrontIOS = async () => {
|
|
165
|
+
return ExpoIapModule.getStorefront();
|
|
166
|
+
};
|
|
134
167
|
/**
|
|
135
168
|
* Refresh the receipt data from Apple's servers and return the updated receipt.
|
|
136
169
|
* This calls AppStore.sync() before reading the receipt, ensuring the latest
|
|
@@ -154,6 +187,8 @@ export const requestReceiptRefreshIOS = async () => {
|
|
|
154
187
|
* @throws Error if called on non-iOS platform
|
|
155
188
|
*
|
|
156
189
|
* @platform iOS
|
|
190
|
+
*
|
|
191
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/is-transaction-verified-ios}
|
|
157
192
|
*/
|
|
158
193
|
export const isTransactionVerifiedIOS = async (sku) => {
|
|
159
194
|
if (!sku) {
|
|
@@ -170,6 +205,8 @@ export const isTransactionVerifiedIOS = async (sku) => {
|
|
|
170
205
|
* @throws Error if called on non-iOS platform
|
|
171
206
|
*
|
|
172
207
|
* @platform iOS
|
|
208
|
+
*
|
|
209
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/get-transaction-jws-ios}
|
|
173
210
|
*/
|
|
174
211
|
export const getTransactionJwsIOS = async (sku) => {
|
|
175
212
|
if (!sku) {
|
|
@@ -193,6 +230,8 @@ export const getTransactionJwsIOS = async (sku) => {
|
|
|
193
230
|
* jwsRepresentation: string;
|
|
194
231
|
* latestTransaction?: Purchase;
|
|
195
232
|
* }>}
|
|
233
|
+
*
|
|
234
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/validate-receipt-ios}
|
|
196
235
|
*/
|
|
197
236
|
const validateReceiptIOSImpl = async (props) => {
|
|
198
237
|
const sku = typeof props === 'string'
|
|
@@ -214,6 +253,8 @@ export const validateReceiptIOS = validateReceiptIOSImpl;
|
|
|
214
253
|
* @throws Error if called on non-iOS platform or tvOS
|
|
215
254
|
*
|
|
216
255
|
* @platform iOS
|
|
256
|
+
*
|
|
257
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/present-code-redemption-sheet-ios}
|
|
217
258
|
*/
|
|
218
259
|
export const presentCodeRedemptionSheetIOS = async () => {
|
|
219
260
|
return !!(await ExpoIapModule.presentCodeRedemptionSheetIOS());
|
|
@@ -231,6 +272,8 @@ export const presentCodeRedemptionSheetIOS = async () => {
|
|
|
231
272
|
*
|
|
232
273
|
* @platform iOS
|
|
233
274
|
* @since iOS 16.0
|
|
275
|
+
*
|
|
276
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/get-app-transaction-ios}
|
|
234
277
|
*/
|
|
235
278
|
export const getAppTransactionIOS = async () => {
|
|
236
279
|
return (await ExpoIapModule.getAppTransactionIOS()) ?? null;
|
|
@@ -244,6 +287,8 @@ export const getAppTransactionIOS = async () => {
|
|
|
244
287
|
* @throws Error if called on non-iOS platform
|
|
245
288
|
*
|
|
246
289
|
* @platform iOS
|
|
290
|
+
*
|
|
291
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/get-promoted-product-ios}
|
|
247
292
|
*/
|
|
248
293
|
export const getPromotedProductIOS = async () => {
|
|
249
294
|
const product = await ExpoIapModule.getPromotedProductIOS();
|
|
@@ -260,6 +305,8 @@ export const getPromotedProductIOS = async () => {
|
|
|
260
305
|
* @throws Error if called on non-iOS platform or no promoted product is available
|
|
261
306
|
*
|
|
262
307
|
* @platform iOS
|
|
308
|
+
*
|
|
309
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/request-purchase-on-promoted-product-ios}
|
|
263
310
|
*/
|
|
264
311
|
export const requestPurchaseOnPromotedProductIOS = async () => {
|
|
265
312
|
const result = await ExpoIapModule.requestPurchaseOnPromotedProductIOS();
|
|
@@ -270,11 +317,18 @@ export const requestPurchaseOnPromotedProductIOS = async () => {
|
|
|
270
317
|
*
|
|
271
318
|
* @returns Promise resolving to array of pending transactions
|
|
272
319
|
* @platform iOS
|
|
320
|
+
*
|
|
321
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/get-pending-transactions-ios}
|
|
273
322
|
*/
|
|
274
323
|
export const getPendingTransactionsIOS = async () => {
|
|
275
324
|
const transactions = await ExpoIapModule.getPendingTransactionsIOS();
|
|
276
325
|
return (transactions ?? []);
|
|
277
326
|
};
|
|
327
|
+
/**
|
|
328
|
+
* List every StoreKit transaction (finished + unfinished) for the current user.
|
|
329
|
+
*
|
|
330
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/get-all-transactions-ios}
|
|
331
|
+
*/
|
|
278
332
|
export const getAllTransactionsIOS = async () => {
|
|
279
333
|
const transactions = await ExpoIapModule.getAllTransactionsIOS();
|
|
280
334
|
return (transactions ?? []);
|
|
@@ -284,6 +338,8 @@ export const getAllTransactionsIOS = async () => {
|
|
|
284
338
|
*
|
|
285
339
|
* @returns Promise resolving when transaction is cleared
|
|
286
340
|
* @platform iOS
|
|
341
|
+
*
|
|
342
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/clear-transaction-ios}
|
|
287
343
|
*/
|
|
288
344
|
export const clearTransactionIOS = async () => {
|
|
289
345
|
return !!(await ExpoIapModule.clearTransactionIOS());
|
|
@@ -296,10 +352,16 @@ export const clearTransactionIOS = async () => {
|
|
|
296
352
|
*/
|
|
297
353
|
export const deepLinkToSubscriptionsIOS = () => Linking.openURL('https://apps.apple.com/account/subscriptions');
|
|
298
354
|
/**
|
|
299
|
-
* Check if the device can present an external purchase notice sheet (iOS
|
|
355
|
+
* Check if the device can present an external purchase notice sheet (iOS 17.4+).
|
|
356
|
+
*
|
|
357
|
+
* Wraps `ExternalPurchase.canPresent`, which Apple introduced in iOS 17.4.
|
|
358
|
+
* Note: the notice sheet itself (`presentExternalPurchaseNoticeSheetIOS`)
|
|
359
|
+
* still requires iOS 18.2+; only the eligibility check is available earlier.
|
|
300
360
|
*
|
|
301
361
|
* @returns Promise resolving to true if the notice sheet can be presented
|
|
302
362
|
* @platform iOS
|
|
363
|
+
*
|
|
364
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/can-present-external-purchase-notice-ios}
|
|
303
365
|
*/
|
|
304
366
|
export const canPresentExternalPurchaseNoticeIOS = async () => {
|
|
305
367
|
return !!(await ExpoIapModule.canPresentExternalPurchaseNoticeIOS());
|
|
@@ -311,6 +373,8 @@ export const canPresentExternalPurchaseNoticeIOS = async () => {
|
|
|
311
373
|
*
|
|
312
374
|
* @returns Promise resolving to the result with action, token, and error if any
|
|
313
375
|
* @platform iOS
|
|
376
|
+
*
|
|
377
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/present-external-purchase-notice-sheet-ios}
|
|
314
378
|
*/
|
|
315
379
|
export const presentExternalPurchaseNoticeSheetIOS = async () => {
|
|
316
380
|
const result = await ExpoIapModule.presentExternalPurchaseNoticeSheetIOS();
|
|
@@ -322,6 +386,8 @@ export const presentExternalPurchaseNoticeSheetIOS = async () => {
|
|
|
322
386
|
* @param url - The external purchase URL to open
|
|
323
387
|
* @returns Promise resolving to the result with success status and error if any
|
|
324
388
|
* @platform iOS
|
|
389
|
+
*
|
|
390
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/present-external-purchase-link-ios}
|
|
325
391
|
*/
|
|
326
392
|
export const presentExternalPurchaseLinkIOS = async (url) => {
|
|
327
393
|
const result = await ExpoIapModule.presentExternalPurchaseLinkIOS(url);
|
|
@@ -334,6 +400,8 @@ export const presentExternalPurchaseLinkIOS = async (url) => {
|
|
|
334
400
|
* @returns Promise resolving to true if eligible
|
|
335
401
|
* @platform iOS
|
|
336
402
|
* @see https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/iseligible
|
|
403
|
+
*
|
|
404
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/is-eligible-for-external-purchase-custom-link-ios}
|
|
337
405
|
*/
|
|
338
406
|
export const isEligibleForExternalPurchaseCustomLinkIOS = async () => {
|
|
339
407
|
return !!(await ExpoIapModule.isEligibleForExternalPurchaseCustomLinkIOS());
|
|
@@ -346,6 +414,8 @@ export const isEligibleForExternalPurchaseCustomLinkIOS = async () => {
|
|
|
346
414
|
* @returns Promise resolving to the token result with token string or error
|
|
347
415
|
* @platform iOS
|
|
348
416
|
* @see https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/token(for:)
|
|
417
|
+
*
|
|
418
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/get-external-purchase-custom-link-token-ios}
|
|
349
419
|
*/
|
|
350
420
|
export const getExternalPurchaseCustomLinkTokenIOS = async (tokenType) => {
|
|
351
421
|
if (!tokenType) {
|
|
@@ -363,6 +433,8 @@ export const getExternalPurchaseCustomLinkTokenIOS = async (tokenType) => {
|
|
|
363
433
|
* @returns Promise resolving to the result with continued status and error if any
|
|
364
434
|
* @platform iOS
|
|
365
435
|
* @see https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/shownotice(type:)
|
|
436
|
+
*
|
|
437
|
+
* @see {@link https://www.openiap.dev/docs/apis/ios/show-external-purchase-custom-link-notice-ios}
|
|
366
438
|
*/
|
|
367
439
|
export const showExternalPurchaseCustomLinkNoticeIOS = async (noticeType) => {
|
|
368
440
|
if (!noticeType) {
|