expo-iap 4.2.3 → 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.
Files changed (40) hide show
  1. package/build/index.d.ts +126 -33
  2. package/build/index.d.ts.map +1 -1
  3. package/build/index.js +123 -33
  4. package/build/index.js.map +1 -1
  5. package/build/kit-api.d.ts +54 -0
  6. package/build/kit-api.d.ts.map +1 -0
  7. package/build/kit-api.js +156 -0
  8. package/build/kit-api.js.map +1 -0
  9. package/build/modules/android.d.ts +16 -0
  10. package/build/modules/android.d.ts.map +1 -1
  11. package/build/modules/android.js +16 -0
  12. package/build/modules/android.js.map +1 -1
  13. package/build/modules/ios.d.ts +56 -1
  14. package/build/modules/ios.d.ts.map +1 -1
  15. package/build/modules/ios.js +58 -1
  16. package/build/modules/ios.js.map +1 -1
  17. package/build/types.d.ts +241 -75
  18. package/build/types.d.ts.map +1 -1
  19. package/build/types.js.map +1 -1
  20. package/build/useIAP.d.ts.map +1 -1
  21. package/build/useIAP.js +125 -3
  22. package/build/useIAP.js.map +1 -1
  23. package/build/useWebhookEvents.d.ts +26 -0
  24. package/build/useWebhookEvents.d.ts.map +1 -0
  25. package/build/useWebhookEvents.js +105 -0
  26. package/build/useWebhookEvents.js.map +1 -0
  27. package/build/webhook-client.d.ts +82 -0
  28. package/build/webhook-client.d.ts.map +1 -0
  29. package/build/webhook-client.js +176 -0
  30. package/build/webhook-client.js.map +1 -0
  31. package/openiap-versions.json +2 -2
  32. package/package.json +1 -1
  33. package/src/index.ts +141 -33
  34. package/src/kit-api.ts +229 -0
  35. package/src/modules/android.ts +16 -0
  36. package/src/modules/ios.ts +58 -1
  37. package/src/types.ts +247 -75
  38. package/src/useIAP.ts +125 -3
  39. package/src/useWebhookEvents.ts +155 -0
  40. package/src/webhook-client.ts +314 -0
package/build/index.d.ts CHANGED
@@ -156,16 +156,75 @@ export declare const developerProvidedBillingListenerAndroid: (listener: (detail
156
156
  export declare const subscriptionBillingIssueListener: (listener: (purchase: Purchase) => void) => {
157
157
  remove: () => void;
158
158
  };
159
+ /**
160
+ * Initialize the store connection. Must be called before any other IAP API.
161
+ *
162
+ * @param config Optional connection config. Use `enableBillingProgramAndroid` (Android,
163
+ * Play Billing 8.2.0+) to opt into External Payments etc. iOS ignores Android-specific fields.
164
+ * @returns Promise resolving to `true` when the platform billing client is connected.
165
+ * @throws When the platform billing client fails to initialize.
166
+ *
167
+ * @example
168
+ * ```ts
169
+ * await initConnection();
170
+ * await initConnection({ enableBillingProgramAndroid: 'external-offer' });
171
+ * ```
172
+ *
173
+ * @remarks When using `useIAP()`, connection is auto-managed on mount/unmount —
174
+ * pass options to the hook instead of calling this directly.
175
+ *
176
+ * @see {@link https://www.openiap.dev/docs/apis/init-connection}
177
+ */
159
178
  export declare const initConnection: MutationField<'initConnection'>;
179
+ /**
180
+ * Close the store connection and release resources.
181
+ *
182
+ * @see {@link https://www.openiap.dev/docs/apis/end-connection}
183
+ */
160
184
  export declare const endConnection: MutationField<'endConnection'>;
161
185
  /**
162
- * Fetch products with unified API (v2.7.0+)
186
+ * Retrieve products or subscriptions from the store by SKU.
187
+ *
188
+ * @param request `ProductRequest` — `skus` (string[]) and optional `type`
189
+ * (`'in-app' | 'subs' | 'all'`, defaults to `'in-app'`).
190
+ * @returns Promise resolving to a `FetchProductsResult` union — `Product[]` for `'in-app'`,
191
+ * `ProductSubscription[]` for `'subs'`, or a mixed array for `'all'`.
192
+ * @throws When the store rejects the request (empty `skus`, not connected,
193
+ * network/store error). Unknown SKUs are simply omitted from the result, not thrown.
194
+ *
195
+ * @example
196
+ * ```ts
197
+ * const products = await fetchProducts({
198
+ * skus: ['com.app.coins_100', 'com.app.premium'],
199
+ * type: 'in-app',
200
+ * });
201
+ * ```
163
202
  *
164
- * @param request - Product fetch configuration
165
- * @param request.skus - Array of product SKUs to fetch
166
- * @param request.type - Product query type: 'in-app', 'subs', or 'all'
203
+ * @remarks This is a regular promise-based call. Don't confuse with `request*` APIs
204
+ * (`requestPurchase`), which are event-based.
205
+ *
206
+ * @see {@link https://www.openiap.dev/docs/apis/fetch-products}
167
207
  */
168
208
  export declare const fetchProducts: QueryField<'fetchProducts'>;
209
+ /**
210
+ * List the user's unfinished purchases — non-consumables, active subscriptions, and any
211
+ * pending transactions not yet finished.
212
+ *
213
+ * @param options Optional `PurchaseOptions`. iOS-only flags:
214
+ * `alsoPublishToEventListenerIOS`, `onlyIncludeActiveItemsIOS`.
215
+ * @returns Promise resolving to an array of `Purchase` currently held by the store.
216
+ * @throws When the platform query fails.
217
+ *
218
+ * @example
219
+ * ```ts
220
+ * const purchases = await getAvailablePurchases();
221
+ * for (const p of purchases) {
222
+ * if (await verifyOnServer(p)) await finishTransaction({ purchase: p, isConsumable: false });
223
+ * }
224
+ * ```
225
+ *
226
+ * @see {@link https://www.openiap.dev/docs/apis/get-available-purchases}
227
+ */
169
228
  export declare const getAvailablePurchases: QueryField<'getAvailablePurchases'>;
170
229
  /**
171
230
  * Get all active subscriptions with detailed information.
@@ -194,6 +253,8 @@ export declare const getAvailablePurchases: QueryField<'getAvailablePurchases'>;
194
253
  * }
195
254
  * });
196
255
  * ```
256
+ *
257
+ * @see {@link https://www.openiap.dev/docs/apis/get-active-subscriptions}
197
258
  */
198
259
  export declare const getActiveSubscriptions: QueryField<'getActiveSubscriptions'>;
199
260
  /**
@@ -210,50 +271,66 @@ export declare const getActiveSubscriptions: QueryField<'getActiveSubscriptions'
210
271
  * // Check specific subscriptions
211
272
  * const hasPremium = await hasActiveSubscriptions(['premium', 'premium_year']);
212
273
  * ```
274
+ *
275
+ * @see {@link https://www.openiap.dev/docs/apis/has-active-subscriptions}
213
276
  */
214
277
  export declare const hasActiveSubscriptions: QueryField<'hasActiveSubscriptions'>;
278
+ /**
279
+ * Return the user's storefront country code.
280
+ *
281
+ * @see {@link https://www.openiap.dev/docs/apis/get-storefront}
282
+ */
215
283
  export declare const getStorefront: QueryField<'getStorefront'>;
216
284
  /**
217
- * Request a purchase for products or subscriptions.
285
+ * Initiate a purchase or subscription flow. The result is delivered through
286
+ * `purchaseUpdatedListener` — NOT the return value.
218
287
  *
219
- * @param requestObj - Purchase request configuration
220
- * @param requestObj.request - Store-specific purchase parameters
221
- * @param requestObj.type - Type of purchase: 'in-app' for products (default) or 'subs' for subscriptions
288
+ * @param args `RequestPurchaseProps`, discriminated by `type`:
289
+ * - `type: 'in-app'` — pass `request.apple.sku` (iOS) and/or `request.google.skus` (Android).
290
+ * - `type: 'subs'` — same shape, plus `request.google.subscriptionOffers: [{ sku, offerToken }]`.
291
+ * @returns The dispatched purchase payload. **Do not rely on it** for the actual outcome.
292
+ * @throws Synchronous rejection from the store (e.g. `E_NOT_PREPARED`, validation failure).
222
293
  *
223
294
  * @example
224
- * ```typescript
225
- * // Product purchase (recommended: use apple/google)
295
+ * ```ts
226
296
  * await requestPurchase({
227
297
  * request: {
228
- * apple: { sku: productId },
229
- * google: { skus: [productId] }
298
+ * apple: { sku: 'com.app.premium' },
299
+ * google: { skus: ['com.app.premium'] },
230
300
  * },
231
- * type: 'in-app'
301
+ * type: 'in-app',
232
302
  * });
303
+ * ```
233
304
  *
234
- * // Subscription purchase
235
- * await requestPurchase({
236
- * request: {
237
- * apple: { sku: subscriptionId },
238
- * google: {
239
- * skus: [subscriptionId],
240
- * subscriptionOffers: [{ sku: subscriptionId, offerToken: 'token' }]
241
- * }
242
- * },
243
- * type: 'subs'
244
- * });
305
+ * @remarks Event-based. Listen for the result via {@link purchaseUpdatedListener} /
306
+ * {@link purchaseErrorListener}, or use `useIAP({ onPurchaseSuccess, onPurchaseError })`.
245
307
  *
246
- * // Legacy format (deprecated, but still supported)
247
- * await requestPurchase({
248
- * request: {
249
- * ios: { sku: productId },
250
- * android: { skus: [productId] }
251
- * },
252
- * type: 'in-app'
253
- * });
254
- * ```
308
+ * @see {@link https://www.openiap.dev/docs/apis/request-purchase}
255
309
  */
256
310
  export declare const requestPurchase: MutationField<'requestPurchase'>;
311
+ /**
312
+ * Complete a purchase transaction. Call after server-side verification to remove it
313
+ * from the queue.
314
+ *
315
+ * @param args.purchase The `Purchase` to finalize.
316
+ * @param args.isConsumable `true` for consumables (consumes the token so the SKU can be
317
+ * re-bought, e.g. coins); `false` (default) for non-consumables and subscriptions.
318
+ * @returns Promise that resolves once the platform finalizes the transaction.
319
+ * @throws When the platform finalize call fails.
320
+ *
321
+ * @example
322
+ * ```ts
323
+ * // Inside purchaseUpdatedListener:
324
+ * if (await verifyOnServer(purchase)) {
325
+ * await finishTransaction({ purchase, isConsumable: false });
326
+ * }
327
+ * ```
328
+ *
329
+ * @remarks **Critical:** Android purchases must be finalized within 3 days or Google
330
+ * auto-refunds. iOS unfinished transactions replay on every app launch.
331
+ *
332
+ * @see {@link https://www.openiap.dev/docs/apis/finish-transaction}
333
+ */
257
334
  export declare const finishTransaction: MutationField<'finishTransaction'>;
258
335
  /**
259
336
  * Restore completed transactions (cross-platform behavior)
@@ -264,6 +341,8 @@ export declare const finishTransaction: MutationField<'finishTransaction'>;
264
341
  *
265
342
  * This helper triggers the refresh flows but does not return the purchases; consumers should
266
343
  * call `getAvailablePurchases` or rely on hook state to inspect the latest items.
344
+ *
345
+ * @see {@link https://www.openiap.dev/docs/apis/restore-purchases}
267
346
  */
268
347
  export declare const restorePurchases: MutationField<'restorePurchases'>;
269
348
  /**
@@ -283,6 +362,8 @@ export declare const restorePurchases: MutationField<'restorePurchases'>;
283
362
  * skuAndroid: 'your_subscription_sku',
284
363
  * packageNameAndroid: 'com.example.app'
285
364
  * });
365
+ *
366
+ * @see {@link https://www.openiap.dev/docs/apis/deep-link-to-subscriptions}
286
367
  */
287
368
  export declare const deepLinkToSubscriptions: MutationField<'deepLinkToSubscriptions'>;
288
369
  /**
@@ -294,6 +375,8 @@ export declare const deepLinkToSubscriptions: MutationField<'deepLinkToSubscript
294
375
  * - Android: Use Google Play Developer API with service account credentials
295
376
  *
296
377
  * @deprecated Use verifyPurchase instead
378
+ *
379
+ * @see {@link https://www.openiap.dev/docs/apis/validate-receipt}
297
380
  */
298
381
  export declare const validateReceipt: MutationField<'validateReceipt'>;
299
382
  /**
@@ -304,6 +387,8 @@ export declare const validateReceipt: MutationField<'validateReceipt'>;
304
387
  *
305
388
  * @param options - Receipt validation options containing the SKU
306
389
  * @returns Promise resolving to receipt validation result
390
+ *
391
+ * @see {@link https://www.openiap.dev/docs/features/validation#verify-purchase}
307
392
  */
308
393
  export declare const verifyPurchase: MutationField<'verifyPurchase'>;
309
394
  /**
@@ -330,9 +415,17 @@ export declare const verifyPurchase: MutationField<'verifyPurchase'>;
330
415
  * }
331
416
  * });
332
417
  * ```
418
+ *
419
+ * @see {@link https://www.openiap.dev/docs/features/validation#verify-purchase-with-provider}
333
420
  */
334
421
  export declare const verifyPurchaseWithProvider: MutationField<'verifyPurchaseWithProvider'>;
335
422
  export * from './useIAP';
423
+ export { useWebhookEvents } from './useWebhookEvents';
424
+ export type { UseWebhookEventsOptions, UseWebhookEventsResult, } from './useWebhookEvents';
425
+ export { connectWebhookStream, parseWebhookEventData } from './webhook-client';
426
+ export type { WebhookEventPayload, WebhookEventStream, WebhookEventType as WebhookEventTypeName, WebhookListener, WebhookListenerError, WebhookListenerOptions, } from './webhook-client';
427
+ export { kitApi, KitApiError } from './kit-api';
428
+ export type { KitApiOptions, KitSubscription, EntitlementsResponse, StatusResponse, } from './kit-api';
336
429
  export { ErrorCodeUtils, ErrorCodeMapping, createPurchaseError, createPurchaseErrorFromPlatform, } from './utils/errorMapping';
337
430
  export type { PurchaseError as ExpoPurchaseError, PurchaseErrorProps, } from './utils/errorMapping';
338
431
  export { ExpoIapConsole } from './utils/debug';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAIV,sCAAsC,EACtC,aAAa,EAGb,OAAO,EACP,gBAAgB,EAEhB,QAAQ,EAER,UAAU,EAOV,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAEjB,OAAO,EA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mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,IAAI,oBAAoB,EACxC,eAAe,EACf,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,WAAW,CAAC;AAC9C,YAAY,EACV,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,cAAc,GACf,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,mBAAmB,EACnB,+BAA+B,GAChC,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,aAAa,IAAI,iBAAiB,EAClC,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAC,cAAc,EAAC,MAAM,eAAe,CAAC"}
package/build/index.js CHANGED
@@ -220,14 +220,54 @@ export const subscriptionBillingIssueListener = (listener) => {
220
220
  };
221
221
  return emitter.addListener(OpenIapEvent.SubscriptionBillingIssue, wrappedListener);
222
222
  };
223
+ /**
224
+ * Initialize the store connection. Must be called before any other IAP API.
225
+ *
226
+ * @param config Optional connection config. Use `enableBillingProgramAndroid` (Android,
227
+ * Play Billing 8.2.0+) to opt into External Payments etc. iOS ignores Android-specific fields.
228
+ * @returns Promise resolving to `true` when the platform billing client is connected.
229
+ * @throws When the platform billing client fails to initialize.
230
+ *
231
+ * @example
232
+ * ```ts
233
+ * await initConnection();
234
+ * await initConnection({ enableBillingProgramAndroid: 'external-offer' });
235
+ * ```
236
+ *
237
+ * @remarks When using `useIAP()`, connection is auto-managed on mount/unmount —
238
+ * pass options to the hook instead of calling this directly.
239
+ *
240
+ * @see {@link https://www.openiap.dev/docs/apis/init-connection}
241
+ */
223
242
  export const initConnection = async (config) => ExpoIapModule.initConnection(config ?? null);
243
+ /**
244
+ * Close the store connection and release resources.
245
+ *
246
+ * @see {@link https://www.openiap.dev/docs/apis/end-connection}
247
+ */
224
248
  export const endConnection = async () => ExpoIapModule.endConnection();
225
249
  /**
226
- * Fetch products with unified API (v2.7.0+)
250
+ * Retrieve products or subscriptions from the store by SKU.
251
+ *
252
+ * @param request `ProductRequest` — `skus` (string[]) and optional `type`
253
+ * (`'in-app' | 'subs' | 'all'`, defaults to `'in-app'`).
254
+ * @returns Promise resolving to a `FetchProductsResult` union — `Product[]` for `'in-app'`,
255
+ * `ProductSubscription[]` for `'subs'`, or a mixed array for `'all'`.
256
+ * @throws When the store rejects the request (empty `skus`, not connected,
257
+ * network/store error). Unknown SKUs are simply omitted from the result, not thrown.
258
+ *
259
+ * @example
260
+ * ```ts
261
+ * const products = await fetchProducts({
262
+ * skus: ['com.app.coins_100', 'com.app.premium'],
263
+ * type: 'in-app',
264
+ * });
265
+ * ```
227
266
  *
228
- * @param request - Product fetch configuration
229
- * @param request.skus - Array of product SKUs to fetch
230
- * @param request.type - Product query type: 'in-app', 'subs', or 'all'
267
+ * @remarks This is a regular promise-based call. Don't confuse with `request*` APIs
268
+ * (`requestPurchase`), which are event-based.
269
+ *
270
+ * @see {@link https://www.openiap.dev/docs/apis/fetch-products}
231
271
  */
232
272
  export const fetchProducts = async (request) => {
233
273
  ExpoIapConsole.debug('fetchProducts called with:', request);
@@ -275,6 +315,25 @@ export const fetchProducts = async (request) => {
275
315
  }
276
316
  throw new Error('Unsupported platform');
277
317
  };
318
+ /**
319
+ * List the user's unfinished purchases — non-consumables, active subscriptions, and any
320
+ * pending transactions not yet finished.
321
+ *
322
+ * @param options Optional `PurchaseOptions`. iOS-only flags:
323
+ * `alsoPublishToEventListenerIOS`, `onlyIncludeActiveItemsIOS`.
324
+ * @returns Promise resolving to an array of `Purchase` currently held by the store.
325
+ * @throws When the platform query fails.
326
+ *
327
+ * @example
328
+ * ```ts
329
+ * const purchases = await getAvailablePurchases();
330
+ * for (const p of purchases) {
331
+ * if (await verifyOnServer(p)) await finishTransaction({ purchase: p, isConsumable: false });
332
+ * }
333
+ * ```
334
+ *
335
+ * @see {@link https://www.openiap.dev/docs/apis/get-available-purchases}
336
+ */
278
337
  export const getAvailablePurchases = async (options) => {
279
338
  const normalizedOptions = {
280
339
  alsoPublishToEventListenerIOS: options?.alsoPublishToEventListenerIOS ?? false,
@@ -315,6 +374,8 @@ export const getAvailablePurchases = async (options) => {
315
374
  * }
316
375
  * });
317
376
  * ```
377
+ *
378
+ * @see {@link https://www.openiap.dev/docs/apis/get-active-subscriptions}
318
379
  */
319
380
  export const getActiveSubscriptions = async (subscriptionIds) => {
320
381
  const result = await ExpoIapModule.getActiveSubscriptions(subscriptionIds ?? null);
@@ -334,10 +395,17 @@ export const getActiveSubscriptions = async (subscriptionIds) => {
334
395
  * // Check specific subscriptions
335
396
  * const hasPremium = await hasActiveSubscriptions(['premium', 'premium_year']);
336
397
  * ```
398
+ *
399
+ * @see {@link https://www.openiap.dev/docs/apis/has-active-subscriptions}
337
400
  */
338
401
  export const hasActiveSubscriptions = async (subscriptionIds) => {
339
402
  return !!(await ExpoIapModule.hasActiveSubscriptions(subscriptionIds ?? null));
340
403
  };
404
+ /**
405
+ * Return the user's storefront country code.
406
+ *
407
+ * @see {@link https://www.openiap.dev/docs/apis/get-storefront}
408
+ */
341
409
  export const getStorefront = async () => {
342
410
  if (Platform.OS !== 'ios' && Platform.OS !== 'android') {
343
411
  return '';
@@ -353,44 +421,30 @@ function normalizeRequestProps(request, platform) {
353
421
  return request.google ?? request.android;
354
422
  }
355
423
  /**
356
- * Request a purchase for products or subscriptions.
424
+ * Initiate a purchase or subscription flow. The result is delivered through
425
+ * `purchaseUpdatedListener` — NOT the return value.
357
426
  *
358
- * @param requestObj - Purchase request configuration
359
- * @param requestObj.request - Store-specific purchase parameters
360
- * @param requestObj.type - Type of purchase: 'in-app' for products (default) or 'subs' for subscriptions
427
+ * @param args `RequestPurchaseProps`, discriminated by `type`:
428
+ * - `type: 'in-app'` — pass `request.apple.sku` (iOS) and/or `request.google.skus` (Android).
429
+ * - `type: 'subs'` — same shape, plus `request.google.subscriptionOffers: [{ sku, offerToken }]`.
430
+ * @returns The dispatched purchase payload. **Do not rely on it** for the actual outcome.
431
+ * @throws Synchronous rejection from the store (e.g. `E_NOT_PREPARED`, validation failure).
361
432
  *
362
433
  * @example
363
- * ```typescript
364
- * // Product purchase (recommended: use apple/google)
434
+ * ```ts
365
435
  * await requestPurchase({
366
436
  * request: {
367
- * apple: { sku: productId },
368
- * google: { skus: [productId] }
437
+ * apple: { sku: 'com.app.premium' },
438
+ * google: { skus: ['com.app.premium'] },
369
439
  * },
370
- * type: 'in-app'
440
+ * type: 'in-app',
371
441
  * });
442
+ * ```
372
443
  *
373
- * // Subscription purchase
374
- * await requestPurchase({
375
- * request: {
376
- * apple: { sku: subscriptionId },
377
- * google: {
378
- * skus: [subscriptionId],
379
- * subscriptionOffers: [{ sku: subscriptionId, offerToken: 'token' }]
380
- * }
381
- * },
382
- * type: 'subs'
383
- * });
444
+ * @remarks Event-based. Listen for the result via {@link purchaseUpdatedListener} /
445
+ * {@link purchaseErrorListener}, or use `useIAP({ onPurchaseSuccess, onPurchaseError })`.
384
446
  *
385
- * // Legacy format (deprecated, but still supported)
386
- * await requestPurchase({
387
- * request: {
388
- * ios: { sku: productId },
389
- * android: { skus: [productId] }
390
- * },
391
- * type: 'in-app'
392
- * });
393
- * ```
447
+ * @see {@link https://www.openiap.dev/docs/apis/request-purchase}
394
448
  */
395
449
  export const requestPurchase = async (args) => {
396
450
  const { request, type } = args;
@@ -492,6 +546,29 @@ export const requestPurchase = async (args) => {
492
546
  }
493
547
  throw new Error('Platform not supported');
494
548
  };
549
+ /**
550
+ * Complete a purchase transaction. Call after server-side verification to remove it
551
+ * from the queue.
552
+ *
553
+ * @param args.purchase The `Purchase` to finalize.
554
+ * @param args.isConsumable `true` for consumables (consumes the token so the SKU can be
555
+ * re-bought, e.g. coins); `false` (default) for non-consumables and subscriptions.
556
+ * @returns Promise that resolves once the platform finalizes the transaction.
557
+ * @throws When the platform finalize call fails.
558
+ *
559
+ * @example
560
+ * ```ts
561
+ * // Inside purchaseUpdatedListener:
562
+ * if (await verifyOnServer(purchase)) {
563
+ * await finishTransaction({ purchase, isConsumable: false });
564
+ * }
565
+ * ```
566
+ *
567
+ * @remarks **Critical:** Android purchases must be finalized within 3 days or Google
568
+ * auto-refunds. iOS unfinished transactions replay on every app launch.
569
+ *
570
+ * @see {@link https://www.openiap.dev/docs/apis/finish-transaction}
571
+ */
495
572
  export const finishTransaction = async ({ purchase, isConsumable = false, }) => {
496
573
  if (Platform.OS === 'ios') {
497
574
  await ExpoIapModule.finishTransaction(purchase, isConsumable);
@@ -525,6 +602,8 @@ export const finishTransaction = async ({ purchase, isConsumable = false, }) =>
525
602
  *
526
603
  * This helper triggers the refresh flows but does not return the purchases; consumers should
527
604
  * call `getAvailablePurchases` or rely on hook state to inspect the latest items.
605
+ *
606
+ * @see {@link https://www.openiap.dev/docs/apis/restore-purchases}
528
607
  */
529
608
  export const restorePurchases = async () => {
530
609
  if (Platform.OS === 'ios') {
@@ -552,6 +631,8 @@ export const restorePurchases = async () => {
552
631
  * skuAndroid: 'your_subscription_sku',
553
632
  * packageNameAndroid: 'com.example.app'
554
633
  * });
634
+ *
635
+ * @see {@link https://www.openiap.dev/docs/apis/deep-link-to-subscriptions}
555
636
  */
556
637
  export const deepLinkToSubscriptions = async (options) => {
557
638
  if (Platform.OS === 'ios') {
@@ -573,6 +654,8 @@ export const deepLinkToSubscriptions = async (options) => {
573
654
  * - Android: Use Google Play Developer API with service account credentials
574
655
  *
575
656
  * @deprecated Use verifyPurchase instead
657
+ *
658
+ * @see {@link https://www.openiap.dev/docs/apis/validate-receipt}
576
659
  */
577
660
  export const validateReceipt = async (options) => {
578
661
  const { apple, google } = options;
@@ -608,6 +691,8 @@ export const validateReceipt = async (options) => {
608
691
  *
609
692
  * @param options - Receipt validation options containing the SKU
610
693
  * @returns Promise resolving to receipt validation result
694
+ *
695
+ * @see {@link https://www.openiap.dev/docs/features/validation#verify-purchase}
611
696
  */
612
697
  export const verifyPurchase = async (options) => {
613
698
  if (Platform.OS === 'ios' || Platform.OS === 'android') {
@@ -639,6 +724,8 @@ export const verifyPurchase = async (options) => {
639
724
  * }
640
725
  * });
641
726
  * ```
727
+ *
728
+ * @see {@link https://www.openiap.dev/docs/features/validation#verify-purchase-with-provider}
642
729
  */
643
730
  export const verifyPurchaseWithProvider = async (options) => {
644
731
  if (Platform.OS === 'ios' || Platform.OS === 'android') {
@@ -671,6 +758,9 @@ export const verifyPurchaseWithProvider = async (options) => {
671
758
  throw new Error(`Unsupported platform: ${Platform.OS}`);
672
759
  };
673
760
  export * from './useIAP';
761
+ export { useWebhookEvents } from './useWebhookEvents';
762
+ export { connectWebhookStream, parseWebhookEventData } from './webhook-client';
763
+ export { kitApi, KitApiError } from './kit-api';
674
764
  export { ErrorCodeUtils, ErrorCodeMapping, createPurchaseError, createPurchaseErrorFromPlatform, } from './utils/errorMapping';
675
765
  export { ExpoIapConsole } from './utils/debug';
676
766
  //# sourceMappingURL=index.js.map