@padosoft/react-native-ecr17 0.0.0 → 2.0.1

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 (80) hide show
  1. package/Ecr17.podspec +39 -39
  2. package/README.md +348 -348
  3. package/android/CMakeLists.txt +41 -41
  4. package/android/build.gradle +148 -148
  5. package/android/fix-prefab.gradle +50 -50
  6. package/android/gradle.properties +5 -5
  7. package/android/src/main/AndroidManifest.xml +2 -2
  8. package/android/src/main/cpp/cpp-adapter.cpp +8 -8
  9. package/android/src/main/java/com/margelo/nitro/ecr17/HybridEcr17Transport.kt +233 -233
  10. package/android/src/main/java/com/padosoft/ecr17/Ecr17Package.kt +30 -30
  11. package/cpp/Ecr17.hpp +1 -1
  12. package/cpp/Ecr17Client/HybridEcr17Client.cpp +598 -598
  13. package/cpp/Ecr17Client/HybridEcr17Client.hpp +85 -85
  14. package/cpp/Ecr17Protocol/Ecr17Protocol.cpp +277 -277
  15. package/cpp/Ecr17Protocol/Ecr17Protocol.hpp +103 -103
  16. package/cpp/Ecr17Response/Ecr17Response.cpp +155 -155
  17. package/cpp/Ecr17Response/Ecr17Response.hpp +113 -113
  18. package/cpp/Lcr/Lcr.cpp +42 -42
  19. package/cpp/Lcr/Lcr.hpp +21 -21
  20. package/cpp/PacketCodec/PacketCodec.cpp +145 -145
  21. package/cpp/PacketCodec/PacketCodec.hpp +47 -47
  22. package/cpp/Session/Ecr17Session.cpp +260 -260
  23. package/cpp/Session/Ecr17Session.hpp +97 -97
  24. package/cpp/Session/RetryPolicy.hpp +23 -23
  25. package/cpp/Transport/FakeTransport.hpp +95 -95
  26. package/cpp/Transport/NativeTransportAdapter.cpp +42 -42
  27. package/cpp/Transport/NativeTransportAdapter.hpp +32 -32
  28. package/cpp/Transport/Transport.hpp +30 -30
  29. package/cpp/tests/CMakeLists.txt +55 -55
  30. package/cpp/tests/PosixTcpTransport.hpp +105 -105
  31. package/cpp/tests/stubs/LrcMode.hpp +25 -25
  32. package/cpp/tests/test_flows.cpp +148 -148
  33. package/cpp/tests/test_integration_terminal.cpp +72 -72
  34. package/cpp/tests/test_lrc.cpp +66 -66
  35. package/cpp/tests/test_packet_codec.cpp +164 -164
  36. package/cpp/tests/test_protocol.cpp +102 -102
  37. package/cpp/tests/test_protocol_commands.cpp +190 -190
  38. package/cpp/tests/test_response.cpp +164 -164
  39. package/cpp/tests/test_retry_policy.cpp +28 -28
  40. package/cpp/tests/test_session.cpp +262 -262
  41. package/ios/HybridEcr17Transport.swift +103 -103
  42. package/lib/commonjs/index.js +50 -0
  43. package/lib/commonjs/index.js.map +1 -0
  44. package/lib/commonjs/package.json +1 -0
  45. package/lib/commonjs/specs/client.nitro.js +17 -0
  46. package/lib/commonjs/specs/client.nitro.js.map +1 -0
  47. package/lib/commonjs/specs/transport.nitro.js +6 -0
  48. package/lib/commonjs/specs/transport.nitro.js.map +1 -0
  49. package/lib/commonjs/types/client.js +2 -0
  50. package/lib/commonjs/types/client.js.map +1 -0
  51. package/lib/commonjs/utils/client.js +13 -0
  52. package/lib/commonjs/utils/client.js.map +1 -0
  53. package/lib/module/index.js +7 -0
  54. package/lib/module/index.js.map +1 -0
  55. package/lib/module/specs/client.nitro.js +13 -0
  56. package/lib/module/specs/client.nitro.js.map +1 -0
  57. package/lib/module/specs/transport.nitro.js +4 -0
  58. package/lib/module/specs/transport.nitro.js.map +1 -0
  59. package/lib/module/types/client.js +2 -0
  60. package/lib/module/types/client.js.map +1 -0
  61. package/lib/module/utils/client.js +9 -0
  62. package/lib/module/utils/client.js.map +1 -0
  63. package/lib/typescript/src/index.d.ts +5 -0
  64. package/lib/typescript/src/index.d.ts.map +1 -0
  65. package/lib/typescript/src/specs/client.nitro.d.ts +63 -0
  66. package/lib/typescript/src/specs/client.nitro.d.ts.map +1 -0
  67. package/lib/typescript/src/specs/transport.nitro.d.ts +13 -0
  68. package/lib/typescript/src/specs/transport.nitro.d.ts.map +1 -0
  69. package/lib/typescript/src/types/client.d.ts +138 -0
  70. package/lib/typescript/src/types/client.d.ts.map +1 -0
  71. package/lib/typescript/src/utils/client.d.ts +3 -0
  72. package/lib/typescript/src/utils/client.d.ts.map +1 -0
  73. package/nitro.json +30 -30
  74. package/package.json +4 -4
  75. package/react-native.config.js +18 -18
  76. package/src/index.ts +4 -4
  77. package/src/specs/client.nitro.ts +102 -102
  78. package/src/specs/transport.nitro.ts +25 -25
  79. package/src/types/client.ts +196 -196
  80. package/src/utils/client.ts +10 -10
@@ -1,196 +1,196 @@
1
- // LRC scope selector. Which framing bytes are folded into the LRC (base 0x7F):
2
- // - "stx": STX + payload + ETX
3
- // - "std": payload only
4
- // - "noext": payload + ETX
5
- // - "stx_noext": STX + payload
6
- export type LrcMode = "stx" | "std" | "noext" | "stx_noext";
7
-
8
- // Transport connection lifecycle.
9
- export type ConnectionState = "disconnected" | "connecting" | "connected";
10
-
11
- // Normalized transaction outcome (mapped from the raw 2-digit result code).
12
- // "00" -> ok, "01" -> ko, "05" -> cardNotPresent, "09" -> unknownTag.
13
- export type TransactionOutcome = "ok" | "ko" | "cardNotPresent" | "unknownTag" | "unknown";
14
-
15
- // Card category reported by the terminal (response "Card type": 1/2/3).
16
- export type CardType = "debit" | "credit" | "other" | "unknown";
17
-
18
- // How the card was read (response "Transaction type": ICC/MAG/MAN/CLM/CLI).
19
- export type TransactionEntryMode = "icc" | "mag" | "manual" | "clessMag" | "clessIcc" | "unknown";
20
-
21
- // Requested card handling for a payment (request "Payment type": 0..3).
22
- export type PaymentCardType = "auto" | "debit" | "credit" | "other";
23
-
24
- // Tokenization service requested alongside a payment/preauth/verification (command "U").
25
- export type TokenizationService = "recurring" | "unscheduledOrOneClick";
26
-
27
- export interface TokenizationRequest {
28
- service: TokenizationService;
29
- // Unique contract code at merchant level, alphanumeric, up to 18 chars.
30
- contractCode: string;
31
- }
32
-
33
- // ---------------------------------------------------------------------------
34
- // Requests
35
- // ---------------------------------------------------------------------------
36
-
37
- export interface PaymentRequest {
38
- amountCents: number;
39
- // Defaults to the configured cashRegisterId when omitted.
40
- cashRegisterId?: string;
41
- paymentType?: PaymentCardType;
42
- // true => start with the card already inserted in the terminal.
43
- cardAlreadyPresent?: boolean;
44
- // Text (e.g. contract code) printed at the end of the receipt (max 128 chars).
45
- receiptText?: string;
46
- // Attach tokenization additional data ("U") to this transaction.
47
- tokenization?: TokenizationRequest;
48
- }
49
-
50
- export interface ReversalRequest {
51
- cashRegisterId?: string;
52
- // STAN of the transaction to reverse; "000000" (default) reverses the last
53
- // payment with no STAN check.
54
- stan?: string;
55
- }
56
-
57
- export interface PreAuthRequest {
58
- amountCents: number;
59
- cashRegisterId?: string;
60
- paymentType?: PaymentCardType;
61
- cardAlreadyPresent?: boolean;
62
- receiptText?: string;
63
- tokenization?: TokenizationRequest;
64
- }
65
-
66
- export interface IncrementalAuthRequest {
67
- amountCents: number;
68
- // Unique pre-authorization code from the original pre-auth response.
69
- originalPreAuthCode: string;
70
- cashRegisterId?: string;
71
- receiptText?: string;
72
- }
73
-
74
- export interface PreAuthClosureRequest {
75
- amountCents: number;
76
- originalPreAuthCode: string;
77
- cashRegisterId?: string;
78
- receiptText?: string;
79
- }
80
-
81
- export interface CardVerificationRequest {
82
- cashRegisterId?: string;
83
- paymentType?: PaymentCardType;
84
- tokenization?: TokenizationRequest;
85
- }
86
-
87
- // ---------------------------------------------------------------------------
88
- // Results
89
- // ---------------------------------------------------------------------------
90
-
91
- // DCC / currency-exchange block (only meaningful when applied === true).
92
- export interface CurrencyExchange {
93
- applied: boolean;
94
- rate?: number;
95
- currencyCode?: string;
96
- amountCents?: number;
97
- precision?: number;
98
- }
99
-
100
- export interface PaymentResult {
101
- outcome: TransactionOutcome;
102
- resultCode: string; // raw "00"/"01"/"05"/"09"
103
- pan?: string;
104
- entryMode?: TransactionEntryMode;
105
- authCode?: string;
106
- hostDateTime?: string; // raw DDDHHMM as received from host
107
- cardType?: CardType;
108
- acquirerId?: string;
109
- stan?: string;
110
- onlineId?: string;
111
- errorDescription?: string;
112
- currencyExchange?: CurrencyExchange;
113
- }
114
-
115
- export interface ReversalResult {
116
- outcome: TransactionOutcome;
117
- resultCode: string;
118
- pan?: string;
119
- entryMode?: TransactionEntryMode;
120
- hostDateTime?: string;
121
- cardType?: CardType;
122
- acquirerId?: string;
123
- stan?: string;
124
- onlineId?: string;
125
- actionCode?: string;
126
- errorDescription?: string;
127
- }
128
-
129
- export interface PreAuthResult {
130
- outcome: TransactionOutcome;
131
- resultCode: string;
132
- pan?: string;
133
- entryMode?: TransactionEntryMode;
134
- authCode?: string;
135
- preAuthorizedAmountCents?: number;
136
- preAuthCode?: string;
137
- actionCode?: string;
138
- hostDateTime?: string;
139
- cardType?: CardType;
140
- acquirerId?: string;
141
- stan?: string;
142
- onlineId?: string;
143
- errorDescription?: string;
144
- }
145
-
146
- export interface CardVerificationResult {
147
- outcome: TransactionOutcome;
148
- resultCode: string;
149
- pan?: string;
150
- entryMode?: TransactionEntryMode;
151
- authCode?: string;
152
- hostDateTime?: string;
153
- cardType?: CardType;
154
- acquirerId?: string;
155
- stan?: string;
156
- onlineId?: string;
157
- actionCode?: string;
158
- errorDescription?: string;
159
- }
160
-
161
- export interface TotalsResult {
162
- outcome: TransactionOutcome;
163
- resultCode: string;
164
- posTotalCents: number;
165
- }
166
-
167
- export interface CloseSessionResult {
168
- outcome: TransactionOutcome;
169
- resultCode: string;
170
- posTotalCents?: number;
171
- hostTotalCents?: number;
172
- actionCode?: string;
173
- errorDescription?: string;
174
- }
175
-
176
- export interface VasResult {
177
- responseId: string; // RESPID ("0" = OK)
178
- responseMessage: string; // RESPMSG
179
- orderId?: string; // ORDER_ID when present
180
- rawXml: string; // full concatenated XML response
181
- }
182
-
183
- // ---------------------------------------------------------------------------
184
- // Events
185
- // ---------------------------------------------------------------------------
186
-
187
- // Progress-update message shown on the ECR display during a procedure (SOH frame).
188
- export interface ProgressEvent {
189
- message: string;
190
- }
191
-
192
- // A single receipt line streamed by the terminal ("S" message) when ECR
193
- // printing is enabled.
194
- export interface ReceiptLine {
195
- text: string;
196
- }
1
+ // LRC scope selector. Which framing bytes are folded into the LRC (base 0x7F):
2
+ // - "stx": STX + payload + ETX
3
+ // - "std": payload only
4
+ // - "noext": payload + ETX
5
+ // - "stx_noext": STX + payload
6
+ export type LrcMode = "stx" | "std" | "noext" | "stx_noext";
7
+
8
+ // Transport connection lifecycle.
9
+ export type ConnectionState = "disconnected" | "connecting" | "connected";
10
+
11
+ // Normalized transaction outcome (mapped from the raw 2-digit result code).
12
+ // "00" -> ok, "01" -> ko, "05" -> cardNotPresent, "09" -> unknownTag.
13
+ export type TransactionOutcome = "ok" | "ko" | "cardNotPresent" | "unknownTag" | "unknown";
14
+
15
+ // Card category reported by the terminal (response "Card type": 1/2/3).
16
+ export type CardType = "debit" | "credit" | "other" | "unknown";
17
+
18
+ // How the card was read (response "Transaction type": ICC/MAG/MAN/CLM/CLI).
19
+ export type TransactionEntryMode = "icc" | "mag" | "manual" | "clessMag" | "clessIcc" | "unknown";
20
+
21
+ // Requested card handling for a payment (request "Payment type": 0..3).
22
+ export type PaymentCardType = "auto" | "debit" | "credit" | "other";
23
+
24
+ // Tokenization service requested alongside a payment/preauth/verification (command "U").
25
+ export type TokenizationService = "recurring" | "unscheduledOrOneClick";
26
+
27
+ export interface TokenizationRequest {
28
+ service: TokenizationService;
29
+ // Unique contract code at merchant level, alphanumeric, up to 18 chars.
30
+ contractCode: string;
31
+ }
32
+
33
+ // ---------------------------------------------------------------------------
34
+ // Requests
35
+ // ---------------------------------------------------------------------------
36
+
37
+ export interface PaymentRequest {
38
+ amountCents: number;
39
+ // Defaults to the configured cashRegisterId when omitted.
40
+ cashRegisterId?: string;
41
+ paymentType?: PaymentCardType;
42
+ // true => start with the card already inserted in the terminal.
43
+ cardAlreadyPresent?: boolean;
44
+ // Text (e.g. contract code) printed at the end of the receipt (max 128 chars).
45
+ receiptText?: string;
46
+ // Attach tokenization additional data ("U") to this transaction.
47
+ tokenization?: TokenizationRequest;
48
+ }
49
+
50
+ export interface ReversalRequest {
51
+ cashRegisterId?: string;
52
+ // STAN of the transaction to reverse; "000000" (default) reverses the last
53
+ // payment with no STAN check.
54
+ stan?: string;
55
+ }
56
+
57
+ export interface PreAuthRequest {
58
+ amountCents: number;
59
+ cashRegisterId?: string;
60
+ paymentType?: PaymentCardType;
61
+ cardAlreadyPresent?: boolean;
62
+ receiptText?: string;
63
+ tokenization?: TokenizationRequest;
64
+ }
65
+
66
+ export interface IncrementalAuthRequest {
67
+ amountCents: number;
68
+ // Unique pre-authorization code from the original pre-auth response.
69
+ originalPreAuthCode: string;
70
+ cashRegisterId?: string;
71
+ receiptText?: string;
72
+ }
73
+
74
+ export interface PreAuthClosureRequest {
75
+ amountCents: number;
76
+ originalPreAuthCode: string;
77
+ cashRegisterId?: string;
78
+ receiptText?: string;
79
+ }
80
+
81
+ export interface CardVerificationRequest {
82
+ cashRegisterId?: string;
83
+ paymentType?: PaymentCardType;
84
+ tokenization?: TokenizationRequest;
85
+ }
86
+
87
+ // ---------------------------------------------------------------------------
88
+ // Results
89
+ // ---------------------------------------------------------------------------
90
+
91
+ // DCC / currency-exchange block (only meaningful when applied === true).
92
+ export interface CurrencyExchange {
93
+ applied: boolean;
94
+ rate?: number;
95
+ currencyCode?: string;
96
+ amountCents?: number;
97
+ precision?: number;
98
+ }
99
+
100
+ export interface PaymentResult {
101
+ outcome: TransactionOutcome;
102
+ resultCode: string; // raw "00"/"01"/"05"/"09"
103
+ pan?: string;
104
+ entryMode?: TransactionEntryMode;
105
+ authCode?: string;
106
+ hostDateTime?: string; // raw DDDHHMM as received from host
107
+ cardType?: CardType;
108
+ acquirerId?: string;
109
+ stan?: string;
110
+ onlineId?: string;
111
+ errorDescription?: string;
112
+ currencyExchange?: CurrencyExchange;
113
+ }
114
+
115
+ export interface ReversalResult {
116
+ outcome: TransactionOutcome;
117
+ resultCode: string;
118
+ pan?: string;
119
+ entryMode?: TransactionEntryMode;
120
+ hostDateTime?: string;
121
+ cardType?: CardType;
122
+ acquirerId?: string;
123
+ stan?: string;
124
+ onlineId?: string;
125
+ actionCode?: string;
126
+ errorDescription?: string;
127
+ }
128
+
129
+ export interface PreAuthResult {
130
+ outcome: TransactionOutcome;
131
+ resultCode: string;
132
+ pan?: string;
133
+ entryMode?: TransactionEntryMode;
134
+ authCode?: string;
135
+ preAuthorizedAmountCents?: number;
136
+ preAuthCode?: string;
137
+ actionCode?: string;
138
+ hostDateTime?: string;
139
+ cardType?: CardType;
140
+ acquirerId?: string;
141
+ stan?: string;
142
+ onlineId?: string;
143
+ errorDescription?: string;
144
+ }
145
+
146
+ export interface CardVerificationResult {
147
+ outcome: TransactionOutcome;
148
+ resultCode: string;
149
+ pan?: string;
150
+ entryMode?: TransactionEntryMode;
151
+ authCode?: string;
152
+ hostDateTime?: string;
153
+ cardType?: CardType;
154
+ acquirerId?: string;
155
+ stan?: string;
156
+ onlineId?: string;
157
+ actionCode?: string;
158
+ errorDescription?: string;
159
+ }
160
+
161
+ export interface TotalsResult {
162
+ outcome: TransactionOutcome;
163
+ resultCode: string;
164
+ posTotalCents: number;
165
+ }
166
+
167
+ export interface CloseSessionResult {
168
+ outcome: TransactionOutcome;
169
+ resultCode: string;
170
+ posTotalCents?: number;
171
+ hostTotalCents?: number;
172
+ actionCode?: string;
173
+ errorDescription?: string;
174
+ }
175
+
176
+ export interface VasResult {
177
+ responseId: string; // RESPID ("0" = OK)
178
+ responseMessage: string; // RESPMSG
179
+ orderId?: string; // ORDER_ID when present
180
+ rawXml: string; // full concatenated XML response
181
+ }
182
+
183
+ // ---------------------------------------------------------------------------
184
+ // Events
185
+ // ---------------------------------------------------------------------------
186
+
187
+ // Progress-update message shown on the ECR display during a procedure (SOH frame).
188
+ export interface ProgressEvent {
189
+ message: string;
190
+ }
191
+
192
+ // A single receipt line streamed by the terminal ("S" message) when ECR
193
+ // printing is enabled.
194
+ export interface ReceiptLine {
195
+ text: string;
196
+ }
@@ -1,10 +1,10 @@
1
- import { NitroModules } from "react-native-nitro-modules";
2
- import type { Ecr17Client, Ecr17Config } from "../specs/client.nitro";
3
-
4
- export function createEcr17Client(config: Ecr17Config): Ecr17Client {
5
- const client = NitroModules.createHybridObject<Ecr17Client>("Ecr17Client");
6
-
7
- client.configure(config);
8
-
9
- return client;
10
- }
1
+ import { NitroModules } from "react-native-nitro-modules";
2
+ import type { Ecr17Client, Ecr17Config } from "../specs/client.nitro";
3
+
4
+ export function createEcr17Client(config: Ecr17Config): Ecr17Client {
5
+ const client = NitroModules.createHybridObject<Ecr17Client>("Ecr17Client");
6
+
7
+ client.configure(config);
8
+
9
+ return client;
10
+ }