react-native-iap 15.5.1 → 15.5.3
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.
- package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +26 -3
- package/ios/HybridRnIap.swift +16 -0
- package/lib/module/hooks/useIAP.js +6 -2
- package/lib/module/hooks/useIAP.js.map +1 -1
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.kepler.js.map +1 -1
- package/lib/module/kit-api.js +27 -0
- package/lib/module/kit-api.js.map +1 -1
- package/lib/module/types.js +7 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/vega-adapter.js +10 -6
- package/lib/module/vega-adapter.js.map +1 -1
- package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/index.kepler.d.ts +1 -0
- package/lib/typescript/src/index.kepler.d.ts.map +1 -1
- package/lib/typescript/src/kit-api.d.ts +60 -0
- package/lib/typescript/src/kit-api.d.ts.map +1 -1
- package/lib/typescript/src/specs/RnIap.nitro.d.ts +16 -0
- package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +36 -1
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/vega-adapter.d.ts.map +1 -1
- package/nitrogen/generated/android/NitroIap+autolinking.cmake +1 -0
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +9 -0
- package/nitrogen/generated/android/c++/JIapkitClientPayloadFormat.hpp +61 -0
- package/nitrogen/generated/android/c++/JNitroIapkitProductClientPayload.hpp +71 -0
- package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithIapkitProps.hpp +7 -3
- package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithIapkitResult.hpp +20 -1
- package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithProviderResult.hpp +5 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_NitroIapkitProductClientPayload.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_NitroIapkitProductClientPayload.hpp +74 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_NitroVerifyPurchaseWithIapkitResult.hpp +8 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/IapkitClientPayloadFormat.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroIapkitProductClientPayload.kt +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroVerifyPurchaseWithIapkitProps.kt +9 -4
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroVerifyPurchaseWithIapkitResult.kt +14 -4
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Variant_NullType_NitroIapkitProductClientPayload.kt +62 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +50 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +6 -0
- package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +6 -0
- package/nitrogen/generated/ios/swift/IapkitClientPayloadFormat.swift +44 -0
- package/nitrogen/generated/ios/swift/NitroIapkitProductClientPayload.swift +44 -0
- package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithIapkitProps.swift +38 -1
- package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithIapkitResult.swift +76 -2
- package/nitrogen/generated/ios/swift/Variant_NullType_NitroIapkitProductClientPayload.swift +30 -0
- package/nitrogen/generated/shared/c++/IapkitClientPayloadFormat.hpp +80 -0
- package/nitrogen/generated/shared/c++/NitroIapkitProductClientPayload.hpp +97 -0
- package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithIapkitProps.hpp +6 -2
- package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithIapkitResult.hpp +16 -1
- package/openiap-versions.json +3 -3
- package/package.json +1 -1
- package/src/hooks/useIAP.ts +6 -2
- package/src/index.kepler.ts +13 -0
- package/src/index.ts +13 -0
- package/src/kit-api.ts +107 -0
- package/src/specs/RnIap.nitro.ts +18 -0
- package/src/types.ts +38 -1
- package/src/vega-adapter.ts +14 -11
|
@@ -18,7 +18,7 @@ public extension NitroVerifyPurchaseWithIapkitProps {
|
|
|
18
18
|
/**
|
|
19
19
|
* Create a new instance of `NitroVerifyPurchaseWithIapkitProps`.
|
|
20
20
|
*/
|
|
21
|
-
init(apiKey: Variant_NullType_String?, amazon: Variant_NullType_NitroVerifyPurchaseWithIapkitAmazonProps?, apple: Variant_NullType_NitroVerifyPurchaseWithIapkitAppleProps?, baseUrl: Variant_NullType_String?, google: Variant_NullType_NitroVerifyPurchaseWithIapkitGoogleProps?) {
|
|
21
|
+
init(apiKey: Variant_NullType_String?, amazon: Variant_NullType_NitroVerifyPurchaseWithIapkitAmazonProps?, apple: Variant_NullType_NitroVerifyPurchaseWithIapkitAppleProps?, baseUrl: Variant_NullType_String?, google: Variant_NullType_NitroVerifyPurchaseWithIapkitGoogleProps?, includeClientPayload: Variant_NullType_Bool?) {
|
|
22
22
|
self.init({ () -> bridge.std__optional_std__variant_nitro__NullType__std__string__ in
|
|
23
23
|
if let __unwrappedValue = apiKey {
|
|
24
24
|
return bridge.create_std__optional_std__variant_nitro__NullType__std__string__({ () -> bridge.std__variant_nitro__NullType__std__string_ in
|
|
@@ -84,6 +84,19 @@ public extension NitroVerifyPurchaseWithIapkitProps {
|
|
|
84
84
|
} else {
|
|
85
85
|
return .init()
|
|
86
86
|
}
|
|
87
|
+
}(), { () -> bridge.std__optional_std__variant_nitro__NullType__bool__ in
|
|
88
|
+
if let __unwrappedValue = includeClientPayload {
|
|
89
|
+
return bridge.create_std__optional_std__variant_nitro__NullType__bool__({ () -> bridge.std__variant_nitro__NullType__bool_ in
|
|
90
|
+
switch __unwrappedValue {
|
|
91
|
+
case .first(let __value):
|
|
92
|
+
return bridge.create_std__variant_nitro__NullType__bool_(margelo.nitro.NullType.null)
|
|
93
|
+
case .second(let __value):
|
|
94
|
+
return bridge.create_std__variant_nitro__NullType__bool_(__value)
|
|
95
|
+
}
|
|
96
|
+
}().variant)
|
|
97
|
+
} else {
|
|
98
|
+
return .init()
|
|
99
|
+
}
|
|
87
100
|
}())
|
|
88
101
|
}
|
|
89
102
|
|
|
@@ -206,4 +219,28 @@ public extension NitroVerifyPurchaseWithIapkitProps {
|
|
|
206
219
|
}
|
|
207
220
|
}()
|
|
208
221
|
}
|
|
222
|
+
|
|
223
|
+
@inline(__always)
|
|
224
|
+
var includeClientPayload: Variant_NullType_Bool? {
|
|
225
|
+
return { () -> Variant_NullType_Bool? in
|
|
226
|
+
if bridge.has_value_std__optional_std__variant_nitro__NullType__bool__(self.__includeClientPayload) {
|
|
227
|
+
let __unwrapped = bridge.get_std__optional_std__variant_nitro__NullType__bool__(self.__includeClientPayload)
|
|
228
|
+
return { () -> Variant_NullType_Bool in
|
|
229
|
+
let __variant = bridge.std__variant_nitro__NullType__bool_(__unwrapped)
|
|
230
|
+
switch __variant.index() {
|
|
231
|
+
case 0:
|
|
232
|
+
let __actual = __variant.get_0()
|
|
233
|
+
return .first(NullType.null)
|
|
234
|
+
case 1:
|
|
235
|
+
let __actual = __variant.get_1()
|
|
236
|
+
return .second(__actual)
|
|
237
|
+
default:
|
|
238
|
+
fatalError("Variant can never have index \(__variant.index())!")
|
|
239
|
+
}
|
|
240
|
+
}()
|
|
241
|
+
} else {
|
|
242
|
+
return nil
|
|
243
|
+
}
|
|
244
|
+
}()
|
|
245
|
+
}
|
|
209
246
|
}
|
|
@@ -18,15 +18,89 @@ public extension NitroVerifyPurchaseWithIapkitResult {
|
|
|
18
18
|
/**
|
|
19
19
|
* Create a new instance of `NitroVerifyPurchaseWithIapkitResult`.
|
|
20
20
|
*/
|
|
21
|
-
init(isValid: Bool, state: IapkitPurchaseState, store: IapStore) {
|
|
22
|
-
self.init(
|
|
21
|
+
init(clientPayload: Variant_NullType_NitroIapkitProductClientPayload?, isValid: Bool, productId: Variant_NullType_String?, state: IapkitPurchaseState, store: IapStore) {
|
|
22
|
+
self.init({ () -> bridge.std__optional_std__variant_nitro__NullType__NitroIapkitProductClientPayload__ in
|
|
23
|
+
if let __unwrappedValue = clientPayload {
|
|
24
|
+
return bridge.create_std__optional_std__variant_nitro__NullType__NitroIapkitProductClientPayload__({ () -> bridge.std__variant_nitro__NullType__NitroIapkitProductClientPayload_ in
|
|
25
|
+
switch __unwrappedValue {
|
|
26
|
+
case .first(let __value):
|
|
27
|
+
return bridge.create_std__variant_nitro__NullType__NitroIapkitProductClientPayload_(margelo.nitro.NullType.null)
|
|
28
|
+
case .second(let __value):
|
|
29
|
+
return bridge.create_std__variant_nitro__NullType__NitroIapkitProductClientPayload_(__value)
|
|
30
|
+
}
|
|
31
|
+
}().variant)
|
|
32
|
+
} else {
|
|
33
|
+
return .init()
|
|
34
|
+
}
|
|
35
|
+
}(), isValid, { () -> bridge.std__optional_std__variant_nitro__NullType__std__string__ in
|
|
36
|
+
if let __unwrappedValue = productId {
|
|
37
|
+
return bridge.create_std__optional_std__variant_nitro__NullType__std__string__({ () -> bridge.std__variant_nitro__NullType__std__string_ in
|
|
38
|
+
switch __unwrappedValue {
|
|
39
|
+
case .first(let __value):
|
|
40
|
+
return bridge.create_std__variant_nitro__NullType__std__string_(margelo.nitro.NullType.null)
|
|
41
|
+
case .second(let __value):
|
|
42
|
+
return bridge.create_std__variant_nitro__NullType__std__string_(std.string(__value))
|
|
43
|
+
}
|
|
44
|
+
}().variant)
|
|
45
|
+
} else {
|
|
46
|
+
return .init()
|
|
47
|
+
}
|
|
48
|
+
}(), state, store)
|
|
23
49
|
}
|
|
24
50
|
|
|
51
|
+
@inline(__always)
|
|
52
|
+
var clientPayload: Variant_NullType_NitroIapkitProductClientPayload? {
|
|
53
|
+
return { () -> Variant_NullType_NitroIapkitProductClientPayload? in
|
|
54
|
+
if bridge.has_value_std__optional_std__variant_nitro__NullType__NitroIapkitProductClientPayload__(self.__clientPayload) {
|
|
55
|
+
let __unwrapped = bridge.get_std__optional_std__variant_nitro__NullType__NitroIapkitProductClientPayload__(self.__clientPayload)
|
|
56
|
+
return { () -> Variant_NullType_NitroIapkitProductClientPayload in
|
|
57
|
+
let __variant = bridge.std__variant_nitro__NullType__NitroIapkitProductClientPayload_(__unwrapped)
|
|
58
|
+
switch __variant.index() {
|
|
59
|
+
case 0:
|
|
60
|
+
let __actual = __variant.get_0()
|
|
61
|
+
return .first(NullType.null)
|
|
62
|
+
case 1:
|
|
63
|
+
let __actual = __variant.get_1()
|
|
64
|
+
return .second(__actual)
|
|
65
|
+
default:
|
|
66
|
+
fatalError("Variant can never have index \(__variant.index())!")
|
|
67
|
+
}
|
|
68
|
+
}()
|
|
69
|
+
} else {
|
|
70
|
+
return nil
|
|
71
|
+
}
|
|
72
|
+
}()
|
|
73
|
+
}
|
|
74
|
+
|
|
25
75
|
@inline(__always)
|
|
26
76
|
var isValid: Bool {
|
|
27
77
|
return self.__isValid
|
|
28
78
|
}
|
|
29
79
|
|
|
80
|
+
@inline(__always)
|
|
81
|
+
var productId: Variant_NullType_String? {
|
|
82
|
+
return { () -> Variant_NullType_String? in
|
|
83
|
+
if bridge.has_value_std__optional_std__variant_nitro__NullType__std__string__(self.__productId) {
|
|
84
|
+
let __unwrapped = bridge.get_std__optional_std__variant_nitro__NullType__std__string__(self.__productId)
|
|
85
|
+
return { () -> Variant_NullType_String in
|
|
86
|
+
let __variant = bridge.std__variant_nitro__NullType__std__string_(__unwrapped)
|
|
87
|
+
switch __variant.index() {
|
|
88
|
+
case 0:
|
|
89
|
+
let __actual = __variant.get_0()
|
|
90
|
+
return .first(NullType.null)
|
|
91
|
+
case 1:
|
|
92
|
+
let __actual = __variant.get_1()
|
|
93
|
+
return .second(String(__actual))
|
|
94
|
+
default:
|
|
95
|
+
fatalError("Variant can never have index \(__variant.index())!")
|
|
96
|
+
}
|
|
97
|
+
}()
|
|
98
|
+
} else {
|
|
99
|
+
return nil
|
|
100
|
+
}
|
|
101
|
+
}()
|
|
102
|
+
}
|
|
103
|
+
|
|
30
104
|
@inline(__always)
|
|
31
105
|
var state: IapkitPurchaseState {
|
|
32
106
|
return self.__state
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Variant_NullType_NitroIapkitProductClientPayload.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* An Swift enum with associated values representing a Variant/Union type.
|
|
12
|
+
* JS type: `null | struct`
|
|
13
|
+
*/
|
|
14
|
+
@frozen
|
|
15
|
+
public indirect enum Variant_NullType_NitroIapkitProductClientPayload {
|
|
16
|
+
case first(NullType)
|
|
17
|
+
case second(NitroIapkitProductClientPayload)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public extension Variant_NullType_NitroIapkitProductClientPayload {
|
|
21
|
+
func asType<T>(_ type: T.Type = T.self) -> T? {
|
|
22
|
+
switch self {
|
|
23
|
+
case .first(let value): return value as? T
|
|
24
|
+
case .second(let value): return value as? T
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
func isType<T>(_ type: T.Type = T.self) -> Bool {
|
|
28
|
+
return self.asType(type) != nil
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// IapkitClientPayloadFormat.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 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 (IapkitClientPayloadFormat).
|
|
30
|
+
*/
|
|
31
|
+
enum class IapkitClientPayloadFormat {
|
|
32
|
+
TOML SWIFT_NAME(toml) = 0,
|
|
33
|
+
JSON SWIFT_NAME(json) = 1,
|
|
34
|
+
TEXT SWIFT_NAME(text) = 2,
|
|
35
|
+
} CLOSED_ENUM;
|
|
36
|
+
|
|
37
|
+
} // namespace margelo::nitro::iap
|
|
38
|
+
|
|
39
|
+
namespace margelo::nitro {
|
|
40
|
+
|
|
41
|
+
// C++ IapkitClientPayloadFormat <> JS IapkitClientPayloadFormat (union)
|
|
42
|
+
template <>
|
|
43
|
+
struct JSIConverter<margelo::nitro::iap::IapkitClientPayloadFormat> final {
|
|
44
|
+
static inline margelo::nitro::iap::IapkitClientPayloadFormat 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("toml"): return margelo::nitro::iap::IapkitClientPayloadFormat::TOML;
|
|
48
|
+
case hashString("json"): return margelo::nitro::iap::IapkitClientPayloadFormat::JSON;
|
|
49
|
+
case hashString("text"): return margelo::nitro::iap::IapkitClientPayloadFormat::TEXT;
|
|
50
|
+
default: [[unlikely]]
|
|
51
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum IapkitClientPayloadFormat - invalid value!");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::iap::IapkitClientPayloadFormat arg) {
|
|
55
|
+
switch (arg) {
|
|
56
|
+
case margelo::nitro::iap::IapkitClientPayloadFormat::TOML: return JSIConverter<std::string>::toJSI(runtime, "toml");
|
|
57
|
+
case margelo::nitro::iap::IapkitClientPayloadFormat::JSON: return JSIConverter<std::string>::toJSI(runtime, "json");
|
|
58
|
+
case margelo::nitro::iap::IapkitClientPayloadFormat::TEXT: return JSIConverter<std::string>::toJSI(runtime, "text");
|
|
59
|
+
default: [[unlikely]]
|
|
60
|
+
throw std::invalid_argument("Cannot convert IapkitClientPayloadFormat 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("toml"):
|
|
71
|
+
case hashString("json"):
|
|
72
|
+
case hashString("text"):
|
|
73
|
+
return true;
|
|
74
|
+
default:
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroIapkitProductClientPayload.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 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
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
// Forward declaration of `IapkitClientPayloadFormat` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::iap { enum class IapkitClientPayloadFormat; }
|
|
33
|
+
|
|
34
|
+
#include <string>
|
|
35
|
+
#include "IapkitClientPayloadFormat.hpp"
|
|
36
|
+
|
|
37
|
+
namespace margelo::nitro::iap {
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A struct which can be represented as a JavaScript object (NitroIapkitProductClientPayload).
|
|
41
|
+
*/
|
|
42
|
+
struct NitroIapkitProductClientPayload final {
|
|
43
|
+
public:
|
|
44
|
+
std::string body SWIFT_PRIVATE;
|
|
45
|
+
IapkitClientPayloadFormat format SWIFT_PRIVATE;
|
|
46
|
+
double updatedAt SWIFT_PRIVATE;
|
|
47
|
+
double version SWIFT_PRIVATE;
|
|
48
|
+
|
|
49
|
+
public:
|
|
50
|
+
NitroIapkitProductClientPayload() = default;
|
|
51
|
+
explicit NitroIapkitProductClientPayload(std::string body, IapkitClientPayloadFormat format, double updatedAt, double version): body(body), format(format), updatedAt(updatedAt), version(version) {}
|
|
52
|
+
|
|
53
|
+
public:
|
|
54
|
+
friend bool operator==(const NitroIapkitProductClientPayload& lhs, const NitroIapkitProductClientPayload& rhs) = default;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
} // namespace margelo::nitro::iap
|
|
58
|
+
|
|
59
|
+
namespace margelo::nitro {
|
|
60
|
+
|
|
61
|
+
// C++ NitroIapkitProductClientPayload <> JS NitroIapkitProductClientPayload (object)
|
|
62
|
+
template <>
|
|
63
|
+
struct JSIConverter<margelo::nitro::iap::NitroIapkitProductClientPayload> final {
|
|
64
|
+
static inline margelo::nitro::iap::NitroIapkitProductClientPayload fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
65
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
66
|
+
return margelo::nitro::iap::NitroIapkitProductClientPayload(
|
|
67
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "body"))),
|
|
68
|
+
JSIConverter<margelo::nitro::iap::IapkitClientPayloadFormat>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "format"))),
|
|
69
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "updatedAt"))),
|
|
70
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "version")))
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::NitroIapkitProductClientPayload& arg) {
|
|
74
|
+
jsi::Object obj(runtime);
|
|
75
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "body"), JSIConverter<std::string>::toJSI(runtime, arg.body));
|
|
76
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "format"), JSIConverter<margelo::nitro::iap::IapkitClientPayloadFormat>::toJSI(runtime, arg.format));
|
|
77
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "updatedAt"), JSIConverter<double>::toJSI(runtime, arg.updatedAt));
|
|
78
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "version"), JSIConverter<double>::toJSI(runtime, arg.version));
|
|
79
|
+
return obj;
|
|
80
|
+
}
|
|
81
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
82
|
+
if (!value.isObject()) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
jsi::Object obj = value.getObject(runtime);
|
|
86
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "body")))) return false;
|
|
90
|
+
if (!JSIConverter<margelo::nitro::iap::IapkitClientPayloadFormat>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "format")))) return false;
|
|
91
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "updatedAt")))) return false;
|
|
92
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "version")))) return false;
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
} // namespace margelo::nitro
|
|
@@ -55,10 +55,11 @@ namespace margelo::nitro::iap {
|
|
|
55
55
|
std::optional<std::variant<nitro::NullType, NitroVerifyPurchaseWithIapkitAppleProps>> apple SWIFT_PRIVATE;
|
|
56
56
|
std::optional<std::variant<nitro::NullType, std::string>> baseUrl SWIFT_PRIVATE;
|
|
57
57
|
std::optional<std::variant<nitro::NullType, NitroVerifyPurchaseWithIapkitGoogleProps>> google SWIFT_PRIVATE;
|
|
58
|
+
std::optional<std::variant<nitro::NullType, bool>> includeClientPayload SWIFT_PRIVATE;
|
|
58
59
|
|
|
59
60
|
public:
|
|
60
61
|
NitroVerifyPurchaseWithIapkitProps() = default;
|
|
61
|
-
explicit NitroVerifyPurchaseWithIapkitProps(std::optional<std::variant<nitro::NullType, std::string>> apiKey, std::optional<std::variant<nitro::NullType, NitroVerifyPurchaseWithIapkitAmazonProps>> amazon, std::optional<std::variant<nitro::NullType, NitroVerifyPurchaseWithIapkitAppleProps>> apple, std::optional<std::variant<nitro::NullType, std::string>> baseUrl, std::optional<std::variant<nitro::NullType, NitroVerifyPurchaseWithIapkitGoogleProps>> google): apiKey(apiKey), amazon(amazon), apple(apple), baseUrl(baseUrl), google(google) {}
|
|
62
|
+
explicit NitroVerifyPurchaseWithIapkitProps(std::optional<std::variant<nitro::NullType, std::string>> apiKey, std::optional<std::variant<nitro::NullType, NitroVerifyPurchaseWithIapkitAmazonProps>> amazon, std::optional<std::variant<nitro::NullType, NitroVerifyPurchaseWithIapkitAppleProps>> apple, std::optional<std::variant<nitro::NullType, std::string>> baseUrl, std::optional<std::variant<nitro::NullType, NitroVerifyPurchaseWithIapkitGoogleProps>> google, std::optional<std::variant<nitro::NullType, bool>> includeClientPayload): apiKey(apiKey), amazon(amazon), apple(apple), baseUrl(baseUrl), google(google), includeClientPayload(includeClientPayload) {}
|
|
62
63
|
|
|
63
64
|
public:
|
|
64
65
|
friend bool operator==(const NitroVerifyPurchaseWithIapkitProps& lhs, const NitroVerifyPurchaseWithIapkitProps& rhs) = default;
|
|
@@ -78,7 +79,8 @@ namespace margelo::nitro {
|
|
|
78
79
|
JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::NitroVerifyPurchaseWithIapkitAmazonProps>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "amazon"))),
|
|
79
80
|
JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::NitroVerifyPurchaseWithIapkitAppleProps>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "apple"))),
|
|
80
81
|
JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "baseUrl"))),
|
|
81
|
-
JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::NitroVerifyPurchaseWithIapkitGoogleProps>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "google")))
|
|
82
|
+
JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::NitroVerifyPurchaseWithIapkitGoogleProps>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "google"))),
|
|
83
|
+
JSIConverter<std::optional<std::variant<nitro::NullType, bool>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "includeClientPayload")))
|
|
82
84
|
);
|
|
83
85
|
}
|
|
84
86
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::NitroVerifyPurchaseWithIapkitProps& arg) {
|
|
@@ -88,6 +90,7 @@ namespace margelo::nitro {
|
|
|
88
90
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "apple"), JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::NitroVerifyPurchaseWithIapkitAppleProps>>>::toJSI(runtime, arg.apple));
|
|
89
91
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "baseUrl"), JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::toJSI(runtime, arg.baseUrl));
|
|
90
92
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "google"), JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::NitroVerifyPurchaseWithIapkitGoogleProps>>>::toJSI(runtime, arg.google));
|
|
93
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "includeClientPayload"), JSIConverter<std::optional<std::variant<nitro::NullType, bool>>>::toJSI(runtime, arg.includeClientPayload));
|
|
91
94
|
return obj;
|
|
92
95
|
}
|
|
93
96
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -103,6 +106,7 @@ namespace margelo::nitro {
|
|
|
103
106
|
if (!JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::NitroVerifyPurchaseWithIapkitAppleProps>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "apple")))) return false;
|
|
104
107
|
if (!JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "baseUrl")))) return false;
|
|
105
108
|
if (!JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::NitroVerifyPurchaseWithIapkitGoogleProps>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "google")))) return false;
|
|
109
|
+
if (!JSIConverter<std::optional<std::variant<nitro::NullType, bool>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "includeClientPayload")))) return false;
|
|
106
110
|
return true;
|
|
107
111
|
}
|
|
108
112
|
};
|
|
@@ -28,11 +28,18 @@
|
|
|
28
28
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
29
|
#endif
|
|
30
30
|
|
|
31
|
+
// Forward declaration of `NitroIapkitProductClientPayload` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::iap { struct NitroIapkitProductClientPayload; }
|
|
31
33
|
// Forward declaration of `IapkitPurchaseState` to properly resolve imports.
|
|
32
34
|
namespace margelo::nitro::iap { enum class IapkitPurchaseState; }
|
|
33
35
|
// Forward declaration of `IapStore` to properly resolve imports.
|
|
34
36
|
namespace margelo::nitro::iap { enum class IapStore; }
|
|
35
37
|
|
|
38
|
+
#include <NitroModules/Null.hpp>
|
|
39
|
+
#include "NitroIapkitProductClientPayload.hpp"
|
|
40
|
+
#include <variant>
|
|
41
|
+
#include <optional>
|
|
42
|
+
#include <string>
|
|
36
43
|
#include "IapkitPurchaseState.hpp"
|
|
37
44
|
#include "IapStore.hpp"
|
|
38
45
|
|
|
@@ -43,13 +50,15 @@ namespace margelo::nitro::iap {
|
|
|
43
50
|
*/
|
|
44
51
|
struct NitroVerifyPurchaseWithIapkitResult final {
|
|
45
52
|
public:
|
|
53
|
+
std::optional<std::variant<nitro::NullType, NitroIapkitProductClientPayload>> clientPayload SWIFT_PRIVATE;
|
|
46
54
|
bool isValid SWIFT_PRIVATE;
|
|
55
|
+
std::optional<std::variant<nitro::NullType, std::string>> productId SWIFT_PRIVATE;
|
|
47
56
|
IapkitPurchaseState state SWIFT_PRIVATE;
|
|
48
57
|
IapStore store SWIFT_PRIVATE;
|
|
49
58
|
|
|
50
59
|
public:
|
|
51
60
|
NitroVerifyPurchaseWithIapkitResult() = default;
|
|
52
|
-
explicit NitroVerifyPurchaseWithIapkitResult(bool isValid, IapkitPurchaseState state, IapStore store): isValid(isValid), state(state), store(store) {}
|
|
61
|
+
explicit NitroVerifyPurchaseWithIapkitResult(std::optional<std::variant<nitro::NullType, NitroIapkitProductClientPayload>> clientPayload, bool isValid, std::optional<std::variant<nitro::NullType, std::string>> productId, IapkitPurchaseState state, IapStore store): clientPayload(clientPayload), isValid(isValid), productId(productId), state(state), store(store) {}
|
|
53
62
|
|
|
54
63
|
public:
|
|
55
64
|
friend bool operator==(const NitroVerifyPurchaseWithIapkitResult& lhs, const NitroVerifyPurchaseWithIapkitResult& rhs) = default;
|
|
@@ -65,14 +74,18 @@ namespace margelo::nitro {
|
|
|
65
74
|
static inline margelo::nitro::iap::NitroVerifyPurchaseWithIapkitResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
66
75
|
jsi::Object obj = arg.asObject(runtime);
|
|
67
76
|
return margelo::nitro::iap::NitroVerifyPurchaseWithIapkitResult(
|
|
77
|
+
JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::NitroIapkitProductClientPayload>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "clientPayload"))),
|
|
68
78
|
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isValid"))),
|
|
79
|
+
JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "productId"))),
|
|
69
80
|
JSIConverter<margelo::nitro::iap::IapkitPurchaseState>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "state"))),
|
|
70
81
|
JSIConverter<margelo::nitro::iap::IapStore>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "store")))
|
|
71
82
|
);
|
|
72
83
|
}
|
|
73
84
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::NitroVerifyPurchaseWithIapkitResult& arg) {
|
|
74
85
|
jsi::Object obj(runtime);
|
|
86
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "clientPayload"), JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::NitroIapkitProductClientPayload>>>::toJSI(runtime, arg.clientPayload));
|
|
75
87
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "isValid"), JSIConverter<bool>::toJSI(runtime, arg.isValid));
|
|
88
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "productId"), JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::toJSI(runtime, arg.productId));
|
|
76
89
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "state"), JSIConverter<margelo::nitro::iap::IapkitPurchaseState>::toJSI(runtime, arg.state));
|
|
77
90
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "store"), JSIConverter<margelo::nitro::iap::IapStore>::toJSI(runtime, arg.store));
|
|
78
91
|
return obj;
|
|
@@ -85,7 +98,9 @@ namespace margelo::nitro {
|
|
|
85
98
|
if (!nitro::isPlainObject(runtime, obj)) {
|
|
86
99
|
return false;
|
|
87
100
|
}
|
|
101
|
+
if (!JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::NitroIapkitProductClientPayload>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "clientPayload")))) return false;
|
|
88
102
|
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isValid")))) return false;
|
|
103
|
+
if (!JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "productId")))) return false;
|
|
89
104
|
if (!JSIConverter<margelo::nitro::iap::IapkitPurchaseState>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "state")))) return false;
|
|
90
105
|
if (!JSIConverter<margelo::nitro::iap::IapStore>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "store")))) return false;
|
|
91
106
|
return true;
|
package/openiap-versions.json
CHANGED
package/package.json
CHANGED
package/src/hooks/useIAP.ts
CHANGED
|
@@ -505,7 +505,9 @@ export function useIAP(options?: UseIapOptions): UseIap {
|
|
|
505
505
|
onlyIncludeActiveItemsIOS: options?.onlyIncludeActiveItemsIOS ?? true,
|
|
506
506
|
includeSuspendedAndroid: options?.includeSuspendedAndroid ?? false,
|
|
507
507
|
});
|
|
508
|
-
|
|
508
|
+
if (isMountedRef.current) {
|
|
509
|
+
setAvailablePurchases(result);
|
|
510
|
+
}
|
|
509
511
|
} catch (error) {
|
|
510
512
|
RnIapConsole.error('Error fetching available purchases:', error);
|
|
511
513
|
invokeOnError(error);
|
|
@@ -518,7 +520,9 @@ export function useIAP(options?: UseIapOptions): UseIap {
|
|
|
518
520
|
async (subscriptionIds?: string[]): Promise<ActiveSubscription[]> => {
|
|
519
521
|
try {
|
|
520
522
|
const result = await getActiveSubscriptions(subscriptionIds);
|
|
521
|
-
|
|
523
|
+
if (isMountedRef.current) {
|
|
524
|
+
setActiveSubscriptions(result);
|
|
525
|
+
}
|
|
522
526
|
return result;
|
|
523
527
|
} catch (error) {
|
|
524
528
|
RnIapConsole.error('Error getting active subscriptions:', error);
|
package/src/index.kepler.ts
CHANGED
|
@@ -32,6 +32,19 @@ export * from './vega';
|
|
|
32
32
|
export {useIAP, type UseIapOptions} from './hooks/useIAP';
|
|
33
33
|
export {connectWebhookStream, parseWebhookEventData} from './webhook-client';
|
|
34
34
|
export {kitApi, KitApiError} from './kit-api';
|
|
35
|
+
export type {
|
|
36
|
+
EntitlementsResponse,
|
|
37
|
+
KitApiOptions,
|
|
38
|
+
KitClientPayloadResponse,
|
|
39
|
+
KitProduct,
|
|
40
|
+
KitProductClientPayload,
|
|
41
|
+
KitProductOffer,
|
|
42
|
+
KitProductPlatform,
|
|
43
|
+
KitProductsOptions,
|
|
44
|
+
KitProductsResponse,
|
|
45
|
+
KitSubscription,
|
|
46
|
+
StatusResponse,
|
|
47
|
+
} from './kit-api';
|
|
35
48
|
|
|
36
49
|
export type ProductTypeInput = 'inapp' | 'in-app' | 'subs';
|
|
37
50
|
|
package/src/index.ts
CHANGED
|
@@ -165,6 +165,13 @@ export type {
|
|
|
165
165
|
export {kitApi, KitApiError} from './kit-api';
|
|
166
166
|
export type {
|
|
167
167
|
KitApiOptions,
|
|
168
|
+
KitClientPayloadResponse,
|
|
169
|
+
KitProduct,
|
|
170
|
+
KitProductClientPayload,
|
|
171
|
+
KitProductOffer,
|
|
172
|
+
KitProductPlatform,
|
|
173
|
+
KitProductsOptions,
|
|
174
|
+
KitProductsResponse,
|
|
168
175
|
KitSubscription,
|
|
169
176
|
EntitlementsResponse,
|
|
170
177
|
StatusResponse,
|
|
@@ -2337,7 +2344,13 @@ export const verifyPurchaseWithProvider: MutationField<
|
|
|
2337
2344
|
provider: result.provider,
|
|
2338
2345
|
iapkit: result.iapkit
|
|
2339
2346
|
? {
|
|
2347
|
+
...(result.iapkit.clientPayload == null
|
|
2348
|
+
? {}
|
|
2349
|
+
: {clientPayload: result.iapkit.clientPayload}),
|
|
2340
2350
|
isValid: result.iapkit.isValid,
|
|
2351
|
+
...(result.iapkit.productId == null
|
|
2352
|
+
? {}
|
|
2353
|
+
: {productId: result.iapkit.productId}),
|
|
2341
2354
|
state: result.iapkit.state,
|
|
2342
2355
|
store: result.iapkit.store,
|
|
2343
2356
|
}
|