react-native-iap 14.3.5-rc.1 → 14.3.6

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 (79) 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 +6 -39
  9. package/lib/module/hooks/useIAP.js.map +1 -1
  10. package/lib/module/index.js +54 -55
  11. package/lib/module/index.js.map +1 -1
  12. package/lib/module/types.js +1 -1
  13. package/lib/module/utils/type-bridge.js.map +1 -1
  14. package/lib/typescript/src/hooks/useIAP.d.ts +4 -8
  15. package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -1
  16. package/lib/typescript/src/index.d.ts +8 -7
  17. package/lib/typescript/src/index.d.ts.map +1 -1
  18. package/lib/typescript/src/specs/RnIap.nitro.d.ts +2 -1
  19. package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
  20. package/lib/typescript/src/types.d.ts +141 -146
  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/NitroIap+autolinking.cmake +9 -4
  24. package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +32 -5
  25. package/nitrogen/generated/android/c++/JHybridRnIapSpec.hpp +1 -1
  26. package/nitrogen/generated/android/c++/JIapPlatform.hpp +59 -0
  27. package/nitrogen/generated/android/c++/JPurchase.cpp +26 -0
  28. package/nitrogen/generated/android/c++/JPurchase.hpp +80 -0
  29. package/nitrogen/generated/android/c++/JPurchaseAndroid.hpp +140 -0
  30. package/nitrogen/generated/android/c++/JPurchaseIOS.hpp +194 -0
  31. package/nitrogen/generated/android/c++/JPurchaseOfferIOS.hpp +61 -0
  32. package/nitrogen/generated/android/c++/JPurchaseState.hpp +71 -0
  33. package/nitrogen/generated/android/c++/JRequestPurchaseResult.hpp +89 -0
  34. package/nitrogen/generated/android/c++/JVariant_PurchaseAndroid_PurchaseIOS.cpp +26 -0
  35. package/nitrogen/generated/android/c++/JVariant_PurchaseAndroid_PurchaseIOS.hpp +80 -0
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +1 -1
  37. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/IapPlatform.kt +21 -0
  38. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Purchase.kt +42 -0
  39. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseAndroid.kt +77 -0
  40. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseIOS.kt +116 -0
  41. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseOfferIOS.kt +35 -0
  42. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseState.kt +25 -0
  43. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/RequestPurchaseResult.kt +32 -0
  44. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Variant_PurchaseAndroid_PurchaseIOS.kt +42 -0
  45. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.cpp +13 -5
  46. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +186 -25
  47. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +18 -0
  48. package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +20 -2
  49. package/nitrogen/generated/ios/swift/Func_void_RequestPurchaseResult.swift +47 -0
  50. package/nitrogen/generated/ios/swift/HybridRnIapSpec.swift +1 -1
  51. package/nitrogen/generated/ios/swift/HybridRnIapSpec_cxx.swift +7 -7
  52. package/nitrogen/generated/ios/swift/IapPlatform.swift +40 -0
  53. package/nitrogen/generated/ios/swift/Purchase.swift +18 -0
  54. package/nitrogen/generated/ios/swift/PurchaseAndroid.swift +399 -0
  55. package/nitrogen/generated/ios/swift/PurchaseIOS.swift +768 -0
  56. package/nitrogen/generated/ios/swift/PurchaseOfferIOS.swift +57 -0
  57. package/nitrogen/generated/ios/swift/PurchaseState.swift +56 -0
  58. package/nitrogen/generated/ios/swift/RequestPurchaseResult.swift +148 -0
  59. package/nitrogen/generated/ios/swift/Variant_PurchaseAndroid_PurchaseIOS.swift +18 -0
  60. package/nitrogen/generated/shared/c++/HybridRnIapSpec.hpp +4 -1
  61. package/nitrogen/generated/shared/c++/IapPlatform.hpp +76 -0
  62. package/nitrogen/generated/shared/c++/PurchaseAndroid.hpp +138 -0
  63. package/nitrogen/generated/shared/c++/PurchaseIOS.hpp +193 -0
  64. package/nitrogen/generated/shared/c++/PurchaseOfferIOS.hpp +75 -0
  65. package/nitrogen/generated/shared/c++/PurchaseState.hpp +92 -0
  66. package/nitrogen/generated/shared/c++/RequestPurchaseResult.hpp +78 -0
  67. package/package.json +5 -4
  68. package/plugin/build/withIAP.js +1 -1
  69. package/plugin/src/withIAP.ts +1 -1
  70. package/plugin/tsconfig.tsbuildinfo +1 -1
  71. package/src/hooks/useIAP.ts +17 -59
  72. package/src/index.ts +73 -77
  73. package/src/specs/RnIap.nitro.ts +4 -1
  74. package/src/types.ts +168 -178
  75. package/src/utils/type-bridge.ts +3 -1
  76. package/lib/index.d.ts +0 -8
  77. package/lib/index.js +0 -36
  78. package/lib/specs/RnIap.nitro.d.ts +0 -7
  79. package/lib/specs/RnIap.nitro.js +0 -1
@@ -0,0 +1,61 @@
1
+ ///
2
+ /// JPurchaseOfferIOS.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
+ #include <fbjni/fbjni.h>
11
+ #include "PurchaseOfferIOS.hpp"
12
+
13
+ #include <string>
14
+
15
+ namespace margelo::nitro::iap {
16
+
17
+ using namespace facebook;
18
+
19
+ /**
20
+ * The C++ JNI bridge between the C++ struct "PurchaseOfferIOS" and the the Kotlin data class "PurchaseOfferIOS".
21
+ */
22
+ struct JPurchaseOfferIOS final: public jni::JavaClass<JPurchaseOfferIOS> {
23
+ public:
24
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/iap/PurchaseOfferIOS;";
25
+
26
+ public:
27
+ /**
28
+ * Convert this Java/Kotlin-based struct to the C++ struct PurchaseOfferIOS by copying all values to C++.
29
+ */
30
+ [[maybe_unused]]
31
+ [[nodiscard]]
32
+ PurchaseOfferIOS toCpp() const {
33
+ static const auto clazz = javaClassStatic();
34
+ static const auto fieldId = clazz->getField<jni::JString>("id");
35
+ jni::local_ref<jni::JString> id = this->getFieldValue(fieldId);
36
+ static const auto fieldPaymentMode = clazz->getField<jni::JString>("paymentMode");
37
+ jni::local_ref<jni::JString> paymentMode = this->getFieldValue(fieldPaymentMode);
38
+ static const auto fieldType = clazz->getField<jni::JString>("type");
39
+ jni::local_ref<jni::JString> type = this->getFieldValue(fieldType);
40
+ return PurchaseOfferIOS(
41
+ id->toStdString(),
42
+ paymentMode->toStdString(),
43
+ type->toStdString()
44
+ );
45
+ }
46
+
47
+ public:
48
+ /**
49
+ * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
50
+ */
51
+ [[maybe_unused]]
52
+ static jni::local_ref<JPurchaseOfferIOS::javaobject> fromCpp(const PurchaseOfferIOS& value) {
53
+ return newInstance(
54
+ jni::make_jstring(value.id),
55
+ jni::make_jstring(value.paymentMode),
56
+ jni::make_jstring(value.type)
57
+ );
58
+ }
59
+ };
60
+
61
+ } // namespace margelo::nitro::iap
@@ -0,0 +1,71 @@
1
+ ///
2
+ /// JPurchaseState.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
+ #include <fbjni/fbjni.h>
11
+ #include "PurchaseState.hpp"
12
+
13
+ namespace margelo::nitro::iap {
14
+
15
+ using namespace facebook;
16
+
17
+ /**
18
+ * The C++ JNI bridge between the C++ enum "PurchaseState" and the the Kotlin enum "PurchaseState".
19
+ */
20
+ struct JPurchaseState final: public jni::JavaClass<JPurchaseState> {
21
+ public:
22
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/iap/PurchaseState;";
23
+
24
+ public:
25
+ /**
26
+ * Convert this Java/Kotlin-based enum to the C++ enum PurchaseState.
27
+ */
28
+ [[maybe_unused]]
29
+ [[nodiscard]]
30
+ PurchaseState toCpp() const {
31
+ static const auto clazz = javaClassStatic();
32
+ static const auto fieldOrdinal = clazz->getField<int>("value");
33
+ int ordinal = this->getFieldValue(fieldOrdinal);
34
+ return static_cast<PurchaseState>(ordinal);
35
+ }
36
+
37
+ public:
38
+ /**
39
+ * Create a Java/Kotlin-based enum with the given C++ enum's value.
40
+ */
41
+ [[maybe_unused]]
42
+ static jni::alias_ref<JPurchaseState> fromCpp(PurchaseState value) {
43
+ static const auto clazz = javaClassStatic();
44
+ static const auto fieldDEFERRED = clazz->getStaticField<JPurchaseState>("DEFERRED");
45
+ static const auto fieldFAILED = clazz->getStaticField<JPurchaseState>("FAILED");
46
+ static const auto fieldPENDING = clazz->getStaticField<JPurchaseState>("PENDING");
47
+ static const auto fieldPURCHASED = clazz->getStaticField<JPurchaseState>("PURCHASED");
48
+ static const auto fieldRESTORED = clazz->getStaticField<JPurchaseState>("RESTORED");
49
+ static const auto fieldUNKNOWN = clazz->getStaticField<JPurchaseState>("UNKNOWN");
50
+
51
+ switch (value) {
52
+ case PurchaseState::DEFERRED:
53
+ return clazz->getStaticFieldValue(fieldDEFERRED);
54
+ case PurchaseState::FAILED:
55
+ return clazz->getStaticFieldValue(fieldFAILED);
56
+ case PurchaseState::PENDING:
57
+ return clazz->getStaticFieldValue(fieldPENDING);
58
+ case PurchaseState::PURCHASED:
59
+ return clazz->getStaticFieldValue(fieldPURCHASED);
60
+ case PurchaseState::RESTORED:
61
+ return clazz->getStaticFieldValue(fieldRESTORED);
62
+ case PurchaseState::UNKNOWN:
63
+ return clazz->getStaticFieldValue(fieldUNKNOWN);
64
+ default:
65
+ std::string stringValue = std::to_string(static_cast<int>(value));
66
+ throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
67
+ }
68
+ }
69
+ };
70
+
71
+ } // namespace margelo::nitro::iap
@@ -0,0 +1,89 @@
1
+ ///
2
+ /// JRequestPurchaseResult.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
+ #include <fbjni/fbjni.h>
11
+ #include "RequestPurchaseResult.hpp"
12
+
13
+ #include "IapPlatform.hpp"
14
+ #include "JIapPlatform.hpp"
15
+ #include "JPurchase.hpp"
16
+ #include "JPurchaseAndroid.hpp"
17
+ #include "JPurchaseIOS.hpp"
18
+ #include "JPurchaseOfferIOS.hpp"
19
+ #include "JPurchaseState.hpp"
20
+ #include "JVariant_PurchaseAndroid_PurchaseIOS.hpp"
21
+ #include "PurchaseAndroid.hpp"
22
+ #include "PurchaseIOS.hpp"
23
+ #include "PurchaseOfferIOS.hpp"
24
+ #include "PurchaseState.hpp"
25
+ #include <optional>
26
+ #include <string>
27
+ #include <variant>
28
+ #include <vector>
29
+
30
+ namespace margelo::nitro::iap {
31
+
32
+ using namespace facebook;
33
+
34
+ /**
35
+ * The C++ JNI bridge between the C++ struct "RequestPurchaseResult" and the the Kotlin data class "RequestPurchaseResult".
36
+ */
37
+ struct JRequestPurchaseResult final: public jni::JavaClass<JRequestPurchaseResult> {
38
+ public:
39
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/iap/RequestPurchaseResult;";
40
+
41
+ public:
42
+ /**
43
+ * Convert this Java/Kotlin-based struct to the C++ struct RequestPurchaseResult by copying all values to C++.
44
+ */
45
+ [[maybe_unused]]
46
+ [[nodiscard]]
47
+ RequestPurchaseResult toCpp() const {
48
+ static const auto clazz = javaClassStatic();
49
+ static const auto fieldPurchase = clazz->getField<JVariant_PurchaseAndroid_PurchaseIOS>("purchase");
50
+ jni::local_ref<JVariant_PurchaseAndroid_PurchaseIOS> purchase = this->getFieldValue(fieldPurchase);
51
+ static const auto fieldPurchases = clazz->getField<jni::JArrayClass<JPurchase>>("purchases");
52
+ jni::local_ref<jni::JArrayClass<JPurchase>> purchases = this->getFieldValue(fieldPurchases);
53
+ return RequestPurchaseResult(
54
+ purchase != nullptr ? std::make_optional(purchase->toCpp()) : std::nullopt,
55
+ purchases != nullptr ? std::make_optional([&]() {
56
+ size_t __size = purchases->size();
57
+ std::vector<std::variant<PurchaseAndroid, PurchaseIOS>> __vector;
58
+ __vector.reserve(__size);
59
+ for (size_t __i = 0; __i < __size; __i++) {
60
+ auto __element = purchases->getElement(__i);
61
+ __vector.push_back(__element->toCpp());
62
+ }
63
+ return __vector;
64
+ }()) : std::nullopt
65
+ );
66
+ }
67
+
68
+ public:
69
+ /**
70
+ * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
71
+ */
72
+ [[maybe_unused]]
73
+ static jni::local_ref<JRequestPurchaseResult::javaobject> fromCpp(const RequestPurchaseResult& value) {
74
+ return newInstance(
75
+ value.purchase.has_value() ? JVariant_PurchaseAndroid_PurchaseIOS::fromCpp(value.purchase.value()) : nullptr,
76
+ value.purchases.has_value() ? [&]() {
77
+ size_t __size = value.purchases.value().size();
78
+ jni::local_ref<jni::JArrayClass<JPurchase>> __array = jni::JArrayClass<JPurchase>::newArray(__size);
79
+ for (size_t __i = 0; __i < __size; __i++) {
80
+ const auto& __element = value.purchases.value()[__i];
81
+ __array->setElement(__i, *JPurchase::fromCpp(__element));
82
+ }
83
+ return __array;
84
+ }() : nullptr
85
+ );
86
+ }
87
+ };
88
+
89
+ } // namespace margelo::nitro::iap
@@ -0,0 +1,26 @@
1
+ ///
2
+ /// JVariant_PurchaseAndroid_PurchaseIOS.cpp
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
+ #include "JVariant_PurchaseAndroid_PurchaseIOS.hpp"
9
+
10
+ namespace margelo::nitro::iap {
11
+ /**
12
+ * Converts JVariant_PurchaseAndroid_PurchaseIOS to std::variant<PurchaseAndroid, PurchaseIOS>
13
+ */
14
+ std::variant<PurchaseAndroid, PurchaseIOS> JVariant_PurchaseAndroid_PurchaseIOS::toCpp() const {
15
+ if (isInstanceOf(JVariant_PurchaseAndroid_PurchaseIOS_impl::First::javaClassStatic())) {
16
+ // It's a `PurchaseAndroid`
17
+ auto jniValue = static_cast<const JVariant_PurchaseAndroid_PurchaseIOS_impl::First*>(this)->getValue();
18
+ return jniValue->toCpp();
19
+ } else if (isInstanceOf(JVariant_PurchaseAndroid_PurchaseIOS_impl::Second::javaClassStatic())) {
20
+ // It's a `PurchaseIOS`
21
+ auto jniValue = static_cast<const JVariant_PurchaseAndroid_PurchaseIOS_impl::Second*>(this)->getValue();
22
+ return jniValue->toCpp();
23
+ }
24
+ throw std::invalid_argument("Variant is unknown Kotlin instance!");
25
+ }
26
+ } // namespace margelo::nitro::iap
@@ -0,0 +1,80 @@
1
+ ///
2
+ /// JVariant_PurchaseAndroid_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
+ #include <fbjni/fbjni.h>
11
+ #include <variant>
12
+
13
+ #include "PurchaseAndroid.hpp"
14
+ #include "PurchaseIOS.hpp"
15
+ #include <variant>
16
+ #include "JPurchaseAndroid.hpp"
17
+ #include <optional>
18
+ #include <string>
19
+ #include <vector>
20
+ #include "IapPlatform.hpp"
21
+ #include "JIapPlatform.hpp"
22
+ #include "PurchaseState.hpp"
23
+ #include "JPurchaseState.hpp"
24
+ #include "JPurchaseIOS.hpp"
25
+ #include "PurchaseOfferIOS.hpp"
26
+ #include "JPurchaseOfferIOS.hpp"
27
+
28
+ namespace margelo::nitro::iap {
29
+
30
+ using namespace facebook;
31
+
32
+ /**
33
+ * The C++ JNI bridge between the C++ std::variant and the Java class "Variant_PurchaseAndroid_PurchaseIOS".
34
+ */
35
+ class JVariant_PurchaseAndroid_PurchaseIOS: public jni::JavaClass<JVariant_PurchaseAndroid_PurchaseIOS> {
36
+ public:
37
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/iap/Variant_PurchaseAndroid_PurchaseIOS;";
38
+
39
+ static jni::local_ref<JVariant_PurchaseAndroid_PurchaseIOS> create_0(jni::alias_ref<JPurchaseAndroid> value) {
40
+ static const auto method = javaClassStatic()->getStaticMethod<JVariant_PurchaseAndroid_PurchaseIOS(jni::alias_ref<JPurchaseAndroid>)>("create");
41
+ return method(javaClassStatic(), value);
42
+ }
43
+ static jni::local_ref<JVariant_PurchaseAndroid_PurchaseIOS> create_1(jni::alias_ref<JPurchaseIOS> value) {
44
+ static const auto method = javaClassStatic()->getStaticMethod<JVariant_PurchaseAndroid_PurchaseIOS(jni::alias_ref<JPurchaseIOS>)>("create");
45
+ return method(javaClassStatic(), value);
46
+ }
47
+
48
+ static jni::local_ref<JVariant_PurchaseAndroid_PurchaseIOS> fromCpp(const std::variant<PurchaseAndroid, PurchaseIOS>& variant) {
49
+ switch (variant.index()) {
50
+ case 0: return create_0(JPurchaseAndroid::fromCpp(std::get<0>(variant)));
51
+ case 1: return create_1(JPurchaseIOS::fromCpp(std::get<1>(variant)));
52
+ default: throw std::invalid_argument("Variant holds unknown index! (" + std::to_string(variant.index()) + ")");
53
+ }
54
+ }
55
+
56
+ [[nodiscard]] std::variant<PurchaseAndroid, PurchaseIOS> toCpp() const;
57
+ };
58
+
59
+ namespace JVariant_PurchaseAndroid_PurchaseIOS_impl {
60
+ class First: public jni::JavaClass<First, JVariant_PurchaseAndroid_PurchaseIOS> {
61
+ public:
62
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/iap/Variant_PurchaseAndroid_PurchaseIOS$First;";
63
+
64
+ [[nodiscard]] jni::local_ref<JPurchaseAndroid> getValue() const {
65
+ static const auto field = javaClassStatic()->getField<JPurchaseAndroid>("value");
66
+ return getFieldValue(field);
67
+ }
68
+ };
69
+
70
+ class Second: public jni::JavaClass<Second, JVariant_PurchaseAndroid_PurchaseIOS> {
71
+ public:
72
+ static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/iap/Variant_PurchaseAndroid_PurchaseIOS$Second;";
73
+
74
+ [[nodiscard]] jni::local_ref<JPurchaseIOS> getValue() const {
75
+ static const auto field = javaClassStatic()->getField<JPurchaseIOS>("value");
76
+ return getFieldValue(field);
77
+ }
78
+ };
79
+ } // namespace JVariant_PurchaseAndroid_PurchaseIOS_impl
80
+ } // namespace margelo::nitro::iap
@@ -54,7 +54,7 @@ abstract class HybridRnIapSpec: HybridObject() {
54
54
 
55
55
  @DoNotStrip
56
56
  @Keep
57
- abstract fun requestPurchase(request: NitroPurchaseRequest): Promise<Unit>
57
+ abstract fun requestPurchase(request: NitroPurchaseRequest): Promise<RequestPurchaseResult>
58
58
 
59
59
  @DoNotStrip
60
60
  @Keep
@@ -0,0 +1,21 @@
1
+ ///
2
+ /// IapPlatform.kt
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
+ package com.margelo.nitro.iap
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+
13
+ /**
14
+ * Represents the JavaScript enum/union "IapPlatform".
15
+ */
16
+ @DoNotStrip
17
+ @Keep
18
+ enum class IapPlatform(@DoNotStrip @Keep val value: Int) {
19
+ ANDROID(0),
20
+ IOS(1);
21
+ }
@@ -0,0 +1,42 @@
1
+ ///
2
+ /// Purchase.kt
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
+ package com.margelo.nitro.iap
9
+
10
+ import com.facebook.proguard.annotations.DoNotStrip
11
+
12
+
13
+ /**
14
+ * Represents the TypeScript variant "PurchaseAndroid|PurchaseIOS".
15
+ */
16
+ @Suppress("ClassName")
17
+ @DoNotStrip
18
+ sealed class Purchase {
19
+ @DoNotStrip
20
+ data class First(@DoNotStrip val value: PurchaseAndroid): Purchase()
21
+ @DoNotStrip
22
+ data class Second(@DoNotStrip val value: PurchaseIOS): Purchase()
23
+
24
+ inline fun <reified T> getAs(): T? = when (this) {
25
+ is First -> value as? T
26
+ is Second -> value as? T
27
+ }
28
+
29
+ val isFirst: Boolean
30
+ get() = this is First
31
+ val isSecond: Boolean
32
+ get() = this is Second
33
+
34
+ companion object {
35
+ @JvmStatic
36
+ @DoNotStrip
37
+ fun create(value: PurchaseAndroid): Purchase = First(value)
38
+ @JvmStatic
39
+ @DoNotStrip
40
+ fun create(value: PurchaseIOS): Purchase = Second(value)
41
+ }
42
+ }
@@ -0,0 +1,77 @@
1
+ ///
2
+ /// PurchaseAndroid.kt
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
+ package com.margelo.nitro.iap
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+ import com.margelo.nitro.core.*
13
+
14
+
15
+ /**
16
+ * Represents the JavaScript object/struct "PurchaseAndroid".
17
+ */
18
+ @DoNotStrip
19
+ @Keep
20
+ data class PurchaseAndroid
21
+ @DoNotStrip
22
+ @Keep
23
+ constructor(
24
+ @DoNotStrip
25
+ @Keep
26
+ val autoRenewingAndroid: Boolean?,
27
+ @DoNotStrip
28
+ @Keep
29
+ val dataAndroid: String?,
30
+ @DoNotStrip
31
+ @Keep
32
+ val developerPayloadAndroid: String?,
33
+ @DoNotStrip
34
+ @Keep
35
+ val id: String,
36
+ @DoNotStrip
37
+ @Keep
38
+ val ids: Array<String>?,
39
+ @DoNotStrip
40
+ @Keep
41
+ val isAcknowledgedAndroid: Boolean?,
42
+ @DoNotStrip
43
+ @Keep
44
+ val isAutoRenewing: Boolean,
45
+ @DoNotStrip
46
+ @Keep
47
+ val obfuscatedAccountIdAndroid: String?,
48
+ @DoNotStrip
49
+ @Keep
50
+ val obfuscatedProfileIdAndroid: String?,
51
+ @DoNotStrip
52
+ @Keep
53
+ val packageNameAndroid: String?,
54
+ @DoNotStrip
55
+ @Keep
56
+ val platform: IapPlatform,
57
+ @DoNotStrip
58
+ @Keep
59
+ val productId: String,
60
+ @DoNotStrip
61
+ @Keep
62
+ val purchaseState: PurchaseState,
63
+ @DoNotStrip
64
+ @Keep
65
+ val purchaseToken: String?,
66
+ @DoNotStrip
67
+ @Keep
68
+ val quantity: Double,
69
+ @DoNotStrip
70
+ @Keep
71
+ val signatureAndroid: String?,
72
+ @DoNotStrip
73
+ @Keep
74
+ val transactionDate: Double
75
+ ) {
76
+ /* main constructor */
77
+ }
@@ -0,0 +1,116 @@
1
+ ///
2
+ /// PurchaseIOS.kt
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
+ package com.margelo.nitro.iap
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+ import com.margelo.nitro.core.*
13
+
14
+
15
+ /**
16
+ * Represents the JavaScript object/struct "PurchaseIOS".
17
+ */
18
+ @DoNotStrip
19
+ @Keep
20
+ data class PurchaseIOS
21
+ @DoNotStrip
22
+ @Keep
23
+ constructor(
24
+ @DoNotStrip
25
+ @Keep
26
+ val appAccountToken: String?,
27
+ @DoNotStrip
28
+ @Keep
29
+ val appBundleIdIOS: String?,
30
+ @DoNotStrip
31
+ @Keep
32
+ val countryCodeIOS: String?,
33
+ @DoNotStrip
34
+ @Keep
35
+ val currencyCodeIOS: String?,
36
+ @DoNotStrip
37
+ @Keep
38
+ val currencySymbolIOS: String?,
39
+ @DoNotStrip
40
+ @Keep
41
+ val environmentIOS: String?,
42
+ @DoNotStrip
43
+ @Keep
44
+ val expirationDateIOS: Double?,
45
+ @DoNotStrip
46
+ @Keep
47
+ val id: String,
48
+ @DoNotStrip
49
+ @Keep
50
+ val ids: Array<String>?,
51
+ @DoNotStrip
52
+ @Keep
53
+ val isAutoRenewing: Boolean,
54
+ @DoNotStrip
55
+ @Keep
56
+ val isUpgradedIOS: Boolean?,
57
+ @DoNotStrip
58
+ @Keep
59
+ val offerIOS: PurchaseOfferIOS?,
60
+ @DoNotStrip
61
+ @Keep
62
+ val originalTransactionDateIOS: Double?,
63
+ @DoNotStrip
64
+ @Keep
65
+ val originalTransactionIdentifierIOS: String?,
66
+ @DoNotStrip
67
+ @Keep
68
+ val ownershipTypeIOS: String?,
69
+ @DoNotStrip
70
+ @Keep
71
+ val platform: IapPlatform,
72
+ @DoNotStrip
73
+ @Keep
74
+ val productId: String,
75
+ @DoNotStrip
76
+ @Keep
77
+ val purchaseState: PurchaseState,
78
+ @DoNotStrip
79
+ @Keep
80
+ val purchaseToken: String?,
81
+ @DoNotStrip
82
+ @Keep
83
+ val quantity: Double,
84
+ @DoNotStrip
85
+ @Keep
86
+ val quantityIOS: Double?,
87
+ @DoNotStrip
88
+ @Keep
89
+ val reasonIOS: String?,
90
+ @DoNotStrip
91
+ @Keep
92
+ val reasonStringRepresentationIOS: String?,
93
+ @DoNotStrip
94
+ @Keep
95
+ val revocationDateIOS: Double?,
96
+ @DoNotStrip
97
+ @Keep
98
+ val revocationReasonIOS: String?,
99
+ @DoNotStrip
100
+ @Keep
101
+ val storefrontCountryCodeIOS: String?,
102
+ @DoNotStrip
103
+ @Keep
104
+ val subscriptionGroupIdIOS: String?,
105
+ @DoNotStrip
106
+ @Keep
107
+ val transactionDate: Double,
108
+ @DoNotStrip
109
+ @Keep
110
+ val transactionReasonIOS: String?,
111
+ @DoNotStrip
112
+ @Keep
113
+ val webOrderLineItemIdIOS: String?
114
+ ) {
115
+ /* main constructor */
116
+ }
@@ -0,0 +1,35 @@
1
+ ///
2
+ /// PurchaseOfferIOS.kt
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
+ package com.margelo.nitro.iap
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+ import com.margelo.nitro.core.*
13
+
14
+
15
+ /**
16
+ * Represents the JavaScript object/struct "PurchaseOfferIOS".
17
+ */
18
+ @DoNotStrip
19
+ @Keep
20
+ data class PurchaseOfferIOS
21
+ @DoNotStrip
22
+ @Keep
23
+ constructor(
24
+ @DoNotStrip
25
+ @Keep
26
+ val id: String,
27
+ @DoNotStrip
28
+ @Keep
29
+ val paymentMode: String,
30
+ @DoNotStrip
31
+ @Keep
32
+ val type: String
33
+ ) {
34
+ /* main constructor */
35
+ }
@@ -0,0 +1,25 @@
1
+ ///
2
+ /// PurchaseState.kt
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
+ package com.margelo.nitro.iap
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+
13
+ /**
14
+ * Represents the JavaScript enum/union "PurchaseState".
15
+ */
16
+ @DoNotStrip
17
+ @Keep
18
+ enum class PurchaseState(@DoNotStrip @Keep val value: Int) {
19
+ DEFERRED(0),
20
+ FAILED(1),
21
+ PENDING(2),
22
+ PURCHASED(3),
23
+ RESTORED(4),
24
+ UNKNOWN(5);
25
+ }
@@ -0,0 +1,32 @@
1
+ ///
2
+ /// RequestPurchaseResult.kt
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
+ package com.margelo.nitro.iap
9
+
10
+ import androidx.annotation.Keep
11
+ import com.facebook.proguard.annotations.DoNotStrip
12
+ import com.margelo.nitro.core.*
13
+
14
+
15
+ /**
16
+ * Represents the JavaScript object/struct "RequestPurchaseResult".
17
+ */
18
+ @DoNotStrip
19
+ @Keep
20
+ data class RequestPurchaseResult
21
+ @DoNotStrip
22
+ @Keep
23
+ constructor(
24
+ @DoNotStrip
25
+ @Keep
26
+ val purchase: Variant_PurchaseAndroid_PurchaseIOS?,
27
+ @DoNotStrip
28
+ @Keep
29
+ val purchases: Array<Purchase>?
30
+ ) {
31
+ /* main constructor */
32
+ }