react-native-iap 15.0.2 → 15.2.0

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 (35) hide show
  1. package/README.md +2 -2
  2. package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +86 -32
  3. package/ios/HybridRnIap.swift +39 -1
  4. package/lib/module/hooks/useIAP.js +11 -1
  5. package/lib/module/hooks/useIAP.js.map +1 -1
  6. package/lib/module/index.js +74 -0
  7. package/lib/module/index.js.map +1 -1
  8. package/lib/module/types.js +1 -0
  9. package/lib/module/types.js.map +1 -1
  10. package/lib/module/utils/errorMapping.js +1 -0
  11. package/lib/module/utils/errorMapping.js.map +1 -1
  12. package/lib/typescript/src/hooks/useIAP.d.ts +10 -0
  13. package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -1
  14. package/lib/typescript/src/index.d.ts +1 -0
  15. package/lib/typescript/src/index.d.ts.map +1 -1
  16. package/lib/typescript/src/specs/RnIap.nitro.d.ts +17 -0
  17. package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
  18. package/lib/typescript/src/types.d.ts +18 -1
  19. package/lib/typescript/src/types.d.ts.map +1 -1
  20. package/lib/typescript/src/utils/errorMapping.d.ts.map +1 -1
  21. package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +8 -0
  22. package/nitrogen/generated/android/c++/JHybridRnIapSpec.hpp +2 -0
  23. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +18 -0
  24. package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +12 -0
  25. package/nitrogen/generated/ios/swift/HybridRnIapSpec.swift +2 -0
  26. package/nitrogen/generated/ios/swift/HybridRnIapSpec_cxx.swift +32 -0
  27. package/nitrogen/generated/shared/c++/HybridRnIapSpec.cpp +2 -0
  28. package/nitrogen/generated/shared/c++/HybridRnIapSpec.hpp +2 -0
  29. package/openiap-versions.json +2 -2
  30. package/package.json +1 -1
  31. package/src/hooks/useIAP.ts +23 -0
  32. package/src/index.ts +92 -0
  33. package/src/specs/RnIap.nitro.ts +23 -0
  34. package/src/types.ts +18 -1
  35. package/src/utils/errorMapping.ts +1 -0
package/README.md CHANGED
@@ -13,7 +13,7 @@
13
13
 
14
14
  **React Native IAP** is a high-performance in-app purchase library using Nitro Modules that **conforms to the [Open IAP specification](https://openiap.dev)**. It provides a unified API for handling in-app purchases across iOS and Android platforms with comprehensive error handling and modern TypeScript support.
15
15
 
16
- <a href="https://openiap.dev"><img src="https://github.com/hyodotdev/openiap/blob/main/logo.png" alt="Open IAP" height="40" /></a>
16
+ <a href="https://openiap.dev"><img src="https://raw.githubusercontent.com/hyodotdev/openiap/main/logo.png" alt="Open IAP" height="40" /></a>
17
17
  </div>
18
18
 
19
19
  ## 🎨 Promotion
@@ -190,7 +190,7 @@ Quick links:
190
190
 
191
191
  ## Powered by OpenIAP
192
192
 
193
- <a href="https://openiap.dev"><img src="https://github.com/hyodotdev/openiap/blob/main/logo.png" alt="OpenIAP" height="50" /></a>
193
+ <a href="https://openiap.dev"><img src="https://raw.githubusercontent.com/hyodotdev/openiap/main/logo.png" alt="OpenIAP" height="50" /></a>
194
194
 
195
195
  React Native IAP conforms to the **[OpenIAP specification](https://openiap.dev)** — an open, vendor-neutral interoperability standard for in-app purchases. OpenIAP provides:
196
196
 
@@ -84,6 +84,7 @@ class HybridRnIap : HybridRnIapSpec() {
84
84
  private val promotedProductListenersIOS = mutableListOf<(NitroProduct) -> Unit>()
85
85
  private val userChoiceBillingListenersAndroid = mutableListOf<(UserChoiceBillingDetails) -> Unit>()
86
86
  private val developerProvidedBillingListenersAndroid = mutableListOf<(DeveloperProvidedBillingDetailsAndroid) -> Unit>()
87
+ private val subscriptionBillingIssueListeners = mutableListOf<(NitroPurchase) -> Unit>()
87
88
  private var listenersAttached = false
88
89
  private var isInitialized = false
89
90
  private var initDeferred: CompletableDeferred<Boolean>? = null
@@ -314,6 +315,8 @@ class HybridRnIap : HybridRnIapSpec() {
314
315
  promotedProductListenersIOS.clear()
315
316
  synchronized(userChoiceBillingListenersAndroid) { userChoiceBillingListenersAndroid.clear() }
316
317
  synchronized(developerProvidedBillingListenersAndroid) { developerProvidedBillingListenersAndroid.clear() }
318
+ synchronized(subscriptionBillingIssueListeners) { subscriptionBillingIssueListeners.clear() }
319
+ detachSubscriptionBillingIssueIfNeeded()
317
320
  initDeferred = null
318
321
  RnIapLog.result("endConnection", true)
319
322
  true
@@ -411,7 +414,7 @@ class HybridRnIap : HybridRnIapSpec() {
411
414
 
412
415
  if (androidRequest == null) {
413
416
  RnIapLog.warn("requestPurchase called without android payload")
414
- sendPurchaseError(toErrorResult(OpenIAPError.DeveloperError))
417
+ sendPurchaseError(toErrorResult(OpenIAPError.DeveloperError()))
415
418
  return@async defaultResult
416
419
  }
417
420
 
@@ -549,7 +552,7 @@ class HybridRnIap : HybridRnIapSpec() {
549
552
  RnIapLog.failure("requestPurchase", e)
550
553
  sendPurchaseError(
551
554
  toErrorResult(
552
- error = OpenIAPError.PurchaseFailed,
555
+ error = OpenIAPError.PurchaseFailed(),
553
556
  debugMessage = e.message,
554
557
  messageOverride = e.message
555
558
  )
@@ -651,7 +654,7 @@ class HybridRnIap : HybridRnIapSpec() {
651
654
  nitroSubscriptions.toTypedArray()
652
655
  } catch (e: Exception) {
653
656
  RnIapLog.failure("getActiveSubscriptions", e)
654
- val error = OpenIAPError.ServiceUnavailable
657
+ val error = OpenIAPError.ServiceUnavailable()
655
658
  throw OpenIapException(
656
659
  toErrorJson(
657
660
  error = error,
@@ -678,7 +681,7 @@ class HybridRnIap : HybridRnIapSpec() {
678
681
  hasActive
679
682
  } catch (e: Exception) {
680
683
  RnIapLog.failure("hasActiveSubscriptions", e)
681
- val error = OpenIAPError.ServiceUnavailable
684
+ val error = OpenIAPError.ServiceUnavailable()
682
685
  throw OpenIapException(
683
686
  toErrorJson(
684
687
  error = error,
@@ -713,7 +716,7 @@ class HybridRnIap : HybridRnIapSpec() {
713
716
  NitroPurchaseResult(
714
717
  responseCode = -1.0,
715
718
  debugMessage = "Missing purchaseToken",
716
- code = OpenIAPError.toCode(OpenIAPError.DeveloperError),
719
+ code = OpenIAPError.toCode(OpenIAPError.DeveloperError()),
717
720
  message = "Missing purchaseToken",
718
721
  purchaseToken = null
719
722
  )
@@ -754,7 +757,7 @@ class HybridRnIap : HybridRnIapSpec() {
754
757
  RnIapLog.result("finishTransaction", mapOf("success" to true))
755
758
  result
756
759
  } catch (e: Exception) {
757
- val err = OpenIAPError.BillingError
760
+ val err = OpenIAPError.BillingError()
758
761
  RnIapLog.failure("finishTransaction", e)
759
762
  Variant_Boolean_NitroPurchaseResult.Second(
760
763
  NitroPurchaseResult(
@@ -1276,14 +1279,14 @@ class HybridRnIap : HybridRnIapSpec() {
1276
1279
  // iOS-specific method - not supported on Android
1277
1280
  override fun getStorefrontIOS(): Promise<String> {
1278
1281
  return Promise.async {
1279
- throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported))
1282
+ throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported()))
1280
1283
  }
1281
1284
  }
1282
1285
 
1283
1286
  // iOS-specific method - not supported on Android
1284
1287
  override fun getAppTransactionIOS(): Promise<Variant_NullType_String> {
1285
1288
  return Promise.async {
1286
- throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported))
1289
+ throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported()))
1287
1290
  }
1288
1291
  }
1289
1292
 
@@ -1370,7 +1373,7 @@ class HybridRnIap : HybridRnIapSpec() {
1370
1373
  try {
1371
1374
  // For Android, we need the google options to be provided (new platform-specific structure)
1372
1375
  val nitroGoogleOptions = (params.google as? Variant_NullType_NitroReceiptValidationGoogleOptions.Second)?.value
1373
- ?: throw OpenIapException(toErrorJson(OpenIAPError.DeveloperError, debugMessage = "Missing required parameter: google options"))
1376
+ ?: throw OpenIapException(toErrorJson(OpenIAPError.DeveloperError(), debugMessage = "Missing required parameter: google options"))
1374
1377
 
1375
1378
  // Validate required google fields
1376
1379
  val validations = mapOf(
@@ -1381,7 +1384,7 @@ class HybridRnIap : HybridRnIapSpec() {
1381
1384
  )
1382
1385
  for ((name, value) in validations) {
1383
1386
  if (value.isEmpty()) {
1384
- throw OpenIapException(toErrorJson(OpenIAPError.DeveloperError, debugMessage = "Missing or empty required parameter: $name"))
1387
+ throw OpenIapException(toErrorJson(OpenIAPError.DeveloperError(), debugMessage = "Missing or empty required parameter: $name"))
1385
1388
  }
1386
1389
  }
1387
1390
 
@@ -1521,31 +1524,31 @@ class HybridRnIap : HybridRnIapSpec() {
1521
1524
  // iOS-specific methods - Not applicable on Android, return appropriate defaults
1522
1525
  override fun subscriptionStatusIOS(sku: String): Promise<Variant_NullType_Array_NitroSubscriptionStatus_> {
1523
1526
  return Promise.async {
1524
- throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported))
1527
+ throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported()))
1525
1528
  }
1526
1529
  }
1527
1530
 
1528
1531
  override fun currentEntitlementIOS(sku: String): Promise<Variant_NullType_NitroPurchase> {
1529
1532
  return Promise.async {
1530
- throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported))
1533
+ throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported()))
1531
1534
  }
1532
1535
  }
1533
1536
 
1534
1537
  override fun latestTransactionIOS(sku: String): Promise<Variant_NullType_NitroPurchase> {
1535
1538
  return Promise.async {
1536
- throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported))
1539
+ throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported()))
1537
1540
  }
1538
1541
  }
1539
1542
 
1540
1543
  override fun getPendingTransactionsIOS(): Promise<Array<NitroPurchase>> {
1541
1544
  return Promise.async {
1542
- throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported))
1545
+ throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported()))
1543
1546
  }
1544
1547
  }
1545
1548
 
1546
1549
  override fun syncIOS(): Promise<Boolean> {
1547
1550
  return Promise.async {
1548
- throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported))
1551
+ throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported()))
1549
1552
  }
1550
1553
  }
1551
1554
 
@@ -1553,37 +1556,37 @@ class HybridRnIap : HybridRnIapSpec() {
1553
1556
 
1554
1557
  override fun isEligibleForIntroOfferIOS(groupID: String): Promise<Boolean> {
1555
1558
  return Promise.async {
1556
- throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported))
1559
+ throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported()))
1557
1560
  }
1558
1561
  }
1559
1562
 
1560
1563
  override fun getReceiptDataIOS(): Promise<String> {
1561
1564
  return Promise.async {
1562
- throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported))
1565
+ throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported()))
1563
1566
  }
1564
1567
  }
1565
1568
 
1566
1569
  override fun getReceiptIOS(): Promise<String> {
1567
1570
  return Promise.async {
1568
- throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported))
1571
+ throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported()))
1569
1572
  }
1570
1573
  }
1571
1574
 
1572
1575
  override fun requestReceiptRefreshIOS(): Promise<String> {
1573
1576
  return Promise.async {
1574
- throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported))
1577
+ throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported()))
1575
1578
  }
1576
1579
  }
1577
1580
 
1578
1581
  override fun isTransactionVerifiedIOS(sku: String): Promise<Boolean> {
1579
1582
  return Promise.async {
1580
- throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported))
1583
+ throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported()))
1581
1584
  }
1582
1585
  }
1583
1586
 
1584
1587
  override fun getTransactionJwsIOS(sku: String): Promise<Variant_NullType_String> {
1585
1588
  return Promise.async {
1586
- throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported))
1589
+ throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported()))
1587
1590
  }
1588
1591
  }
1589
1592
 
@@ -1613,7 +1616,7 @@ class HybridRnIap : HybridRnIapSpec() {
1613
1616
  RnIapLog.payload("showAlternativeBillingDialogAndroid", null)
1614
1617
  try {
1615
1618
  val activity = context.currentActivity
1616
- ?: throw OpenIapException(toErrorJson(OpenIAPError.DeveloperError, debugMessage = "Activity not available"))
1619
+ ?: throw OpenIapException(toErrorJson(OpenIAPError.DeveloperError(), debugMessage = "Activity not available"))
1617
1620
 
1618
1621
  val userAccepted = withContext(Dispatchers.Main) {
1619
1622
  openIap.setActivity(activity)
@@ -1685,6 +1688,57 @@ class HybridRnIap : HybridRnIapSpec() {
1685
1688
  snapshot.forEach { it(details) }
1686
1689
  }
1687
1690
 
1691
+ // -------------------------------------------------------------------------
1692
+ // Subscription billing-issue listener (cross-platform event)
1693
+ // Source: Play Billing 8.1+ Purchase.isSuspended detection inside openiap-google.
1694
+ // -------------------------------------------------------------------------
1695
+
1696
+ @Volatile
1697
+ private var subscriptionBillingIssueAttached = false
1698
+ private val subscriptionBillingIssueAttachLock = Any()
1699
+ private var subscriptionBillingIssueNativeListener: dev.hyo.openiap.listener.OpenIapSubscriptionBillingIssueListener? = null
1700
+
1701
+ override fun addSubscriptionBillingIssueListener(listener: (purchase: NitroPurchase) -> Unit) {
1702
+ synchronized(subscriptionBillingIssueListeners) {
1703
+ subscriptionBillingIssueListeners.add(listener)
1704
+ }
1705
+ attachSubscriptionBillingIssueIfNeeded()
1706
+ }
1707
+
1708
+ override fun removeSubscriptionBillingIssueListener(listener: (purchase: NitroPurchase) -> Unit) {
1709
+ synchronized(subscriptionBillingIssueListeners) {
1710
+ subscriptionBillingIssueListeners.remove(listener)
1711
+ }
1712
+ }
1713
+
1714
+ private fun attachSubscriptionBillingIssueIfNeeded() {
1715
+ synchronized(subscriptionBillingIssueAttachLock) {
1716
+ if (subscriptionBillingIssueAttached) return
1717
+ val nativeListener = dev.hyo.openiap.listener.OpenIapSubscriptionBillingIssueListener { purchase ->
1718
+ runCatching {
1719
+ val nitro = convertToNitroPurchase(purchase)
1720
+ val snapshot = synchronized(subscriptionBillingIssueListeners) {
1721
+ ArrayList(subscriptionBillingIssueListeners)
1722
+ }
1723
+ snapshot.forEach { it(nitro) }
1724
+ }.onFailure { RnIapLog.failure("subscriptionBillingIssueListener", it) }
1725
+ }
1726
+ openIap.addSubscriptionBillingIssueListener(nativeListener)
1727
+ subscriptionBillingIssueNativeListener = nativeListener
1728
+ subscriptionBillingIssueAttached = true
1729
+ }
1730
+ }
1731
+
1732
+ private fun detachSubscriptionBillingIssueIfNeeded() {
1733
+ synchronized(subscriptionBillingIssueAttachLock) {
1734
+ subscriptionBillingIssueNativeListener?.let {
1735
+ openIap.removeSubscriptionBillingIssueListener(it)
1736
+ }
1737
+ subscriptionBillingIssueNativeListener = null
1738
+ subscriptionBillingIssueAttached = false
1739
+ }
1740
+ }
1741
+
1688
1742
  // -------------------------------------------------------------------------
1689
1743
  // Billing Programs API (Android 8.2.0+)
1690
1744
  // -------------------------------------------------------------------------
@@ -1759,7 +1813,7 @@ class HybridRnIap : HybridRnIapSpec() {
1759
1813
 
1760
1814
  val activity = withContext(Dispatchers.Main) {
1761
1815
  runCatching { context.currentActivity }.getOrNull()
1762
- } ?: throw OpenIapException(toErrorJson(OpenIAPError.DeveloperError, debugMessage = "Activity not available"))
1816
+ } ?: throw OpenIapException(toErrorJson(OpenIAPError.DeveloperError(), debugMessage = "Activity not available"))
1763
1817
 
1764
1818
  val openIapParams = OpenIapLaunchExternalLinkParams(
1765
1819
  billingProgram = mapBillingProgram(params.billingProgram),
@@ -1814,38 +1868,38 @@ class HybridRnIap : HybridRnIapSpec() {
1814
1868
 
1815
1869
  override fun canPresentExternalPurchaseNoticeIOS(): Promise<Boolean> {
1816
1870
  return Promise.async {
1817
- throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported))
1871
+ throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported()))
1818
1872
  }
1819
1873
  }
1820
1874
 
1821
1875
  override fun presentExternalPurchaseNoticeSheetIOS(): Promise<ExternalPurchaseNoticeResultIOS> {
1822
1876
  return Promise.async {
1823
- throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported))
1877
+ throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported()))
1824
1878
  }
1825
1879
  }
1826
1880
 
1827
1881
  override fun presentExternalPurchaseLinkIOS(url: String): Promise<ExternalPurchaseLinkResultIOS> {
1828
1882
  return Promise.async {
1829
- throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported))
1883
+ throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported()))
1830
1884
  }
1831
1885
  }
1832
1886
 
1833
1887
  // ExternalPurchaseCustomLink (iOS 18.1+) - iOS only stubs
1834
1888
  override fun isEligibleForExternalPurchaseCustomLinkIOS(): Promise<Boolean> {
1835
1889
  return Promise.async {
1836
- throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported))
1890
+ throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported()))
1837
1891
  }
1838
1892
  }
1839
1893
 
1840
1894
  override fun getExternalPurchaseCustomLinkTokenIOS(tokenType: ExternalPurchaseCustomLinkTokenTypeIOS): Promise<ExternalPurchaseCustomLinkTokenResultIOS> {
1841
1895
  return Promise.async {
1842
- throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported))
1896
+ throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported()))
1843
1897
  }
1844
1898
  }
1845
1899
 
1846
1900
  override fun showExternalPurchaseCustomLinkNoticeIOS(noticeType: ExternalPurchaseCustomLinkNoticeTypeIOS): Promise<ExternalPurchaseCustomLinkNoticeResultIOS> {
1847
1901
  return Promise.async {
1848
- throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported))
1902
+ throw OpenIapException(toErrorJson(OpenIAPError.FeatureNotSupported()))
1849
1903
  }
1850
1904
  }
1851
1905
 
@@ -1862,15 +1916,15 @@ class HybridRnIap : HybridRnIapSpec() {
1862
1916
  message.contains("not prepared", ignoreCase = true) ||
1863
1917
  message.contains("not initialized", ignoreCase = true) -> return OpenIAPError.NotPrepared
1864
1918
  message.contains("developer error", ignoreCase = true) ||
1865
- message.contains("activity not available", ignoreCase = true) -> return OpenIAPError.DeveloperError
1919
+ message.contains("activity not available", ignoreCase = true) -> return OpenIAPError.DeveloperError()
1866
1920
  message.contains("network", ignoreCase = true) -> return OpenIAPError.NetworkError
1867
1921
  message.contains("service unavailable", ignoreCase = true) ||
1868
- message.contains("billing unavailable", ignoreCase = true) -> return OpenIAPError.ServiceUnavailable
1922
+ message.contains("billing unavailable", ignoreCase = true) -> return OpenIAPError.ServiceUnavailable()
1869
1923
  }
1870
1924
  cause = cause.cause
1871
1925
  }
1872
1926
  // Default to ServiceUnavailable if we can't determine the error type
1873
- return OpenIAPError.ServiceUnavailable
1927
+ return OpenIAPError.ServiceUnavailable()
1874
1928
  }
1875
1929
 
1876
1930
  private fun toErrorJson(
@@ -17,6 +17,8 @@ class HybridRnIap: HybridRnIapSpec {
17
17
  private var purchaseUpdatedListeners: [(NitroPurchase) -> Void] = []
18
18
  private var purchaseErrorListeners: [(NitroPurchaseResult) -> Void] = []
19
19
  private var promotedProductListeners: [(NitroProduct) -> Void] = []
20
+ private var subscriptionBillingIssueListeners: [(NitroPurchase) -> Void] = []
21
+ private var subscriptionBillingIssueSub: Subscription?
20
22
  private var lastPurchaseErrorKey: String? = nil
21
23
  private var lastPurchaseErrorTimestamp: TimeInterval = 0
22
24
  private var deliveredPurchaseEventKeys: Set<String> = []
@@ -922,7 +924,16 @@ class HybridRnIap: HybridRnIapSpec {
922
924
  func removePurchaseErrorListener(listener: @escaping (NitroPurchaseResult) -> Void) throws {
923
925
  listenerLock.withLock { purchaseErrorListeners.removeAll() }
924
926
  }
925
-
927
+
928
+ func addSubscriptionBillingIssueListener(listener: @escaping (NitroPurchase) -> Void) throws {
929
+ listenerLock.withLock { subscriptionBillingIssueListeners.append(listener) }
930
+ attachSubscriptionBillingIssueSubIfNeeded()
931
+ }
932
+
933
+ func removeSubscriptionBillingIssueListener(listener: @escaping (NitroPurchase) -> Void) throws {
934
+ listenerLock.withLock { subscriptionBillingIssueListeners.removeAll() }
935
+ }
936
+
926
937
  // MARK: - Private Helper Methods
927
938
 
928
939
  private func attachListenersIfNeeded() {
@@ -1004,6 +1015,27 @@ class HybridRnIap: HybridRnIapSpec {
1004
1015
  }
1005
1016
  }
1006
1017
 
1018
+ private func attachSubscriptionBillingIssueSubIfNeeded() {
1019
+ guard subscriptionBillingIssueSub == nil else { return }
1020
+ RnIapLog.payload("subscriptionBillingIssueListener.register", nil)
1021
+ subscriptionBillingIssueSub = OpenIapModule.shared.subscriptionBillingIssueListener { [weak self] openIapPurchase in
1022
+ guard let self else {
1023
+ RnIapLog.warn("subscriptionBillingIssueListener: HybridRnIap deallocated, event dropped")
1024
+ return
1025
+ }
1026
+ Task { @MainActor in
1027
+ let payload = RnIapHelper.sanitizeDictionary(OpenIapSerialization.purchase(openIapPurchase))
1028
+ RnIapLog.result("subscriptionBillingIssueListener", payload)
1029
+ let nitro = RnIapHelper.convertPurchaseDictionary(payload)
1030
+ let snapshot: [(NitroPurchase) -> Void] = self.listenerLock.withLock {
1031
+ Array(self.subscriptionBillingIssueListeners)
1032
+ }
1033
+ for l in snapshot { l(nitro) }
1034
+ }
1035
+ }
1036
+ RnIapLog.result("subscriptionBillingIssueListener.register", "attached")
1037
+ }
1038
+
1007
1039
  private func ensureConnection() throws {
1008
1040
  guard isInitialized else {
1009
1041
  throw OpenIapException.make(code: .initConnection, message: "Connection not initialized. Call initConnection() first.")
@@ -1121,9 +1153,14 @@ class HybridRnIap: HybridRnIapSpec {
1121
1153
  RnIapLog.payload("removeListener", "promotedProduct")
1122
1154
  OpenIapModule.shared.removeListener(sub)
1123
1155
  }
1156
+ if let sub = subscriptionBillingIssueSub {
1157
+ RnIapLog.payload("removeListener", "subscriptionBillingIssue")
1158
+ OpenIapModule.shared.removeListener(sub)
1159
+ }
1124
1160
  purchaseUpdatedSub = nil
1125
1161
  purchaseErrorSub = nil
1126
1162
  promotedProductSub = nil
1163
+ subscriptionBillingIssueSub = nil
1127
1164
  Task {
1128
1165
  RnIapLog.payload("endConnection", nil)
1129
1166
  let result = try? await OpenIapModule.shared.endConnection()
@@ -1135,6 +1172,7 @@ class HybridRnIap: HybridRnIapSpec {
1135
1172
  purchaseUpdatedListeners.removeAll()
1136
1173
  purchaseErrorListeners.removeAll()
1137
1174
  promotedProductListeners.removeAll()
1175
+ subscriptionBillingIssueListeners.removeAll()
1138
1176
  lastPurchaseErrorKey = nil
1139
1177
  lastPurchaseErrorTimestamp = 0
1140
1178
  deliveredPurchaseEventKeys.removeAll()
@@ -6,7 +6,7 @@ import { Platform } from 'react-native';
6
6
  import { RnIapConsole } from "../utils/debug.js";
7
7
 
8
8
  // Internal modules
9
- import { initConnection, purchaseErrorListener, purchaseUpdatedListener, promotedProductListenerIOS, getAvailablePurchases, finishTransaction as finishTransactionInternal, requestPurchase as requestPurchaseInternal, fetchProducts, validateReceipt as validateReceiptInternal, verifyPurchase as verifyPurchaseTopLevel, verifyPurchaseWithProvider as verifyPurchaseWithProviderTopLevel, getActiveSubscriptions, hasActiveSubscriptions, syncIOS, getPromotedProductIOS, requestPurchaseOnPromotedProductIOS, checkAlternativeBillingAvailabilityAndroid, showAlternativeBillingDialogAndroid, createAlternativeBillingTokenAndroid, userChoiceBillingListenerAndroid, isStandardIOS } from "../index.js";
9
+ import { initConnection, purchaseErrorListener, purchaseUpdatedListener, promotedProductListenerIOS, getAvailablePurchases, finishTransaction as finishTransactionInternal, requestPurchase as requestPurchaseInternal, fetchProducts, validateReceipt as validateReceiptInternal, verifyPurchase as verifyPurchaseTopLevel, verifyPurchaseWithProvider as verifyPurchaseWithProviderTopLevel, getActiveSubscriptions, hasActiveSubscriptions, syncIOS, getPromotedProductIOS, requestPurchaseOnPromotedProductIOS, checkAlternativeBillingAvailabilityAndroid, showAlternativeBillingDialogAndroid, createAlternativeBillingTokenAndroid, userChoiceBillingListenerAndroid, subscriptionBillingIssueListener, isStandardIOS } from "../index.js";
10
10
 
11
11
  // Types
12
12
  import { ErrorCode } from "../types.js";
@@ -219,6 +219,14 @@ export function useIAP(options) {
219
219
  }
220
220
  });
221
221
  }
222
+
223
+ // Always attach so callers that supply `onSubscriptionBillingIssue` later
224
+ // (after the hook has already set up listeners) still receive events.
225
+ if (!subscriptionsRef.current.subscriptionBillingIssue) {
226
+ subscriptionsRef.current.subscriptionBillingIssue = subscriptionBillingIssueListener(purchase => {
227
+ optionsRef.current?.onSubscriptionBillingIssue?.(purchase);
228
+ });
229
+ }
222
230
  }, [getActiveSubscriptionsInternal, getAvailablePurchasesInternal]);
223
231
 
224
232
  // Shared helper: clean up all listeners
@@ -227,10 +235,12 @@ export function useIAP(options) {
227
235
  subscriptionsRef.current.purchaseError?.remove();
228
236
  subscriptionsRef.current.promotedProductIOS?.remove();
229
237
  subscriptionsRef.current.userChoiceBillingAndroid?.remove();
238
+ subscriptionsRef.current.subscriptionBillingIssue?.remove();
230
239
  subscriptionsRef.current.purchaseUpdate = undefined;
231
240
  subscriptionsRef.current.purchaseError = undefined;
232
241
  subscriptionsRef.current.promotedProductIOS = undefined;
233
242
  subscriptionsRef.current.userChoiceBillingAndroid = undefined;
243
+ subscriptionsRef.current.subscriptionBillingIssue = undefined;
234
244
  }, []);
235
245
  const initIapWithSubscriptions = useCallback(async () => {
236
246
  const config = buildAndroidConfig();
@@ -1 +1 @@
1
- {"version":3,"names":["useCallback","useEffect","useState","useRef","Platform","RnIapConsole","initConnection","purchaseErrorListener","purchaseUpdatedListener","promotedProductListenerIOS","getAvailablePurchases","finishTransaction","finishTransactionInternal","requestPurchase","requestPurchaseInternal","fetchProducts","validateReceipt","validateReceiptInternal","verifyPurchase","verifyPurchaseTopLevel","verifyPurchaseWithProvider","verifyPurchaseWithProviderTopLevel","getActiveSubscriptions","hasActiveSubscriptions","syncIOS","getPromotedProductIOS","requestPurchaseOnPromotedProductIOS","checkAlternativeBillingAvailabilityAndroid","showAlternativeBillingDialogAndroid","createAlternativeBillingTokenAndroid","userChoiceBillingListenerAndroid","isStandardIOS","ErrorCode","useIAP","options","connected","setConnected","products","setProducts","subscriptions","setSubscriptions","availablePurchases","setAvailablePurchases","promotedProductIOS","setPromotedProductIOS","activeSubscriptions","setActiveSubscriptions","optionsRef","connectedRef","mergeWithDuplicateCheck","existingItems","newItems","getKey","merged","forEach","newItem","isDuplicate","some","existingItem","push","current","subscriptionsRef","isMountedRef","subscriptionsRefState","invokeOnError","error","onError","Error","String","fetchProductsInternal","params","warn","requestType","type","debug","skus","result","items","prevSubscriptions","subscription","id","newProducts","filter","item","newSubscriptions","prevProducts","product","getAvailablePurchasesInternal","alsoPublishToEventListenerIOS","onlyIncludeActiveItemsIOS","includeSuspendedAndroid","getActiveSubscriptionsInternal","subscriptionIds","hasActiveSubscriptionsInternal","args","requestObj","restorePurchases","OS","buildAndroidConfig","config","enableBillingProgramAndroid","alternativeBillingModeAndroid","registerListeners","purchaseUpdate","purchase","e","onPurchaseSuccess","purchaseError","code","InitConnection","onPurchaseError","onPromotedProductIOS","onUserChoiceBillingAndroid","userChoiceBillingAndroid","details","cleanupListeners","remove","undefined","initIapWithSubscriptions","reconnect"],"sourceRoot":"../../../src","sources":["hooks/useIAP.ts"],"mappings":";;AAAA;AACA,SAAQA,WAAW,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,QAAO,OAAO;AAC9D,SAAQC,QAAQ,QAAO,cAAc;AACrC,SAAQC,YAAY,QAAO,mBAAgB;;AAE3C;AACA,SACEC,cAAc,EACdC,qBAAqB,EACrBC,uBAAuB,EACvBC,0BAA0B,EAC1BC,qBAAqB,EACrBC,iBAAiB,IAAIC,yBAAyB,EAC9CC,eAAe,IAAIC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IAAInH,QAAQ,CAAC6F,EAAE,KAAK,SAAS,GACzB;MACEtE,0CAA0C;MAC1CC,mCAAmC;MACnCC;IACF,CAAC,GACD,CAAC,CAAC;EACR,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["useCallback","useEffect","useState","useRef","Platform","RnIapConsole","initConnection","purchaseErrorListener","purchaseUpdatedListener","promotedProductListenerIOS","getAvailablePurchases","finishTransaction","finishTransactionInternal","requestPurchase","requestPurchaseInternal","fetchProducts","validateReceipt","validateReceiptInternal","verifyPurchase","verifyPurchaseTopLevel","verifyPurchaseWithProvider","verifyPurchaseWithProviderTopLevel","getActiveSubscriptions","hasActiveSubscriptions","syncIOS","getPromotedProductIOS","requestPurchaseOnPromotedProductIOS","checkAlternativeBillingAvailabilityAndroid","showAlternativeBillingDialogAndroid","createAlternativeBillingTokenAndroid","userChoiceBillingListenerAndroid","subscriptionBillingIssueListener","isStandardIOS","ErrorCode","useIAP","options","connected","setConnected","products","setProducts","subscriptions","setSubscriptions","availablePurchases","setAvailablePurchases","promotedProductIOS","setPromotedProductIOS","activeSubscriptions","setActiveSubscriptions","optionsRef","connectedRef","mergeWithDuplicateCheck","existingItems","newItems","getKey","merged","forEach","newItem","isDuplicate","some","existingItem","push","current","subscriptionsRef","isMountedRef","subscriptionsRefState","invokeOnError","error","onError","Error","String","fetchProductsInternal","params","warn","requestType","type","debug","skus","result","items","prevSubscriptions","subscription","id","newProducts","filter","item","newSubscriptions","prevProducts","product","getAvailablePurchasesInternal","alsoPublishToEventListenerIOS","onlyIncludeActiveItemsIOS","includeSuspendedAndroid","getActiveSubscriptionsInternal","subscriptionIds","hasActiveSubscriptionsInternal","args","requestObj","restorePurchases","OS","buildAndroidConfig","config","enableBillingProgramAndroid","alternativeBillingModeAndroid","registerListeners","purchaseUpdate","purchase","e","onPurchaseSuccess","purchaseError","code","InitConnection","onPurchaseError","onPromotedProductIOS","onUserChoiceBillingAndroid","userChoiceBillingAndroid","details","subscriptionBillingIssue","onSubscriptionBillingIssue","cleanupListeners","remove","undefined","initIapWithSubscriptions","reconnect"],"sourceRoot":"../../../src","sources":["hooks/useIAP.ts"],"mappings":";;AAAA;AACA,SAAQA,WAAW,EAAEC,SAAS,EAAEC,QAAQ,EAAEC,MAAM,QAAO,OAAO;AAC9D,SAAQC,QAAQ,QAAO,cAAc;AACrC,SAAQC,YAAY,QAAO,mBAAgB;;AAE3C;AACA,SACEC,cAAc,EACdC,qBAAqB,EACrBC,uBAAuB,EACvBC,0BAA0B,EAC1BC,qBAAqB,EACrBC,iBAAiB,IAAIC,yBAAyB,EAC9CC,eAAe,IAAIC,uBAAuB,EAC1CC,aAAa,EACbC,eAAe,IAAIC,uBAAuB,EAC1CC,cAAc,IAAIC,sBAAsB,EACxCC,0BAA0B,IAAIC,kCAAkC,EAChEC,sBAAsB,EACtBC,sBAAsB,EACtBC,OAAO,EACPC,qBAAqB,EACrBC,mCAAmC,EACnCC,0CAA0C,EAC1CC,mCAAmC,EACnCC,oCAAoC,EACpCC,gCAAgC,EAChCC,gCAAgC,EAChCC,aAAa,QACR,aAAK;;AAEZ;AACA,SAAQC,SAAS,QAAO,aAAU;;AAsBlC;;AAsFA;AACA;AACA;AACA;AACA,OAAO,SAASC,MAAMA,CAACC,OAAuB,EAAU;EACtD,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGnC,QAAQ,CAAU,KAAK,CAAC;EAC1D,MAAM,CAACoC,QAAQ,EAAEC,WAAW,CAAC,GAAGrC,QAAQ,CAAY,EAAE,CAAC;EACvD,MAAM,CAACsC,aAAa,EAAEC,gBAAgB,CAAC,GAAGvC,QAAQ,CAAwB,EAAE,CAAC;EAC7E,MAAM,CAACwC,kBAAkB,EAAEC,qBAAqB,CAAC,GAAGzC,QAAQ,CAAa,EAAE,CAAC;EAC5E,MAAM,CAAC0C,kBAAkB,EAAEC,qBAAqB,CAAC,GAAG3C,QAAQ,CAAU,CAAC;EACvE,MAAM,CAAC4C,mBAAmB,EAAEC,sBAAs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B,OAAO,KAAK;IACd;EACF,CAAC,EAAE,CAACiC,kBAAkB,EAAEI,iBAAiB,EAAEe,gBAAgB,EAAErD,aAAa,CAAC,CAAC;EAE5EhE,SAAS,CAAC,MAAM;IACd8D,YAAY,CAACF,OAAO,GAAG,IAAI;IAC3B4D,wBAAwB,CAAC,CAAC;IAE1B,OAAO,MAAM;MACX1D,YAAY,CAACF,OAAO,GAAG,KAAK;MAC5ByD,gBAAgB,CAAC,CAAC;MAClB;MACAjF,YAAY,CAAC,KAAK,CAAC;IACrB,CAAC;EACH,CAAC,EAAE,CAACoF,wBAAwB,EAAEH,gBAAgB,CAAC,CAAC;EAEhD,OAAO;IACLlF,SAAS;IACTE,QAAQ;IACRE,aAAa;IACb7B,iBAAiB;IACjB+B,kBAAkB;IAClBE,kBAAkB;IAClBE,mBAAmB;IACnBpC,qBAAqB,EAAE8E,6BAA6B;IACpDzE,aAAa,EAAEuD,qBAAqB;IACpCzD,eAAe;IACfG,eAAe;IACfE,cAAc;IACdE,0BAA0B;IAC1B6E,gBAAgB;IAChBxE,qBAAqB;IACrBC,mCAAmC;IACnCJ,sBAAsB,EAAEsE,8BAA8B;IACtDrE,sBAAsB,EAAEuE,8BAA8B;IACtD4B,SAAS;IACT;IACA,IAAItH,QAAQ,CAAC8F,EAAE,KAAK,SAAS,GACzB;MACEvE,0CAA0C;MAC1CC,mCAAmC;MACnCC;IACF,CAAC,GACD,CAAC,CAAC;EACR,CAAC;AACH","ignoreList":[]}
@@ -170,12 +170,14 @@ export const resetListenerState = () => {
170
170
  promotedProductNativeAttached = false;
171
171
  userChoiceBillingNativeAttached = false;
172
172
  developerProvidedBillingNativeAttached = false;
173
+ subscriptionBillingIssueNativeAttached = false;
173
174
  // Clear all JS listeners since native side clears them in endConnection
174
175
  purchaseUpdateJsListeners.clear();
175
176
  purchaseErrorJsListeners.clear();
176
177
  promotedProductJsListeners.clear();
177
178
  userChoiceBillingJsListeners.clear();
178
179
  developerProvidedBillingJsListeners.clear();
180
+ subscriptionBillingIssueJsListeners.clear();
179
181
  };
180
182
  export const purchaseUpdatedListener = listener => {
181
183
  purchaseUpdateJsListeners.add(listener);
@@ -388,6 +390,78 @@ export const developerProvidedBillingListenerAndroid = listener => {
388
390
  };
389
391
  };
390
392
 
393
+ /**
394
+ * Listen for subscription billing-issue events (cross-platform).
395
+ *
396
+ * Fires when an active subscription enters a billing-issue state:
397
+ * - iOS 18+ / Mac Catalyst 18+: via StoreKit 2 `Message.Reason.billingIssue`.
398
+ * - Android (Play Billing 8.1+): when `isSuspendedAndroid === true` is observed.
399
+ * - Horizon / iOS 17 / older platforms: never fires.
400
+ *
401
+ * Recommended UX: on fire, call `deepLinkToSubscriptions()` so the user can
402
+ * update their payment method in the platform subscription center.
403
+ *
404
+ * @param listener - Function to call with the affected Purchase
405
+ * @returns EventSubscription with remove() method to unsubscribe
406
+ *
407
+ * @example
408
+ * ```typescript
409
+ * const subscription = subscriptionBillingIssueListener((purchase) => {
410
+ * console.warn('Subscription needs attention:', purchase.productId);
411
+ * deepLinkToSubscriptions({skuAndroid: purchase.productId, packageNameAndroid: 'com.example.app'});
412
+ * });
413
+ *
414
+ * subscription.remove();
415
+ * ```
416
+ */
417
+
418
+ const subscriptionBillingIssueJsListeners = new Set();
419
+ let subscriptionBillingIssueNativeAttached = false;
420
+ const subscriptionBillingIssueNativeHandler = nitroPurchase => {
421
+ if (!validateNitroPurchase(nitroPurchase)) {
422
+ RnIapConsole.warn('[subscriptionBillingIssueListener] dropped malformed native payload');
423
+ return;
424
+ }
425
+ const purchase = convertNitroPurchaseToPurchase(nitroPurchase);
426
+ for (const listener of subscriptionBillingIssueJsListeners) {
427
+ try {
428
+ listener(purchase);
429
+ } catch (e) {
430
+ RnIapConsole.error('[subscriptionBillingIssueListener] callback threw:', e);
431
+ }
432
+ }
433
+ };
434
+ function tryAttachSubscriptionBillingIssueNative() {
435
+ if (subscriptionBillingIssueNativeAttached) return;
436
+ try {
437
+ IAP.instance.addSubscriptionBillingIssueListener(subscriptionBillingIssueNativeHandler);
438
+ subscriptionBillingIssueNativeAttached = true;
439
+ } catch (e) {
440
+ const msg = toErrorMessage(e);
441
+ if (msg.includes('Nitro runtime not installed')) {
442
+ RnIapConsole.warn('[subscriptionBillingIssueListener] Nitro not ready yet; will retry on next registration after initConnection()');
443
+ } else {
444
+ throw e;
445
+ }
446
+ }
447
+ }
448
+ export const subscriptionBillingIssueListener = listener => {
449
+ subscriptionBillingIssueJsListeners.add(listener);
450
+ // Retry attachment every call so a listener registered before initConnection()
451
+ // doesn't stay permanently inert once Nitro is ready.
452
+ try {
453
+ tryAttachSubscriptionBillingIssueNative();
454
+ } catch (error) {
455
+ subscriptionBillingIssueJsListeners.delete(listener);
456
+ throw error;
457
+ }
458
+ return {
459
+ remove: () => {
460
+ subscriptionBillingIssueJsListeners.delete(listener);
461
+ }
462
+ };
463
+ };
464
+
391
465
  // ------------------------------
392
466
  // Query API
393
467
  // ------------------------------