react-native-iap 14.4.46 → 14.4.47
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/NitroIap.podspec +2 -2
- package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +113 -3
- package/ios/HybridRnIap.swift +61 -2
- package/lib/module/hooks/useIAP.js +9 -1
- package/lib/module/hooks/useIAP.js.map +1 -1
- package/lib/module/index.js +68 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js +5 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/errorMapping.js +32 -6
- package/lib/module/utils/errorMapping.js.map +1 -1
- package/lib/typescript/src/hooks/useIAP.d.ts +5 -1
- package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +34 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/RnIap.nitro.d.ts +72 -26
- package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +109 -51
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/errorMapping.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +76 -0
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.hpp +2 -0
- package/nitrogen/generated/android/c++/JIapkitPurchaseState.hpp +80 -0
- package/nitrogen/generated/android/c++/JIapkitStore.hpp +59 -0
- package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithIapkitAppleProps.hpp +57 -0
- package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithIapkitGoogleProps.hpp +57 -0
- package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithIapkitProps.hpp +70 -0
- package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithIapkitResult.hpp +68 -0
- package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithProviderProps.hpp +70 -0
- package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithProviderResult.hpp +86 -0
- package/nitrogen/generated/android/c++/JPurchaseVerificationProvider.hpp +59 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +8 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/IapkitPurchaseState.kt +28 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/IapkitStore.kt +21 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroVerifyPurchaseWithIapkitAppleProps.kt +36 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroVerifyPurchaseWithIapkitGoogleProps.kt +36 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroVerifyPurchaseWithIapkitProps.kt +42 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroVerifyPurchaseWithIapkitResult.kt +42 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroVerifyPurchaseWithProviderProps.kt +39 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroVerifyPurchaseWithProviderResult.kt +39 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseVerificationProvider.kt +21 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.cpp +8 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +123 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +27 -0
- package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +43 -0
- package/nitrogen/generated/ios/swift/Func_void_NitroVerifyPurchaseWithProviderResult.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridRnIapSpec.swift +2 -0
- package/nitrogen/generated/ios/swift/HybridRnIapSpec_cxx.swift +45 -0
- package/nitrogen/generated/ios/swift/IapkitPurchaseState.swift +68 -0
- package/nitrogen/generated/ios/swift/IapkitStore.swift +40 -0
- package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithIapkitAppleProps.swift +35 -0
- package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithIapkitGoogleProps.swift +35 -0
- package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithIapkitProps.swift +100 -0
- package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithIapkitResult.swift +57 -0
- package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithProviderProps.swift +58 -0
- package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithProviderResult.swift +58 -0
- package/nitrogen/generated/ios/swift/PurchaseVerificationProvider.swift +40 -0
- package/nitrogen/generated/shared/c++/HybridRnIapSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridRnIapSpec.hpp +8 -0
- package/nitrogen/generated/shared/c++/IapkitPurchaseState.hpp +104 -0
- package/nitrogen/generated/shared/c++/IapkitStore.hpp +76 -0
- package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithIapkitAppleProps.hpp +75 -0
- package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithIapkitGoogleProps.hpp +75 -0
- package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithIapkitProps.hpp +89 -0
- package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithIapkitResult.hpp +87 -0
- package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithProviderProps.hpp +84 -0
- package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithProviderResult.hpp +84 -0
- package/nitrogen/generated/shared/c++/PurchaseVerificationProvider.hpp +76 -0
- package/openiap-versions.json +3 -3
- package/package.json +1 -1
- package/src/hooks/useIAP.ts +32 -0
- package/src/index.ts +74 -5
- package/src/specs/RnIap.nitro.ts +101 -28
- package/src/types.ts +126 -57
- package/src/utils/errorMapping.ts +32 -4
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroVerifyPurchaseWithProviderResult.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 `NitroVerifyPurchaseWithProviderResult`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias NitroVerifyPurchaseWithProviderResult = margelo.nitro.iap.NitroVerifyPurchaseWithProviderResult
|
|
14
|
+
|
|
15
|
+
public extension NitroVerifyPurchaseWithProviderResult {
|
|
16
|
+
private typealias bridge = margelo.nitro.iap.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `NitroVerifyPurchaseWithProviderResult`.
|
|
20
|
+
*/
|
|
21
|
+
init(iapkit: [NitroVerifyPurchaseWithIapkitResult], provider: PurchaseVerificationProvider) {
|
|
22
|
+
self.init({ () -> bridge.std__vector_NitroVerifyPurchaseWithIapkitResult_ in
|
|
23
|
+
var __vector = bridge.create_std__vector_NitroVerifyPurchaseWithIapkitResult_(iapkit.count)
|
|
24
|
+
for __item in iapkit {
|
|
25
|
+
__vector.push_back(__item)
|
|
26
|
+
}
|
|
27
|
+
return __vector
|
|
28
|
+
}(), provider)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var iapkit: [NitroVerifyPurchaseWithIapkitResult] {
|
|
32
|
+
@inline(__always)
|
|
33
|
+
get {
|
|
34
|
+
return self.__iapkit.map({ __item in __item })
|
|
35
|
+
}
|
|
36
|
+
@inline(__always)
|
|
37
|
+
set {
|
|
38
|
+
self.__iapkit = { () -> bridge.std__vector_NitroVerifyPurchaseWithIapkitResult_ in
|
|
39
|
+
var __vector = bridge.create_std__vector_NitroVerifyPurchaseWithIapkitResult_(newValue.count)
|
|
40
|
+
for __item in newValue {
|
|
41
|
+
__vector.push_back(__item)
|
|
42
|
+
}
|
|
43
|
+
return __vector
|
|
44
|
+
}()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
var provider: PurchaseVerificationProvider {
|
|
49
|
+
@inline(__always)
|
|
50
|
+
get {
|
|
51
|
+
return self.__provider
|
|
52
|
+
}
|
|
53
|
+
@inline(__always)
|
|
54
|
+
set {
|
|
55
|
+
self.__provider = newValue
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// PurchaseVerificationProvider.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
|
+
/**
|
|
9
|
+
* Represents the JS union `PurchaseVerificationProvider`, backed by a C++ enum.
|
|
10
|
+
*/
|
|
11
|
+
public typealias PurchaseVerificationProvider = margelo.nitro.iap.PurchaseVerificationProvider
|
|
12
|
+
|
|
13
|
+
public extension PurchaseVerificationProvider {
|
|
14
|
+
/**
|
|
15
|
+
* Get a PurchaseVerificationProvider for the given String value, or
|
|
16
|
+
* return `nil` if the given value was invalid/unknown.
|
|
17
|
+
*/
|
|
18
|
+
init?(fromString string: String) {
|
|
19
|
+
switch string {
|
|
20
|
+
case "none":
|
|
21
|
+
self = .none
|
|
22
|
+
case "iapkit":
|
|
23
|
+
self = .iapkit
|
|
24
|
+
default:
|
|
25
|
+
return nil
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get the String value this PurchaseVerificationProvider represents.
|
|
31
|
+
*/
|
|
32
|
+
var stringValue: String {
|
|
33
|
+
switch self {
|
|
34
|
+
case .none:
|
|
35
|
+
return "none"
|
|
36
|
+
case .iapkit:
|
|
37
|
+
return "iapkit"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -20,6 +20,7 @@ namespace margelo::nitro::iap {
|
|
|
20
20
|
prototype.registerHybridMethod("requestPurchase", &HybridRnIapSpec::requestPurchase);
|
|
21
21
|
prototype.registerHybridMethod("getAvailablePurchases", &HybridRnIapSpec::getAvailablePurchases);
|
|
22
22
|
prototype.registerHybridMethod("getActiveSubscriptions", &HybridRnIapSpec::getActiveSubscriptions);
|
|
23
|
+
prototype.registerHybridMethod("hasActiveSubscriptions", &HybridRnIapSpec::hasActiveSubscriptions);
|
|
23
24
|
prototype.registerHybridMethod("finishTransaction", &HybridRnIapSpec::finishTransaction);
|
|
24
25
|
prototype.registerHybridMethod("addPurchaseUpdatedListener", &HybridRnIapSpec::addPurchaseUpdatedListener);
|
|
25
26
|
prototype.registerHybridMethod("addPurchaseErrorListener", &HybridRnIapSpec::addPurchaseErrorListener);
|
|
@@ -49,6 +50,7 @@ namespace margelo::nitro::iap {
|
|
|
49
50
|
prototype.registerHybridMethod("isTransactionVerifiedIOS", &HybridRnIapSpec::isTransactionVerifiedIOS);
|
|
50
51
|
prototype.registerHybridMethod("getTransactionJwsIOS", &HybridRnIapSpec::getTransactionJwsIOS);
|
|
51
52
|
prototype.registerHybridMethod("validateReceipt", &HybridRnIapSpec::validateReceipt);
|
|
53
|
+
prototype.registerHybridMethod("verifyPurchaseWithProvider", &HybridRnIapSpec::verifyPurchaseWithProvider);
|
|
52
54
|
prototype.registerHybridMethod("getStorefront", &HybridRnIapSpec::getStorefront);
|
|
53
55
|
prototype.registerHybridMethod("deepLinkToSubscriptionsAndroid", &HybridRnIapSpec::deepLinkToSubscriptionsAndroid);
|
|
54
56
|
prototype.registerHybridMethod("checkAlternativeBillingAvailabilityAndroid", &HybridRnIapSpec::checkAlternativeBillingAvailabilityAndroid);
|
|
@@ -41,6 +41,10 @@ namespace margelo::nitro::iap { struct NitroReceiptValidationResultIOS; }
|
|
|
41
41
|
namespace margelo::nitro::iap { struct NitroReceiptValidationResultAndroid; }
|
|
42
42
|
// Forward declaration of `NitroReceiptValidationParams` to properly resolve imports.
|
|
43
43
|
namespace margelo::nitro::iap { struct NitroReceiptValidationParams; }
|
|
44
|
+
// Forward declaration of `NitroVerifyPurchaseWithProviderResult` to properly resolve imports.
|
|
45
|
+
namespace margelo::nitro::iap { struct NitroVerifyPurchaseWithProviderResult; }
|
|
46
|
+
// Forward declaration of `NitroVerifyPurchaseWithProviderProps` to properly resolve imports.
|
|
47
|
+
namespace margelo::nitro::iap { struct NitroVerifyPurchaseWithProviderProps; }
|
|
44
48
|
// Forward declaration of `NitroDeepLinkOptionsAndroid` to properly resolve imports.
|
|
45
49
|
namespace margelo::nitro::iap { struct NitroDeepLinkOptionsAndroid; }
|
|
46
50
|
// Forward declaration of `UserChoiceBillingDetails` to properly resolve imports.
|
|
@@ -70,6 +74,8 @@ namespace margelo::nitro::iap { struct ExternalPurchaseLinkResultIOS; }
|
|
|
70
74
|
#include "NitroReceiptValidationResultIOS.hpp"
|
|
71
75
|
#include "NitroReceiptValidationResultAndroid.hpp"
|
|
72
76
|
#include "NitroReceiptValidationParams.hpp"
|
|
77
|
+
#include "NitroVerifyPurchaseWithProviderResult.hpp"
|
|
78
|
+
#include "NitroVerifyPurchaseWithProviderProps.hpp"
|
|
73
79
|
#include "NitroDeepLinkOptionsAndroid.hpp"
|
|
74
80
|
#include "UserChoiceBillingDetails.hpp"
|
|
75
81
|
#include "ExternalPurchaseNoticeResultIOS.hpp"
|
|
@@ -112,6 +118,7 @@ namespace margelo::nitro::iap {
|
|
|
112
118
|
virtual std::shared_ptr<Promise<std::optional<std::variant<PurchaseAndroid, PurchaseIOS, std::vector<std::variant<PurchaseAndroid, PurchaseIOS>>>>>> requestPurchase(const NitroPurchaseRequest& request) = 0;
|
|
113
119
|
virtual std::shared_ptr<Promise<std::vector<NitroPurchase>>> getAvailablePurchases(const std::optional<NitroAvailablePurchasesOptions>& options) = 0;
|
|
114
120
|
virtual std::shared_ptr<Promise<std::vector<NitroActiveSubscription>>> getActiveSubscriptions(const std::optional<std::vector<std::string>>& subscriptionIds) = 0;
|
|
121
|
+
virtual std::shared_ptr<Promise<bool>> hasActiveSubscriptions(const std::optional<std::vector<std::string>>& subscriptionIds) = 0;
|
|
115
122
|
virtual std::shared_ptr<Promise<std::variant<bool, NitroPurchaseResult>>> finishTransaction(const NitroFinishTransactionParams& params) = 0;
|
|
116
123
|
virtual void addPurchaseUpdatedListener(const std::function<void(const NitroPurchase& /* purchase */)>& listener) = 0;
|
|
117
124
|
virtual void addPurchaseErrorListener(const std::function<void(const NitroPurchaseResult& /* error */)>& listener) = 0;
|
|
@@ -141,6 +148,7 @@ namespace margelo::nitro::iap {
|
|
|
141
148
|
virtual std::shared_ptr<Promise<bool>> isTransactionVerifiedIOS(const std::string& sku) = 0;
|
|
142
149
|
virtual std::shared_ptr<Promise<std::optional<std::string>>> getTransactionJwsIOS(const std::string& sku) = 0;
|
|
143
150
|
virtual std::shared_ptr<Promise<std::variant<NitroReceiptValidationResultIOS, NitroReceiptValidationResultAndroid>>> validateReceipt(const NitroReceiptValidationParams& params) = 0;
|
|
151
|
+
virtual std::shared_ptr<Promise<NitroVerifyPurchaseWithProviderResult>> verifyPurchaseWithProvider(const NitroVerifyPurchaseWithProviderProps& params) = 0;
|
|
144
152
|
virtual std::shared_ptr<Promise<std::string>> getStorefront() = 0;
|
|
145
153
|
virtual std::shared_ptr<Promise<void>> deepLinkToSubscriptionsAndroid(const NitroDeepLinkOptionsAndroid& options) = 0;
|
|
146
154
|
virtual std::shared_ptr<Promise<bool>> checkAlternativeBillingAvailabilityAndroid() = 0;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// IapkitPurchaseState.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::iap {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (IapkitPurchaseState).
|
|
30
|
+
*/
|
|
31
|
+
enum class IapkitPurchaseState {
|
|
32
|
+
PENDING SWIFT_NAME(pending) = 0,
|
|
33
|
+
UNKNOWN SWIFT_NAME(unknown) = 1,
|
|
34
|
+
ENTITLED SWIFT_NAME(entitled) = 2,
|
|
35
|
+
PENDING_ACKNOWLEDGMENT SWIFT_NAME(pendingAcknowledgment) = 3,
|
|
36
|
+
CANCELED SWIFT_NAME(canceled) = 4,
|
|
37
|
+
EXPIRED SWIFT_NAME(expired) = 5,
|
|
38
|
+
READY_TO_CONSUME SWIFT_NAME(readyToConsume) = 6,
|
|
39
|
+
CONSUMED SWIFT_NAME(consumed) = 7,
|
|
40
|
+
INAUTHENTIC SWIFT_NAME(inauthentic) = 8,
|
|
41
|
+
} CLOSED_ENUM;
|
|
42
|
+
|
|
43
|
+
} // namespace margelo::nitro::iap
|
|
44
|
+
|
|
45
|
+
namespace margelo::nitro {
|
|
46
|
+
|
|
47
|
+
// C++ IapkitPurchaseState <> JS IapkitPurchaseState (union)
|
|
48
|
+
template <>
|
|
49
|
+
struct JSIConverter<margelo::nitro::iap::IapkitPurchaseState> final {
|
|
50
|
+
static inline margelo::nitro::iap::IapkitPurchaseState fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
51
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
52
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
53
|
+
case hashString("pending"): return margelo::nitro::iap::IapkitPurchaseState::PENDING;
|
|
54
|
+
case hashString("unknown"): return margelo::nitro::iap::IapkitPurchaseState::UNKNOWN;
|
|
55
|
+
case hashString("entitled"): return margelo::nitro::iap::IapkitPurchaseState::ENTITLED;
|
|
56
|
+
case hashString("pending-acknowledgment"): return margelo::nitro::iap::IapkitPurchaseState::PENDING_ACKNOWLEDGMENT;
|
|
57
|
+
case hashString("canceled"): return margelo::nitro::iap::IapkitPurchaseState::CANCELED;
|
|
58
|
+
case hashString("expired"): return margelo::nitro::iap::IapkitPurchaseState::EXPIRED;
|
|
59
|
+
case hashString("ready-to-consume"): return margelo::nitro::iap::IapkitPurchaseState::READY_TO_CONSUME;
|
|
60
|
+
case hashString("consumed"): return margelo::nitro::iap::IapkitPurchaseState::CONSUMED;
|
|
61
|
+
case hashString("inauthentic"): return margelo::nitro::iap::IapkitPurchaseState::INAUTHENTIC;
|
|
62
|
+
default: [[unlikely]]
|
|
63
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum IapkitPurchaseState - invalid value!");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::iap::IapkitPurchaseState arg) {
|
|
67
|
+
switch (arg) {
|
|
68
|
+
case margelo::nitro::iap::IapkitPurchaseState::PENDING: return JSIConverter<std::string>::toJSI(runtime, "pending");
|
|
69
|
+
case margelo::nitro::iap::IapkitPurchaseState::UNKNOWN: return JSIConverter<std::string>::toJSI(runtime, "unknown");
|
|
70
|
+
case margelo::nitro::iap::IapkitPurchaseState::ENTITLED: return JSIConverter<std::string>::toJSI(runtime, "entitled");
|
|
71
|
+
case margelo::nitro::iap::IapkitPurchaseState::PENDING_ACKNOWLEDGMENT: return JSIConverter<std::string>::toJSI(runtime, "pending-acknowledgment");
|
|
72
|
+
case margelo::nitro::iap::IapkitPurchaseState::CANCELED: return JSIConverter<std::string>::toJSI(runtime, "canceled");
|
|
73
|
+
case margelo::nitro::iap::IapkitPurchaseState::EXPIRED: return JSIConverter<std::string>::toJSI(runtime, "expired");
|
|
74
|
+
case margelo::nitro::iap::IapkitPurchaseState::READY_TO_CONSUME: return JSIConverter<std::string>::toJSI(runtime, "ready-to-consume");
|
|
75
|
+
case margelo::nitro::iap::IapkitPurchaseState::CONSUMED: return JSIConverter<std::string>::toJSI(runtime, "consumed");
|
|
76
|
+
case margelo::nitro::iap::IapkitPurchaseState::INAUTHENTIC: return JSIConverter<std::string>::toJSI(runtime, "inauthentic");
|
|
77
|
+
default: [[unlikely]]
|
|
78
|
+
throw std::invalid_argument("Cannot convert IapkitPurchaseState to JS - invalid value: "
|
|
79
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
83
|
+
if (!value.isString()) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
87
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
88
|
+
case hashString("pending"):
|
|
89
|
+
case hashString("unknown"):
|
|
90
|
+
case hashString("entitled"):
|
|
91
|
+
case hashString("pending-acknowledgment"):
|
|
92
|
+
case hashString("canceled"):
|
|
93
|
+
case hashString("expired"):
|
|
94
|
+
case hashString("ready-to-consume"):
|
|
95
|
+
case hashString("consumed"):
|
|
96
|
+
case hashString("inauthentic"):
|
|
97
|
+
return true;
|
|
98
|
+
default:
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// IapkitStore.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::iap {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (IapkitStore).
|
|
30
|
+
*/
|
|
31
|
+
enum class IapkitStore {
|
|
32
|
+
APPLE SWIFT_NAME(apple) = 0,
|
|
33
|
+
GOOGLE SWIFT_NAME(google) = 1,
|
|
34
|
+
} CLOSED_ENUM;
|
|
35
|
+
|
|
36
|
+
} // namespace margelo::nitro::iap
|
|
37
|
+
|
|
38
|
+
namespace margelo::nitro {
|
|
39
|
+
|
|
40
|
+
// C++ IapkitStore <> JS IapkitStore (union)
|
|
41
|
+
template <>
|
|
42
|
+
struct JSIConverter<margelo::nitro::iap::IapkitStore> final {
|
|
43
|
+
static inline margelo::nitro::iap::IapkitStore fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
44
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
45
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
46
|
+
case hashString("apple"): return margelo::nitro::iap::IapkitStore::APPLE;
|
|
47
|
+
case hashString("google"): return margelo::nitro::iap::IapkitStore::GOOGLE;
|
|
48
|
+
default: [[unlikely]]
|
|
49
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum IapkitStore - invalid value!");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::iap::IapkitStore arg) {
|
|
53
|
+
switch (arg) {
|
|
54
|
+
case margelo::nitro::iap::IapkitStore::APPLE: return JSIConverter<std::string>::toJSI(runtime, "apple");
|
|
55
|
+
case margelo::nitro::iap::IapkitStore::GOOGLE: return JSIConverter<std::string>::toJSI(runtime, "google");
|
|
56
|
+
default: [[unlikely]]
|
|
57
|
+
throw std::invalid_argument("Cannot convert IapkitStore to JS - invalid value: "
|
|
58
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
62
|
+
if (!value.isString()) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
66
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
67
|
+
case hashString("apple"):
|
|
68
|
+
case hashString("google"):
|
|
69
|
+
return true;
|
|
70
|
+
default:
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroVerifyPurchaseWithIapkitAppleProps.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 (NitroVerifyPurchaseWithIapkitAppleProps).
|
|
34
|
+
*/
|
|
35
|
+
struct NitroVerifyPurchaseWithIapkitAppleProps {
|
|
36
|
+
public:
|
|
37
|
+
std::string jws SWIFT_PRIVATE;
|
|
38
|
+
|
|
39
|
+
public:
|
|
40
|
+
NitroVerifyPurchaseWithIapkitAppleProps() = default;
|
|
41
|
+
explicit NitroVerifyPurchaseWithIapkitAppleProps(std::string jws): jws(jws) {}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
} // namespace margelo::nitro::iap
|
|
45
|
+
|
|
46
|
+
namespace margelo::nitro {
|
|
47
|
+
|
|
48
|
+
// C++ NitroVerifyPurchaseWithIapkitAppleProps <> JS NitroVerifyPurchaseWithIapkitAppleProps (object)
|
|
49
|
+
template <>
|
|
50
|
+
struct JSIConverter<margelo::nitro::iap::NitroVerifyPurchaseWithIapkitAppleProps> final {
|
|
51
|
+
static inline margelo::nitro::iap::NitroVerifyPurchaseWithIapkitAppleProps fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
52
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
53
|
+
return margelo::nitro::iap::NitroVerifyPurchaseWithIapkitAppleProps(
|
|
54
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "jws"))
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::NitroVerifyPurchaseWithIapkitAppleProps& arg) {
|
|
58
|
+
jsi::Object obj(runtime);
|
|
59
|
+
obj.setProperty(runtime, "jws", JSIConverter<std::string>::toJSI(runtime, arg.jws));
|
|
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, "jws"))) return false;
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroVerifyPurchaseWithIapkitGoogleProps.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 (NitroVerifyPurchaseWithIapkitGoogleProps).
|
|
34
|
+
*/
|
|
35
|
+
struct NitroVerifyPurchaseWithIapkitGoogleProps {
|
|
36
|
+
public:
|
|
37
|
+
std::string purchaseToken SWIFT_PRIVATE;
|
|
38
|
+
|
|
39
|
+
public:
|
|
40
|
+
NitroVerifyPurchaseWithIapkitGoogleProps() = default;
|
|
41
|
+
explicit NitroVerifyPurchaseWithIapkitGoogleProps(std::string purchaseToken): purchaseToken(purchaseToken) {}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
} // namespace margelo::nitro::iap
|
|
45
|
+
|
|
46
|
+
namespace margelo::nitro {
|
|
47
|
+
|
|
48
|
+
// C++ NitroVerifyPurchaseWithIapkitGoogleProps <> JS NitroVerifyPurchaseWithIapkitGoogleProps (object)
|
|
49
|
+
template <>
|
|
50
|
+
struct JSIConverter<margelo::nitro::iap::NitroVerifyPurchaseWithIapkitGoogleProps> final {
|
|
51
|
+
static inline margelo::nitro::iap::NitroVerifyPurchaseWithIapkitGoogleProps fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
52
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
53
|
+
return margelo::nitro::iap::NitroVerifyPurchaseWithIapkitGoogleProps(
|
|
54
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "purchaseToken"))
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::NitroVerifyPurchaseWithIapkitGoogleProps& arg) {
|
|
58
|
+
jsi::Object obj(runtime);
|
|
59
|
+
obj.setProperty(runtime, "purchaseToken", JSIConverter<std::string>::toJSI(runtime, arg.purchaseToken));
|
|
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, "purchaseToken"))) return false;
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroVerifyPurchaseWithIapkitProps.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
|
+
// Forward declaration of `NitroVerifyPurchaseWithIapkitAppleProps` to properly resolve imports.
|
|
27
|
+
namespace margelo::nitro::iap { struct NitroVerifyPurchaseWithIapkitAppleProps; }
|
|
28
|
+
// Forward declaration of `NitroVerifyPurchaseWithIapkitGoogleProps` to properly resolve imports.
|
|
29
|
+
namespace margelo::nitro::iap { struct NitroVerifyPurchaseWithIapkitGoogleProps; }
|
|
30
|
+
|
|
31
|
+
#include <string>
|
|
32
|
+
#include <optional>
|
|
33
|
+
#include "NitroVerifyPurchaseWithIapkitAppleProps.hpp"
|
|
34
|
+
#include "NitroVerifyPurchaseWithIapkitGoogleProps.hpp"
|
|
35
|
+
|
|
36
|
+
namespace margelo::nitro::iap {
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A struct which can be represented as a JavaScript object (NitroVerifyPurchaseWithIapkitProps).
|
|
40
|
+
*/
|
|
41
|
+
struct NitroVerifyPurchaseWithIapkitProps {
|
|
42
|
+
public:
|
|
43
|
+
std::optional<std::string> apiKey SWIFT_PRIVATE;
|
|
44
|
+
std::optional<NitroVerifyPurchaseWithIapkitAppleProps> apple SWIFT_PRIVATE;
|
|
45
|
+
std::optional<NitroVerifyPurchaseWithIapkitGoogleProps> google SWIFT_PRIVATE;
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
NitroVerifyPurchaseWithIapkitProps() = default;
|
|
49
|
+
explicit NitroVerifyPurchaseWithIapkitProps(std::optional<std::string> apiKey, std::optional<NitroVerifyPurchaseWithIapkitAppleProps> apple, std::optional<NitroVerifyPurchaseWithIapkitGoogleProps> google): apiKey(apiKey), apple(apple), google(google) {}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
} // namespace margelo::nitro::iap
|
|
53
|
+
|
|
54
|
+
namespace margelo::nitro {
|
|
55
|
+
|
|
56
|
+
// C++ NitroVerifyPurchaseWithIapkitProps <> JS NitroVerifyPurchaseWithIapkitProps (object)
|
|
57
|
+
template <>
|
|
58
|
+
struct JSIConverter<margelo::nitro::iap::NitroVerifyPurchaseWithIapkitProps> final {
|
|
59
|
+
static inline margelo::nitro::iap::NitroVerifyPurchaseWithIapkitProps fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
60
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
61
|
+
return margelo::nitro::iap::NitroVerifyPurchaseWithIapkitProps(
|
|
62
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "apiKey")),
|
|
63
|
+
JSIConverter<std::optional<margelo::nitro::iap::NitroVerifyPurchaseWithIapkitAppleProps>>::fromJSI(runtime, obj.getProperty(runtime, "apple")),
|
|
64
|
+
JSIConverter<std::optional<margelo::nitro::iap::NitroVerifyPurchaseWithIapkitGoogleProps>>::fromJSI(runtime, obj.getProperty(runtime, "google"))
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::NitroVerifyPurchaseWithIapkitProps& arg) {
|
|
68
|
+
jsi::Object obj(runtime);
|
|
69
|
+
obj.setProperty(runtime, "apiKey", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.apiKey));
|
|
70
|
+
obj.setProperty(runtime, "apple", JSIConverter<std::optional<margelo::nitro::iap::NitroVerifyPurchaseWithIapkitAppleProps>>::toJSI(runtime, arg.apple));
|
|
71
|
+
obj.setProperty(runtime, "google", JSIConverter<std::optional<margelo::nitro::iap::NitroVerifyPurchaseWithIapkitGoogleProps>>::toJSI(runtime, arg.google));
|
|
72
|
+
return obj;
|
|
73
|
+
}
|
|
74
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
75
|
+
if (!value.isObject()) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
jsi::Object obj = value.getObject(runtime);
|
|
79
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "apiKey"))) return false;
|
|
83
|
+
if (!JSIConverter<std::optional<margelo::nitro::iap::NitroVerifyPurchaseWithIapkitAppleProps>>::canConvert(runtime, obj.getProperty(runtime, "apple"))) return false;
|
|
84
|
+
if (!JSIConverter<std::optional<margelo::nitro::iap::NitroVerifyPurchaseWithIapkitGoogleProps>>::canConvert(runtime, obj.getProperty(runtime, "google"))) return false;
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroVerifyPurchaseWithIapkitResult.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
|
+
// Forward declaration of `IapkitPurchaseState` to properly resolve imports.
|
|
27
|
+
namespace margelo::nitro::iap { enum class IapkitPurchaseState; }
|
|
28
|
+
// Forward declaration of `IapkitStore` to properly resolve imports.
|
|
29
|
+
namespace margelo::nitro::iap { enum class IapkitStore; }
|
|
30
|
+
|
|
31
|
+
#include "IapkitPurchaseState.hpp"
|
|
32
|
+
#include "IapkitStore.hpp"
|
|
33
|
+
|
|
34
|
+
namespace margelo::nitro::iap {
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A struct which can be represented as a JavaScript object (NitroVerifyPurchaseWithIapkitResult).
|
|
38
|
+
*/
|
|
39
|
+
struct NitroVerifyPurchaseWithIapkitResult {
|
|
40
|
+
public:
|
|
41
|
+
bool isValid SWIFT_PRIVATE;
|
|
42
|
+
IapkitPurchaseState state SWIFT_PRIVATE;
|
|
43
|
+
IapkitStore store SWIFT_PRIVATE;
|
|
44
|
+
|
|
45
|
+
public:
|
|
46
|
+
NitroVerifyPurchaseWithIapkitResult() = default;
|
|
47
|
+
explicit NitroVerifyPurchaseWithIapkitResult(bool isValid, IapkitPurchaseState state, IapkitStore store): isValid(isValid), state(state), store(store) {}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
} // namespace margelo::nitro::iap
|
|
51
|
+
|
|
52
|
+
namespace margelo::nitro {
|
|
53
|
+
|
|
54
|
+
// C++ NitroVerifyPurchaseWithIapkitResult <> JS NitroVerifyPurchaseWithIapkitResult (object)
|
|
55
|
+
template <>
|
|
56
|
+
struct JSIConverter<margelo::nitro::iap::NitroVerifyPurchaseWithIapkitResult> final {
|
|
57
|
+
static inline margelo::nitro::iap::NitroVerifyPurchaseWithIapkitResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
58
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
59
|
+
return margelo::nitro::iap::NitroVerifyPurchaseWithIapkitResult(
|
|
60
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "isValid")),
|
|
61
|
+
JSIConverter<margelo::nitro::iap::IapkitPurchaseState>::fromJSI(runtime, obj.getProperty(runtime, "state")),
|
|
62
|
+
JSIConverter<margelo::nitro::iap::IapkitStore>::fromJSI(runtime, obj.getProperty(runtime, "store"))
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::NitroVerifyPurchaseWithIapkitResult& arg) {
|
|
66
|
+
jsi::Object obj(runtime);
|
|
67
|
+
obj.setProperty(runtime, "isValid", JSIConverter<bool>::toJSI(runtime, arg.isValid));
|
|
68
|
+
obj.setProperty(runtime, "state", JSIConverter<margelo::nitro::iap::IapkitPurchaseState>::toJSI(runtime, arg.state));
|
|
69
|
+
obj.setProperty(runtime, "store", JSIConverter<margelo::nitro::iap::IapkitStore>::toJSI(runtime, arg.store));
|
|
70
|
+
return obj;
|
|
71
|
+
}
|
|
72
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
73
|
+
if (!value.isObject()) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
jsi::Object obj = value.getObject(runtime);
|
|
77
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "isValid"))) return false;
|
|
81
|
+
if (!JSIConverter<margelo::nitro::iap::IapkitPurchaseState>::canConvert(runtime, obj.getProperty(runtime, "state"))) return false;
|
|
82
|
+
if (!JSIConverter<margelo::nitro::iap::IapkitStore>::canConvert(runtime, obj.getProperty(runtime, "store"))) return false;
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
} // namespace margelo::nitro
|