react-native-iap 14.6.0-rc.1 → 14.6.0-rc.2
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/README.md +1 -0
- package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +72 -36
- package/ios/HybridRnIap.swift +8 -2
- package/lib/module/hooks/useIAP.js +1 -6
- package/lib/module/hooks/useIAP.js.map +1 -1
- package/lib/module/index.js +62 -10
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js +58 -0
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/plugin/src/withIAP.d.ts +6 -0
- package/lib/typescript/plugin/src/withIAP.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useIAP.d.ts +5 -7
- package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +20 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/RnIap.nitro.d.ts +19 -8
- package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +94 -9
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +12 -4
- package/nitrogen/generated/android/c++/JNitroReceiptValidationAppleOptions.hpp +57 -0
- package/nitrogen/generated/android/c++/{JNitroReceiptValidationAndroidOptions.hpp → JNitroReceiptValidationGoogleOptions.hpp} +18 -14
- package/nitrogen/generated/android/c++/JNitroReceiptValidationHorizonOptions.hpp +65 -0
- package/nitrogen/generated/android/c++/JNitroReceiptValidationParams.hpp +19 -11
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroReceiptValidationAppleOptions.kt +36 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/{NitroReceiptValidationAndroidOptions.kt → NitroReceiptValidationGoogleOptions.kt} +9 -6
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroReceiptValidationHorizonOptions.kt +42 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroReceiptValidationParams.kt +7 -4
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +46 -10
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +9 -3
- package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +9 -3
- package/nitrogen/generated/ios/swift/NitroReceiptValidationAppleOptions.swift +35 -0
- package/nitrogen/generated/ios/swift/{NitroReceiptValidationAndroidOptions.swift → NitroReceiptValidationGoogleOptions.swift} +21 -10
- package/nitrogen/generated/ios/swift/NitroReceiptValidationHorizonOptions.swift +57 -0
- package/nitrogen/generated/ios/swift/NitroReceiptValidationParams.swift +46 -11
- package/nitrogen/generated/shared/c++/NitroReceiptValidationAppleOptions.hpp +75 -0
- package/nitrogen/generated/shared/c++/{NitroReceiptValidationAndroidOptions.hpp → NitroReceiptValidationGoogleOptions.hpp} +18 -14
- package/nitrogen/generated/shared/c++/NitroReceiptValidationHorizonOptions.hpp +83 -0
- package/nitrogen/generated/shared/c++/NitroReceiptValidationParams.hpp +22 -13
- package/openiap-versions.json +3 -3
- package/package.json +1 -1
- package/plugin/build/withIAP.d.ts +6 -0
- package/plugin/build/withIAP.js +46 -2
- package/plugin/src/withIAP.ts +67 -2
- package/src/hooks/useIAP.ts +8 -23
- package/src/index.ts +79 -14
- package/src/specs/RnIap.nitro.ts +24 -10
- package/src/types.ts +97 -9
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroReceiptValidationHorizonOptions.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents an instance of `NitroReceiptValidationHorizonOptions`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias NitroReceiptValidationHorizonOptions = margelo.nitro.iap.NitroReceiptValidationHorizonOptions
|
|
14
|
+
|
|
15
|
+
public extension NitroReceiptValidationHorizonOptions {
|
|
16
|
+
private typealias bridge = margelo.nitro.iap.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `NitroReceiptValidationHorizonOptions`.
|
|
20
|
+
*/
|
|
21
|
+
init(accessToken: String, sku: String, userId: String) {
|
|
22
|
+
self.init(std.string(accessToken), std.string(sku), std.string(userId))
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var accessToken: String {
|
|
26
|
+
@inline(__always)
|
|
27
|
+
get {
|
|
28
|
+
return String(self.__accessToken)
|
|
29
|
+
}
|
|
30
|
+
@inline(__always)
|
|
31
|
+
set {
|
|
32
|
+
self.__accessToken = std.string(newValue)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var sku: String {
|
|
37
|
+
@inline(__always)
|
|
38
|
+
get {
|
|
39
|
+
return String(self.__sku)
|
|
40
|
+
}
|
|
41
|
+
@inline(__always)
|
|
42
|
+
set {
|
|
43
|
+
self.__sku = std.string(newValue)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var userId: String {
|
|
48
|
+
@inline(__always)
|
|
49
|
+
get {
|
|
50
|
+
return String(self.__userId)
|
|
51
|
+
}
|
|
52
|
+
@inline(__always)
|
|
53
|
+
set {
|
|
54
|
+
self.__userId = std.string(newValue)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -18,37 +18,72 @@ public extension NitroReceiptValidationParams {
|
|
|
18
18
|
/**
|
|
19
19
|
* Create a new instance of `NitroReceiptValidationParams`.
|
|
20
20
|
*/
|
|
21
|
-
init(
|
|
22
|
-
self.init(
|
|
23
|
-
if let __unwrappedValue =
|
|
24
|
-
return bridge.
|
|
21
|
+
init(apple: NitroReceiptValidationAppleOptions?, google: NitroReceiptValidationGoogleOptions?, horizon: NitroReceiptValidationHorizonOptions?) {
|
|
22
|
+
self.init({ () -> bridge.std__optional_NitroReceiptValidationAppleOptions_ in
|
|
23
|
+
if let __unwrappedValue = apple {
|
|
24
|
+
return bridge.create_std__optional_NitroReceiptValidationAppleOptions_(__unwrappedValue)
|
|
25
|
+
} else {
|
|
26
|
+
return .init()
|
|
27
|
+
}
|
|
28
|
+
}(), { () -> bridge.std__optional_NitroReceiptValidationGoogleOptions_ in
|
|
29
|
+
if let __unwrappedValue = google {
|
|
30
|
+
return bridge.create_std__optional_NitroReceiptValidationGoogleOptions_(__unwrappedValue)
|
|
31
|
+
} else {
|
|
32
|
+
return .init()
|
|
33
|
+
}
|
|
34
|
+
}(), { () -> bridge.std__optional_NitroReceiptValidationHorizonOptions_ in
|
|
35
|
+
if let __unwrappedValue = horizon {
|
|
36
|
+
return bridge.create_std__optional_NitroReceiptValidationHorizonOptions_(__unwrappedValue)
|
|
25
37
|
} else {
|
|
26
38
|
return .init()
|
|
27
39
|
}
|
|
28
40
|
}())
|
|
29
41
|
}
|
|
30
42
|
|
|
31
|
-
var
|
|
43
|
+
var apple: NitroReceiptValidationAppleOptions? {
|
|
44
|
+
@inline(__always)
|
|
45
|
+
get {
|
|
46
|
+
return self.__apple.value
|
|
47
|
+
}
|
|
48
|
+
@inline(__always)
|
|
49
|
+
set {
|
|
50
|
+
self.__apple = { () -> bridge.std__optional_NitroReceiptValidationAppleOptions_ in
|
|
51
|
+
if let __unwrappedValue = newValue {
|
|
52
|
+
return bridge.create_std__optional_NitroReceiptValidationAppleOptions_(__unwrappedValue)
|
|
53
|
+
} else {
|
|
54
|
+
return .init()
|
|
55
|
+
}
|
|
56
|
+
}()
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
var google: NitroReceiptValidationGoogleOptions? {
|
|
32
61
|
@inline(__always)
|
|
33
62
|
get {
|
|
34
|
-
return
|
|
63
|
+
return self.__google.value
|
|
35
64
|
}
|
|
36
65
|
@inline(__always)
|
|
37
66
|
set {
|
|
38
|
-
self.
|
|
67
|
+
self.__google = { () -> bridge.std__optional_NitroReceiptValidationGoogleOptions_ in
|
|
68
|
+
if let __unwrappedValue = newValue {
|
|
69
|
+
return bridge.create_std__optional_NitroReceiptValidationGoogleOptions_(__unwrappedValue)
|
|
70
|
+
} else {
|
|
71
|
+
return .init()
|
|
72
|
+
}
|
|
73
|
+
}()
|
|
39
74
|
}
|
|
40
75
|
}
|
|
41
76
|
|
|
42
|
-
var
|
|
77
|
+
var horizon: NitroReceiptValidationHorizonOptions? {
|
|
43
78
|
@inline(__always)
|
|
44
79
|
get {
|
|
45
|
-
return self.
|
|
80
|
+
return self.__horizon.value
|
|
46
81
|
}
|
|
47
82
|
@inline(__always)
|
|
48
83
|
set {
|
|
49
|
-
self.
|
|
84
|
+
self.__horizon = { () -> bridge.std__optional_NitroReceiptValidationHorizonOptions_ in
|
|
50
85
|
if let __unwrappedValue = newValue {
|
|
51
|
-
return bridge.
|
|
86
|
+
return bridge.create_std__optional_NitroReceiptValidationHorizonOptions_(__unwrappedValue)
|
|
52
87
|
} else {
|
|
53
88
|
return .init()
|
|
54
89
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroReceiptValidationAppleOptions.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
|
+
#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
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
#include <string>
|
|
29
|
+
|
|
30
|
+
namespace margelo::nitro::iap {
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A struct which can be represented as a JavaScript object (NitroReceiptValidationAppleOptions).
|
|
34
|
+
*/
|
|
35
|
+
struct NitroReceiptValidationAppleOptions {
|
|
36
|
+
public:
|
|
37
|
+
std::string sku SWIFT_PRIVATE;
|
|
38
|
+
|
|
39
|
+
public:
|
|
40
|
+
NitroReceiptValidationAppleOptions() = default;
|
|
41
|
+
explicit NitroReceiptValidationAppleOptions(std::string sku): sku(sku) {}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
} // namespace margelo::nitro::iap
|
|
45
|
+
|
|
46
|
+
namespace margelo::nitro {
|
|
47
|
+
|
|
48
|
+
// C++ NitroReceiptValidationAppleOptions <> JS NitroReceiptValidationAppleOptions (object)
|
|
49
|
+
template <>
|
|
50
|
+
struct JSIConverter<margelo::nitro::iap::NitroReceiptValidationAppleOptions> final {
|
|
51
|
+
static inline margelo::nitro::iap::NitroReceiptValidationAppleOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
52
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
53
|
+
return margelo::nitro::iap::NitroReceiptValidationAppleOptions(
|
|
54
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "sku"))
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::NitroReceiptValidationAppleOptions& arg) {
|
|
58
|
+
jsi::Object obj(runtime);
|
|
59
|
+
obj.setProperty(runtime, "sku", JSIConverter<std::string>::toJSI(runtime, arg.sku));
|
|
60
|
+
return obj;
|
|
61
|
+
}
|
|
62
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
63
|
+
if (!value.isObject()) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
jsi::Object obj = value.getObject(runtime);
|
|
67
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "sku"))) return false;
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
} // namespace margelo::nitro
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
///
|
|
2
|
-
///
|
|
2
|
+
/// NitroReceiptValidationGoogleOptions.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
5
|
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
@@ -31,42 +31,45 @@
|
|
|
31
31
|
namespace margelo::nitro::iap {
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* A struct which can be represented as a JavaScript object (
|
|
34
|
+
* A struct which can be represented as a JavaScript object (NitroReceiptValidationGoogleOptions).
|
|
35
35
|
*/
|
|
36
|
-
struct
|
|
36
|
+
struct NitroReceiptValidationGoogleOptions {
|
|
37
37
|
public:
|
|
38
38
|
std::string accessToken SWIFT_PRIVATE;
|
|
39
39
|
std::optional<bool> isSub SWIFT_PRIVATE;
|
|
40
40
|
std::string packageName SWIFT_PRIVATE;
|
|
41
|
-
std::string
|
|
41
|
+
std::string purchaseToken SWIFT_PRIVATE;
|
|
42
|
+
std::string sku SWIFT_PRIVATE;
|
|
42
43
|
|
|
43
44
|
public:
|
|
44
|
-
|
|
45
|
-
explicit
|
|
45
|
+
NitroReceiptValidationGoogleOptions() = default;
|
|
46
|
+
explicit NitroReceiptValidationGoogleOptions(std::string accessToken, std::optional<bool> isSub, std::string packageName, std::string purchaseToken, std::string sku): accessToken(accessToken), isSub(isSub), packageName(packageName), purchaseToken(purchaseToken), sku(sku) {}
|
|
46
47
|
};
|
|
47
48
|
|
|
48
49
|
} // namespace margelo::nitro::iap
|
|
49
50
|
|
|
50
51
|
namespace margelo::nitro {
|
|
51
52
|
|
|
52
|
-
// C++
|
|
53
|
+
// C++ NitroReceiptValidationGoogleOptions <> JS NitroReceiptValidationGoogleOptions (object)
|
|
53
54
|
template <>
|
|
54
|
-
struct JSIConverter<margelo::nitro::iap::
|
|
55
|
-
static inline margelo::nitro::iap::
|
|
55
|
+
struct JSIConverter<margelo::nitro::iap::NitroReceiptValidationGoogleOptions> final {
|
|
56
|
+
static inline margelo::nitro::iap::NitroReceiptValidationGoogleOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
56
57
|
jsi::Object obj = arg.asObject(runtime);
|
|
57
|
-
return margelo::nitro::iap::
|
|
58
|
+
return margelo::nitro::iap::NitroReceiptValidationGoogleOptions(
|
|
58
59
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "accessToken")),
|
|
59
60
|
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, "isSub")),
|
|
60
61
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "packageName")),
|
|
61
|
-
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "
|
|
62
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "purchaseToken")),
|
|
63
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "sku"))
|
|
62
64
|
);
|
|
63
65
|
}
|
|
64
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::
|
|
66
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::NitroReceiptValidationGoogleOptions& arg) {
|
|
65
67
|
jsi::Object obj(runtime);
|
|
66
68
|
obj.setProperty(runtime, "accessToken", JSIConverter<std::string>::toJSI(runtime, arg.accessToken));
|
|
67
69
|
obj.setProperty(runtime, "isSub", JSIConverter<std::optional<bool>>::toJSI(runtime, arg.isSub));
|
|
68
70
|
obj.setProperty(runtime, "packageName", JSIConverter<std::string>::toJSI(runtime, arg.packageName));
|
|
69
|
-
obj.setProperty(runtime, "
|
|
71
|
+
obj.setProperty(runtime, "purchaseToken", JSIConverter<std::string>::toJSI(runtime, arg.purchaseToken));
|
|
72
|
+
obj.setProperty(runtime, "sku", JSIConverter<std::string>::toJSI(runtime, arg.sku));
|
|
70
73
|
return obj;
|
|
71
74
|
}
|
|
72
75
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -80,7 +83,8 @@ namespace margelo::nitro {
|
|
|
80
83
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "accessToken"))) return false;
|
|
81
84
|
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, "isSub"))) return false;
|
|
82
85
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "packageName"))) return false;
|
|
83
|
-
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "
|
|
86
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "purchaseToken"))) return false;
|
|
87
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "sku"))) return false;
|
|
84
88
|
return true;
|
|
85
89
|
}
|
|
86
90
|
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroReceiptValidationHorizonOptions.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
|
+
#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
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
#include <string>
|
|
29
|
+
|
|
30
|
+
namespace margelo::nitro::iap {
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A struct which can be represented as a JavaScript object (NitroReceiptValidationHorizonOptions).
|
|
34
|
+
*/
|
|
35
|
+
struct NitroReceiptValidationHorizonOptions {
|
|
36
|
+
public:
|
|
37
|
+
std::string accessToken SWIFT_PRIVATE;
|
|
38
|
+
std::string sku SWIFT_PRIVATE;
|
|
39
|
+
std::string userId SWIFT_PRIVATE;
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
NitroReceiptValidationHorizonOptions() = default;
|
|
43
|
+
explicit NitroReceiptValidationHorizonOptions(std::string accessToken, std::string sku, std::string userId): accessToken(accessToken), sku(sku), userId(userId) {}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
} // namespace margelo::nitro::iap
|
|
47
|
+
|
|
48
|
+
namespace margelo::nitro {
|
|
49
|
+
|
|
50
|
+
// C++ NitroReceiptValidationHorizonOptions <> JS NitroReceiptValidationHorizonOptions (object)
|
|
51
|
+
template <>
|
|
52
|
+
struct JSIConverter<margelo::nitro::iap::NitroReceiptValidationHorizonOptions> final {
|
|
53
|
+
static inline margelo::nitro::iap::NitroReceiptValidationHorizonOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
54
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
55
|
+
return margelo::nitro::iap::NitroReceiptValidationHorizonOptions(
|
|
56
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "accessToken")),
|
|
57
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "sku")),
|
|
58
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "userId"))
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::NitroReceiptValidationHorizonOptions& arg) {
|
|
62
|
+
jsi::Object obj(runtime);
|
|
63
|
+
obj.setProperty(runtime, "accessToken", JSIConverter<std::string>::toJSI(runtime, arg.accessToken));
|
|
64
|
+
obj.setProperty(runtime, "sku", JSIConverter<std::string>::toJSI(runtime, arg.sku));
|
|
65
|
+
obj.setProperty(runtime, "userId", JSIConverter<std::string>::toJSI(runtime, arg.userId));
|
|
66
|
+
return obj;
|
|
67
|
+
}
|
|
68
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
69
|
+
if (!value.isObject()) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
jsi::Object obj = value.getObject(runtime);
|
|
73
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "accessToken"))) return false;
|
|
77
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "sku"))) return false;
|
|
78
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "userId"))) return false;
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
} // namespace margelo::nitro
|
|
@@ -23,12 +23,17 @@
|
|
|
23
23
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
24
|
#endif
|
|
25
25
|
|
|
26
|
-
// Forward declaration of `
|
|
27
|
-
namespace margelo::nitro::iap { struct
|
|
26
|
+
// Forward declaration of `NitroReceiptValidationAppleOptions` to properly resolve imports.
|
|
27
|
+
namespace margelo::nitro::iap { struct NitroReceiptValidationAppleOptions; }
|
|
28
|
+
// Forward declaration of `NitroReceiptValidationGoogleOptions` to properly resolve imports.
|
|
29
|
+
namespace margelo::nitro::iap { struct NitroReceiptValidationGoogleOptions; }
|
|
30
|
+
// Forward declaration of `NitroReceiptValidationHorizonOptions` to properly resolve imports.
|
|
31
|
+
namespace margelo::nitro::iap { struct NitroReceiptValidationHorizonOptions; }
|
|
28
32
|
|
|
29
|
-
#include
|
|
30
|
-
#include "NitroReceiptValidationAndroidOptions.hpp"
|
|
33
|
+
#include "NitroReceiptValidationAppleOptions.hpp"
|
|
31
34
|
#include <optional>
|
|
35
|
+
#include "NitroReceiptValidationGoogleOptions.hpp"
|
|
36
|
+
#include "NitroReceiptValidationHorizonOptions.hpp"
|
|
32
37
|
|
|
33
38
|
namespace margelo::nitro::iap {
|
|
34
39
|
|
|
@@ -37,12 +42,13 @@ namespace margelo::nitro::iap {
|
|
|
37
42
|
*/
|
|
38
43
|
struct NitroReceiptValidationParams {
|
|
39
44
|
public:
|
|
40
|
-
std::
|
|
41
|
-
std::optional<
|
|
45
|
+
std::optional<NitroReceiptValidationAppleOptions> apple SWIFT_PRIVATE;
|
|
46
|
+
std::optional<NitroReceiptValidationGoogleOptions> google SWIFT_PRIVATE;
|
|
47
|
+
std::optional<NitroReceiptValidationHorizonOptions> horizon SWIFT_PRIVATE;
|
|
42
48
|
|
|
43
49
|
public:
|
|
44
50
|
NitroReceiptValidationParams() = default;
|
|
45
|
-
explicit NitroReceiptValidationParams(std::
|
|
51
|
+
explicit NitroReceiptValidationParams(std::optional<NitroReceiptValidationAppleOptions> apple, std::optional<NitroReceiptValidationGoogleOptions> google, std::optional<NitroReceiptValidationHorizonOptions> horizon): apple(apple), google(google), horizon(horizon) {}
|
|
46
52
|
};
|
|
47
53
|
|
|
48
54
|
} // namespace margelo::nitro::iap
|
|
@@ -55,14 +61,16 @@ namespace margelo::nitro {
|
|
|
55
61
|
static inline margelo::nitro::iap::NitroReceiptValidationParams fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
56
62
|
jsi::Object obj = arg.asObject(runtime);
|
|
57
63
|
return margelo::nitro::iap::NitroReceiptValidationParams(
|
|
58
|
-
JSIConverter<std::
|
|
59
|
-
JSIConverter<std::optional<margelo::nitro::iap::
|
|
64
|
+
JSIConverter<std::optional<margelo::nitro::iap::NitroReceiptValidationAppleOptions>>::fromJSI(runtime, obj.getProperty(runtime, "apple")),
|
|
65
|
+
JSIConverter<std::optional<margelo::nitro::iap::NitroReceiptValidationGoogleOptions>>::fromJSI(runtime, obj.getProperty(runtime, "google")),
|
|
66
|
+
JSIConverter<std::optional<margelo::nitro::iap::NitroReceiptValidationHorizonOptions>>::fromJSI(runtime, obj.getProperty(runtime, "horizon"))
|
|
60
67
|
);
|
|
61
68
|
}
|
|
62
69
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::NitroReceiptValidationParams& arg) {
|
|
63
70
|
jsi::Object obj(runtime);
|
|
64
|
-
obj.setProperty(runtime, "
|
|
65
|
-
obj.setProperty(runtime, "
|
|
71
|
+
obj.setProperty(runtime, "apple", JSIConverter<std::optional<margelo::nitro::iap::NitroReceiptValidationAppleOptions>>::toJSI(runtime, arg.apple));
|
|
72
|
+
obj.setProperty(runtime, "google", JSIConverter<std::optional<margelo::nitro::iap::NitroReceiptValidationGoogleOptions>>::toJSI(runtime, arg.google));
|
|
73
|
+
obj.setProperty(runtime, "horizon", JSIConverter<std::optional<margelo::nitro::iap::NitroReceiptValidationHorizonOptions>>::toJSI(runtime, arg.horizon));
|
|
66
74
|
return obj;
|
|
67
75
|
}
|
|
68
76
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -73,8 +81,9 @@ namespace margelo::nitro {
|
|
|
73
81
|
if (!nitro::isPlainObject(runtime, obj)) {
|
|
74
82
|
return false;
|
|
75
83
|
}
|
|
76
|
-
if (!JSIConverter<std::
|
|
77
|
-
if (!JSIConverter<std::optional<margelo::nitro::iap::
|
|
84
|
+
if (!JSIConverter<std::optional<margelo::nitro::iap::NitroReceiptValidationAppleOptions>>::canConvert(runtime, obj.getProperty(runtime, "apple"))) return false;
|
|
85
|
+
if (!JSIConverter<std::optional<margelo::nitro::iap::NitroReceiptValidationGoogleOptions>>::canConvert(runtime, obj.getProperty(runtime, "google"))) return false;
|
|
86
|
+
if (!JSIConverter<std::optional<margelo::nitro::iap::NitroReceiptValidationHorizonOptions>>::canConvert(runtime, obj.getProperty(runtime, "horizon"))) return false;
|
|
78
87
|
return true;
|
|
79
88
|
}
|
|
80
89
|
};
|
package/openiap-versions.json
CHANGED
package/package.json
CHANGED
|
@@ -31,6 +31,12 @@ type IapPluginProps = {
|
|
|
31
31
|
* @platform ios
|
|
32
32
|
*/
|
|
33
33
|
iosAlternativeBilling?: IosAlternativeBillingConfig;
|
|
34
|
+
/**
|
|
35
|
+
* IAPKit API key for purchase verification.
|
|
36
|
+
* This key will be added to AndroidManifest.xml (as meta-data) and Info.plist.
|
|
37
|
+
* Get your API key from https://iapkit.com
|
|
38
|
+
*/
|
|
39
|
+
iapkitApiKey?: string;
|
|
34
40
|
};
|
|
35
41
|
type IapPluginCallable = {
|
|
36
42
|
(config: ExpoConfig): ExpoConfig;
|
package/plugin/build/withIAP.js
CHANGED
|
@@ -86,7 +86,7 @@ const modifyAppBuildGradle = (gradle) => {
|
|
|
86
86
|
}
|
|
87
87
|
return modified;
|
|
88
88
|
};
|
|
89
|
-
const withIapAndroid = (config) => {
|
|
89
|
+
const withIapAndroid = (config, props) => {
|
|
90
90
|
// Add OpenIAP dependency to app build.gradle
|
|
91
91
|
config = (0, config_plugins_1.withAppBuildGradle)(config, (config) => {
|
|
92
92
|
config.modResults.contents = modifyAppBuildGradle(config.modResults.contents);
|
|
@@ -111,6 +111,29 @@ const withIapAndroid = (config) => {
|
|
|
111
111
|
console.log('ℹ️ com.android.vending.BILLING already exists in AndroidManifest.xml');
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
+
// Add IAPKit API key as meta-data if provided
|
|
115
|
+
if (props?.iapkitApiKey) {
|
|
116
|
+
const application = manifest.manifest.application;
|
|
117
|
+
const app = application?.[0];
|
|
118
|
+
if (app) {
|
|
119
|
+
if (!app['meta-data']) {
|
|
120
|
+
app['meta-data'] = [];
|
|
121
|
+
}
|
|
122
|
+
const metaDataKey = 'dev.iapkit.API_KEY';
|
|
123
|
+
const existingMetaData = app['meta-data'].find((m) => m.$?.['android:name'] === metaDataKey);
|
|
124
|
+
if (!existingMetaData) {
|
|
125
|
+
app['meta-data'].push({
|
|
126
|
+
$: {
|
|
127
|
+
'android:name': metaDataKey,
|
|
128
|
+
'android:value': props.iapkitApiKey,
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
if (!hasLoggedPluginExecution) {
|
|
132
|
+
console.log('✅ Added IAPKit API key to AndroidManifest.xml');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
114
137
|
return config;
|
|
115
138
|
});
|
|
116
139
|
return config;
|
|
@@ -247,14 +270,35 @@ end
|
|
|
247
270
|
return config;
|
|
248
271
|
});
|
|
249
272
|
};
|
|
273
|
+
/** Add IAPKit API key to iOS Info.plist */
|
|
274
|
+
const withIapkitApiKeyIOS = (config, apiKey) => {
|
|
275
|
+
if (!apiKey) {
|
|
276
|
+
return config;
|
|
277
|
+
}
|
|
278
|
+
return (0, config_plugins_1.withInfoPlist)(config, (config) => {
|
|
279
|
+
const plist = config.modResults;
|
|
280
|
+
const plistKey = 'IAPKitAPIKey';
|
|
281
|
+
if (!plist[plistKey]) {
|
|
282
|
+
plist[plistKey] = apiKey;
|
|
283
|
+
if (!hasLoggedPluginExecution) {
|
|
284
|
+
console.log('✅ Added IAPKit API key to Info.plist');
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return config;
|
|
288
|
+
});
|
|
289
|
+
};
|
|
250
290
|
const withIAP = (config, props) => {
|
|
251
291
|
try {
|
|
252
|
-
let result = withIapAndroid(config);
|
|
292
|
+
let result = withIapAndroid(config, { iapkitApiKey: props?.iapkitApiKey });
|
|
253
293
|
result = withIapIosFollyWorkaround(result, props);
|
|
254
294
|
// Add iOS alternative billing configuration if provided
|
|
255
295
|
if (props?.iosAlternativeBilling) {
|
|
256
296
|
result = withIosAlternativeBilling(result, props.iosAlternativeBilling);
|
|
257
297
|
}
|
|
298
|
+
// Add IAPKit API key to iOS Info.plist if provided
|
|
299
|
+
if (props?.iapkitApiKey) {
|
|
300
|
+
result = withIapkitApiKeyIOS(result, props.iapkitApiKey);
|
|
301
|
+
}
|
|
258
302
|
// Set flag after first execution to prevent duplicate logs
|
|
259
303
|
hasLoggedPluginExecution = true;
|
|
260
304
|
return result;
|
package/plugin/src/withIAP.ts
CHANGED
|
@@ -125,7 +125,10 @@ const modifyAppBuildGradle = (gradle: string): string => {
|
|
|
125
125
|
return modified;
|
|
126
126
|
};
|
|
127
127
|
|
|
128
|
-
const withIapAndroid: ConfigPlugin = (
|
|
128
|
+
const withIapAndroid: ConfigPlugin<{iapkitApiKey?: string} | undefined> = (
|
|
129
|
+
config,
|
|
130
|
+
props,
|
|
131
|
+
) => {
|
|
129
132
|
// Add OpenIAP dependency to app build.gradle
|
|
130
133
|
config = withAppBuildGradle(config, (config) => {
|
|
131
134
|
config.modResults.contents = modifyAppBuildGradle(
|
|
@@ -161,6 +164,34 @@ const withIapAndroid: ConfigPlugin = (config) => {
|
|
|
161
164
|
}
|
|
162
165
|
}
|
|
163
166
|
|
|
167
|
+
// Add IAPKit API key as meta-data if provided
|
|
168
|
+
if (props?.iapkitApiKey) {
|
|
169
|
+
const application = manifest.manifest.application;
|
|
170
|
+
const app = application?.[0];
|
|
171
|
+
if (app) {
|
|
172
|
+
if (!app['meta-data']) {
|
|
173
|
+
app['meta-data'] = [];
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const metaDataKey = 'dev.iapkit.API_KEY';
|
|
177
|
+
const existingMetaData = (
|
|
178
|
+
app['meta-data'] as {$?: {'android:name'?: string}}[]
|
|
179
|
+
).find((m) => m.$?.['android:name'] === metaDataKey);
|
|
180
|
+
|
|
181
|
+
if (!existingMetaData) {
|
|
182
|
+
app['meta-data'].push({
|
|
183
|
+
$: {
|
|
184
|
+
'android:name': metaDataKey,
|
|
185
|
+
'android:value': props.iapkitApiKey,
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
if (!hasLoggedPluginExecution) {
|
|
189
|
+
console.log('✅ Added IAPKit API key to AndroidManifest.xml');
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
164
195
|
return config;
|
|
165
196
|
});
|
|
166
197
|
|
|
@@ -329,6 +360,12 @@ type IapPluginProps = {
|
|
|
329
360
|
* @platform ios
|
|
330
361
|
*/
|
|
331
362
|
iosAlternativeBilling?: IosAlternativeBillingConfig;
|
|
363
|
+
/**
|
|
364
|
+
* IAPKit API key for purchase verification.
|
|
365
|
+
* This key will be added to AndroidManifest.xml (as meta-data) and Info.plist.
|
|
366
|
+
* Get your API key from https://iapkit.com
|
|
367
|
+
*/
|
|
368
|
+
iapkitApiKey?: string;
|
|
332
369
|
};
|
|
333
370
|
|
|
334
371
|
const withIapIosFollyWorkaround: ConfigPlugin<IapPluginProps | undefined> = (
|
|
@@ -389,14 +426,42 @@ end
|
|
|
389
426
|
});
|
|
390
427
|
};
|
|
391
428
|
|
|
429
|
+
/** Add IAPKit API key to iOS Info.plist */
|
|
430
|
+
const withIapkitApiKeyIOS: ConfigPlugin<string | undefined> = (
|
|
431
|
+
config,
|
|
432
|
+
apiKey,
|
|
433
|
+
) => {
|
|
434
|
+
if (!apiKey) {
|
|
435
|
+
return config;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
return withInfoPlist(config, (config) => {
|
|
439
|
+
const plist = config.modResults;
|
|
440
|
+
const plistKey = 'IAPKitAPIKey';
|
|
441
|
+
|
|
442
|
+
if (!plist[plistKey]) {
|
|
443
|
+
plist[plistKey] = apiKey;
|
|
444
|
+
if (!hasLoggedPluginExecution) {
|
|
445
|
+
console.log('✅ Added IAPKit API key to Info.plist');
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
return config;
|
|
450
|
+
});
|
|
451
|
+
};
|
|
452
|
+
|
|
392
453
|
const withIAP: ConfigPlugin<IapPluginProps | undefined> = (config, props) => {
|
|
393
454
|
try {
|
|
394
|
-
let result = withIapAndroid(config);
|
|
455
|
+
let result = withIapAndroid(config, {iapkitApiKey: props?.iapkitApiKey});
|
|
395
456
|
result = withIapIosFollyWorkaround(result, props);
|
|
396
457
|
// Add iOS alternative billing configuration if provided
|
|
397
458
|
if (props?.iosAlternativeBilling) {
|
|
398
459
|
result = withIosAlternativeBilling(result, props.iosAlternativeBilling);
|
|
399
460
|
}
|
|
461
|
+
// Add IAPKit API key to iOS Info.plist if provided
|
|
462
|
+
if (props?.iapkitApiKey) {
|
|
463
|
+
result = withIapkitApiKeyIOS(result, props.iapkitApiKey);
|
|
464
|
+
}
|
|
400
465
|
// Set flag after first execution to prevent duplicate logs
|
|
401
466
|
hasLoggedPluginExecution = true;
|
|
402
467
|
return result;
|