react-native-iap 15.1.0 → 15.2.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 (96) hide show
  1. package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +171 -114
  2. package/android/src/main/java/com/margelo/nitro/iap/ProductQueryHelpers.kt +42 -0
  3. package/android/src/test/java/com/margelo/nitro/iap/ProductQueryHelpersTest.kt +140 -0
  4. package/ios/HybridRnIap.swift +72 -1
  5. package/lib/module/hooks/useIAP.js +11 -1
  6. package/lib/module/hooks/useIAP.js.map +1 -1
  7. package/lib/module/hooks/useWebhookEvents.js +113 -0
  8. package/lib/module/hooks/useWebhookEvents.js.map +1 -0
  9. package/lib/module/index.js +405 -131
  10. package/lib/module/index.js.map +1 -1
  11. package/lib/module/kit-api.js +161 -0
  12. package/lib/module/kit-api.js.map +1 -0
  13. package/lib/module/types.js +16 -0
  14. package/lib/module/types.js.map +1 -1
  15. package/lib/module/utils/error.js.map +1 -1
  16. package/lib/module/utils/errorMapping.js +6 -0
  17. package/lib/module/utils/errorMapping.js.map +1 -1
  18. package/lib/module/webhook-client.js +164 -0
  19. package/lib/module/webhook-client.js.map +1 -0
  20. package/lib/typescript/plugin/src/withIAP.d.ts +1 -1
  21. package/lib/typescript/src/hooks/useIAP.d.ts +172 -2
  22. package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -1
  23. package/lib/typescript/src/hooks/useWebhookEvents.d.ts +55 -0
  24. package/lib/typescript/src/hooks/useWebhookEvents.d.ts.map +1 -0
  25. package/lib/typescript/src/index.d.ts +283 -129
  26. package/lib/typescript/src/index.d.ts.map +1 -1
  27. package/lib/typescript/src/kit-api.d.ts +54 -0
  28. package/lib/typescript/src/kit-api.d.ts.map +1 -0
  29. package/lib/typescript/src/specs/RnIap.nitro.d.ts +24 -0
  30. package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
  31. package/lib/typescript/src/types.d.ts +320 -75
  32. package/lib/typescript/src/types.d.ts.map +1 -1
  33. package/lib/typescript/src/utils/error.d.ts +3 -0
  34. package/lib/typescript/src/utils/error.d.ts.map +1 -1
  35. package/lib/typescript/src/utils/errorMapping.d.ts +6 -0
  36. package/lib/typescript/src/utils/errorMapping.d.ts.map +1 -1
  37. package/lib/typescript/src/webhook-client.d.ts +82 -0
  38. package/lib/typescript/src/webhook-client.d.ts.map +1 -0
  39. package/nitrogen/generated/android/NitroIap+autolinking.cmake +3 -0
  40. package/nitrogen/generated/android/c++/JAdvancedCommerceInfoIOS.hpp +118 -0
  41. package/nitrogen/generated/android/c++/JAdvancedCommerceItemDetailsIOS.hpp +62 -0
  42. package/nitrogen/generated/android/c++/JAdvancedCommerceItemIOS.hpp +78 -0
  43. package/nitrogen/generated/android/c++/JAdvancedCommerceRefundIOS.hpp +62 -0
  44. package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +52 -0
  45. package/nitrogen/generated/android/c++/JHybridRnIapSpec.hpp +3 -0
  46. package/nitrogen/generated/android/c++/JPurchase.hpp +11 -0
  47. package/nitrogen/generated/android/c++/JPurchaseIOS.hpp +16 -1
  48. package/nitrogen/generated/android/c++/JRequestPurchaseResult.hpp +11 -0
  49. package/nitrogen/generated/android/c++/JVariant_NullType_AdvancedCommerceInfoIOS.cpp +26 -0
  50. package/nitrogen/generated/android/c++/JVariant_NullType_AdvancedCommerceInfoIOS.hpp +84 -0
  51. package/nitrogen/generated/android/c++/JVariant_NullType_AdvancedCommerceItemDetailsIOS.cpp +26 -0
  52. package/nitrogen/generated/android/c++/JVariant_NullType_AdvancedCommerceItemDetailsIOS.hpp +74 -0
  53. package/nitrogen/generated/android/c++/JVariant_NullType_Array_AdvancedCommerceRefundIOS_.cpp +35 -0
  54. package/nitrogen/generated/android/c++/JVariant_NullType_Array_AdvancedCommerceRefundIOS_.hpp +84 -0
  55. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/AdvancedCommerceInfoIOS.kt +59 -0
  56. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/AdvancedCommerceItemDetailsIOS.kt +38 -0
  57. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/AdvancedCommerceItemIOS.kt +44 -0
  58. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/AdvancedCommerceRefundIOS.kt +38 -0
  59. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +22 -0
  60. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseIOS.kt +5 -2
  61. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Variant_NullType_AdvancedCommerceInfoIOS.kt +53 -0
  62. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Variant_NullType_AdvancedCommerceItemDetailsIOS.kt +53 -0
  63. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Variant_NullType_Array_AdvancedCommerceRefundIOS_.kt +53 -0
  64. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +166 -0
  65. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +12 -0
  66. package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +32 -0
  67. package/nitrogen/generated/ios/swift/AdvancedCommerceInfoIOS.swift +294 -0
  68. package/nitrogen/generated/ios/swift/AdvancedCommerceItemDetailsIOS.swift +61 -0
  69. package/nitrogen/generated/ios/swift/AdvancedCommerceItemIOS.swift +141 -0
  70. package/nitrogen/generated/ios/swift/AdvancedCommerceRefundIOS.swift +61 -0
  71. package/nitrogen/generated/ios/swift/HybridRnIapSpec.swift +3 -0
  72. package/nitrogen/generated/ios/swift/HybridRnIapSpec_cxx.swift +57 -0
  73. package/nitrogen/generated/ios/swift/PurchaseIOS.swift +39 -2
  74. package/nitrogen/generated/ios/swift/Variant_NullType_AdvancedCommerceInfoIOS.swift +18 -0
  75. package/nitrogen/generated/ios/swift/Variant_NullType_AdvancedCommerceItemDetailsIOS.swift +18 -0
  76. package/nitrogen/generated/ios/swift/Variant_NullType__AdvancedCommerceRefundIOS_.swift +18 -0
  77. package/nitrogen/generated/shared/c++/AdvancedCommerceInfoIOS.hpp +117 -0
  78. package/nitrogen/generated/shared/c++/AdvancedCommerceItemDetailsIOS.hpp +86 -0
  79. package/nitrogen/generated/shared/c++/AdvancedCommerceItemIOS.hpp +99 -0
  80. package/nitrogen/generated/shared/c++/AdvancedCommerceRefundIOS.hpp +86 -0
  81. package/nitrogen/generated/shared/c++/HybridRnIapSpec.cpp +3 -0
  82. package/nitrogen/generated/shared/c++/HybridRnIapSpec.hpp +3 -0
  83. package/nitrogen/generated/shared/c++/PurchaseIOS.hpp +9 -2
  84. package/openiap-versions.json +3 -3
  85. package/package.json +1 -1
  86. package/plugin/build/withIAP.d.ts +1 -1
  87. package/plugin/src/withIAP.ts +1 -1
  88. package/src/hooks/useIAP.ts +185 -2
  89. package/src/hooks/useWebhookEvents.ts +180 -0
  90. package/src/index.ts +440 -130
  91. package/src/kit-api.ts +225 -0
  92. package/src/specs/RnIap.nitro.ts +31 -0
  93. package/src/types.ts +330 -75
  94. package/src/utils/error.ts +3 -0
  95. package/src/utils/errorMapping.ts +12 -0
  96. package/src/webhook-client.ts +312 -0
@@ -30,6 +30,52 @@ export interface ActiveSubscription {
30
30
  */
31
31
  willExpireSoon?: (boolean | null);
32
32
  }
33
+ /**
34
+ * Advanced Commerce metadata from a transaction (iOS 18.4+).
35
+ * Contains item details, tax information, and refund data for purchases
36
+ * made through the Advanced Commerce API using generic SKUs.
37
+ * Only present for transactions that use the Advanced Commerce API.
38
+ */
39
+ export interface AdvancedCommerceInfoIOS {
40
+ /** Optional description */
41
+ description?: (string | null);
42
+ /** Optional display name */
43
+ displayName?: (string | null);
44
+ /** Estimated tax amount (decimal string) */
45
+ estimatedTax?: (string | null);
46
+ /** The items purchased as part of this transaction */
47
+ items: AdvancedCommerceItemIOS[];
48
+ /** Request reference identifier for tracking */
49
+ requestReferenceId?: (string | null);
50
+ /** Tax code for the transaction */
51
+ taxCode?: (string | null);
52
+ /** Price excluding tax (decimal string) */
53
+ taxExclusivePrice?: (string | null);
54
+ /** Tax rate applied (decimal string) */
55
+ taxRate?: (string | null);
56
+ }
57
+ /** Details of an Advanced Commerce item (iOS 18.4+). */
58
+ export interface AdvancedCommerceItemDetailsIOS {
59
+ /** JSON representation of the item details */
60
+ jsonRepresentation?: (string | null);
61
+ }
62
+ /**
63
+ * An item purchased through the Advanced Commerce API (iOS 18.4+).
64
+ * Represents a developer-defined product within a generic SKU transaction.
65
+ */
66
+ export interface AdvancedCommerceItemIOS {
67
+ /** The item's detail information */
68
+ details?: (AdvancedCommerceItemDetailsIOS | null);
69
+ /** Refunds issued for this item, if any */
70
+ refunds?: (AdvancedCommerceRefundIOS[] | null);
71
+ /** Date access to this item was revoked (milliseconds since epoch) */
72
+ revocationDate?: (number | null);
73
+ }
74
+ /** Refund information for an Advanced Commerce item (iOS 18.4+). */
75
+ export interface AdvancedCommerceRefundIOS {
76
+ /** JSON representation of the refund details */
77
+ jsonRepresentation?: (string | null);
78
+ }
33
79
  /**
34
80
  * Alternative billing mode for Android
35
81
  * Controls which billing system is used
@@ -419,7 +465,7 @@ export interface ExternalPurchaseNoticeResultIOS {
419
465
  result: ExternalPurchaseNoticeAction;
420
466
  }
421
467
  export type FetchProductsResult = ProductOrSubscription[] | Product[] | ProductSubscription[] | null;
422
- export type IapEvent = 'purchase-updated' | 'purchase-error' | 'promoted-product-ios' | 'user-choice-billing-android' | 'developer-provided-billing-android';
468
+ export type IapEvent = 'purchase-updated' | 'purchase-error' | 'promoted-product-ios' | 'user-choice-billing-android' | 'developer-provided-billing-android' | 'subscription-billing-issue';
423
469
  export type IapPlatform = 'ios' | 'android';
424
470
  export type IapStore = 'unknown' | 'apple' | 'google' | 'horizon';
425
471
  /** Unified purchase states from IAPKit verification response. */
@@ -489,118 +535,176 @@ export interface LimitedQuantityInfoAndroid {
489
535
  remainingQuantity: number;
490
536
  }
491
537
  export interface Mutation {
492
- /** Acknowledge a non-consumable purchase or subscription */
538
+ /**
539
+ * Acknowledge a non-consumable purchase. Required within 3 days or Google auto-refunds.
540
+ * See: https://www.openiap.dev/docs/apis/android/acknowledge-purchase-android
541
+ */
493
542
  acknowledgePurchaseAndroid: Promise<boolean>;
494
- /** Initiate a refund request for a product (iOS 15+) */
543
+ /**
544
+ * Present the refund request sheet (iOS 15+). See also Features → Refund.
545
+ * See: https://www.openiap.dev/docs/apis/ios/begin-refund-request-ios
546
+ */
495
547
  beginRefundRequestIOS?: Promise<(string | null)>;
496
548
  /**
497
- * Check if alternative billing is available for this user/device
498
- * Step 1 of alternative billing flow
549
+ * Check whether alternative billing is available for the user. Step 1 of the alternative billing flow.
499
550
  *
500
- * Returns true if available, false otherwise
501
- * Throws OpenIapError.NotPrepared if billing client not ready
551
+ * Returns true if available, false otherwise.
552
+ * Throws OpenIapError.NotPrepared if billing client not ready.
553
+ * See: https://www.openiap.dev/docs/apis/android/check-alternative-billing-availability-android
502
554
  */
503
555
  checkAlternativeBillingAvailabilityAndroid: Promise<boolean>;
504
- /** Clear pending transactions from the StoreKit payment queue */
556
+ /**
557
+ * Clear pending transactions in the queue (sandbox helper).
558
+ * See: https://www.openiap.dev/docs/apis/ios/clear-transaction-ios
559
+ */
505
560
  clearTransactionIOS: Promise<boolean>;
506
- /** Consume a purchase token so it can be repurchased */
561
+ /**
562
+ * Consume a consumable purchase so it can be re-bought.
563
+ * See: https://www.openiap.dev/docs/apis/android/consume-purchase-android
564
+ */
507
565
  consumePurchaseAndroid: Promise<boolean>;
508
566
  /**
509
- * Create external transaction token for Google Play reporting
510
- * Step 3 of alternative billing flow
511
- * Must be called AFTER successful payment in your payment system
512
- * Token must be reported to Google Play backend within 24 hours
567
+ * Create a reporting token for an alternative billing flow. Step 3 of the alternative billing flow.
568
+ * Must be called AFTER successful payment in your payment system.
569
+ * Token must be reported to Google Play backend within 24 hours.
513
570
  *
514
- * Returns token string, or null if creation failed
515
- * Throws OpenIapError.NotPrepared if billing client not ready
571
+ * Returns token string, or null if creation failed.
572
+ * Throws OpenIapError.NotPrepared if billing client not ready.
573
+ * See: https://www.openiap.dev/docs/apis/android/create-alternative-billing-token-android
516
574
  */
517
575
  createAlternativeBillingTokenAndroid?: Promise<(string | null)>;
518
576
  /**
519
- * Create reporting details for a billing program
520
- * Replaces the deprecated createExternalOfferReportingDetailsAsync API
577
+ * Create the reporting payload Google requires after a Developer-Provided Billing transaction (Play Billing 8.3.0+).
578
+ * Replaces the deprecated createExternalOfferReportingDetailsAsync API.
521
579
  *
522
- * Available in Google Play Billing Library 8.2.0+
523
- * Returns external transaction token needed for reporting external transactions
524
- * Throws OpenIapError.NotPrepared if billing client not ready
580
+ * Returns external transaction token needed for reporting external transactions.
581
+ * Throws OpenIapError.NotPrepared if billing client not ready.
582
+ * See: https://www.openiap.dev/docs/apis/android/create-billing-program-reporting-details-android
525
583
  */
526
584
  createBillingProgramReportingDetailsAndroid: Promise<BillingProgramReportingDetailsAndroid>;
527
- /** Open the native subscription management surface */
585
+ /**
586
+ * Open the platform's subscription management UI.
587
+ * See: https://www.openiap.dev/docs/apis/deep-link-to-subscriptions
588
+ */
528
589
  deepLinkToSubscriptions: Promise<void>;
529
- /** Close the platform billing connection */
590
+ /**
591
+ * Close the store connection and release resources.
592
+ * See: https://www.openiap.dev/docs/apis/end-connection
593
+ */
530
594
  endConnection: Promise<boolean>;
531
- /** Finish a transaction after validating receipts */
595
+ /**
596
+ * Complete a transaction after server-side verification. Required on Android within 3 days.
597
+ * See: https://www.openiap.dev/docs/apis/finish-transaction
598
+ */
532
599
  finishTransaction: Promise<void>;
533
- /** Establish the platform billing connection */
600
+ /**
601
+ * Initialize the store connection. Call before any IAP API.
602
+ * See: https://www.openiap.dev/docs/apis/init-connection
603
+ */
534
604
  initConnection: Promise<boolean>;
535
605
  /**
536
- * Check if a billing program is available for the current user
537
- * Replaces the deprecated isExternalOfferAvailableAsync API
606
+ * Check whether a billing program (e.g., External Payments) is available for the current user.
607
+ * Replaces the deprecated isExternalOfferAvailableAsync API.
538
608
  *
539
- * Available in Google Play Billing Library 8.2.0+
540
- * Returns availability result with isAvailable flag
541
- * Throws OpenIapError.NotPrepared if billing client not ready
609
+ * Available in Google Play Billing Library 8.2.0+.
610
+ * Returns availability result with isAvailable flag.
611
+ * Throws OpenIapError.NotPrepared if billing client not ready.
612
+ * See: https://www.openiap.dev/docs/apis/android/is-billing-program-available-android
542
613
  */
543
614
  isBillingProgramAvailableAndroid: Promise<BillingProgramAvailabilityResultAndroid>;
544
615
  /**
545
- * Launch external link flow for external billing programs
546
- * Replaces the deprecated showExternalOfferInformationDialog API
616
+ * Launch an external content/offer link from inside the Billing Programs flow (Play Billing 8.2.0+).
617
+ * Replaces the deprecated showExternalOfferInformationDialog API.
547
618
  *
548
- * Available in Google Play Billing Library 8.2.0+
549
- * Shows Play Store dialog and optionally launches external URL
550
- * Throws OpenIapError.NotPrepared if billing client not ready
619
+ * Shows Play Store dialog and optionally launches external URL.
620
+ * Throws OpenIapError.NotPrepared if billing client not ready.
621
+ * See: https://www.openiap.dev/docs/apis/android/launch-external-link-android
551
622
  */
552
623
  launchExternalLinkAndroid: Promise<boolean>;
553
- /** Present the App Store code redemption sheet */
624
+ /**
625
+ * Show the App Store offer code redemption sheet.
626
+ * See: https://www.openiap.dev/docs/apis/ios/present-code-redemption-sheet-ios
627
+ */
554
628
  presentCodeRedemptionSheetIOS: Promise<boolean>;
555
- /** Present external purchase custom link with StoreKit UI */
629
+ /**
630
+ * Present an external purchase link, StoreKit External (iOS 16+).
631
+ * See: https://www.openiap.dev/docs/apis/ios/present-external-purchase-link-ios
632
+ */
556
633
  presentExternalPurchaseLinkIOS: Promise<ExternalPurchaseLinkResultIOS>;
557
634
  /**
558
- * Present external purchase notice sheet (iOS 17.4+).
559
- * Uses ExternalPurchase.presentNoticeSheet() which returns a token when user continues.
635
+ * Present the external purchase notice sheet (iOS 17.4+).
636
+ * Uses ExternalPurchase.presentNoticeSheet() which returns a token when the user continues.
560
637
  * Reference: https://developer.apple.com/documentation/storekit/externalpurchase/presentnoticesheet()
638
+ * See: https://www.openiap.dev/docs/apis/ios/present-external-purchase-notice-sheet-ios
561
639
  */
562
640
  presentExternalPurchaseNoticeSheetIOS: Promise<ExternalPurchaseNoticeResultIOS>;
563
- /** Initiate a purchase flow; rely on events for final state */
641
+ /**
642
+ * Initiate a purchase or subscription flow; rely on events for final state.
643
+ * See: https://www.openiap.dev/docs/apis/request-purchase
644
+ */
564
645
  requestPurchase?: Promise<(Purchase | Purchase[] | null)>;
565
646
  /**
566
- * Purchase the promoted product surfaced by the App Store.
647
+ * Buy the currently promoted product.
567
648
  *
568
649
  * @deprecated Use promotedProductListenerIOS to receive the productId,
569
650
  * then call requestPurchase with that SKU instead. In StoreKit 2,
570
651
  * promoted products can be purchased directly via the standard purchase flow.
652
+ * See: https://www.openiap.dev/docs/apis/ios/request-purchase-on-promoted-product-ios
571
653
  * @deprecated Use promotedProductListenerIOS + requestPurchase instead
572
654
  */
573
655
  requestPurchaseOnPromotedProductIOS: Promise<boolean>;
574
- /** Restore completed purchases across platforms */
656
+ /**
657
+ * Restore non-consumable and active subscription purchases.
658
+ * See: https://www.openiap.dev/docs/apis/restore-purchases
659
+ */
575
660
  restorePurchases: Promise<void>;
576
661
  /**
577
- * Show alternative billing information dialog to user
578
- * Step 2 of alternative billing flow
579
- * Must be called BEFORE processing payment in your payment system
662
+ * Display Google's alternative billing information dialog. Step 2 of the alternative billing flow.
663
+ * Must be called BEFORE processing payment in your payment system.
580
664
  *
581
- * Returns true if user accepted, false if user canceled
582
- * Throws OpenIapError.NotPrepared if billing client not ready
665
+ * Returns true if user accepted, false if user canceled.
666
+ * Throws OpenIapError.NotPrepared if billing client not ready.
667
+ * See: https://www.openiap.dev/docs/apis/android/show-alternative-billing-dialog-android
583
668
  */
584
669
  showAlternativeBillingDialogAndroid: Promise<boolean>;
585
670
  /**
586
- * Show ExternalPurchaseCustomLink notice sheet (iOS 18.1+).
587
- * Displays the system disclosure notice sheet for custom external purchase links.
671
+ * Present the disclosure sheet required before linking out via ExternalPurchaseCustomLink (iOS 18.1+).
588
672
  * Call this after a deliberate customer interaction before linking out to external purchases.
589
673
  * Reference: https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/shownotice(type:)
674
+ * See: https://www.openiap.dev/docs/apis/ios/show-external-purchase-custom-link-notice-ios
590
675
  */
591
676
  showExternalPurchaseCustomLinkNoticeIOS: Promise<ExternalPurchaseCustomLinkNoticeResultIOS>;
592
- /** Open subscription management UI and return changed purchases (iOS 15+) */
677
+ /**
678
+ * Present the manage-subscriptions sheet and return changed purchases (iOS 15+).
679
+ * See: https://www.openiap.dev/docs/apis/ios/show-manage-subscriptions-ios
680
+ */
593
681
  showManageSubscriptionsIOS: Promise<PurchaseIOS[]>;
594
- /** Force a StoreKit sync for transactions (iOS 15+) */
682
+ /**
683
+ * Force sync transactions with the App Store (iOS 15+).
684
+ * See: https://www.openiap.dev/docs/apis/ios/sync-ios
685
+ */
595
686
  syncIOS: Promise<boolean>;
596
687
  /**
597
- * Validate purchase receipts with the configured providers
688
+ * Deprecated. Validate purchase receipts with the configured providers — use verifyPurchase instead.
689
+ * See: https://www.openiap.dev/docs/features/validation#verify-purchase
598
690
  * @deprecated Use verifyPurchase
599
691
  */
600
692
  validateReceipt: Promise<VerifyPurchaseResult>;
601
- /** Verify purchases with the configured providers */
693
+ /**
694
+ * Verify a purchase against your own backend. Returns a platform-specific
695
+ * variant of VerifyPurchaseResult — VerifyPurchaseResultIOS exposes isValid
696
+ * + receipt/JWS metadata, VerifyPurchaseResultAndroid carries Play Store
697
+ * receipt fields (no isValid), and VerifyPurchaseResultHorizon uses success.
698
+ * Inspect the concrete variant before reading fields.
699
+ * See: https://www.openiap.dev/docs/features/validation#verify-purchase
700
+ */
602
701
  verifyPurchase: Promise<VerifyPurchaseResult>;
603
- /** Verify purchases with a specific provider (e.g., IAPKit) */
702
+ /**
703
+ * Verify via a managed provider without standing up your own server. The
704
+ * PurchaseVerificationProvider enum currently exposes only IAPKit; platform
705
+ * availability may differ by implementation.
706
+ * See: https://www.openiap.dev/docs/features/validation#verify-purchase-with-provider
707
+ */
604
708
  verifyPurchaseWithProvider: Promise<VerifyPurchaseWithProviderResult>;
605
709
  }
606
710
  export type MutationAcknowledgePurchaseAndroidArgs = string;
@@ -1014,10 +1118,20 @@ export interface PurchaseCommon {
1014
1118
  export interface PurchaseError {
1015
1119
  code: ErrorCode;
1016
1120
  debugMessage?: (string | null);
1121
+ isEmptyProductList?: (boolean | null);
1017
1122
  message: string;
1018
1123
  productId?: (string | null);
1124
+ productIds?: (string[] | null);
1125
+ productType?: (string | null);
1126
+ responseCode?: (number | null);
1019
1127
  }
1020
1128
  export interface PurchaseIOS extends PurchaseCommon {
1129
+ /**
1130
+ * Advanced Commerce API metadata (iOS 18.4+).
1131
+ * Present only for transactions that use the Advanced Commerce API.
1132
+ * Contains item details, tax information, and refund data for generic SKU purchases.
1133
+ */
1134
+ advancedCommerceInfoIOS?: (AdvancedCommerceInfoIOS | null);
1021
1135
  appAccountToken?: (string | null);
1022
1136
  appBundleIdIOS?: (string | null);
1023
1137
  countryCodeIOS?: (string | null);
@@ -1078,59 +1192,117 @@ export type PurchaseState = 'pending' | 'purchased' | 'unknown';
1078
1192
  export type PurchaseVerificationProvider = 'iapkit';
1079
1193
  export interface Query {
1080
1194
  /**
1081
- * Check if external purchase notice sheet can be presented (iOS 17.4+)
1082
- * Uses ExternalPurchase.canPresent
1195
+ * Check eligibility for the external purchase notice sheet (iOS 17.4+).
1196
+ * Uses ExternalPurchase.canPresent.
1197
+ * See: https://www.openiap.dev/docs/apis/ios/can-present-external-purchase-notice-ios
1083
1198
  */
1084
1199
  canPresentExternalPurchaseNoticeIOS: Promise<boolean>;
1085
- /** Get current StoreKit 2 entitlements (iOS 15+) */
1200
+ /**
1201
+ * Get the user's current entitlement for a product, using StoreKit 2 (iOS 15+).
1202
+ * See: https://www.openiap.dev/docs/apis/ios/current-entitlement-ios
1203
+ */
1086
1204
  currentEntitlementIOS?: Promise<(PurchaseIOS | null)>;
1087
- /** Retrieve products or subscriptions from the store */
1205
+ /**
1206
+ * Fetch products or subscriptions from the store.
1207
+ * See: https://www.openiap.dev/docs/apis/fetch-products
1208
+ */
1088
1209
  fetchProducts: Promise<(ProductOrSubscription[] | Product[] | ProductSubscription[] | null)>;
1089
- /** Get active subscriptions (filters by subscriptionIds when provided) */
1210
+ /**
1211
+ * Get details of all currently active subscriptions (filters by subscriptionIds when provided).
1212
+ * See: https://www.openiap.dev/docs/apis/get-active-subscriptions
1213
+ */
1090
1214
  getActiveSubscriptions: Promise<ActiveSubscription[]>;
1091
- /** Fetch the current app transaction (iOS 16+) */
1215
+ /**
1216
+ * List every StoreKit transaction (finished + unfinished) for the current user.
1217
+ * Requires the SK2ConsumableTransactionHistory Info.plist key in the host app
1218
+ * for finished consumables to be included (iOS 18+).
1219
+ * Unlike getAvailablePurchases, always returns the iOS-specific PurchaseIOS shape.
1220
+ * See: https://www.openiap.dev/docs/apis/ios/get-all-transactions-ios
1221
+ */
1222
+ getAllTransactionsIOS: Promise<PurchaseIOS[]>;
1223
+ /**
1224
+ * Fetch the app transaction (iOS 16+).
1225
+ * See: https://www.openiap.dev/docs/apis/ios/get-app-transaction-ios
1226
+ */
1092
1227
  getAppTransactionIOS?: Promise<(AppTransaction | null)>;
1093
- /** Get all available purchases for the current user */
1228
+ /**
1229
+ * List active purchases for the current user.
1230
+ * See: https://www.openiap.dev/docs/apis/get-available-purchases
1231
+ */
1094
1232
  getAvailablePurchases: Promise<Purchase[]>;
1095
1233
  /**
1096
- * Get external purchase token for reporting to Apple (iOS 18.1+).
1097
- * Use this token with Apple's External Purchase Server API to report transactions.
1234
+ * Fetch a token for Apple's External Purchase Server reporting API (iOS 18.1+).
1235
+ * Use this token to report transactions made through ExternalPurchaseCustomLink.
1098
1236
  * Reference: https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/token(for:)
1237
+ * See: https://www.openiap.dev/docs/apis/ios/get-external-purchase-custom-link-token-ios
1099
1238
  */
1100
1239
  getExternalPurchaseCustomLinkTokenIOS: Promise<ExternalPurchaseCustomLinkTokenResultIOS>;
1101
- /** Retrieve all pending transactions in the StoreKit queue */
1240
+ /**
1241
+ * List unfinished StoreKit transactions in the queue.
1242
+ * See: https://www.openiap.dev/docs/apis/ios/get-pending-transactions-ios
1243
+ */
1102
1244
  getPendingTransactionsIOS: Promise<PurchaseIOS[]>;
1103
- /** Get the currently promoted product (iOS 11+) */
1245
+ /**
1246
+ * Read the App Store-promoted product, if any (iOS 11+).
1247
+ * See: https://www.openiap.dev/docs/apis/ios/get-promoted-product-ios
1248
+ */
1104
1249
  getPromotedProductIOS?: Promise<(ProductIOS | null)>;
1105
- /** Get base64-encoded receipt data for validation */
1250
+ /**
1251
+ * Get base64-encoded receipt data (legacy validation).
1252
+ * See: https://www.openiap.dev/docs/apis/ios/get-receipt-data-ios
1253
+ */
1106
1254
  getReceiptDataIOS?: Promise<(string | null)>;
1107
- /** Get the current storefront country code */
1255
+ /**
1256
+ * Return the user's storefront country code.
1257
+ * See: https://www.openiap.dev/docs/apis/get-storefront
1258
+ */
1108
1259
  getStorefront: Promise<string>;
1109
1260
  /**
1110
- * Get the current App Store storefront country code
1261
+ * Deprecated. Get the current App Store storefront country code — use cross-platform getStorefront instead.
1262
+ * See: https://www.openiap.dev/docs/apis/ios/get-storefront-ios
1111
1263
  * @deprecated Use getStorefront
1112
1264
  */
1113
1265
  getStorefrontIOS: Promise<string>;
1114
- /** Get the transaction JWS (StoreKit 2) */
1266
+ /**
1267
+ * Return the JWS string for a transaction (StoreKit 2).
1268
+ * See: https://www.openiap.dev/docs/apis/ios/get-transaction-jws-ios
1269
+ */
1115
1270
  getTransactionJwsIOS?: Promise<(string | null)>;
1116
- /** Check whether the user has active subscriptions */
1271
+ /**
1272
+ * Check whether the user has any active subscription.
1273
+ * See: https://www.openiap.dev/docs/apis/has-active-subscriptions
1274
+ */
1117
1275
  hasActiveSubscriptions: Promise<boolean>;
1118
1276
  /**
1119
- * Check if app is eligible for ExternalPurchaseCustomLink API (iOS 18.1+).
1277
+ * Check eligibility for the custom-link variant of external purchase (iOS 18.1+).
1120
1278
  * Returns true if the app can use custom external purchase links.
1121
1279
  * Reference: https://developer.apple.com/documentation/storekit/externalpurchasecustomlink/iseligible
1280
+ * See: https://www.openiap.dev/docs/apis/ios/is-eligible-for-external-purchase-custom-link-ios
1122
1281
  */
1123
1282
  isEligibleForExternalPurchaseCustomLinkIOS: Promise<boolean>;
1124
- /** Check introductory offer eligibility for a subscription group */
1283
+ /**
1284
+ * Check intro-offer eligibility for a subscription group.
1285
+ * See: https://www.openiap.dev/docs/apis/ios/is-eligible-for-intro-offer-ios
1286
+ */
1125
1287
  isEligibleForIntroOfferIOS: Promise<boolean>;
1126
- /** Verify a StoreKit 2 transaction signature */
1288
+ /**
1289
+ * Check whether a transaction's JWS verification passed (StoreKit 2).
1290
+ * See: https://www.openiap.dev/docs/apis/ios/is-transaction-verified-ios
1291
+ */
1127
1292
  isTransactionVerifiedIOS: Promise<boolean>;
1128
- /** Get the latest transaction for a product using StoreKit 2 */
1293
+ /**
1294
+ * Get the latest verified transaction for a product, using StoreKit 2.
1295
+ * See: https://www.openiap.dev/docs/apis/ios/latest-transaction-ios
1296
+ */
1129
1297
  latestTransactionIOS?: Promise<(PurchaseIOS | null)>;
1130
- /** Get StoreKit 2 subscription status details (iOS 15+) */
1298
+ /**
1299
+ * Get subscription status objects from StoreKit 2 (iOS 15+).
1300
+ * See: https://www.openiap.dev/docs/apis/ios/subscription-status-ios
1301
+ */
1131
1302
  subscriptionStatusIOS: Promise<SubscriptionStatusIOS[]>;
1132
1303
  /**
1133
- * Validate a receipt for a specific product
1304
+ * Deprecated. Legacy App Store receipt validation use verifyPurchase instead.
1305
+ * See: https://www.openiap.dev/docs/apis/ios/validate-receipt-ios
1134
1306
  * @deprecated Use verifyPurchase
1135
1307
  */
1136
1308
  validateReceiptIOS: Promise<VerifyPurchaseResultIOS>;
@@ -1427,6 +1599,20 @@ export interface Subscription {
1427
1599
  purchaseError: PurchaseError;
1428
1600
  /** Fires when a purchase completes successfully or a pending purchase resolves */
1429
1601
  purchaseUpdated: Purchase;
1602
+ /**
1603
+ * Fires when an active subscription enters a billing-issue state that needs user action
1604
+ * (payment method failed, card expired, etc.). Cross-platform unification:
1605
+ *
1606
+ * - iOS 18+: delivered via StoreKit 2 `Message.Reason.billingIssue`.
1607
+ * - Android (Play flavor, Billing 8.1+): emitted when `isSuspended == true` is first detected
1608
+ * on a previously healthy subscription. Requires Google Play Billing Library 8.1.0 or newer.
1609
+ * - Android (Horizon flavor): NOT emitted. The Horizon Billing Compatibility SDK implements
1610
+ * the Play Billing 7.0 API surface which does not expose a suspended-subscription signal.
1611
+ *
1612
+ * Listeners should not assume the event will fire on every store. Direct users to the
1613
+ * platform subscription management UI (`deepLinkToSubscriptions`) to resolve the issue.
1614
+ */
1615
+ subscriptionBillingIssue: Purchase;
1430
1616
  /**
1431
1617
  * Fires when a user selects alternative billing in the User Choice Billing dialog (Android only)
1432
1618
  * Only triggered when the user selects alternative billing instead of Google Play billing
@@ -1565,6 +1751,7 @@ export interface SubscriptionProductReplacementParamsAndroid {
1565
1751
  * Available in Google Play Billing Library 8.1.0+
1566
1752
  */
1567
1753
  export type SubscriptionReplacementModeAndroid = 'unknown-replacement-mode' | 'with-time-proration' | 'charge-prorated-price' | 'charge-full-price' | 'without-proration' | 'deferred' | 'keep-existing';
1754
+ export type SubscriptionState = 'active' | 'expired' | 'in-billing-retry' | 'in-grace-period' | 'paused' | 'refunded' | 'revoked' | 'unknown';
1568
1755
  export interface SubscriptionStatusIOS {
1569
1756
  renewalInfo?: (RenewalInfoIOS | null);
1570
1757
  state: string;
@@ -1711,6 +1898,62 @@ export interface VerifyPurchaseWithProviderResult {
1711
1898
  provider: PurchaseVerificationProvider;
1712
1899
  }
1713
1900
  export type VoidResult = void;
1901
+ export type WebhookCancellationReason = 'billing-error' | 'other' | 'price-increase-declined' | 'product-unavailable' | 'refunded' | 'user-canceled';
1902
+ export interface WebhookEvent {
1903
+ /** Reason for cancellation, when applicable. */
1904
+ cancellationReason?: (WebhookCancellationReason | null);
1905
+ /** Localized currency code (ISO 4217) at event time, when available. */
1906
+ currency?: (string | null);
1907
+ environment: WebhookEventEnvironment;
1908
+ /** When the current subscription period ends. Epoch milliseconds. */
1909
+ expiresAt?: (number | null);
1910
+ /**
1911
+ * Stable identifier suitable for idempotency. Derived from the source notification
1912
+ * UUID where the store provides one (ASN v2 `notificationUUID`, RTDN message id);
1913
+ * otherwise hashed from the canonicalized payload.
1914
+ */
1915
+ id: string;
1916
+ /** Time the underlying event occurred at the store. Epoch milliseconds. */
1917
+ occurredAt: number;
1918
+ platform: IapPlatform;
1919
+ /**
1920
+ * Price in micros (1/1,000,000 of the currency unit) at event time, when available.
1921
+ * Matches Google Play's `priceAmountMicros` convention; iOS values are converted.
1922
+ */
1923
+ priceAmountMicros?: (number | null);
1924
+ /** Product the event pertains to. May be null for account-level events. */
1925
+ productId?: (string | null);
1926
+ /** kit project that owns the subscription / purchase this event refers to. */
1927
+ projectId: string;
1928
+ /**
1929
+ * Cross-platform purchase identity used to correlate this event with an existing
1930
+ * purchase record. iOS: `originalTransactionId`. Android: `purchaseToken`.
1931
+ * Null for `TestNotification` events (Apple ASN v2 / Google RTDN test
1932
+ * payloads carry no transaction); always present for every other event type.
1933
+ */
1934
+ purchaseToken?: (string | null);
1935
+ /**
1936
+ * Original signed payload from the store. ASN v2 events expose the JWS string;
1937
+ * RTDN events expose the base64-decoded Pub/Sub message JSON. Provided so that
1938
+ * consumers can independently verify or extract platform-specific fields. kit
1939
+ * always validates this payload before emitting the event.
1940
+ */
1941
+ rawSignedPayload?: (string | null);
1942
+ /** Time kit ingested and normalized this event. Epoch milliseconds. */
1943
+ receivedAt: number;
1944
+ /** When auto-renewal will charge again. Epoch milliseconds. */
1945
+ renewsAt?: (number | null);
1946
+ source: WebhookEventSource;
1947
+ /**
1948
+ * Normalized subscription state at the time of event, when the event refers to
1949
+ * a subscription. Null for one-time purchase events.
1950
+ */
1951
+ subscriptionState?: (SubscriptionState | null);
1952
+ type: WebhookEventType;
1953
+ }
1954
+ export type WebhookEventEnvironment = 'production' | 'sandbox' | 'xcode';
1955
+ export type WebhookEventSource = 'apple-app-store-server-notifications-v2' | 'google-play-real-time-developer-notifications' | 'meta-horizon-reconciler';
1956
+ export type WebhookEventType = 'purchase-consumption-request' | 'purchase-refunded' | 'subscription-canceled' | 'subscription-expired' | 'subscription-in-billing-retry' | 'subscription-in-grace-period' | 'subscription-paused' | 'subscription-price-change' | 'subscription-product-changed' | 'subscription-recovered' | 'subscription-renewed' | 'subscription-resumed' | 'subscription-revoked' | 'subscription-started' | 'subscription-uncanceled' | 'test-notification';
1714
1957
  /**
1715
1958
  * Win-back offer input for iOS 18+ (StoreKit 2)
1716
1959
  * Win-back offers are used to re-engage churned subscribers.
@@ -1726,6 +1969,7 @@ export type QueryArgsMap = {
1726
1969
  currentEntitlementIOS: QueryCurrentEntitlementIosArgs;
1727
1970
  fetchProducts: QueryFetchProductsArgs;
1728
1971
  getActiveSubscriptions: QueryGetActiveSubscriptionsArgs;
1972
+ getAllTransactionsIOS: never;
1729
1973
  getAppTransactionIOS: never;
1730
1974
  getAvailablePurchases: QueryGetAvailablePurchasesArgs;
1731
1975
  getExternalPurchaseCustomLinkTokenIOS: QueryGetExternalPurchaseCustomLinkTokenIosArgs;
@@ -1784,6 +2028,7 @@ export type SubscriptionArgsMap = {
1784
2028
  promotedProductIOS: never;
1785
2029
  purchaseError: never;
1786
2030
  purchaseUpdated: never;
2031
+ subscriptionBillingIssue: never;
1787
2032
  userChoiceBillingAndroid: never;
1788
2033
  };
1789
2034
  export type SubscriptionField<K extends keyof Subscription> = SubscriptionArgsMap[K] extends never ? () => NonNullable<Subscription[K]> : undefined extends SubscriptionArgsMap[K] ? (args?: SubscriptionArgsMap[K]) => NonNullable<Subscription[K]> : (args: SubscriptionArgsMap[K]) => NonNullable<Subscription[K]>;