react-native-iap 14.4.46 → 14.5.0
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 +134 -4
- package/ios/HybridRnIap.swift +73 -2
- package/ios/RnIapHelper.swift +8 -0
- package/lib/module/hooks/useIAP.js +9 -1
- package/lib/module/hooks/useIAP.js.map +1 -1
- package/lib/module/index.js +69 -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/module/utils/type-bridge.js +19 -0
- package/lib/module/utils/type-bridge.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 +86 -26
- package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +145 -55
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/errorMapping.d.ts.map +1 -1
- package/lib/typescript/src/utils/type-bridge.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JFunc_void_NitroPurchase.hpp +2 -0
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +80 -0
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.hpp +2 -0
- package/nitrogen/generated/android/c++/JIapStore.hpp +65 -0
- package/nitrogen/generated/android/c++/JIapkitPurchaseState.hpp +80 -0
- package/nitrogen/generated/android/c++/JNitroPurchase.hpp +7 -1
- package/nitrogen/generated/android/c++/JNitroPurchaseRequest.hpp +11 -3
- package/nitrogen/generated/android/c++/JNitroReceiptValidationResultIOS.hpp +2 -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++/JNitroVerifyPurchaseWithProviderError.hpp +62 -0
- package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithProviderProps.hpp +70 -0
- package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithProviderResult.hpp +94 -0
- package/nitrogen/generated/android/c++/JPurchase.hpp +2 -0
- package/nitrogen/generated/android/c++/JPurchaseAndroid.hpp +7 -1
- package/nitrogen/generated/android/c++/JPurchaseIOS.hpp +7 -1
- package/nitrogen/generated/android/c++/JPurchaseVerificationProvider.hpp +59 -0
- package/nitrogen/generated/android/c++/JRequestPurchaseResult.hpp +2 -0
- package/nitrogen/generated/android/c++/JVariant_NitroReceiptValidationResultIOS_NitroReceiptValidationResultAndroid.hpp +2 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +8 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/IapStore.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/IapkitPurchaseState.kt +28 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroPurchase.kt +5 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroPurchaseRequest.kt +9 -3
- 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/NitroVerifyPurchaseWithProviderError.kt +39 -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 +42 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseAndroid.kt +5 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseIOS.kt +5 -2
- 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 +156 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +30 -0
- package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +46 -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/IapStore.swift +48 -0
- package/nitrogen/generated/ios/swift/IapkitPurchaseState.swift +68 -0
- package/nitrogen/generated/ios/swift/NitroPurchase.swift +13 -2
- package/nitrogen/generated/ios/swift/NitroPurchaseRequest.swift +47 -1
- 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/NitroVerifyPurchaseWithProviderError.swift +65 -0
- package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithProviderProps.swift +58 -0
- package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithProviderResult.swift +100 -0
- package/nitrogen/generated/ios/swift/PurchaseAndroid.swift +13 -2
- package/nitrogen/generated/ios/swift/PurchaseIOS.swift +13 -2
- 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++/IapStore.hpp +84 -0
- package/nitrogen/generated/shared/c++/IapkitPurchaseState.hpp +104 -0
- package/nitrogen/generated/shared/c++/NitroPurchase.hpp +8 -1
- package/nitrogen/generated/shared/c++/NitroPurchaseRequest.hpp +10 -2
- 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++/NitroVerifyPurchaseWithProviderError.hpp +80 -0
- package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithProviderProps.hpp +84 -0
- package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithProviderResult.hpp +92 -0
- package/nitrogen/generated/shared/c++/PurchaseAndroid.hpp +8 -1
- package/nitrogen/generated/shared/c++/PurchaseIOS.hpp +8 -1
- 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 +77 -5
- package/src/specs/RnIap.nitro.ts +117 -28
- package/src/types.ts +163 -61
- package/src/utils/errorMapping.ts +32 -4
- package/src/utils/type-bridge.ts +22 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroVerifyPurchaseWithIapkitResult.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 `NitroVerifyPurchaseWithIapkitResult`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias NitroVerifyPurchaseWithIapkitResult = margelo.nitro.iap.NitroVerifyPurchaseWithIapkitResult
|
|
14
|
+
|
|
15
|
+
public extension NitroVerifyPurchaseWithIapkitResult {
|
|
16
|
+
private typealias bridge = margelo.nitro.iap.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `NitroVerifyPurchaseWithIapkitResult`.
|
|
20
|
+
*/
|
|
21
|
+
init(isValid: Bool, state: IapkitPurchaseState, store: IapStore) {
|
|
22
|
+
self.init(isValid, state, store)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var isValid: Bool {
|
|
26
|
+
@inline(__always)
|
|
27
|
+
get {
|
|
28
|
+
return self.__isValid
|
|
29
|
+
}
|
|
30
|
+
@inline(__always)
|
|
31
|
+
set {
|
|
32
|
+
self.__isValid = newValue
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var state: IapkitPurchaseState {
|
|
37
|
+
@inline(__always)
|
|
38
|
+
get {
|
|
39
|
+
return self.__state
|
|
40
|
+
}
|
|
41
|
+
@inline(__always)
|
|
42
|
+
set {
|
|
43
|
+
self.__state = newValue
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var store: IapStore {
|
|
48
|
+
@inline(__always)
|
|
49
|
+
get {
|
|
50
|
+
return self.__store
|
|
51
|
+
}
|
|
52
|
+
@inline(__always)
|
|
53
|
+
set {
|
|
54
|
+
self.__store = newValue
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroVerifyPurchaseWithProviderError.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 `NitroVerifyPurchaseWithProviderError`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias NitroVerifyPurchaseWithProviderError = margelo.nitro.iap.NitroVerifyPurchaseWithProviderError
|
|
14
|
+
|
|
15
|
+
public extension NitroVerifyPurchaseWithProviderError {
|
|
16
|
+
private typealias bridge = margelo.nitro.iap.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `NitroVerifyPurchaseWithProviderError`.
|
|
20
|
+
*/
|
|
21
|
+
init(code: String?, message: String) {
|
|
22
|
+
self.init({ () -> bridge.std__optional_std__string_ in
|
|
23
|
+
if let __unwrappedValue = code {
|
|
24
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
25
|
+
} else {
|
|
26
|
+
return .init()
|
|
27
|
+
}
|
|
28
|
+
}(), std.string(message))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var code: String? {
|
|
32
|
+
@inline(__always)
|
|
33
|
+
get {
|
|
34
|
+
return { () -> String? in
|
|
35
|
+
if bridge.has_value_std__optional_std__string_(self.__code) {
|
|
36
|
+
let __unwrapped = bridge.get_std__optional_std__string_(self.__code)
|
|
37
|
+
return String(__unwrapped)
|
|
38
|
+
} else {
|
|
39
|
+
return nil
|
|
40
|
+
}
|
|
41
|
+
}()
|
|
42
|
+
}
|
|
43
|
+
@inline(__always)
|
|
44
|
+
set {
|
|
45
|
+
self.__code = { () -> bridge.std__optional_std__string_ in
|
|
46
|
+
if let __unwrappedValue = newValue {
|
|
47
|
+
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
48
|
+
} else {
|
|
49
|
+
return .init()
|
|
50
|
+
}
|
|
51
|
+
}()
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
var message: String {
|
|
56
|
+
@inline(__always)
|
|
57
|
+
get {
|
|
58
|
+
return String(self.__message)
|
|
59
|
+
}
|
|
60
|
+
@inline(__always)
|
|
61
|
+
set {
|
|
62
|
+
self.__message = std.string(newValue)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroVerifyPurchaseWithProviderProps.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 `NitroVerifyPurchaseWithProviderProps`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias NitroVerifyPurchaseWithProviderProps = margelo.nitro.iap.NitroVerifyPurchaseWithProviderProps
|
|
14
|
+
|
|
15
|
+
public extension NitroVerifyPurchaseWithProviderProps {
|
|
16
|
+
private typealias bridge = margelo.nitro.iap.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `NitroVerifyPurchaseWithProviderProps`.
|
|
20
|
+
*/
|
|
21
|
+
init(iapkit: NitroVerifyPurchaseWithIapkitProps?, provider: PurchaseVerificationProvider) {
|
|
22
|
+
self.init({ () -> bridge.std__optional_NitroVerifyPurchaseWithIapkitProps_ in
|
|
23
|
+
if let __unwrappedValue = iapkit {
|
|
24
|
+
return bridge.create_std__optional_NitroVerifyPurchaseWithIapkitProps_(__unwrappedValue)
|
|
25
|
+
} else {
|
|
26
|
+
return .init()
|
|
27
|
+
}
|
|
28
|
+
}(), provider)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
var iapkit: NitroVerifyPurchaseWithIapkitProps? {
|
|
32
|
+
@inline(__always)
|
|
33
|
+
get {
|
|
34
|
+
return self.__iapkit.value
|
|
35
|
+
}
|
|
36
|
+
@inline(__always)
|
|
37
|
+
set {
|
|
38
|
+
self.__iapkit = { () -> bridge.std__optional_NitroVerifyPurchaseWithIapkitProps_ in
|
|
39
|
+
if let __unwrappedValue = newValue {
|
|
40
|
+
return bridge.create_std__optional_NitroVerifyPurchaseWithIapkitProps_(__unwrappedValue)
|
|
41
|
+
} else {
|
|
42
|
+
return .init()
|
|
43
|
+
}
|
|
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,100 @@
|
|
|
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?, errors: [NitroVerifyPurchaseWithProviderError]?, provider: PurchaseVerificationProvider) {
|
|
22
|
+
self.init({ () -> bridge.std__optional_NitroVerifyPurchaseWithIapkitResult_ in
|
|
23
|
+
if let __unwrappedValue = iapkit {
|
|
24
|
+
return bridge.create_std__optional_NitroVerifyPurchaseWithIapkitResult_(__unwrappedValue)
|
|
25
|
+
} else {
|
|
26
|
+
return .init()
|
|
27
|
+
}
|
|
28
|
+
}(), { () -> bridge.std__optional_std__vector_NitroVerifyPurchaseWithProviderError__ in
|
|
29
|
+
if let __unwrappedValue = errors {
|
|
30
|
+
return bridge.create_std__optional_std__vector_NitroVerifyPurchaseWithProviderError__({ () -> bridge.std__vector_NitroVerifyPurchaseWithProviderError_ in
|
|
31
|
+
var __vector = bridge.create_std__vector_NitroVerifyPurchaseWithProviderError_(__unwrappedValue.count)
|
|
32
|
+
for __item in __unwrappedValue {
|
|
33
|
+
__vector.push_back(__item)
|
|
34
|
+
}
|
|
35
|
+
return __vector
|
|
36
|
+
}())
|
|
37
|
+
} else {
|
|
38
|
+
return .init()
|
|
39
|
+
}
|
|
40
|
+
}(), provider)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
var iapkit: NitroVerifyPurchaseWithIapkitResult? {
|
|
44
|
+
@inline(__always)
|
|
45
|
+
get {
|
|
46
|
+
return self.__iapkit.value
|
|
47
|
+
}
|
|
48
|
+
@inline(__always)
|
|
49
|
+
set {
|
|
50
|
+
self.__iapkit = { () -> bridge.std__optional_NitroVerifyPurchaseWithIapkitResult_ in
|
|
51
|
+
if let __unwrappedValue = newValue {
|
|
52
|
+
return bridge.create_std__optional_NitroVerifyPurchaseWithIapkitResult_(__unwrappedValue)
|
|
53
|
+
} else {
|
|
54
|
+
return .init()
|
|
55
|
+
}
|
|
56
|
+
}()
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
var errors: [NitroVerifyPurchaseWithProviderError]? {
|
|
61
|
+
@inline(__always)
|
|
62
|
+
get {
|
|
63
|
+
return { () -> [NitroVerifyPurchaseWithProviderError]? in
|
|
64
|
+
if bridge.has_value_std__optional_std__vector_NitroVerifyPurchaseWithProviderError__(self.__errors) {
|
|
65
|
+
let __unwrapped = bridge.get_std__optional_std__vector_NitroVerifyPurchaseWithProviderError__(self.__errors)
|
|
66
|
+
return __unwrapped.map({ __item in __item })
|
|
67
|
+
} else {
|
|
68
|
+
return nil
|
|
69
|
+
}
|
|
70
|
+
}()
|
|
71
|
+
}
|
|
72
|
+
@inline(__always)
|
|
73
|
+
set {
|
|
74
|
+
self.__errors = { () -> bridge.std__optional_std__vector_NitroVerifyPurchaseWithProviderError__ in
|
|
75
|
+
if let __unwrappedValue = newValue {
|
|
76
|
+
return bridge.create_std__optional_std__vector_NitroVerifyPurchaseWithProviderError__({ () -> bridge.std__vector_NitroVerifyPurchaseWithProviderError_ in
|
|
77
|
+
var __vector = bridge.create_std__vector_NitroVerifyPurchaseWithProviderError_(__unwrappedValue.count)
|
|
78
|
+
for __item in __unwrappedValue {
|
|
79
|
+
__vector.push_back(__item)
|
|
80
|
+
}
|
|
81
|
+
return __vector
|
|
82
|
+
}())
|
|
83
|
+
} else {
|
|
84
|
+
return .init()
|
|
85
|
+
}
|
|
86
|
+
}()
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
var provider: PurchaseVerificationProvider {
|
|
91
|
+
@inline(__always)
|
|
92
|
+
get {
|
|
93
|
+
return self.__provider
|
|
94
|
+
}
|
|
95
|
+
@inline(__always)
|
|
96
|
+
set {
|
|
97
|
+
self.__provider = newValue
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -18,7 +18,7 @@ public extension PurchaseAndroid {
|
|
|
18
18
|
/**
|
|
19
19
|
* Create a new instance of `PurchaseAndroid`.
|
|
20
20
|
*/
|
|
21
|
-
init(autoRenewingAndroid: Bool?, currentPlanId: String?, dataAndroid: String?, developerPayloadAndroid: String?, id: String, ids: [String]?, isAcknowledgedAndroid: Bool?, isAutoRenewing: Bool, obfuscatedAccountIdAndroid: String?, obfuscatedProfileIdAndroid: String?, packageNameAndroid: String?, platform: IapPlatform, productId: String, purchaseState: PurchaseState, purchaseToken: String?, quantity: Double, signatureAndroid: String?, transactionDate: Double, transactionId: String?) {
|
|
21
|
+
init(autoRenewingAndroid: Bool?, currentPlanId: String?, dataAndroid: String?, developerPayloadAndroid: String?, id: String, ids: [String]?, isAcknowledgedAndroid: Bool?, isAutoRenewing: Bool, obfuscatedAccountIdAndroid: String?, obfuscatedProfileIdAndroid: String?, packageNameAndroid: String?, platform: IapPlatform, productId: String, purchaseState: PurchaseState, purchaseToken: String?, quantity: Double, signatureAndroid: String?, store: IapStore, transactionDate: Double, transactionId: String?) {
|
|
22
22
|
self.init({ () -> bridge.std__optional_bool_ in
|
|
23
23
|
if let __unwrappedValue = autoRenewingAndroid {
|
|
24
24
|
return bridge.create_std__optional_bool_(__unwrappedValue)
|
|
@@ -91,7 +91,7 @@ public extension PurchaseAndroid {
|
|
|
91
91
|
} else {
|
|
92
92
|
return .init()
|
|
93
93
|
}
|
|
94
|
-
}(), transactionDate, { () -> bridge.std__optional_std__string_ in
|
|
94
|
+
}(), store, transactionDate, { () -> bridge.std__optional_std__string_ in
|
|
95
95
|
if let __unwrappedValue = transactionId {
|
|
96
96
|
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
97
97
|
} else {
|
|
@@ -436,6 +436,17 @@ public extension PurchaseAndroid {
|
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
438
|
|
|
439
|
+
var store: IapStore {
|
|
440
|
+
@inline(__always)
|
|
441
|
+
get {
|
|
442
|
+
return self.__store
|
|
443
|
+
}
|
|
444
|
+
@inline(__always)
|
|
445
|
+
set {
|
|
446
|
+
self.__store = newValue
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
439
450
|
var transactionDate: Double {
|
|
440
451
|
@inline(__always)
|
|
441
452
|
get {
|
|
@@ -18,7 +18,7 @@ public extension PurchaseIOS {
|
|
|
18
18
|
/**
|
|
19
19
|
* Create a new instance of `PurchaseIOS`.
|
|
20
20
|
*/
|
|
21
|
-
init(appAccountToken: String?, appBundleIdIOS: String?, countryCodeIOS: String?, currencyCodeIOS: String?, currencySymbolIOS: String?, currentPlanId: String?, environmentIOS: String?, expirationDateIOS: Double?, id: String, ids: [String]?, isAutoRenewing: Bool, isUpgradedIOS: Bool?, offerIOS: PurchaseOfferIOS?, originalTransactionDateIOS: Double?, originalTransactionIdentifierIOS: String?, ownershipTypeIOS: String?, platform: IapPlatform, productId: String, purchaseState: PurchaseState, purchaseToken: String?, quantity: Double, quantityIOS: Double?, reasonIOS: String?, reasonStringRepresentationIOS: String?, renewalInfoIOS: RenewalInfoIOS?, revocationDateIOS: Double?, revocationReasonIOS: String?, storefrontCountryCodeIOS: String?, subscriptionGroupIdIOS: String?, transactionDate: Double, transactionId: String, transactionReasonIOS: String?, webOrderLineItemIdIOS: String?) {
|
|
21
|
+
init(appAccountToken: String?, appBundleIdIOS: String?, countryCodeIOS: String?, currencyCodeIOS: String?, currencySymbolIOS: String?, currentPlanId: String?, environmentIOS: String?, expirationDateIOS: Double?, id: String, ids: [String]?, isAutoRenewing: Bool, isUpgradedIOS: Bool?, offerIOS: PurchaseOfferIOS?, originalTransactionDateIOS: Double?, originalTransactionIdentifierIOS: String?, ownershipTypeIOS: String?, platform: IapPlatform, productId: String, purchaseState: PurchaseState, purchaseToken: String?, quantity: Double, quantityIOS: Double?, reasonIOS: String?, reasonStringRepresentationIOS: String?, renewalInfoIOS: RenewalInfoIOS?, revocationDateIOS: Double?, revocationReasonIOS: String?, store: IapStore, storefrontCountryCodeIOS: String?, subscriptionGroupIdIOS: String?, transactionDate: Double, transactionId: String, transactionReasonIOS: String?, webOrderLineItemIdIOS: String?) {
|
|
22
22
|
self.init({ () -> bridge.std__optional_std__string_ in
|
|
23
23
|
if let __unwrappedValue = appAccountToken {
|
|
24
24
|
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
@@ -151,7 +151,7 @@ public extension PurchaseIOS {
|
|
|
151
151
|
} else {
|
|
152
152
|
return .init()
|
|
153
153
|
}
|
|
154
|
-
}(), { () -> bridge.std__optional_std__string_ in
|
|
154
|
+
}(), store, { () -> bridge.std__optional_std__string_ in
|
|
155
155
|
if let __unwrappedValue = storefrontCountryCodeIOS {
|
|
156
156
|
return bridge.create_std__optional_std__string_(std.string(__unwrappedValue))
|
|
157
157
|
} else {
|
|
@@ -712,6 +712,17 @@ public extension PurchaseIOS {
|
|
|
712
712
|
}
|
|
713
713
|
}
|
|
714
714
|
|
|
715
|
+
var store: IapStore {
|
|
716
|
+
@inline(__always)
|
|
717
|
+
get {
|
|
718
|
+
return self.__store
|
|
719
|
+
}
|
|
720
|
+
@inline(__always)
|
|
721
|
+
set {
|
|
722
|
+
self.__store = newValue
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
|
|
715
726
|
var storefrontCountryCodeIOS: String? {
|
|
716
727
|
@inline(__always)
|
|
717
728
|
get {
|
|
@@ -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,84 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// IapStore.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 (IapStore).
|
|
30
|
+
*/
|
|
31
|
+
enum class IapStore {
|
|
32
|
+
UNKNOWN SWIFT_NAME(unknown) = 0,
|
|
33
|
+
APPLE SWIFT_NAME(apple) = 1,
|
|
34
|
+
GOOGLE SWIFT_NAME(google) = 2,
|
|
35
|
+
HORIZON SWIFT_NAME(horizon) = 3,
|
|
36
|
+
} CLOSED_ENUM;
|
|
37
|
+
|
|
38
|
+
} // namespace margelo::nitro::iap
|
|
39
|
+
|
|
40
|
+
namespace margelo::nitro {
|
|
41
|
+
|
|
42
|
+
// C++ IapStore <> JS IapStore (union)
|
|
43
|
+
template <>
|
|
44
|
+
struct JSIConverter<margelo::nitro::iap::IapStore> final {
|
|
45
|
+
static inline margelo::nitro::iap::IapStore fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
46
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
47
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
48
|
+
case hashString("unknown"): return margelo::nitro::iap::IapStore::UNKNOWN;
|
|
49
|
+
case hashString("apple"): return margelo::nitro::iap::IapStore::APPLE;
|
|
50
|
+
case hashString("google"): return margelo::nitro::iap::IapStore::GOOGLE;
|
|
51
|
+
case hashString("horizon"): return margelo::nitro::iap::IapStore::HORIZON;
|
|
52
|
+
default: [[unlikely]]
|
|
53
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum IapStore - invalid value!");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::iap::IapStore arg) {
|
|
57
|
+
switch (arg) {
|
|
58
|
+
case margelo::nitro::iap::IapStore::UNKNOWN: return JSIConverter<std::string>::toJSI(runtime, "unknown");
|
|
59
|
+
case margelo::nitro::iap::IapStore::APPLE: return JSIConverter<std::string>::toJSI(runtime, "apple");
|
|
60
|
+
case margelo::nitro::iap::IapStore::GOOGLE: return JSIConverter<std::string>::toJSI(runtime, "google");
|
|
61
|
+
case margelo::nitro::iap::IapStore::HORIZON: return JSIConverter<std::string>::toJSI(runtime, "horizon");
|
|
62
|
+
default: [[unlikely]]
|
|
63
|
+
throw std::invalid_argument("Cannot convert IapStore to JS - invalid value: "
|
|
64
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
68
|
+
if (!value.isString()) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
72
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
73
|
+
case hashString("unknown"):
|
|
74
|
+
case hashString("apple"):
|
|
75
|
+
case hashString("google"):
|
|
76
|
+
case hashString("horizon"):
|
|
77
|
+
return true;
|
|
78
|
+
default:
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
} // namespace margelo::nitro
|
|
@@ -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
|