expo-iap 3.1.38 → 3.3.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/.prettierignore +1 -0
  2. package/android/src/main/java/expo/modules/iap/ExpoIapModule.kt +124 -0
  3. package/build/index.d.ts +15 -6
  4. package/build/index.d.ts.map +1 -1
  5. package/build/index.js +30 -17
  6. package/build/index.js.map +1 -1
  7. package/build/modules/android.d.ts +53 -1
  8. package/build/modules/android.d.ts.map +1 -1
  9. package/build/modules/android.js +61 -0
  10. package/build/modules/android.js.map +1 -1
  11. package/build/types.d.ts +255 -11
  12. package/build/types.d.ts.map +1 -1
  13. package/build/types.js.map +1 -1
  14. package/build/useIAP.d.ts.map +1 -1
  15. package/build/useIAP.js +2 -0
  16. package/build/useIAP.js.map +1 -1
  17. package/coverage/clover.xml +147 -139
  18. package/coverage/coverage-final.json +5 -5
  19. package/coverage/lcov-report/block-navigation.js +1 -1
  20. package/coverage/lcov-report/index.html +23 -23
  21. package/coverage/lcov-report/sorter.js +7 -21
  22. package/coverage/lcov-report/src/ExpoIap.types.ts.html +1396 -0
  23. package/coverage/lcov-report/src/helpers/index.html +116 -0
  24. package/coverage/lcov-report/src/helpers/subscription.ts.html +499 -0
  25. package/coverage/lcov-report/src/index.html +14 -14
  26. package/coverage/lcov-report/src/index.ts.html +64 -25
  27. package/coverage/lcov-report/src/modules/android.ts.html +233 -8
  28. package/coverage/lcov-report/src/modules/index.html +15 -15
  29. package/coverage/lcov-report/src/modules/ios.ts.html +1 -1
  30. package/coverage/lcov-report/src/onside/ExpoOnsideMarketplaceAvailabilityModule.ts.html +145 -0
  31. package/coverage/lcov-report/src/onside/index.html +131 -0
  32. package/coverage/lcov-report/src/onside/index.ts.html +253 -0
  33. package/coverage/lcov-report/src/types/ExpoIapAndroid.types.ts.html +502 -0
  34. package/coverage/lcov-report/src/types/index.html +116 -0
  35. package/coverage/lcov-report/src/useIAP.ts.html +1654 -0
  36. package/coverage/lcov-report/src/utils/constants.ts.html +127 -0
  37. package/coverage/lcov-report/src/utils/debug.ts.html +1 -1
  38. package/coverage/lcov-report/src/utils/errorMapping.ts.html +1 -1
  39. package/coverage/lcov-report/src/utils/index.html +1 -1
  40. package/coverage/lcov.info +249 -232
  41. package/ios/expoiap.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  42. package/ios/expoiap.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  43. package/openiap-versions.json +3 -3
  44. package/package.json +1 -1
  45. package/plugin/tsconfig.tsbuildinfo +1 -1
  46. package/src/index.ts +30 -17
  47. package/src/modules/android.ts +75 -0
  48. package/src/types.ts +273 -12
  49. package/src/useIAP.ts +2 -0
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Workspace
3
+ version = "1.0">
4
+ <FileRef
5
+ location = "self:">
6
+ </FileRef>
7
+ </Workspace>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>IDEDidComputeMac32BitWarning</key>
6
+ <true/>
7
+ </dict>
8
+ </plist>
@@ -1,5 +1,5 @@
1
1
  {
2
- "apple": "1.2.42",
3
- "google": "1.3.8",
4
- "gql": "1.2.7"
2
+ "apple": "1.3.0",
3
+ "google": "1.3.12",
4
+ "gql": "1.3.2"
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-iap",
3
- "version": "3.1.38",
3
+ "version": "3.3.0-rc.1",
4
4
  "description": "In App Purchase module in Expo",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -1 +1 @@
1
- {"root":["./src/expoConfig.augmentation.d.ts","./src/withIAP.ts","./src/withIosAlternativeBilling.ts","./src/withLocalOpenIAP.ts"],"version":"5.9.3"}
1
+ {"root":["./src/expoconfig.augmentation.d.ts","./src/withiap.ts","./src/withiosalternativebilling.ts","./src/withlocalopeniap.ts"],"version":"5.9.2"}
package/src/index.ts CHANGED
@@ -424,24 +424,28 @@ function normalizeRequestProps(
424
424
  | RequestSubscriptionPropsByPlatforms,
425
425
  platform: 'ios' | 'android',
426
426
  ) {
427
- // Platform-specific format - directly return the appropriate platform data
428
- return platform === 'ios' ? request.ios : request.android;
427
+ // Support both new (apple/google) and legacy (ios/android) field names
428
+ // New fields take precedence over deprecated ones
429
+ if (platform === 'ios') {
430
+ return request.apple ?? request.ios;
431
+ }
432
+ return request.google ?? request.android;
429
433
  }
430
434
 
431
435
  /**
432
436
  * Request a purchase for products or subscriptions.
433
437
  *
434
438
  * @param requestObj - Purchase request configuration
435
- * @param requestObj.request - Platform-specific purchase parameters
439
+ * @param requestObj.request - Store-specific purchase parameters
436
440
  * @param requestObj.type - Type of purchase: 'in-app' for products (default) or 'subs' for subscriptions
437
441
  *
438
442
  * @example
439
443
  * ```typescript
440
- * // Product purchase
444
+ * // Product purchase (recommended: use apple/google)
441
445
  * await requestPurchase({
442
446
  * request: {
443
- * ios: { sku: productId },
444
- * android: { skus: [productId] }
447
+ * apple: { sku: productId },
448
+ * google: { skus: [productId] }
445
449
  * },
446
450
  * type: 'in-app'
447
451
  * });
@@ -449,14 +453,23 @@ function normalizeRequestProps(
449
453
  * // Subscription purchase
450
454
  * await requestPurchase({
451
455
  * request: {
452
- * ios: { sku: subscriptionId },
453
- * android: {
456
+ * apple: { sku: subscriptionId },
457
+ * google: {
454
458
  * skus: [subscriptionId],
455
459
  * subscriptionOffers: [{ sku: subscriptionId, offerToken: 'token' }]
456
460
  * }
457
461
  * },
458
462
  * type: 'subs'
459
463
  * });
464
+ *
465
+ * // Legacy format (deprecated, but still supported)
466
+ * await requestPurchase({
467
+ * request: {
468
+ * ios: { sku: productId },
469
+ * android: { skus: [productId] }
470
+ * },
471
+ * type: 'in-app'
472
+ * });
460
473
  * ```
461
474
  */
462
475
  export const requestPurchase: MutationField<'requestPurchase'> = async (
@@ -471,12 +484,12 @@ export const requestPurchase: MutationField<'requestPurchase'> = async (
471
484
 
472
485
  if (!normalizedRequest?.sku) {
473
486
  throw new Error(
474
- 'Invalid request for iOS. The `sku` property is required and must be a string.\n\n' +
487
+ 'Invalid request for Apple. The `sku` property is required and must be a string.\n\n' +
475
488
  'Expected format:\n' +
476
489
  ' requestPurchase({\n' +
477
490
  ' request: {\n' +
478
- ' android: { skus: ["product_id"] },\n' +
479
- ' ios: { sku: "product_id" }\n' +
491
+ ' apple: { sku: "product_id" },\n' +
492
+ ' google: { skus: ["product_id"] }\n' +
480
493
  ' },\n' +
481
494
  ' type: "in-app"\n' +
482
495
  ' })\n\n' +
@@ -519,12 +532,12 @@ export const requestPurchase: MutationField<'requestPurchase'> = async (
519
532
 
520
533
  if (!normalizedRequest?.skus?.length) {
521
534
  throw new Error(
522
- 'Invalid request for Android. The `skus` property is required and must be a non-empty array.\n\n' +
535
+ 'Invalid request for Google. The `skus` property is required and must be a non-empty array.\n\n' +
523
536
  'Expected format:\n' +
524
537
  ' requestPurchase({\n' +
525
538
  ' request: {\n' +
526
- ' android: { skus: ["product_id"] },\n' +
527
- ' ios: { sku: "product_id" }\n' +
539
+ ' apple: { sku: "product_id" },\n' +
540
+ ' google: { skus: ["product_id"] }\n' +
528
541
  ' },\n' +
529
542
  ' type: "in-app"\n' +
530
543
  ' })\n\n' +
@@ -561,12 +574,12 @@ export const requestPurchase: MutationField<'requestPurchase'> = async (
561
574
 
562
575
  if (!normalizedRequest?.skus?.length) {
563
576
  throw new Error(
564
- 'Invalid request for Android. The `skus` property is required and must be a non-empty array.\n\n' +
577
+ 'Invalid request for Google. The `skus` property is required and must be a non-empty array.\n\n' +
565
578
  'Expected format:\n' +
566
579
  ' requestPurchase({\n' +
567
580
  ' request: {\n' +
568
- ' android: { skus: ["subscription_id"] },\n' +
569
- ' ios: { sku: "subscription_id" }\n' +
581
+ ' apple: { sku: "subscription_id" },\n' +
582
+ ' google: { skus: ["subscription_id"] }\n' +
570
583
  ' },\n' +
571
584
  ' type: "subs"\n' +
572
585
  ' })\n\n' +
@@ -6,7 +6,11 @@ import ExpoIapModule from '../ExpoIapModule';
6
6
 
7
7
  // Types
8
8
  import type {
9
+ BillingProgramAndroid,
10
+ BillingProgramAvailabilityResultAndroid,
11
+ BillingProgramReportingDetailsAndroid,
9
12
  DeepLinkOptions,
13
+ LaunchExternalLinkParamsAndroid,
10
14
  MutationField,
11
15
  VerifyPurchaseResultAndroid,
12
16
  } from '../types';
@@ -248,3 +252,74 @@ export const createAlternativeBillingTokenAndroid: MutationField<
248
252
  > = async (sku?: string) => {
249
253
  return ExpoIapModule.createAlternativeBillingTokenAndroid(sku);
250
254
  };
255
+
256
+ // ============================================================================
257
+ // Billing Programs API (Google Play Billing Library 8.2.0+)
258
+ // ============================================================================
259
+
260
+ /**
261
+ * Check if a specific billing program is available for this user/device (Android only).
262
+ * Available in Google Play Billing Library 8.2.0+.
263
+ *
264
+ * @param program - The billing program to check ('external-offer' or 'external-content-link')
265
+ * @returns Promise resolving to availability result
266
+ *
267
+ * @example
268
+ * ```typescript
269
+ * const result = await isBillingProgramAvailableAndroid('external-offer');
270
+ * if (result.isAvailable) {
271
+ * // Proceed with billing program flow
272
+ * }
273
+ * ```
274
+ */
275
+ export const isBillingProgramAvailableAndroid = async (
276
+ program: BillingProgramAndroid,
277
+ ): Promise<BillingProgramAvailabilityResultAndroid> => {
278
+ return ExpoIapModule.isBillingProgramAvailableAndroid(program);
279
+ };
280
+
281
+ /**
282
+ * Launch an external link for the specified billing program (Android only).
283
+ * Available in Google Play Billing Library 8.2.0+.
284
+ *
285
+ * @param params - The external link parameters
286
+ * @returns Promise resolving when the link is launched
287
+ *
288
+ * @example
289
+ * ```typescript
290
+ * await launchExternalLinkAndroid({
291
+ * billingProgram: 'external-offer',
292
+ * launchMode: 'launch-in-external-browser-or-app',
293
+ * linkType: 'link-to-digital-content-offer',
294
+ * linkUri: 'https://your-payment-site.com',
295
+ * });
296
+ * ```
297
+ */
298
+ export const launchExternalLinkAndroid = async (
299
+ params: LaunchExternalLinkParamsAndroid,
300
+ ): Promise<void> => {
301
+ return ExpoIapModule.launchExternalLinkAndroid(params);
302
+ };
303
+
304
+ /**
305
+ * Create billing program reporting details for Google Play reporting (Android only).
306
+ * Available in Google Play Billing Library 8.2.0+.
307
+ *
308
+ * Must be called AFTER successful payment in your payment system.
309
+ * Token must be reported to Google Play backend within 24 hours.
310
+ *
311
+ * @param program - The billing program type
312
+ * @returns Promise resolving to reporting details including the external transaction token
313
+ *
314
+ * @example
315
+ * ```typescript
316
+ * const details = await createBillingProgramReportingDetailsAndroid('external-offer');
317
+ * // Report details.externalTransactionToken to Google Play within 24 hours
318
+ * await reportToGooglePlay(details.externalTransactionToken);
319
+ * ```
320
+ */
321
+ export const createBillingProgramReportingDetailsAndroid = async (
322
+ program: BillingProgramAndroid,
323
+ ): Promise<BillingProgramReportingDetailsAndroid> => {
324
+ return ExpoIapModule.createBillingProgramReportingDetailsAndroid(program);
325
+ };