@padosoft/react-native-ecr17 0.0.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.
Files changed (107) hide show
  1. package/Ecr17.podspec +39 -0
  2. package/README.md +348 -0
  3. package/android/CMakeLists.txt +41 -0
  4. package/android/build.gradle +149 -0
  5. package/android/fix-prefab.gradle +51 -0
  6. package/android/gradle.properties +5 -0
  7. package/android/src/main/AndroidManifest.xml +2 -0
  8. package/android/src/main/cpp/cpp-adapter.cpp +9 -0
  9. package/android/src/main/java/com/margelo/nitro/ecr17/HybridEcr17Transport.kt +233 -0
  10. package/android/src/main/java/com/padosoft/ecr17/Ecr17Package.kt +30 -0
  11. package/cpp/Ecr17.cpp +1 -0
  12. package/cpp/Ecr17.hpp +2 -0
  13. package/cpp/Ecr17Client/HybridEcr17Client.cpp +598 -0
  14. package/cpp/Ecr17Client/HybridEcr17Client.hpp +85 -0
  15. package/cpp/Ecr17Protocol/Ecr17Protocol.cpp +277 -0
  16. package/cpp/Ecr17Protocol/Ecr17Protocol.hpp +103 -0
  17. package/cpp/Ecr17Response/Ecr17Response.cpp +155 -0
  18. package/cpp/Ecr17Response/Ecr17Response.hpp +113 -0
  19. package/cpp/Lcr/Lcr.cpp +42 -0
  20. package/cpp/Lcr/Lcr.hpp +22 -0
  21. package/cpp/PacketCodec/PacketCodec.cpp +146 -0
  22. package/cpp/PacketCodec/PacketCodec.hpp +48 -0
  23. package/cpp/Session/Ecr17Session.cpp +260 -0
  24. package/cpp/Session/Ecr17Session.hpp +97 -0
  25. package/cpp/Session/RetryPolicy.hpp +23 -0
  26. package/cpp/Transport/FakeTransport.hpp +95 -0
  27. package/cpp/Transport/NativeTransportAdapter.cpp +42 -0
  28. package/cpp/Transport/NativeTransportAdapter.hpp +32 -0
  29. package/cpp/Transport/Transport.hpp +31 -0
  30. package/cpp/tests/CMakeLists.txt +55 -0
  31. package/cpp/tests/PosixTcpTransport.hpp +105 -0
  32. package/cpp/tests/stubs/LrcMode.hpp +25 -0
  33. package/cpp/tests/test_flows.cpp +148 -0
  34. package/cpp/tests/test_integration_terminal.cpp +72 -0
  35. package/cpp/tests/test_lrc.cpp +66 -0
  36. package/cpp/tests/test_packet_codec.cpp +164 -0
  37. package/cpp/tests/test_protocol.cpp +102 -0
  38. package/cpp/tests/test_protocol_commands.cpp +190 -0
  39. package/cpp/tests/test_response.cpp +164 -0
  40. package/cpp/tests/test_retry_policy.cpp +28 -0
  41. package/cpp/tests/test_session.cpp +262 -0
  42. package/ios/Bridge.h +1 -0
  43. package/ios/HybridEcr17Transport.swift +103 -0
  44. package/nitro.json +30 -0
  45. package/nitrogen/generated/.gitattributes +1 -0
  46. package/nitrogen/generated/android/Ecr17+autolinking.cmake +82 -0
  47. package/nitrogen/generated/android/Ecr17+autolinking.gradle +27 -0
  48. package/nitrogen/generated/android/Ecr17OnLoad.cpp +68 -0
  49. package/nitrogen/generated/android/Ecr17OnLoad.hpp +34 -0
  50. package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
  51. package/nitrogen/generated/android/c++/JFunc_void_std__shared_ptr_ArrayBuffer_.hpp +77 -0
  52. package/nitrogen/generated/android/c++/JHybridEcr17TransportSpec.cpp +93 -0
  53. package/nitrogen/generated/android/c++/JHybridEcr17TransportSpec.hpp +68 -0
  54. package/nitrogen/generated/android/kotlin/com/margelo/nitro/ecr17/Ecr17OnLoad.kt +35 -0
  55. package/nitrogen/generated/android/kotlin/com/margelo/nitro/ecr17/Func_void.kt +80 -0
  56. package/nitrogen/generated/android/kotlin/com/margelo/nitro/ecr17/Func_void_std__shared_ptr_ArrayBuffer_.kt +80 -0
  57. package/nitrogen/generated/android/kotlin/com/margelo/nitro/ecr17/HybridEcr17TransportSpec.kt +86 -0
  58. package/nitrogen/generated/ios/Ecr17+autolinking.rb +62 -0
  59. package/nitrogen/generated/ios/Ecr17-Swift-Cxx-Bridge.cpp +57 -0
  60. package/nitrogen/generated/ios/Ecr17-Swift-Cxx-Bridge.hpp +154 -0
  61. package/nitrogen/generated/ios/Ecr17-Swift-Cxx-Umbrella.hpp +47 -0
  62. package/nitrogen/generated/ios/Ecr17Autolinking.mm +43 -0
  63. package/nitrogen/generated/ios/Ecr17Autolinking.swift +26 -0
  64. package/nitrogen/generated/ios/c++/HybridEcr17TransportSpecSwift.cpp +11 -0
  65. package/nitrogen/generated/ios/c++/HybridEcr17TransportSpecSwift.hpp +119 -0
  66. package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
  67. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
  68. package/nitrogen/generated/ios/swift/Func_void_std__shared_ptr_ArrayBuffer_.swift +46 -0
  69. package/nitrogen/generated/ios/swift/HybridEcr17TransportSpec.swift +60 -0
  70. package/nitrogen/generated/ios/swift/HybridEcr17TransportSpec_cxx.swift +211 -0
  71. package/nitrogen/generated/shared/c++/CardType.hpp +84 -0
  72. package/nitrogen/generated/shared/c++/CardVerificationRequest.hpp +97 -0
  73. package/nitrogen/generated/shared/c++/CardVerificationResult.hpp +136 -0
  74. package/nitrogen/generated/shared/c++/CloseSessionResult.hpp +106 -0
  75. package/nitrogen/generated/shared/c++/ConnectionState.hpp +80 -0
  76. package/nitrogen/generated/shared/c++/CurrencyExchange.hpp +100 -0
  77. package/nitrogen/generated/shared/c++/Ecr17Config.hpp +138 -0
  78. package/nitrogen/generated/shared/c++/HybridEcr17ClientSpec.cpp +42 -0
  79. package/nitrogen/generated/shared/c++/HybridEcr17ClientSpec.hpp +138 -0
  80. package/nitrogen/generated/shared/c++/HybridEcr17TransportSpec.cpp +26 -0
  81. package/nitrogen/generated/shared/c++/HybridEcr17TransportSpec.hpp +70 -0
  82. package/nitrogen/generated/shared/c++/IncrementalAuthRequest.hpp +96 -0
  83. package/nitrogen/generated/shared/c++/LrcMode.hpp +84 -0
  84. package/nitrogen/generated/shared/c++/PaymentCardType.hpp +84 -0
  85. package/nitrogen/generated/shared/c++/PaymentRequest.hpp +109 -0
  86. package/nitrogen/generated/shared/c++/PaymentResult.hpp +139 -0
  87. package/nitrogen/generated/shared/c++/PosStatusResponse.hpp +96 -0
  88. package/nitrogen/generated/shared/c++/PreAuthClosureRequest.hpp +96 -0
  89. package/nitrogen/generated/shared/c++/PreAuthRequest.hpp +109 -0
  90. package/nitrogen/generated/shared/c++/PreAuthResult.hpp +144 -0
  91. package/nitrogen/generated/shared/c++/ProgressEvent.hpp +83 -0
  92. package/nitrogen/generated/shared/c++/ReceiptLine.hpp +83 -0
  93. package/nitrogen/generated/shared/c++/ReversalRequest.hpp +88 -0
  94. package/nitrogen/generated/shared/c++/ReversalResult.hpp +132 -0
  95. package/nitrogen/generated/shared/c++/TokenizationRequest.hpp +89 -0
  96. package/nitrogen/generated/shared/c++/TokenizationService.hpp +76 -0
  97. package/nitrogen/generated/shared/c++/TotalsResult.hpp +93 -0
  98. package/nitrogen/generated/shared/c++/TransactionEntryMode.hpp +92 -0
  99. package/nitrogen/generated/shared/c++/TransactionOutcome.hpp +88 -0
  100. package/nitrogen/generated/shared/c++/VasResult.hpp +96 -0
  101. package/package.json +102 -0
  102. package/react-native.config.js +18 -0
  103. package/src/index.ts +4 -0
  104. package/src/specs/client.nitro.ts +102 -0
  105. package/src/specs/transport.nitro.ts +25 -0
  106. package/src/types/client.ts +196 -0
  107. package/src/utils/client.ts +10 -0
@@ -0,0 +1,211 @@
1
+ ///
2
+ /// HybridEcr17TransportSpec_cxx.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * A class implementation that bridges HybridEcr17TransportSpec over to C++.
12
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
13
+ *
14
+ * Also, some Swift types need to be bridged with special handling:
15
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
16
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
17
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
18
+ */
19
+ open class HybridEcr17TransportSpec_cxx {
20
+ /**
21
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::ecr17::bridge::swift`)
22
+ * from `Ecr17-Swift-Cxx-Bridge.hpp`.
23
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
24
+ */
25
+ public typealias bridge = margelo.nitro.ecr17.bridge.swift
26
+
27
+ /**
28
+ * Holds an instance of the `HybridEcr17TransportSpec` Swift protocol.
29
+ */
30
+ private var __implementation: any HybridEcr17TransportSpec
31
+
32
+ /**
33
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
34
+ */
35
+ private var __cxxPart: bridge.std__weak_ptr_HybridEcr17TransportSpec_
36
+
37
+ /**
38
+ * Create a new `HybridEcr17TransportSpec_cxx` that wraps the given `HybridEcr17TransportSpec`.
39
+ * All properties and methods bridge to C++ types.
40
+ */
41
+ public init(_ implementation: any HybridEcr17TransportSpec) {
42
+ self.__implementation = implementation
43
+ self.__cxxPart = .init()
44
+ /* no base class */
45
+ }
46
+
47
+ /**
48
+ * Get the actual `HybridEcr17TransportSpec` instance this class wraps.
49
+ */
50
+ @inline(__always)
51
+ public func getHybridEcr17TransportSpec() -> any HybridEcr17TransportSpec {
52
+ return __implementation
53
+ }
54
+
55
+ /**
56
+ * Casts this instance to a retained unsafe raw pointer.
57
+ * This acquires one additional strong reference on the object!
58
+ */
59
+ public func toUnsafe() -> UnsafeMutableRawPointer {
60
+ return Unmanaged.passRetained(self).toOpaque()
61
+ }
62
+
63
+ /**
64
+ * Casts an unsafe pointer to a `HybridEcr17TransportSpec_cxx`.
65
+ * The pointer has to be a retained opaque `Unmanaged<HybridEcr17TransportSpec_cxx>`.
66
+ * This removes one strong reference from the object!
67
+ */
68
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridEcr17TransportSpec_cxx {
69
+ return Unmanaged<HybridEcr17TransportSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
70
+ }
71
+
72
+ /**
73
+ * Gets (or creates) the C++ part of this Hybrid Object.
74
+ * The C++ part is a `std::shared_ptr<HybridEcr17TransportSpec>`.
75
+ */
76
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridEcr17TransportSpec_ {
77
+ let cachedCxxPart = self.__cxxPart.lock()
78
+ if Bool(fromCxx: cachedCxxPart) {
79
+ return cachedCxxPart
80
+ } else {
81
+ let newCxxPart = bridge.create_std__shared_ptr_HybridEcr17TransportSpec_(self.toUnsafe())
82
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridEcr17TransportSpec_(newCxxPart)
83
+ return newCxxPart
84
+ }
85
+ }
86
+
87
+
88
+
89
+ /**
90
+ * Get the memory size of the Swift class (plus size of any other allocations)
91
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
92
+ */
93
+ @inline(__always)
94
+ public var memorySize: Int {
95
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
96
+ }
97
+
98
+ /**
99
+ * Compares this object with the given [other] object for reference equality.
100
+ */
101
+ @inline(__always)
102
+ public func equals(other: HybridEcr17TransportSpec_cxx) -> Bool {
103
+ return self.__implementation === other.__implementation
104
+ }
105
+
106
+ /**
107
+ * Call dispose() on the Swift class.
108
+ * This _may_ be called manually from JS.
109
+ */
110
+ @inline(__always)
111
+ public func dispose() {
112
+ self.__implementation.dispose()
113
+ }
114
+
115
+ /**
116
+ * Call toString() on the Swift class.
117
+ */
118
+ @inline(__always)
119
+ public func toString() -> String {
120
+ return self.__implementation.toString()
121
+ }
122
+
123
+ // Properties
124
+
125
+
126
+ // Methods
127
+ @inline(__always)
128
+ public final func connect(host: std.string, port: Double, timeoutMs: Double) -> bridge.Result_std__shared_ptr_Promise_void___ {
129
+ do {
130
+ let __result = try self.__implementation.connect(host: String(host), port: port, timeoutMs: timeoutMs)
131
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_void__ in
132
+ let __promise = bridge.create_std__shared_ptr_Promise_void__()
133
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_void__(__promise)
134
+ __result
135
+ .then({ __result in __promiseHolder.resolve() })
136
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
137
+ return __promise
138
+ }()
139
+ return bridge.create_Result_std__shared_ptr_Promise_void___(__resultCpp)
140
+ } catch (let __error) {
141
+ let __exceptionPtr = __error.toCpp()
142
+ return bridge.create_Result_std__shared_ptr_Promise_void___(__exceptionPtr)
143
+ }
144
+ }
145
+
146
+ @inline(__always)
147
+ public final func disconnect() -> bridge.Result_void_ {
148
+ do {
149
+ try self.__implementation.disconnect()
150
+ return bridge.create_Result_void_()
151
+ } catch (let __error) {
152
+ let __exceptionPtr = __error.toCpp()
153
+ return bridge.create_Result_void_(__exceptionPtr)
154
+ }
155
+ }
156
+
157
+ @inline(__always)
158
+ public final func isConnected() -> bridge.Result_bool_ {
159
+ do {
160
+ let __result = try self.__implementation.isConnected()
161
+ let __resultCpp = __result
162
+ return bridge.create_Result_bool_(__resultCpp)
163
+ } catch (let __error) {
164
+ let __exceptionPtr = __error.toCpp()
165
+ return bridge.create_Result_bool_(__exceptionPtr)
166
+ }
167
+ }
168
+
169
+ @inline(__always)
170
+ public final func send(bytes: ArrayBuffer) -> bridge.Result_void_ {
171
+ do {
172
+ try self.__implementation.send(bytes: bytes)
173
+ return bridge.create_Result_void_()
174
+ } catch (let __error) {
175
+ let __exceptionPtr = __error.toCpp()
176
+ return bridge.create_Result_void_(__exceptionPtr)
177
+ }
178
+ }
179
+
180
+ @inline(__always)
181
+ public final func setOnData(callback: bridge.Func_void_std__shared_ptr_ArrayBuffer_) -> bridge.Result_void_ {
182
+ do {
183
+ try self.__implementation.setOnData(callback: { () -> (ArrayBuffer) -> Void in
184
+ let __wrappedFunction = bridge.wrap_Func_void_std__shared_ptr_ArrayBuffer_(callback)
185
+ return { (__bytes: ArrayBuffer) -> Void in
186
+ __wrappedFunction.call(__bytes)
187
+ }
188
+ }())
189
+ return bridge.create_Result_void_()
190
+ } catch (let __error) {
191
+ let __exceptionPtr = __error.toCpp()
192
+ return bridge.create_Result_void_(__exceptionPtr)
193
+ }
194
+ }
195
+
196
+ @inline(__always)
197
+ public final func setOnDisconnect(callback: bridge.Func_void) -> bridge.Result_void_ {
198
+ do {
199
+ try self.__implementation.setOnDisconnect(callback: { () -> () -> Void in
200
+ let __wrappedFunction = bridge.wrap_Func_void(callback)
201
+ return { () -> Void in
202
+ __wrappedFunction.call()
203
+ }
204
+ }())
205
+ return bridge.create_Result_void_()
206
+ } catch (let __error) {
207
+ let __exceptionPtr = __error.toCpp()
208
+ return bridge.create_Result_void_(__exceptionPtr)
209
+ }
210
+ }
211
+ }
@@ -0,0 +1,84 @@
1
+ ///
2
+ /// CardType.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::ecr17 {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (CardType).
30
+ */
31
+ enum class CardType {
32
+ UNKNOWN SWIFT_NAME(unknown) = 0,
33
+ DEBIT SWIFT_NAME(debit) = 1,
34
+ CREDIT SWIFT_NAME(credit) = 2,
35
+ OTHER SWIFT_NAME(other) = 3,
36
+ } CLOSED_ENUM;
37
+
38
+ } // namespace margelo::nitro::ecr17
39
+
40
+ namespace margelo::nitro {
41
+
42
+ // C++ CardType <> JS CardType (union)
43
+ template <>
44
+ struct JSIConverter<margelo::nitro::ecr17::CardType> final {
45
+ static inline margelo::nitro::ecr17::CardType 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::ecr17::CardType::UNKNOWN;
49
+ case hashString("debit"): return margelo::nitro::ecr17::CardType::DEBIT;
50
+ case hashString("credit"): return margelo::nitro::ecr17::CardType::CREDIT;
51
+ case hashString("other"): return margelo::nitro::ecr17::CardType::OTHER;
52
+ default: [[unlikely]]
53
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum CardType - invalid value!");
54
+ }
55
+ }
56
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::ecr17::CardType arg) {
57
+ switch (arg) {
58
+ case margelo::nitro::ecr17::CardType::UNKNOWN: return JSIConverter<std::string>::toJSI(runtime, "unknown");
59
+ case margelo::nitro::ecr17::CardType::DEBIT: return JSIConverter<std::string>::toJSI(runtime, "debit");
60
+ case margelo::nitro::ecr17::CardType::CREDIT: return JSIConverter<std::string>::toJSI(runtime, "credit");
61
+ case margelo::nitro::ecr17::CardType::OTHER: return JSIConverter<std::string>::toJSI(runtime, "other");
62
+ default: [[unlikely]]
63
+ throw std::invalid_argument("Cannot convert CardType 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("debit"):
75
+ case hashString("credit"):
76
+ case hashString("other"):
77
+ return true;
78
+ default:
79
+ return false;
80
+ }
81
+ }
82
+ };
83
+
84
+ } // namespace margelo::nitro
@@ -0,0 +1,97 @@
1
+ ///
2
+ /// CardVerificationRequest.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+ // Forward declaration of `PaymentCardType` to properly resolve imports.
32
+ namespace margelo::nitro::ecr17 { enum class PaymentCardType; }
33
+ // Forward declaration of `TokenizationRequest` to properly resolve imports.
34
+ namespace margelo::nitro::ecr17 { struct TokenizationRequest; }
35
+
36
+ #include <string>
37
+ #include <optional>
38
+ #include "PaymentCardType.hpp"
39
+ #include "TokenizationRequest.hpp"
40
+
41
+ namespace margelo::nitro::ecr17 {
42
+
43
+ /**
44
+ * A struct which can be represented as a JavaScript object (CardVerificationRequest).
45
+ */
46
+ struct CardVerificationRequest final {
47
+ public:
48
+ std::optional<std::string> cashRegisterId SWIFT_PRIVATE;
49
+ std::optional<PaymentCardType> paymentType SWIFT_PRIVATE;
50
+ std::optional<TokenizationRequest> tokenization SWIFT_PRIVATE;
51
+
52
+ public:
53
+ CardVerificationRequest() = default;
54
+ explicit CardVerificationRequest(std::optional<std::string> cashRegisterId, std::optional<PaymentCardType> paymentType, std::optional<TokenizationRequest> tokenization): cashRegisterId(cashRegisterId), paymentType(paymentType), tokenization(tokenization) {}
55
+
56
+ public:
57
+ friend bool operator==(const CardVerificationRequest& lhs, const CardVerificationRequest& rhs) = default;
58
+ };
59
+
60
+ } // namespace margelo::nitro::ecr17
61
+
62
+ namespace margelo::nitro {
63
+
64
+ // C++ CardVerificationRequest <> JS CardVerificationRequest (object)
65
+ template <>
66
+ struct JSIConverter<margelo::nitro::ecr17::CardVerificationRequest> final {
67
+ static inline margelo::nitro::ecr17::CardVerificationRequest fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
68
+ jsi::Object obj = arg.asObject(runtime);
69
+ return margelo::nitro::ecr17::CardVerificationRequest(
70
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cashRegisterId"))),
71
+ JSIConverter<std::optional<margelo::nitro::ecr17::PaymentCardType>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "paymentType"))),
72
+ JSIConverter<std::optional<margelo::nitro::ecr17::TokenizationRequest>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tokenization")))
73
+ );
74
+ }
75
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::ecr17::CardVerificationRequest& arg) {
76
+ jsi::Object obj(runtime);
77
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "cashRegisterId"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.cashRegisterId));
78
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "paymentType"), JSIConverter<std::optional<margelo::nitro::ecr17::PaymentCardType>>::toJSI(runtime, arg.paymentType));
79
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "tokenization"), JSIConverter<std::optional<margelo::nitro::ecr17::TokenizationRequest>>::toJSI(runtime, arg.tokenization));
80
+ return obj;
81
+ }
82
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
83
+ if (!value.isObject()) {
84
+ return false;
85
+ }
86
+ jsi::Object obj = value.getObject(runtime);
87
+ if (!nitro::isPlainObject(runtime, obj)) {
88
+ return false;
89
+ }
90
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cashRegisterId")))) return false;
91
+ if (!JSIConverter<std::optional<margelo::nitro::ecr17::PaymentCardType>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "paymentType")))) return false;
92
+ if (!JSIConverter<std::optional<margelo::nitro::ecr17::TokenizationRequest>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tokenization")))) return false;
93
+ return true;
94
+ }
95
+ };
96
+
97
+ } // namespace margelo::nitro
@@ -0,0 +1,136 @@
1
+ ///
2
+ /// CardVerificationResult.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+ // Forward declaration of `TransactionOutcome` to properly resolve imports.
32
+ namespace margelo::nitro::ecr17 { enum class TransactionOutcome; }
33
+ // Forward declaration of `TransactionEntryMode` to properly resolve imports.
34
+ namespace margelo::nitro::ecr17 { enum class TransactionEntryMode; }
35
+ // Forward declaration of `CardType` to properly resolve imports.
36
+ namespace margelo::nitro::ecr17 { enum class CardType; }
37
+
38
+ #include "TransactionOutcome.hpp"
39
+ #include <string>
40
+ #include <optional>
41
+ #include "TransactionEntryMode.hpp"
42
+ #include "CardType.hpp"
43
+
44
+ namespace margelo::nitro::ecr17 {
45
+
46
+ /**
47
+ * A struct which can be represented as a JavaScript object (CardVerificationResult).
48
+ */
49
+ struct CardVerificationResult final {
50
+ public:
51
+ TransactionOutcome outcome SWIFT_PRIVATE;
52
+ std::string resultCode SWIFT_PRIVATE;
53
+ std::optional<std::string> pan SWIFT_PRIVATE;
54
+ std::optional<TransactionEntryMode> entryMode SWIFT_PRIVATE;
55
+ std::optional<std::string> authCode SWIFT_PRIVATE;
56
+ std::optional<std::string> hostDateTime SWIFT_PRIVATE;
57
+ std::optional<CardType> cardType SWIFT_PRIVATE;
58
+ std::optional<std::string> acquirerId SWIFT_PRIVATE;
59
+ std::optional<std::string> stan SWIFT_PRIVATE;
60
+ std::optional<std::string> onlineId SWIFT_PRIVATE;
61
+ std::optional<std::string> actionCode SWIFT_PRIVATE;
62
+ std::optional<std::string> errorDescription SWIFT_PRIVATE;
63
+
64
+ public:
65
+ CardVerificationResult() = default;
66
+ explicit CardVerificationResult(TransactionOutcome outcome, std::string resultCode, std::optional<std::string> pan, std::optional<TransactionEntryMode> entryMode, std::optional<std::string> authCode, std::optional<std::string> hostDateTime, std::optional<CardType> cardType, std::optional<std::string> acquirerId, std::optional<std::string> stan, std::optional<std::string> onlineId, std::optional<std::string> actionCode, std::optional<std::string> errorDescription): outcome(outcome), resultCode(resultCode), pan(pan), entryMode(entryMode), authCode(authCode), hostDateTime(hostDateTime), cardType(cardType), acquirerId(acquirerId), stan(stan), onlineId(onlineId), actionCode(actionCode), errorDescription(errorDescription) {}
67
+
68
+ public:
69
+ friend bool operator==(const CardVerificationResult& lhs, const CardVerificationResult& rhs) = default;
70
+ };
71
+
72
+ } // namespace margelo::nitro::ecr17
73
+
74
+ namespace margelo::nitro {
75
+
76
+ // C++ CardVerificationResult <> JS CardVerificationResult (object)
77
+ template <>
78
+ struct JSIConverter<margelo::nitro::ecr17::CardVerificationResult> final {
79
+ static inline margelo::nitro::ecr17::CardVerificationResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
80
+ jsi::Object obj = arg.asObject(runtime);
81
+ return margelo::nitro::ecr17::CardVerificationResult(
82
+ JSIConverter<margelo::nitro::ecr17::TransactionOutcome>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "outcome"))),
83
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "resultCode"))),
84
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "pan"))),
85
+ JSIConverter<std::optional<margelo::nitro::ecr17::TransactionEntryMode>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "entryMode"))),
86
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "authCode"))),
87
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "hostDateTime"))),
88
+ JSIConverter<std::optional<margelo::nitro::ecr17::CardType>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cardType"))),
89
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "acquirerId"))),
90
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "stan"))),
91
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onlineId"))),
92
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "actionCode"))),
93
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "errorDescription")))
94
+ );
95
+ }
96
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::ecr17::CardVerificationResult& arg) {
97
+ jsi::Object obj(runtime);
98
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "outcome"), JSIConverter<margelo::nitro::ecr17::TransactionOutcome>::toJSI(runtime, arg.outcome));
99
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "resultCode"), JSIConverter<std::string>::toJSI(runtime, arg.resultCode));
100
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "pan"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.pan));
101
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "entryMode"), JSIConverter<std::optional<margelo::nitro::ecr17::TransactionEntryMode>>::toJSI(runtime, arg.entryMode));
102
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "authCode"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.authCode));
103
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "hostDateTime"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.hostDateTime));
104
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "cardType"), JSIConverter<std::optional<margelo::nitro::ecr17::CardType>>::toJSI(runtime, arg.cardType));
105
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "acquirerId"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.acquirerId));
106
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "stan"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.stan));
107
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "onlineId"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.onlineId));
108
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "actionCode"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.actionCode));
109
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "errorDescription"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.errorDescription));
110
+ return obj;
111
+ }
112
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
113
+ if (!value.isObject()) {
114
+ return false;
115
+ }
116
+ jsi::Object obj = value.getObject(runtime);
117
+ if (!nitro::isPlainObject(runtime, obj)) {
118
+ return false;
119
+ }
120
+ if (!JSIConverter<margelo::nitro::ecr17::TransactionOutcome>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "outcome")))) return false;
121
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "resultCode")))) return false;
122
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "pan")))) return false;
123
+ if (!JSIConverter<std::optional<margelo::nitro::ecr17::TransactionEntryMode>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "entryMode")))) return false;
124
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "authCode")))) return false;
125
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "hostDateTime")))) return false;
126
+ if (!JSIConverter<std::optional<margelo::nitro::ecr17::CardType>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cardType")))) return false;
127
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "acquirerId")))) return false;
128
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "stan")))) return false;
129
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onlineId")))) return false;
130
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "actionCode")))) return false;
131
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "errorDescription")))) return false;
132
+ return true;
133
+ }
134
+ };
135
+
136
+ } // namespace margelo::nitro
@@ -0,0 +1,106 @@
1
+ ///
2
+ /// CloseSessionResult.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+ // Forward declaration of `TransactionOutcome` to properly resolve imports.
32
+ namespace margelo::nitro::ecr17 { enum class TransactionOutcome; }
33
+
34
+ #include "TransactionOutcome.hpp"
35
+ #include <string>
36
+ #include <optional>
37
+
38
+ namespace margelo::nitro::ecr17 {
39
+
40
+ /**
41
+ * A struct which can be represented as a JavaScript object (CloseSessionResult).
42
+ */
43
+ struct CloseSessionResult final {
44
+ public:
45
+ TransactionOutcome outcome SWIFT_PRIVATE;
46
+ std::string resultCode SWIFT_PRIVATE;
47
+ std::optional<double> posTotalCents SWIFT_PRIVATE;
48
+ std::optional<double> hostTotalCents SWIFT_PRIVATE;
49
+ std::optional<std::string> actionCode SWIFT_PRIVATE;
50
+ std::optional<std::string> errorDescription SWIFT_PRIVATE;
51
+
52
+ public:
53
+ CloseSessionResult() = default;
54
+ explicit CloseSessionResult(TransactionOutcome outcome, std::string resultCode, std::optional<double> posTotalCents, std::optional<double> hostTotalCents, std::optional<std::string> actionCode, std::optional<std::string> errorDescription): outcome(outcome), resultCode(resultCode), posTotalCents(posTotalCents), hostTotalCents(hostTotalCents), actionCode(actionCode), errorDescription(errorDescription) {}
55
+
56
+ public:
57
+ friend bool operator==(const CloseSessionResult& lhs, const CloseSessionResult& rhs) = default;
58
+ };
59
+
60
+ } // namespace margelo::nitro::ecr17
61
+
62
+ namespace margelo::nitro {
63
+
64
+ // C++ CloseSessionResult <> JS CloseSessionResult (object)
65
+ template <>
66
+ struct JSIConverter<margelo::nitro::ecr17::CloseSessionResult> final {
67
+ static inline margelo::nitro::ecr17::CloseSessionResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
68
+ jsi::Object obj = arg.asObject(runtime);
69
+ return margelo::nitro::ecr17::CloseSessionResult(
70
+ JSIConverter<margelo::nitro::ecr17::TransactionOutcome>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "outcome"))),
71
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "resultCode"))),
72
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "posTotalCents"))),
73
+ JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "hostTotalCents"))),
74
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "actionCode"))),
75
+ JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "errorDescription")))
76
+ );
77
+ }
78
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::ecr17::CloseSessionResult& arg) {
79
+ jsi::Object obj(runtime);
80
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "outcome"), JSIConverter<margelo::nitro::ecr17::TransactionOutcome>::toJSI(runtime, arg.outcome));
81
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "resultCode"), JSIConverter<std::string>::toJSI(runtime, arg.resultCode));
82
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "posTotalCents"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.posTotalCents));
83
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "hostTotalCents"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.hostTotalCents));
84
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "actionCode"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.actionCode));
85
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "errorDescription"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.errorDescription));
86
+ return obj;
87
+ }
88
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
89
+ if (!value.isObject()) {
90
+ return false;
91
+ }
92
+ jsi::Object obj = value.getObject(runtime);
93
+ if (!nitro::isPlainObject(runtime, obj)) {
94
+ return false;
95
+ }
96
+ if (!JSIConverter<margelo::nitro::ecr17::TransactionOutcome>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "outcome")))) return false;
97
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "resultCode")))) return false;
98
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "posTotalCents")))) return false;
99
+ if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "hostTotalCents")))) return false;
100
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "actionCode")))) return false;
101
+ if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "errorDescription")))) return false;
102
+ return true;
103
+ }
104
+ };
105
+
106
+ } // namespace margelo::nitro