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/src/types.ts CHANGED
@@ -350,6 +350,7 @@ export enum ErrorCode {
350
350
  RemoteError = 'remote-error',
351
351
  ServiceDisconnected = 'service-disconnected',
352
352
  ServiceError = 'service-error',
353
+ ServiceTimeout = 'service-timeout',
353
354
  SkuNotFound = 'sku-not-found',
354
355
  SkuOfferMismatch = 'sku-offer-mismatch',
355
356
  SyncError = 'sync-error',
@@ -456,7 +457,7 @@ export interface ExternalPurchaseNoticeResultIOS {
456
457
 
457
458
  export type FetchProductsResult = ProductOrSubscription[] | Product[] | ProductSubscription[] | null;
458
459
 
459
- export type IapEvent = 'purchase-updated' | 'purchase-error' | 'promoted-product-ios' | 'user-choice-billing-android' | 'developer-provided-billing-android';
460
+ export type IapEvent = 'purchase-updated' | 'purchase-error' | 'promoted-product-ios' | 'user-choice-billing-android' | 'developer-provided-billing-android' | 'subscription-billing-issue';
460
461
 
461
462
  export type IapPlatform = 'ios' | 'android';
462
463
 
@@ -1105,6 +1106,7 @@ export interface PurchaseCommon {
1105
1106
 
1106
1107
  export interface PurchaseError {
1107
1108
  code: ErrorCode;
1109
+ debugMessage?: (string | null);
1108
1110
  message: string;
1109
1111
  productId?: (string | null);
1110
1112
  }
@@ -1558,6 +1560,20 @@ export interface Subscription {
1558
1560
  purchaseError: PurchaseError;
1559
1561
  /** Fires when a purchase completes successfully or a pending purchase resolves */
1560
1562
  purchaseUpdated: Purchase;
1563
+ /**
1564
+ * Fires when an active subscription enters a billing-issue state that needs user action
1565
+ * (payment method failed, card expired, etc.). Cross-platform unification:
1566
+ *
1567
+ * - iOS 18+: delivered via StoreKit 2 `Message.Reason.billingIssue`.
1568
+ * - Android (Play flavor, Billing 8.1+): emitted when `isSuspended == true` is first detected
1569
+ * on a previously healthy subscription. Requires Google Play Billing Library 8.1.0 or newer.
1570
+ * - Android (Horizon flavor): NOT emitted. The Horizon Billing Compatibility SDK implements
1571
+ * the Play Billing 7.0 API surface which does not expose a suspended-subscription signal.
1572
+ *
1573
+ * Listeners should not assume the event will fire on every store. Direct users to the
1574
+ * platform subscription management UI (`deepLinkToSubscriptions`) to resolve the issue.
1575
+ */
1576
+ subscriptionBillingIssue: Purchase;
1561
1577
  /**
1562
1578
  * Fires when a user selects alternative billing in the User Choice Billing dialog (Android only)
1563
1579
  * Only triggered when the user selects alternative billing instead of Google Play billing
@@ -1963,6 +1979,7 @@ export type SubscriptionArgsMap = {
1963
1979
  promotedProductIOS: never;
1964
1980
  purchaseError: never;
1965
1981
  purchaseUpdated: never;
1982
+ subscriptionBillingIssue: never;
1966
1983
  userChoiceBillingAndroid: never;
1967
1984
  };
1968
1985
 
@@ -104,6 +104,7 @@ const COMMON_ERROR_CODE_MAP: Record<ErrorCode, string> = {
104
104
  [ErrorCode.BillingUnavailable]: ErrorCode.BillingUnavailable,
105
105
  [ErrorCode.FeatureNotSupported]: ErrorCode.FeatureNotSupported,
106
106
  [ErrorCode.DuplicatePurchase]: ErrorCode.DuplicatePurchase,
107
+ [ErrorCode.ServiceTimeout]: ErrorCode.ServiceTimeout,
107
108
  [ErrorCode.EmptySkuList]: ErrorCode.EmptySkuList,
108
109
  [ErrorCode.PurchaseVerificationFailed]: ErrorCode.PurchaseVerificationFailed,
109
110
  [ErrorCode.PurchaseVerificationFinishFailed]: