react-native-iap 14.3.4 → 14.3.5

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 (76) hide show
  1. package/NitroIap.podspec +1 -1
  2. package/README.md +1 -1
  3. package/android/CMakeLists.txt +4 -0
  4. package/android/build.gradle +2 -2
  5. package/android/src/main/cpp/cpp-adapter.cpp +8 -0
  6. package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +93 -51
  7. package/ios/HybridRnIap.swift +38 -30
  8. package/lib/module/hooks/useIAP.js +4 -4
  9. package/lib/module/hooks/useIAP.js.map +1 -1
  10. package/lib/module/index.js +54 -53
  11. package/lib/module/index.js.map +1 -1
  12. package/lib/module/types.js +1 -59
  13. package/lib/module/types.js.map +1 -1
  14. package/lib/module/utils/type-bridge.js +44 -33
  15. package/lib/module/utils/type-bridge.js.map +1 -1
  16. package/lib/typescript/src/hooks/useIAP.d.ts +4 -4
  17. package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -1
  18. package/lib/typescript/src/index.d.ts +8 -7
  19. package/lib/typescript/src/index.d.ts.map +1 -1
  20. package/lib/typescript/src/specs/RnIap.nitro.d.ts +2 -1
  21. package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
  22. package/lib/typescript/src/types.d.ts +159 -204
  23. package/lib/typescript/src/types.d.ts.map +1 -1
  24. package/lib/typescript/src/utils/type-bridge.d.ts.map +1 -1
  25. package/nitrogen/generated/android/NitroIap+autolinking.cmake +9 -4
  26. package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +32 -5
  27. package/nitrogen/generated/android/c++/JHybridRnIapSpec.hpp +1 -1
  28. package/nitrogen/generated/android/c++/JIapPlatform.hpp +59 -0
  29. package/nitrogen/generated/android/c++/JPurchase.cpp +26 -0
  30. package/nitrogen/generated/android/c++/JPurchase.hpp +80 -0
  31. package/nitrogen/generated/android/c++/JPurchaseAndroid.hpp +140 -0
  32. package/nitrogen/generated/android/c++/JPurchaseIOS.hpp +194 -0
  33. package/nitrogen/generated/android/c++/JPurchaseOfferIOS.hpp +61 -0
  34. package/nitrogen/generated/android/c++/JPurchaseState.hpp +71 -0
  35. package/nitrogen/generated/android/c++/JRequestPurchaseResult.hpp +89 -0
  36. package/nitrogen/generated/android/c++/JVariant_PurchaseAndroid_PurchaseIOS.cpp +26 -0
  37. package/nitrogen/generated/android/c++/JVariant_PurchaseAndroid_PurchaseIOS.hpp +80 -0
  38. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +1 -1
  39. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/IapPlatform.kt +21 -0
  40. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Purchase.kt +42 -0
  41. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseAndroid.kt +77 -0
  42. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseIOS.kt +116 -0
  43. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseOfferIOS.kt +35 -0
  44. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseState.kt +25 -0
  45. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/RequestPurchaseResult.kt +32 -0
  46. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Variant_PurchaseAndroid_PurchaseIOS.kt +42 -0
  47. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.cpp +13 -5
  48. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +186 -25
  49. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +18 -0
  50. package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +20 -2
  51. package/nitrogen/generated/ios/swift/Func_void_RequestPurchaseResult.swift +47 -0
  52. package/nitrogen/generated/ios/swift/HybridRnIapSpec.swift +1 -1
  53. package/nitrogen/generated/ios/swift/HybridRnIapSpec_cxx.swift +7 -7
  54. package/nitrogen/generated/ios/swift/IapPlatform.swift +40 -0
  55. package/nitrogen/generated/ios/swift/Purchase.swift +18 -0
  56. package/nitrogen/generated/ios/swift/PurchaseAndroid.swift +399 -0
  57. package/nitrogen/generated/ios/swift/PurchaseIOS.swift +768 -0
  58. package/nitrogen/generated/ios/swift/PurchaseOfferIOS.swift +57 -0
  59. package/nitrogen/generated/ios/swift/PurchaseState.swift +56 -0
  60. package/nitrogen/generated/ios/swift/RequestPurchaseResult.swift +148 -0
  61. package/nitrogen/generated/ios/swift/Variant_PurchaseAndroid_PurchaseIOS.swift +18 -0
  62. package/nitrogen/generated/shared/c++/HybridRnIapSpec.hpp +4 -1
  63. package/nitrogen/generated/shared/c++/IapPlatform.hpp +76 -0
  64. package/nitrogen/generated/shared/c++/PurchaseAndroid.hpp +138 -0
  65. package/nitrogen/generated/shared/c++/PurchaseIOS.hpp +193 -0
  66. package/nitrogen/generated/shared/c++/PurchaseOfferIOS.hpp +75 -0
  67. package/nitrogen/generated/shared/c++/PurchaseState.hpp +92 -0
  68. package/nitrogen/generated/shared/c++/RequestPurchaseResult.hpp +78 -0
  69. package/package.json +5 -4
  70. package/plugin/build/withIAP.js +1 -1
  71. package/plugin/src/withIAP.ts +1 -1
  72. package/src/hooks/useIAP.ts +14 -8
  73. package/src/index.ts +73 -74
  74. package/src/specs/RnIap.nitro.ts +4 -1
  75. package/src/types.ts +183 -216
  76. package/src/utils/type-bridge.ts +55 -43
@@ -0,0 +1,193 @@
1
+ ///
2
+ /// PurchaseIOS.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 `PurchaseOfferIOS` to properly resolve imports.
22
+ namespace margelo::nitro::iap { struct PurchaseOfferIOS; }
23
+ // Forward declaration of `IapPlatform` to properly resolve imports.
24
+ namespace margelo::nitro::iap { enum class IapPlatform; }
25
+ // Forward declaration of `PurchaseState` to properly resolve imports.
26
+ namespace margelo::nitro::iap { enum class PurchaseState; }
27
+
28
+ #include <string>
29
+ #include <optional>
30
+ #include <vector>
31
+ #include "PurchaseOfferIOS.hpp"
32
+ #include "IapPlatform.hpp"
33
+ #include "PurchaseState.hpp"
34
+
35
+ namespace margelo::nitro::iap {
36
+
37
+ /**
38
+ * A struct which can be represented as a JavaScript object (PurchaseIOS).
39
+ */
40
+ struct PurchaseIOS {
41
+ public:
42
+ std::optional<std::string> appAccountToken SWIFT_PRIVATE;
43
+ std::optional<std::string> appBundleIdIOS SWIFT_PRIVATE;
44
+ std::optional<std::string> countryCodeIOS SWIFT_PRIVATE;
45
+ std::optional<std::string> currencyCodeIOS SWIFT_PRIVATE;
46
+ std::optional<std::string> currencySymbolIOS SWIFT_PRIVATE;
47
+ std::optional<std::string> environmentIOS SWIFT_PRIVATE;
48
+ std::optional<double> expirationDateIOS SWIFT_PRIVATE;
49
+ std::string id SWIFT_PRIVATE;
50
+ std::optional<std::vector<std::string>> ids SWIFT_PRIVATE;
51
+ bool isAutoRenewing SWIFT_PRIVATE;
52
+ std::optional<bool> isUpgradedIOS SWIFT_PRIVATE;
53
+ std::optional<PurchaseOfferIOS> offerIOS SWIFT_PRIVATE;
54
+ std::optional<double> originalTransactionDateIOS SWIFT_PRIVATE;
55
+ std::optional<std::string> originalTransactionIdentifierIOS SWIFT_PRIVATE;
56
+ std::optional<std::string> ownershipTypeIOS SWIFT_PRIVATE;
57
+ IapPlatform platform SWIFT_PRIVATE;
58
+ std::string productId SWIFT_PRIVATE;
59
+ PurchaseState purchaseState SWIFT_PRIVATE;
60
+ std::optional<std::string> purchaseToken SWIFT_PRIVATE;
61
+ double quantity SWIFT_PRIVATE;
62
+ std::optional<double> quantityIOS SWIFT_PRIVATE;
63
+ std::optional<std::string> reasonIOS SWIFT_PRIVATE;
64
+ std::optional<std::string> reasonStringRepresentationIOS SWIFT_PRIVATE;
65
+ std::optional<double> revocationDateIOS SWIFT_PRIVATE;
66
+ std::optional<std::string> revocationReasonIOS SWIFT_PRIVATE;
67
+ std::optional<std::string> storefrontCountryCodeIOS SWIFT_PRIVATE;
68
+ std::optional<std::string> subscriptionGroupIdIOS SWIFT_PRIVATE;
69
+ double transactionDate SWIFT_PRIVATE;
70
+ std::optional<std::string> transactionReasonIOS SWIFT_PRIVATE;
71
+ std::optional<std::string> webOrderLineItemIdIOS SWIFT_PRIVATE;
72
+
73
+ public:
74
+ PurchaseIOS() = default;
75
+ explicit PurchaseIOS(std::optional<std::string> appAccountToken, std::optional<std::string> appBundleIdIOS, std::optional<std::string> countryCodeIOS, std::optional<std::string> currencyCodeIOS, std::optional<std::string> currencySymbolIOS, std::optional<std::string> environmentIOS, std::optional<double> expirationDateIOS, std::string id, std::optional<std::vector<std::string>> ids, bool isAutoRenewing, std::optional<bool> isUpgradedIOS, std::optional<PurchaseOfferIOS> offerIOS, std::optional<double> originalTransactionDateIOS, std::optional<std::string> originalTransactionIdentifierIOS, std::optional<std::string> ownershipTypeIOS, IapPlatform platform, std::string productId, PurchaseState purchaseState, std::optional<std::string> purchaseToken, double quantity, std::optional<double> quantityIOS, std::optional<std::string> reasonIOS, std::optional<std::string> reasonStringRepresentationIOS, std::optional<double> revocationDateIOS, std::optional<std::string> revocationReasonIOS, std::optional<std::string> storefrontCountryCodeIOS, std::optional<std::string> subscriptionGroupIdIOS, double transactionDate, std::optional<std::string> transactionReasonIOS, std::optional<std::string> webOrderLineItemIdIOS): appAccountToken(appAccountToken), appBundleIdIOS(appBundleIdIOS), countryCodeIOS(countryCodeIOS), currencyCodeIOS(currencyCodeIOS), currencySymbolIOS(currencySymbolIOS), environmentIOS(environmentIOS), expirationDateIOS(expirationDateIOS), id(id), ids(ids), isAutoRenewing(isAutoRenewing), isUpgradedIOS(isUpgradedIOS), offerIOS(offerIOS), originalTransactionDateIOS(originalTransactionDateIOS), originalTransactionIdentifierIOS(originalTransactionIdentifierIOS), ownershipTypeIOS(ownershipTypeIOS), platform(platform), productId(productId), purchaseState(purchaseState), purchaseToken(purchaseToken), quantity(quantity), quantityIOS(quantityIOS), reasonIOS(reasonIOS), reasonStringRepresentationIOS(reasonStringRepresentationIOS), revocationDateIOS(revocationDateIOS), revocationReasonIOS(revocationReasonIOS), storefrontCountryCodeIOS(storefrontCountryCodeIOS), subscriptionGroupIdIOS(subscriptionGroupIdIOS), transactionDate(transactionDate), transactionReasonIOS(transactionReasonIOS), webOrderLineItemIdIOS(webOrderLineItemIdIOS) {}
76
+ };
77
+
78
+ } // namespace margelo::nitro::iap
79
+
80
+ namespace margelo::nitro {
81
+
82
+ // C++ PurchaseIOS <> JS PurchaseIOS (object)
83
+ template <>
84
+ struct JSIConverter<margelo::nitro::iap::PurchaseIOS> final {
85
+ static inline margelo::nitro::iap::PurchaseIOS fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
86
+ jsi::Object obj = arg.asObject(runtime);
87
+ return margelo::nitro::iap::PurchaseIOS(
88
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "appAccountToken")),
89
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "appBundleIdIOS")),
90
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "countryCodeIOS")),
91
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "currencyCodeIOS")),
92
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "currencySymbolIOS")),
93
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "environmentIOS")),
94
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "expirationDateIOS")),
95
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "id")),
96
+ JSIConverter<std::optional<std::vector<std::string>>>::fromJSI(runtime, obj.getProperty(runtime, "ids")),
97
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "isAutoRenewing")),
98
+ JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, "isUpgradedIOS")),
99
+ JSIConverter<std::optional<margelo::nitro::iap::PurchaseOfferIOS>>::fromJSI(runtime, obj.getProperty(runtime, "offerIOS")),
100
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "originalTransactionDateIOS")),
101
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "originalTransactionIdentifierIOS")),
102
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "ownershipTypeIOS")),
103
+ JSIConverter<margelo::nitro::iap::IapPlatform>::fromJSI(runtime, obj.getProperty(runtime, "platform")),
104
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "productId")),
105
+ JSIConverter<margelo::nitro::iap::PurchaseState>::fromJSI(runtime, obj.getProperty(runtime, "purchaseState")),
106
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "purchaseToken")),
107
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "quantity")),
108
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "quantityIOS")),
109
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "reasonIOS")),
110
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "reasonStringRepresentationIOS")),
111
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "revocationDateIOS")),
112
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "revocationReasonIOS")),
113
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "storefrontCountryCodeIOS")),
114
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "subscriptionGroupIdIOS")),
115
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "transactionDate")),
116
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "transactionReasonIOS")),
117
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "webOrderLineItemIdIOS"))
118
+ );
119
+ }
120
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::PurchaseIOS& arg) {
121
+ jsi::Object obj(runtime);
122
+ obj.setProperty(runtime, "appAccountToken", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.appAccountToken));
123
+ obj.setProperty(runtime, "appBundleIdIOS", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.appBundleIdIOS));
124
+ obj.setProperty(runtime, "countryCodeIOS", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.countryCodeIOS));
125
+ obj.setProperty(runtime, "currencyCodeIOS", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.currencyCodeIOS));
126
+ obj.setProperty(runtime, "currencySymbolIOS", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.currencySymbolIOS));
127
+ obj.setProperty(runtime, "environmentIOS", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.environmentIOS));
128
+ obj.setProperty(runtime, "expirationDateIOS", JSIConverter<std::optional<double>>::toJSI(runtime, arg.expirationDateIOS));
129
+ obj.setProperty(runtime, "id", JSIConverter<std::string>::toJSI(runtime, arg.id));
130
+ obj.setProperty(runtime, "ids", JSIConverter<std::optional<std::vector<std::string>>>::toJSI(runtime, arg.ids));
131
+ obj.setProperty(runtime, "isAutoRenewing", JSIConverter<bool>::toJSI(runtime, arg.isAutoRenewing));
132
+ obj.setProperty(runtime, "isUpgradedIOS", JSIConverter<std::optional<bool>>::toJSI(runtime, arg.isUpgradedIOS));
133
+ obj.setProperty(runtime, "offerIOS", JSIConverter<std::optional<margelo::nitro::iap::PurchaseOfferIOS>>::toJSI(runtime, arg.offerIOS));
134
+ obj.setProperty(runtime, "originalTransactionDateIOS", JSIConverter<std::optional<double>>::toJSI(runtime, arg.originalTransactionDateIOS));
135
+ obj.setProperty(runtime, "originalTransactionIdentifierIOS", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.originalTransactionIdentifierIOS));
136
+ obj.setProperty(runtime, "ownershipTypeIOS", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.ownershipTypeIOS));
137
+ obj.setProperty(runtime, "platform", JSIConverter<margelo::nitro::iap::IapPlatform>::toJSI(runtime, arg.platform));
138
+ obj.setProperty(runtime, "productId", JSIConverter<std::string>::toJSI(runtime, arg.productId));
139
+ obj.setProperty(runtime, "purchaseState", JSIConverter<margelo::nitro::iap::PurchaseState>::toJSI(runtime, arg.purchaseState));
140
+ obj.setProperty(runtime, "purchaseToken", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.purchaseToken));
141
+ obj.setProperty(runtime, "quantity", JSIConverter<double>::toJSI(runtime, arg.quantity));
142
+ obj.setProperty(runtime, "quantityIOS", JSIConverter<std::optional<double>>::toJSI(runtime, arg.quantityIOS));
143
+ obj.setProperty(runtime, "reasonIOS", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.reasonIOS));
144
+ obj.setProperty(runtime, "reasonStringRepresentationIOS", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.reasonStringRepresentationIOS));
145
+ obj.setProperty(runtime, "revocationDateIOS", JSIConverter<std::optional<double>>::toJSI(runtime, arg.revocationDateIOS));
146
+ obj.setProperty(runtime, "revocationReasonIOS", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.revocationReasonIOS));
147
+ obj.setProperty(runtime, "storefrontCountryCodeIOS", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.storefrontCountryCodeIOS));
148
+ obj.setProperty(runtime, "subscriptionGroupIdIOS", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.subscriptionGroupIdIOS));
149
+ obj.setProperty(runtime, "transactionDate", JSIConverter<double>::toJSI(runtime, arg.transactionDate));
150
+ obj.setProperty(runtime, "transactionReasonIOS", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.transactionReasonIOS));
151
+ obj.setProperty(runtime, "webOrderLineItemIdIOS", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.webOrderLineItemIdIOS));
152
+ return obj;
153
+ }
154
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
155
+ if (!value.isObject()) {
156
+ return false;
157
+ }
158
+ jsi::Object obj = value.getObject(runtime);
159
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "appAccountToken"))) return false;
160
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "appBundleIdIOS"))) return false;
161
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "countryCodeIOS"))) return false;
162
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "currencyCodeIOS"))) return false;
163
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "currencySymbolIOS"))) return false;
164
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "environmentIOS"))) return false;
165
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "expirationDateIOS"))) return false;
166
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "id"))) return false;
167
+ if (!JSIConverter<std::optional<std::vector<std::string>>>::canConvert(runtime, obj.getProperty(runtime, "ids"))) return false;
168
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "isAutoRenewing"))) return false;
169
+ if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, "isUpgradedIOS"))) return false;
170
+ if (!JSIConverter<std::optional<margelo::nitro::iap::PurchaseOfferIOS>>::canConvert(runtime, obj.getProperty(runtime, "offerIOS"))) return false;
171
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "originalTransactionDateIOS"))) return false;
172
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "originalTransactionIdentifierIOS"))) return false;
173
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "ownershipTypeIOS"))) return false;
174
+ if (!JSIConverter<margelo::nitro::iap::IapPlatform>::canConvert(runtime, obj.getProperty(runtime, "platform"))) return false;
175
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "productId"))) return false;
176
+ if (!JSIConverter<margelo::nitro::iap::PurchaseState>::canConvert(runtime, obj.getProperty(runtime, "purchaseState"))) return false;
177
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "purchaseToken"))) return false;
178
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "quantity"))) return false;
179
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "quantityIOS"))) return false;
180
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "reasonIOS"))) return false;
181
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "reasonStringRepresentationIOS"))) return false;
182
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "revocationDateIOS"))) return false;
183
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "revocationReasonIOS"))) return false;
184
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "storefrontCountryCodeIOS"))) return false;
185
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "subscriptionGroupIdIOS"))) return false;
186
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "transactionDate"))) return false;
187
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "transactionReasonIOS"))) return false;
188
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "webOrderLineItemIdIOS"))) return false;
189
+ return true;
190
+ }
191
+ };
192
+
193
+ } // namespace margelo::nitro
@@ -0,0 +1,75 @@
1
+ ///
2
+ /// PurchaseOfferIOS.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 (PurchaseOfferIOS).
29
+ */
30
+ struct PurchaseOfferIOS {
31
+ public:
32
+ std::string id SWIFT_PRIVATE;
33
+ std::string paymentMode SWIFT_PRIVATE;
34
+ std::string type SWIFT_PRIVATE;
35
+
36
+ public:
37
+ PurchaseOfferIOS() = default;
38
+ explicit PurchaseOfferIOS(std::string id, std::string paymentMode, std::string type): id(id), paymentMode(paymentMode), type(type) {}
39
+ };
40
+
41
+ } // namespace margelo::nitro::iap
42
+
43
+ namespace margelo::nitro {
44
+
45
+ // C++ PurchaseOfferIOS <> JS PurchaseOfferIOS (object)
46
+ template <>
47
+ struct JSIConverter<margelo::nitro::iap::PurchaseOfferIOS> final {
48
+ static inline margelo::nitro::iap::PurchaseOfferIOS fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
49
+ jsi::Object obj = arg.asObject(runtime);
50
+ return margelo::nitro::iap::PurchaseOfferIOS(
51
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "id")),
52
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "paymentMode")),
53
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "type"))
54
+ );
55
+ }
56
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::PurchaseOfferIOS& arg) {
57
+ jsi::Object obj(runtime);
58
+ obj.setProperty(runtime, "id", JSIConverter<std::string>::toJSI(runtime, arg.id));
59
+ obj.setProperty(runtime, "paymentMode", JSIConverter<std::string>::toJSI(runtime, arg.paymentMode));
60
+ obj.setProperty(runtime, "type", JSIConverter<std::string>::toJSI(runtime, arg.type));
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, "id"))) return false;
69
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "paymentMode"))) return false;
70
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "type"))) return false;
71
+ return true;
72
+ }
73
+ };
74
+
75
+ } // namespace margelo::nitro
@@ -0,0 +1,92 @@
1
+ ///
2
+ /// PurchaseState.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 (PurchaseState).
30
+ */
31
+ enum class PurchaseState {
32
+ DEFERRED SWIFT_NAME(deferred) = 0,
33
+ FAILED SWIFT_NAME(failed) = 1,
34
+ PENDING SWIFT_NAME(pending) = 2,
35
+ PURCHASED SWIFT_NAME(purchased) = 3,
36
+ RESTORED SWIFT_NAME(restored) = 4,
37
+ UNKNOWN SWIFT_NAME(unknown) = 5,
38
+ } CLOSED_ENUM;
39
+
40
+ } // namespace margelo::nitro::iap
41
+
42
+ namespace margelo::nitro {
43
+
44
+ // C++ PurchaseState <> JS PurchaseState (union)
45
+ template <>
46
+ struct JSIConverter<margelo::nitro::iap::PurchaseState> final {
47
+ static inline margelo::nitro::iap::PurchaseState fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
48
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
49
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
50
+ case hashString("deferred"): return margelo::nitro::iap::PurchaseState::DEFERRED;
51
+ case hashString("failed"): return margelo::nitro::iap::PurchaseState::FAILED;
52
+ case hashString("pending"): return margelo::nitro::iap::PurchaseState::PENDING;
53
+ case hashString("purchased"): return margelo::nitro::iap::PurchaseState::PURCHASED;
54
+ case hashString("restored"): return margelo::nitro::iap::PurchaseState::RESTORED;
55
+ case hashString("unknown"): return margelo::nitro::iap::PurchaseState::UNKNOWN;
56
+ default: [[unlikely]]
57
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum PurchaseState - invalid value!");
58
+ }
59
+ }
60
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::iap::PurchaseState arg) {
61
+ switch (arg) {
62
+ case margelo::nitro::iap::PurchaseState::DEFERRED: return JSIConverter<std::string>::toJSI(runtime, "deferred");
63
+ case margelo::nitro::iap::PurchaseState::FAILED: return JSIConverter<std::string>::toJSI(runtime, "failed");
64
+ case margelo::nitro::iap::PurchaseState::PENDING: return JSIConverter<std::string>::toJSI(runtime, "pending");
65
+ case margelo::nitro::iap::PurchaseState::PURCHASED: return JSIConverter<std::string>::toJSI(runtime, "purchased");
66
+ case margelo::nitro::iap::PurchaseState::RESTORED: return JSIConverter<std::string>::toJSI(runtime, "restored");
67
+ case margelo::nitro::iap::PurchaseState::UNKNOWN: return JSIConverter<std::string>::toJSI(runtime, "unknown");
68
+ default: [[unlikely]]
69
+ throw std::invalid_argument("Cannot convert PurchaseState to JS - invalid value: "
70
+ + std::to_string(static_cast<int>(arg)) + "!");
71
+ }
72
+ }
73
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
74
+ if (!value.isString()) {
75
+ return false;
76
+ }
77
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
78
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
79
+ case hashString("deferred"):
80
+ case hashString("failed"):
81
+ case hashString("pending"):
82
+ case hashString("purchased"):
83
+ case hashString("restored"):
84
+ case hashString("unknown"):
85
+ return true;
86
+ default:
87
+ return false;
88
+ }
89
+ }
90
+ };
91
+
92
+ } // namespace margelo::nitro
@@ -0,0 +1,78 @@
1
+ ///
2
+ /// RequestPurchaseResult.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 `PurchaseAndroid` to properly resolve imports.
22
+ namespace margelo::nitro::iap { struct PurchaseAndroid; }
23
+ // Forward declaration of `PurchaseIOS` to properly resolve imports.
24
+ namespace margelo::nitro::iap { struct PurchaseIOS; }
25
+
26
+ #include "PurchaseAndroid.hpp"
27
+ #include "PurchaseIOS.hpp"
28
+ #include <variant>
29
+ #include <optional>
30
+ #include <vector>
31
+
32
+ namespace margelo::nitro::iap {
33
+
34
+ /**
35
+ * A struct which can be represented as a JavaScript object (RequestPurchaseResult).
36
+ */
37
+ struct RequestPurchaseResult {
38
+ public:
39
+ std::optional<std::variant<PurchaseAndroid, PurchaseIOS>> purchase SWIFT_PRIVATE;
40
+ std::optional<std::vector<std::variant<PurchaseAndroid, PurchaseIOS>>> purchases SWIFT_PRIVATE;
41
+
42
+ public:
43
+ RequestPurchaseResult() = default;
44
+ explicit RequestPurchaseResult(std::optional<std::variant<PurchaseAndroid, PurchaseIOS>> purchase, std::optional<std::vector<std::variant<PurchaseAndroid, PurchaseIOS>>> purchases): purchase(purchase), purchases(purchases) {}
45
+ };
46
+
47
+ } // namespace margelo::nitro::iap
48
+
49
+ namespace margelo::nitro {
50
+
51
+ // C++ RequestPurchaseResult <> JS RequestPurchaseResult (object)
52
+ template <>
53
+ struct JSIConverter<margelo::nitro::iap::RequestPurchaseResult> final {
54
+ static inline margelo::nitro::iap::RequestPurchaseResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
55
+ jsi::Object obj = arg.asObject(runtime);
56
+ return margelo::nitro::iap::RequestPurchaseResult(
57
+ JSIConverter<std::optional<std::variant<margelo::nitro::iap::PurchaseAndroid, margelo::nitro::iap::PurchaseIOS>>>::fromJSI(runtime, obj.getProperty(runtime, "purchase")),
58
+ JSIConverter<std::optional<std::vector<std::variant<margelo::nitro::iap::PurchaseAndroid, margelo::nitro::iap::PurchaseIOS>>>>::fromJSI(runtime, obj.getProperty(runtime, "purchases"))
59
+ );
60
+ }
61
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::RequestPurchaseResult& arg) {
62
+ jsi::Object obj(runtime);
63
+ obj.setProperty(runtime, "purchase", JSIConverter<std::optional<std::variant<margelo::nitro::iap::PurchaseAndroid, margelo::nitro::iap::PurchaseIOS>>>::toJSI(runtime, arg.purchase));
64
+ obj.setProperty(runtime, "purchases", JSIConverter<std::optional<std::vector<std::variant<margelo::nitro::iap::PurchaseAndroid, margelo::nitro::iap::PurchaseIOS>>>>::toJSI(runtime, arg.purchases));
65
+ return obj;
66
+ }
67
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
68
+ if (!value.isObject()) {
69
+ return false;
70
+ }
71
+ jsi::Object obj = value.getObject(runtime);
72
+ if (!JSIConverter<std::optional<std::variant<margelo::nitro::iap::PurchaseAndroid, margelo::nitro::iap::PurchaseIOS>>>::canConvert(runtime, obj.getProperty(runtime, "purchase"))) return false;
73
+ if (!JSIConverter<std::optional<std::vector<std::variant<margelo::nitro::iap::PurchaseAndroid, margelo::nitro::iap::PurchaseIOS>>>>::canConvert(runtime, obj.getProperty(runtime, "purchases"))) return false;
74
+ return true;
75
+ }
76
+ };
77
+
78
+ } // namespace margelo::nitro
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-iap",
3
- "version": "14.3.4",
3
+ "version": "14.3.5",
4
4
  "description": "React Native In-App Purchases module for iOS and Android using Nitro",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -67,6 +67,7 @@
67
67
  "prepare:husky": "husky install",
68
68
  "precommit": "lint-staged",
69
69
  "ci:check": "./scripts/ci-check.sh",
70
+ "generate:types": "node scripts/update-types.mjs --tag 1.0.2",
70
71
  "generate:icon": "cd docs/static/img && npx sharp-cli resize 32 32 --input icon.png --output favicon-32x32.png && npx sharp-cli resize 16 16 --input icon.png --output favicon-16x16.png && npx sharp-cli resize 192 192 --input icon.png --output android-chrome-192x192.png && npx sharp-cli resize 512 512 --input icon.png --output android-chrome-512x512.png && npx sharp-cli resize 180 180 --input icon.png --output apple-touch-icon.png && npx sharp-cli resize 1200 630 --input icon.png --output og-image.png && npx sharp-cli resize 150 150 --input icon.png --output favicon.png && npx sharp-cli --input favicon-32x32.png --output favicon.ico",
71
72
  "commitlint": "commitlint"
72
73
  },
@@ -106,19 +107,19 @@
106
107
  "husky": "^8.0.3",
107
108
  "jest": "^30.1.1",
108
109
  "lint-staged": "^15.2.0",
109
- "nitrogen": "^0.29.4",
110
+ "nitrogen": "^0.29.6",
110
111
  "prettier": "^3.3.3",
111
112
  "react": "19.1.0",
112
113
  "react-native": "0.81.1",
113
114
  "react-native-builder-bob": "^0.38.4",
114
- "react-native-nitro-modules": "^0.29.4",
115
+ "react-native-nitro-modules": "^0.29.6",
115
116
  "react-test-renderer": "^19.1.1",
116
117
  "typescript": "^5.9.2"
117
118
  },
118
119
  "peerDependencies": {
119
120
  "react": "*",
120
121
  "react-native": "*",
121
- "react-native-nitro-modules": "*"
122
+ "react-native-nitro-modules": "^0.29.6"
122
123
  },
123
124
  "workspaces": [
124
125
  "example"
@@ -31,7 +31,7 @@ const modifyProjectBuildGradle = (gradle) => {
31
31
  };
32
32
  exports.modifyProjectBuildGradle = modifyProjectBuildGradle;
33
33
  const OPENIAP_COORD = 'io.github.hyochan.openiap:openiap-google';
34
- const OPENIAP_VERSION = '1.1.0';
34
+ const OPENIAP_VERSION = '1.1.10';
35
35
  const modifyAppBuildGradle = (gradle) => {
36
36
  let modified = gradle;
37
37
  // Replace legacy Billing/GMS instructions with OpenIAP Google library
@@ -46,7 +46,7 @@ export const modifyProjectBuildGradle = (gradle: string): string => {
46
46
  };
47
47
 
48
48
  const OPENIAP_COORD = 'io.github.hyochan.openiap:openiap-google';
49
- const OPENIAP_VERSION = '1.1.0';
49
+ const OPENIAP_VERSION = '1.1.10';
50
50
 
51
51
  const modifyAppBuildGradle = (gradle: string): string => {
52
52
  let modified = gradle;
@@ -21,14 +21,18 @@ import {
21
21
  } from '../';
22
22
 
23
23
  // Types
24
- import {ProductQueryType, ErrorCode} from '../types';
24
+ import {ErrorCode} from '../types';
25
+ import type {
26
+ ProductQueryType,
27
+ RequestPurchaseProps,
28
+ RequestPurchaseResult,
29
+ } from '../types';
25
30
  import type {
26
31
  ActiveSubscription,
27
32
  Product,
28
33
  Purchase,
29
34
  PurchaseError,
30
35
  ProductSubscription,
31
- PurchaseParams,
32
36
  } from '../types';
33
37
  import type {FinishTransactionParams} from '../';
34
38
  import type {NitroPurchaseResult} from '../specs/RnIap.nitro';
@@ -62,7 +66,7 @@ type UseIap = {
62
66
  type?: ProductQueryType | null;
63
67
  }) => Promise<void>;
64
68
  /**
65
- * @deprecated Use fetchProducts({ skus, type: 'inapp' }) instead. This method will be removed in version 3.0.0.
69
+ * @deprecated Use fetchProducts({ skus, type: 'in-app' }) instead. This method will be removed in version 3.0.0.
66
70
  * Note: This method internally uses fetchProducts, so no deprecation warning is shown.
67
71
  */
68
72
  getProducts: (skus: string[]) => Promise<void>;
@@ -71,7 +75,9 @@ type UseIap = {
71
75
  * Note: This method internally uses fetchProducts, so no deprecation warning is shown.
72
76
  */
73
77
  getSubscriptions: (skus: string[]) => Promise<void>;
74
- requestPurchase: (params: PurchaseParams) => Promise<any>;
78
+ requestPurchase: (
79
+ params: RequestPurchaseProps,
80
+ ) => Promise<RequestPurchaseResult>;
75
81
  validateReceipt: (
76
82
  sku: string,
77
83
  androidOptions?: {
@@ -175,7 +181,7 @@ export function useIAP(options?: UseIapOptions): UseIap {
175
181
  try {
176
182
  const result = await fetchProducts({
177
183
  skus,
178
- type: ProductQueryType.InApp,
184
+ type: 'in-app',
179
185
  });
180
186
  setProducts((prevProducts: Product[]) =>
181
187
  mergeWithDuplicateCheck(
@@ -196,7 +202,7 @@ export function useIAP(options?: UseIapOptions): UseIap {
196
202
  try {
197
203
  const result = await fetchProducts({
198
204
  skus,
199
- type: ProductQueryType.Subs,
205
+ type: 'subs',
200
206
  });
201
207
  setSubscriptions((prevSubscriptions: ProductSubscription[]) =>
202
208
  mergeWithDuplicateCheck(
@@ -225,7 +231,7 @@ export function useIAP(options?: UseIapOptions): UseIap {
225
231
  }
226
232
  try {
227
233
  const result = await fetchProducts(params);
228
- if (params.type === ProductQueryType.Subs) {
234
+ if (params.type === 'subs') {
229
235
  setSubscriptions((prevSubscriptions: ProductSubscription[]) =>
230
236
  mergeWithDuplicateCheck(
231
237
  prevSubscriptions,
@@ -325,7 +331,7 @@ export function useIAP(options?: UseIapOptions): UseIap {
325
331
  );
326
332
 
327
333
  const requestPurchaseWithReset = useCallback(
328
- async (requestObj: PurchaseParams) => {
334
+ async (requestObj: RequestPurchaseProps) => {
329
335
  clearCurrentPurchase();
330
336
  clearCurrentPurchaseError();
331
337