react-native-iap 14.4.10 → 14.4.12

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 (94) hide show
  1. package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +195 -12
  2. package/ios/HybridRnIap.swift +115 -2
  3. package/ios/RnIapHelper.swift +32 -1
  4. package/lib/module/hooks/useIAP.js +24 -3
  5. package/lib/module/hooks/useIAP.js.map +1 -1
  6. package/lib/module/index.js +275 -2
  7. package/lib/module/index.js.map +1 -1
  8. package/lib/module/types.js +18 -0
  9. package/lib/module/types.js.map +1 -1
  10. package/lib/module/utils/type-bridge.js +39 -1
  11. package/lib/module/utils/type-bridge.js.map +1 -1
  12. package/lib/typescript/plugin/src/withIAP.d.ts +27 -0
  13. package/lib/typescript/plugin/src/withIAP.d.ts.map +1 -1
  14. package/lib/typescript/src/hooks/useIAP.d.ts +6 -1
  15. package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -1
  16. package/lib/typescript/src/index.d.ts +133 -0
  17. package/lib/typescript/src/index.d.ts.map +1 -1
  18. package/lib/typescript/src/specs/RnIap.nitro.d.ts +101 -2
  19. package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
  20. package/lib/typescript/src/types.d.ts +116 -13
  21. package/lib/typescript/src/types.d.ts.map +1 -1
  22. package/lib/typescript/src/utils/type-bridge.d.ts.map +1 -1
  23. package/nitrogen/generated/android/NitroIapOnLoad.cpp +2 -0
  24. package/nitrogen/generated/android/c++/JAlternativeBillingModeAndroid.hpp +62 -0
  25. package/nitrogen/generated/android/c++/JExternalPurchaseLinkResultIOS.hpp +58 -0
  26. package/nitrogen/generated/android/c++/JExternalPurchaseNoticeAction.hpp +59 -0
  27. package/nitrogen/generated/android/c++/JExternalPurchaseNoticeResultIOS.hpp +60 -0
  28. package/nitrogen/generated/android/c++/JFunc_void_NitroProduct.hpp +2 -0
  29. package/nitrogen/generated/android/c++/JFunc_void_UserChoiceBillingDetails.hpp +78 -0
  30. package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +136 -3
  31. package/nitrogen/generated/android/c++/JHybridRnIapSpec.hpp +9 -1
  32. package/nitrogen/generated/android/c++/JInitConnectionConfig.hpp +55 -0
  33. package/nitrogen/generated/android/c++/JNitroOneTimePurchaseOfferDetail.hpp +61 -0
  34. package/nitrogen/generated/android/c++/JNitroProduct.hpp +16 -2
  35. package/nitrogen/generated/android/c++/JNitroPurchase.hpp +74 -2
  36. package/nitrogen/generated/android/c++/JPurchaseAndroid.hpp +4 -0
  37. package/nitrogen/generated/android/c++/JPurchaseIOS.hpp +4 -0
  38. package/nitrogen/generated/android/c++/JUserChoiceBillingDetails.hpp +75 -0
  39. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/AlternativeBillingModeAndroid.kt +22 -0
  40. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/ExternalPurchaseLinkResultIOS.kt +32 -0
  41. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/ExternalPurchaseNoticeAction.kt +21 -0
  42. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/ExternalPurchaseNoticeResultIOS.kt +32 -0
  43. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Func_void_UserChoiceBillingDetails.kt +81 -0
  44. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +43 -1
  45. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/InitConnectionConfig.kt +29 -0
  46. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroOneTimePurchaseOfferDetail.kt +35 -0
  47. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroProduct.kt +10 -1
  48. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroPurchase.kt +55 -1
  49. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseAndroid.kt +3 -0
  50. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseIOS.kt +3 -0
  51. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/UserChoiceBillingDetails.kt +32 -0
  52. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.cpp +24 -0
  53. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +174 -0
  54. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +21 -0
  55. package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +84 -3
  56. package/nitrogen/generated/ios/swift/AlternativeBillingModeAndroid.swift +44 -0
  57. package/nitrogen/generated/ios/swift/ExternalPurchaseLinkResultIOS.swift +65 -0
  58. package/nitrogen/generated/ios/swift/ExternalPurchaseNoticeAction.swift +40 -0
  59. package/nitrogen/generated/ios/swift/ExternalPurchaseNoticeResultIOS.swift +65 -0
  60. package/nitrogen/generated/ios/swift/Func_void_ExternalPurchaseLinkResultIOS.swift +47 -0
  61. package/nitrogen/generated/ios/swift/Func_void_ExternalPurchaseNoticeResultIOS.swift +47 -0
  62. package/nitrogen/generated/ios/swift/Func_void_UserChoiceBillingDetails.swift +47 -0
  63. package/nitrogen/generated/ios/swift/HybridRnIapSpec.swift +9 -1
  64. package/nitrogen/generated/ios/swift/HybridRnIapSpec_cxx.swift +168 -2
  65. package/nitrogen/generated/ios/swift/InitConnectionConfig.swift +47 -0
  66. package/nitrogen/generated/ios/swift/NitroOneTimePurchaseOfferDetail.swift +57 -0
  67. package/nitrogen/generated/ios/swift/NitroProduct.swift +91 -1
  68. package/nitrogen/generated/ios/swift/NitroPurchase.swift +520 -1
  69. package/nitrogen/generated/ios/swift/PurchaseAndroid.swift +31 -1
  70. package/nitrogen/generated/ios/swift/PurchaseIOS.swift +31 -1
  71. package/nitrogen/generated/ios/swift/UserChoiceBillingDetails.swift +58 -0
  72. package/nitrogen/generated/shared/c++/AlternativeBillingModeAndroid.hpp +80 -0
  73. package/nitrogen/generated/shared/c++/ExternalPurchaseLinkResultIOS.hpp +72 -0
  74. package/nitrogen/generated/shared/c++/ExternalPurchaseNoticeAction.hpp +76 -0
  75. package/nitrogen/generated/shared/c++/ExternalPurchaseNoticeResultIOS.hpp +74 -0
  76. package/nitrogen/generated/shared/c++/HybridRnIapSpec.cpp +8 -0
  77. package/nitrogen/generated/shared/c++/HybridRnIapSpec.hpp +22 -2
  78. package/nitrogen/generated/shared/c++/InitConnectionConfig.hpp +69 -0
  79. package/nitrogen/generated/shared/c++/NitroOneTimePurchaseOfferDetail.hpp +75 -0
  80. package/nitrogen/generated/shared/c++/NitroProduct.hpp +17 -2
  81. package/nitrogen/generated/shared/c++/NitroPurchase.hpp +74 -2
  82. package/nitrogen/generated/shared/c++/PurchaseAndroid.hpp +5 -1
  83. package/nitrogen/generated/shared/c++/PurchaseIOS.hpp +5 -1
  84. package/nitrogen/generated/shared/c++/UserChoiceBillingDetails.hpp +72 -0
  85. package/openiap-versions.json +3 -3
  86. package/package.json +3 -3
  87. package/plugin/build/withIAP.d.ts +27 -0
  88. package/plugin/build/withIAP.js +91 -1
  89. package/plugin/src/withIAP.ts +162 -0
  90. package/src/hooks/useIAP.ts +47 -1
  91. package/src/index.ts +313 -2
  92. package/src/specs/RnIap.nitro.ts +131 -1
  93. package/src/types.ts +124 -13
  94. package/src/utils/type-bridge.ts +76 -16
@@ -0,0 +1,58 @@
1
+ ///
2
+ /// UserChoiceBillingDetails.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * Represents an instance of `UserChoiceBillingDetails`, backed by a C++ struct.
12
+ */
13
+ public typealias UserChoiceBillingDetails = margelo.nitro.iap.UserChoiceBillingDetails
14
+
15
+ public extension UserChoiceBillingDetails {
16
+ private typealias bridge = margelo.nitro.iap.bridge.swift
17
+
18
+ /**
19
+ * Create a new instance of `UserChoiceBillingDetails`.
20
+ */
21
+ init(externalTransactionToken: String, products: [String]) {
22
+ self.init(std.string(externalTransactionToken), { () -> bridge.std__vector_std__string_ in
23
+ var __vector = bridge.create_std__vector_std__string_(products.count)
24
+ for __item in products {
25
+ __vector.push_back(std.string(__item))
26
+ }
27
+ return __vector
28
+ }())
29
+ }
30
+
31
+ var externalTransactionToken: String {
32
+ @inline(__always)
33
+ get {
34
+ return String(self.__externalTransactionToken)
35
+ }
36
+ @inline(__always)
37
+ set {
38
+ self.__externalTransactionToken = std.string(newValue)
39
+ }
40
+ }
41
+
42
+ var products: [String] {
43
+ @inline(__always)
44
+ get {
45
+ return self.__products.map({ __item in String(__item) })
46
+ }
47
+ @inline(__always)
48
+ set {
49
+ self.__products = { () -> bridge.std__vector_std__string_ in
50
+ var __vector = bridge.create_std__vector_std__string_(newValue.count)
51
+ for __item in newValue {
52
+ __vector.push_back(std.string(__item))
53
+ }
54
+ return __vector
55
+ }()
56
+ }
57
+ }
58
+ }
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// AlternativeBillingModeAndroid.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::iap {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (AlternativeBillingModeAndroid).
30
+ */
31
+ enum class AlternativeBillingModeAndroid {
32
+ NONE SWIFT_NAME(none) = 0,
33
+ USER_CHOICE SWIFT_NAME(userChoice) = 1,
34
+ ALTERNATIVE_ONLY SWIFT_NAME(alternativeOnly) = 2,
35
+ } CLOSED_ENUM;
36
+
37
+ } // namespace margelo::nitro::iap
38
+
39
+ namespace margelo::nitro {
40
+
41
+ // C++ AlternativeBillingModeAndroid <> JS AlternativeBillingModeAndroid (union)
42
+ template <>
43
+ struct JSIConverter<margelo::nitro::iap::AlternativeBillingModeAndroid> final {
44
+ static inline margelo::nitro::iap::AlternativeBillingModeAndroid fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
45
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
46
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
47
+ case hashString("none"): return margelo::nitro::iap::AlternativeBillingModeAndroid::NONE;
48
+ case hashString("user-choice"): return margelo::nitro::iap::AlternativeBillingModeAndroid::USER_CHOICE;
49
+ case hashString("alternative-only"): return margelo::nitro::iap::AlternativeBillingModeAndroid::ALTERNATIVE_ONLY;
50
+ default: [[unlikely]]
51
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum AlternativeBillingModeAndroid - invalid value!");
52
+ }
53
+ }
54
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::iap::AlternativeBillingModeAndroid arg) {
55
+ switch (arg) {
56
+ case margelo::nitro::iap::AlternativeBillingModeAndroid::NONE: return JSIConverter<std::string>::toJSI(runtime, "none");
57
+ case margelo::nitro::iap::AlternativeBillingModeAndroid::USER_CHOICE: return JSIConverter<std::string>::toJSI(runtime, "user-choice");
58
+ case margelo::nitro::iap::AlternativeBillingModeAndroid::ALTERNATIVE_ONLY: return JSIConverter<std::string>::toJSI(runtime, "alternative-only");
59
+ default: [[unlikely]]
60
+ throw std::invalid_argument("Cannot convert AlternativeBillingModeAndroid to JS - invalid value: "
61
+ + std::to_string(static_cast<int>(arg)) + "!");
62
+ }
63
+ }
64
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
65
+ if (!value.isString()) {
66
+ return false;
67
+ }
68
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
69
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
70
+ case hashString("none"):
71
+ case hashString("user-choice"):
72
+ case hashString("alternative-only"):
73
+ return true;
74
+ default:
75
+ return false;
76
+ }
77
+ }
78
+ };
79
+
80
+ } // namespace margelo::nitro
@@ -0,0 +1,72 @@
1
+ ///
2
+ /// ExternalPurchaseLinkResultIOS.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+
21
+
22
+
23
+ #include <string>
24
+ #include <optional>
25
+
26
+ namespace margelo::nitro::iap {
27
+
28
+ /**
29
+ * A struct which can be represented as a JavaScript object (ExternalPurchaseLinkResultIOS).
30
+ */
31
+ struct ExternalPurchaseLinkResultIOS {
32
+ public:
33
+ std::optional<std::string> error SWIFT_PRIVATE;
34
+ bool success SWIFT_PRIVATE;
35
+
36
+ public:
37
+ ExternalPurchaseLinkResultIOS() = default;
38
+ explicit ExternalPurchaseLinkResultIOS(std::optional<std::string> error, bool success): error(error), success(success) {}
39
+ };
40
+
41
+ } // namespace margelo::nitro::iap
42
+
43
+ namespace margelo::nitro {
44
+
45
+ // C++ ExternalPurchaseLinkResultIOS <> JS ExternalPurchaseLinkResultIOS (object)
46
+ template <>
47
+ struct JSIConverter<margelo::nitro::iap::ExternalPurchaseLinkResultIOS> final {
48
+ static inline margelo::nitro::iap::ExternalPurchaseLinkResultIOS fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
49
+ jsi::Object obj = arg.asObject(runtime);
50
+ return margelo::nitro::iap::ExternalPurchaseLinkResultIOS(
51
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "error")),
52
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "success"))
53
+ );
54
+ }
55
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::ExternalPurchaseLinkResultIOS& arg) {
56
+ jsi::Object obj(runtime);
57
+ obj.setProperty(runtime, "error", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.error));
58
+ obj.setProperty(runtime, "success", JSIConverter<bool>::toJSI(runtime, arg.success));
59
+ return obj;
60
+ }
61
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
62
+ if (!value.isObject()) {
63
+ return false;
64
+ }
65
+ jsi::Object obj = value.getObject(runtime);
66
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "error"))) return false;
67
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "success"))) return false;
68
+ return true;
69
+ }
70
+ };
71
+
72
+ } // namespace margelo::nitro
@@ -0,0 +1,76 @@
1
+ ///
2
+ /// ExternalPurchaseNoticeAction.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::iap {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (ExternalPurchaseNoticeAction).
30
+ */
31
+ enum class ExternalPurchaseNoticeAction {
32
+ CONTINUE SWIFT_NAME(continue) = 0,
33
+ DISMISSED SWIFT_NAME(dismissed) = 1,
34
+ } CLOSED_ENUM;
35
+
36
+ } // namespace margelo::nitro::iap
37
+
38
+ namespace margelo::nitro {
39
+
40
+ // C++ ExternalPurchaseNoticeAction <> JS ExternalPurchaseNoticeAction (union)
41
+ template <>
42
+ struct JSIConverter<margelo::nitro::iap::ExternalPurchaseNoticeAction> final {
43
+ static inline margelo::nitro::iap::ExternalPurchaseNoticeAction fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
44
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
45
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
46
+ case hashString("continue"): return margelo::nitro::iap::ExternalPurchaseNoticeAction::CONTINUE;
47
+ case hashString("dismissed"): return margelo::nitro::iap::ExternalPurchaseNoticeAction::DISMISSED;
48
+ default: [[unlikely]]
49
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum ExternalPurchaseNoticeAction - invalid value!");
50
+ }
51
+ }
52
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::iap::ExternalPurchaseNoticeAction arg) {
53
+ switch (arg) {
54
+ case margelo::nitro::iap::ExternalPurchaseNoticeAction::CONTINUE: return JSIConverter<std::string>::toJSI(runtime, "continue");
55
+ case margelo::nitro::iap::ExternalPurchaseNoticeAction::DISMISSED: return JSIConverter<std::string>::toJSI(runtime, "dismissed");
56
+ default: [[unlikely]]
57
+ throw std::invalid_argument("Cannot convert ExternalPurchaseNoticeAction to JS - invalid value: "
58
+ + std::to_string(static_cast<int>(arg)) + "!");
59
+ }
60
+ }
61
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
62
+ if (!value.isString()) {
63
+ return false;
64
+ }
65
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
66
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
67
+ case hashString("continue"):
68
+ case hashString("dismissed"):
69
+ return true;
70
+ default:
71
+ return false;
72
+ }
73
+ }
74
+ };
75
+
76
+ } // namespace margelo::nitro
@@ -0,0 +1,74 @@
1
+ ///
2
+ /// ExternalPurchaseNoticeResultIOS.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+
21
+ // Forward declaration of `ExternalPurchaseNoticeAction` to properly resolve imports.
22
+ namespace margelo::nitro::iap { enum class ExternalPurchaseNoticeAction; }
23
+
24
+ #include <string>
25
+ #include <optional>
26
+ #include "ExternalPurchaseNoticeAction.hpp"
27
+
28
+ namespace margelo::nitro::iap {
29
+
30
+ /**
31
+ * A struct which can be represented as a JavaScript object (ExternalPurchaseNoticeResultIOS).
32
+ */
33
+ struct ExternalPurchaseNoticeResultIOS {
34
+ public:
35
+ std::optional<std::string> error SWIFT_PRIVATE;
36
+ ExternalPurchaseNoticeAction result SWIFT_PRIVATE;
37
+
38
+ public:
39
+ ExternalPurchaseNoticeResultIOS() = default;
40
+ explicit ExternalPurchaseNoticeResultIOS(std::optional<std::string> error, ExternalPurchaseNoticeAction result): error(error), result(result) {}
41
+ };
42
+
43
+ } // namespace margelo::nitro::iap
44
+
45
+ namespace margelo::nitro {
46
+
47
+ // C++ ExternalPurchaseNoticeResultIOS <> JS ExternalPurchaseNoticeResultIOS (object)
48
+ template <>
49
+ struct JSIConverter<margelo::nitro::iap::ExternalPurchaseNoticeResultIOS> final {
50
+ static inline margelo::nitro::iap::ExternalPurchaseNoticeResultIOS fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
51
+ jsi::Object obj = arg.asObject(runtime);
52
+ return margelo::nitro::iap::ExternalPurchaseNoticeResultIOS(
53
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "error")),
54
+ JSIConverter<margelo::nitro::iap::ExternalPurchaseNoticeAction>::fromJSI(runtime, obj.getProperty(runtime, "result"))
55
+ );
56
+ }
57
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::ExternalPurchaseNoticeResultIOS& arg) {
58
+ jsi::Object obj(runtime);
59
+ obj.setProperty(runtime, "error", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.error));
60
+ obj.setProperty(runtime, "result", JSIConverter<margelo::nitro::iap::ExternalPurchaseNoticeAction>::toJSI(runtime, arg.result));
61
+ return obj;
62
+ }
63
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
64
+ if (!value.isObject()) {
65
+ return false;
66
+ }
67
+ jsi::Object obj = value.getObject(runtime);
68
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "error"))) return false;
69
+ if (!JSIConverter<margelo::nitro::iap::ExternalPurchaseNoticeAction>::canConvert(runtime, obj.getProperty(runtime, "result"))) return false;
70
+ return true;
71
+ }
72
+ };
73
+
74
+ } // namespace margelo::nitro
@@ -50,6 +50,14 @@ namespace margelo::nitro::iap {
50
50
  prototype.registerHybridMethod("validateReceipt", &HybridRnIapSpec::validateReceipt);
51
51
  prototype.registerHybridMethod("getStorefront", &HybridRnIapSpec::getStorefront);
52
52
  prototype.registerHybridMethod("deepLinkToSubscriptionsAndroid", &HybridRnIapSpec::deepLinkToSubscriptionsAndroid);
53
+ prototype.registerHybridMethod("checkAlternativeBillingAvailabilityAndroid", &HybridRnIapSpec::checkAlternativeBillingAvailabilityAndroid);
54
+ prototype.registerHybridMethod("showAlternativeBillingDialogAndroid", &HybridRnIapSpec::showAlternativeBillingDialogAndroid);
55
+ prototype.registerHybridMethod("createAlternativeBillingTokenAndroid", &HybridRnIapSpec::createAlternativeBillingTokenAndroid);
56
+ prototype.registerHybridMethod("addUserChoiceBillingListenerAndroid", &HybridRnIapSpec::addUserChoiceBillingListenerAndroid);
57
+ prototype.registerHybridMethod("removeUserChoiceBillingListenerAndroid", &HybridRnIapSpec::removeUserChoiceBillingListenerAndroid);
58
+ prototype.registerHybridMethod("canPresentExternalPurchaseNoticeIOS", &HybridRnIapSpec::canPresentExternalPurchaseNoticeIOS);
59
+ prototype.registerHybridMethod("presentExternalPurchaseNoticeSheetIOS", &HybridRnIapSpec::presentExternalPurchaseNoticeSheetIOS);
60
+ prototype.registerHybridMethod("presentExternalPurchaseLinkIOS", &HybridRnIapSpec::presentExternalPurchaseLinkIOS);
53
61
  });
54
62
  }
55
63
 
@@ -13,6 +13,8 @@
13
13
  #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
14
  #endif
15
15
 
16
+ // Forward declaration of `InitConnectionConfig` to properly resolve imports.
17
+ namespace margelo::nitro::iap { struct InitConnectionConfig; }
16
18
  // Forward declaration of `NitroProduct` to properly resolve imports.
17
19
  namespace margelo::nitro::iap { struct NitroProduct; }
18
20
  // Forward declaration of `PurchaseAndroid` to properly resolve imports.
@@ -39,15 +41,22 @@ namespace margelo::nitro::iap { struct NitroReceiptValidationResultAndroid; }
39
41
  namespace margelo::nitro::iap { struct NitroReceiptValidationParams; }
40
42
  // Forward declaration of `NitroDeepLinkOptionsAndroid` to properly resolve imports.
41
43
  namespace margelo::nitro::iap { struct NitroDeepLinkOptionsAndroid; }
44
+ // Forward declaration of `UserChoiceBillingDetails` to properly resolve imports.
45
+ namespace margelo::nitro::iap { struct UserChoiceBillingDetails; }
46
+ // Forward declaration of `ExternalPurchaseNoticeResultIOS` to properly resolve imports.
47
+ namespace margelo::nitro::iap { struct ExternalPurchaseNoticeResultIOS; }
48
+ // Forward declaration of `ExternalPurchaseLinkResultIOS` to properly resolve imports.
49
+ namespace margelo::nitro::iap { struct ExternalPurchaseLinkResultIOS; }
42
50
 
43
51
  #include <NitroModules/Promise.hpp>
52
+ #include "InitConnectionConfig.hpp"
53
+ #include <optional>
44
54
  #include "NitroProduct.hpp"
45
55
  #include <vector>
46
56
  #include <string>
47
57
  #include "PurchaseAndroid.hpp"
48
58
  #include "PurchaseIOS.hpp"
49
59
  #include <variant>
50
- #include <optional>
51
60
  #include "NitroPurchaseRequest.hpp"
52
61
  #include "NitroPurchase.hpp"
53
62
  #include "NitroAvailablePurchasesOptions.hpp"
@@ -59,6 +68,9 @@ namespace margelo::nitro::iap { struct NitroDeepLinkOptionsAndroid; }
59
68
  #include "NitroReceiptValidationResultAndroid.hpp"
60
69
  #include "NitroReceiptValidationParams.hpp"
61
70
  #include "NitroDeepLinkOptionsAndroid.hpp"
71
+ #include "UserChoiceBillingDetails.hpp"
72
+ #include "ExternalPurchaseNoticeResultIOS.hpp"
73
+ #include "ExternalPurchaseLinkResultIOS.hpp"
62
74
 
63
75
  namespace margelo::nitro::iap {
64
76
 
@@ -91,7 +103,7 @@ namespace margelo::nitro::iap {
91
103
 
92
104
  public:
93
105
  // Methods
94
- virtual std::shared_ptr<Promise<bool>> initConnection() = 0;
106
+ virtual std::shared_ptr<Promise<bool>> initConnection(const std::optional<InitConnectionConfig>& config) = 0;
95
107
  virtual std::shared_ptr<Promise<bool>> endConnection() = 0;
96
108
  virtual std::shared_ptr<Promise<std::vector<NitroProduct>>> fetchProducts(const std::vector<std::string>& skus, const std::string& type) = 0;
97
109
  virtual std::shared_ptr<Promise<std::optional<std::variant<PurchaseAndroid, PurchaseIOS, std::vector<std::variant<PurchaseAndroid, PurchaseIOS>>>>>> requestPurchase(const NitroPurchaseRequest& request) = 0;
@@ -127,6 +139,14 @@ namespace margelo::nitro::iap {
127
139
  virtual std::shared_ptr<Promise<std::variant<NitroReceiptValidationResultIOS, NitroReceiptValidationResultAndroid>>> validateReceipt(const NitroReceiptValidationParams& params) = 0;
128
140
  virtual std::shared_ptr<Promise<std::string>> getStorefront() = 0;
129
141
  virtual std::shared_ptr<Promise<void>> deepLinkToSubscriptionsAndroid(const NitroDeepLinkOptionsAndroid& options) = 0;
142
+ virtual std::shared_ptr<Promise<bool>> checkAlternativeBillingAvailabilityAndroid() = 0;
143
+ virtual std::shared_ptr<Promise<bool>> showAlternativeBillingDialogAndroid() = 0;
144
+ virtual std::shared_ptr<Promise<std::optional<std::string>>> createAlternativeBillingTokenAndroid(const std::optional<std::string>& sku) = 0;
145
+ virtual void addUserChoiceBillingListenerAndroid(const std::function<void(const UserChoiceBillingDetails& /* details */)>& listener) = 0;
146
+ virtual void removeUserChoiceBillingListenerAndroid(const std::function<void(const UserChoiceBillingDetails& /* details */)>& listener) = 0;
147
+ virtual std::shared_ptr<Promise<bool>> canPresentExternalPurchaseNoticeIOS() = 0;
148
+ virtual std::shared_ptr<Promise<ExternalPurchaseNoticeResultIOS>> presentExternalPurchaseNoticeSheetIOS() = 0;
149
+ virtual std::shared_ptr<Promise<ExternalPurchaseLinkResultIOS>> presentExternalPurchaseLinkIOS(const std::string& url) = 0;
130
150
 
131
151
  protected:
132
152
  // Hybrid Setup
@@ -0,0 +1,69 @@
1
+ ///
2
+ /// InitConnectionConfig.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+
21
+ // Forward declaration of `AlternativeBillingModeAndroid` to properly resolve imports.
22
+ namespace margelo::nitro::iap { enum class AlternativeBillingModeAndroid; }
23
+
24
+ #include "AlternativeBillingModeAndroid.hpp"
25
+ #include <optional>
26
+
27
+ namespace margelo::nitro::iap {
28
+
29
+ /**
30
+ * A struct which can be represented as a JavaScript object (InitConnectionConfig).
31
+ */
32
+ struct InitConnectionConfig {
33
+ public:
34
+ std::optional<AlternativeBillingModeAndroid> alternativeBillingModeAndroid SWIFT_PRIVATE;
35
+
36
+ public:
37
+ InitConnectionConfig() = default;
38
+ explicit InitConnectionConfig(std::optional<AlternativeBillingModeAndroid> alternativeBillingModeAndroid): alternativeBillingModeAndroid(alternativeBillingModeAndroid) {}
39
+ };
40
+
41
+ } // namespace margelo::nitro::iap
42
+
43
+ namespace margelo::nitro {
44
+
45
+ // C++ InitConnectionConfig <> JS InitConnectionConfig (object)
46
+ template <>
47
+ struct JSIConverter<margelo::nitro::iap::InitConnectionConfig> final {
48
+ static inline margelo::nitro::iap::InitConnectionConfig fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
49
+ jsi::Object obj = arg.asObject(runtime);
50
+ return margelo::nitro::iap::InitConnectionConfig(
51
+ JSIConverter<std::optional<margelo::nitro::iap::AlternativeBillingModeAndroid>>::fromJSI(runtime, obj.getProperty(runtime, "alternativeBillingModeAndroid"))
52
+ );
53
+ }
54
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::InitConnectionConfig& arg) {
55
+ jsi::Object obj(runtime);
56
+ obj.setProperty(runtime, "alternativeBillingModeAndroid", JSIConverter<std::optional<margelo::nitro::iap::AlternativeBillingModeAndroid>>::toJSI(runtime, arg.alternativeBillingModeAndroid));
57
+ return obj;
58
+ }
59
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
60
+ if (!value.isObject()) {
61
+ return false;
62
+ }
63
+ jsi::Object obj = value.getObject(runtime);
64
+ if (!JSIConverter<std::optional<margelo::nitro::iap::AlternativeBillingModeAndroid>>::canConvert(runtime, obj.getProperty(runtime, "alternativeBillingModeAndroid"))) return false;
65
+ return true;
66
+ }
67
+ };
68
+
69
+ } // namespace margelo::nitro
@@ -0,0 +1,75 @@
1
+ ///
2
+ /// NitroOneTimePurchaseOfferDetail.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2025 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+
21
+
22
+
23
+ #include <string>
24
+
25
+ namespace margelo::nitro::iap {
26
+
27
+ /**
28
+ * A struct which can be represented as a JavaScript object (NitroOneTimePurchaseOfferDetail).
29
+ */
30
+ struct NitroOneTimePurchaseOfferDetail {
31
+ public:
32
+ std::string formattedPrice SWIFT_PRIVATE;
33
+ std::string priceAmountMicros SWIFT_PRIVATE;
34
+ std::string priceCurrencyCode SWIFT_PRIVATE;
35
+
36
+ public:
37
+ NitroOneTimePurchaseOfferDetail() = default;
38
+ explicit NitroOneTimePurchaseOfferDetail(std::string formattedPrice, std::string priceAmountMicros, std::string priceCurrencyCode): formattedPrice(formattedPrice), priceAmountMicros(priceAmountMicros), priceCurrencyCode(priceCurrencyCode) {}
39
+ };
40
+
41
+ } // namespace margelo::nitro::iap
42
+
43
+ namespace margelo::nitro {
44
+
45
+ // C++ NitroOneTimePurchaseOfferDetail <> JS NitroOneTimePurchaseOfferDetail (object)
46
+ template <>
47
+ struct JSIConverter<margelo::nitro::iap::NitroOneTimePurchaseOfferDetail> final {
48
+ static inline margelo::nitro::iap::NitroOneTimePurchaseOfferDetail fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
49
+ jsi::Object obj = arg.asObject(runtime);
50
+ return margelo::nitro::iap::NitroOneTimePurchaseOfferDetail(
51
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "formattedPrice")),
52
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "priceAmountMicros")),
53
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "priceCurrencyCode"))
54
+ );
55
+ }
56
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::NitroOneTimePurchaseOfferDetail& arg) {
57
+ jsi::Object obj(runtime);
58
+ obj.setProperty(runtime, "formattedPrice", JSIConverter<std::string>::toJSI(runtime, arg.formattedPrice));
59
+ obj.setProperty(runtime, "priceAmountMicros", JSIConverter<std::string>::toJSI(runtime, arg.priceAmountMicros));
60
+ obj.setProperty(runtime, "priceCurrencyCode", JSIConverter<std::string>::toJSI(runtime, arg.priceCurrencyCode));
61
+ return obj;
62
+ }
63
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
64
+ if (!value.isObject()) {
65
+ return false;
66
+ }
67
+ jsi::Object obj = value.getObject(runtime);
68
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "formattedPrice"))) return false;
69
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "priceAmountMicros"))) return false;
70
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "priceCurrencyCode"))) return false;
71
+ return true;
72
+ }
73
+ };
74
+
75
+ } // namespace margelo::nitro