@fire-spark/payments-clisitef-pinpad-rn 0.7.1 → 0.8.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/dist/index.d.ts +142 -14
- package/dist/index.js +827 -206
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DeviceField, PaymentAdapter, PaymentAdapterCapabilities, PaymentErrorEntry, PaymentMetadata, PaymentStorage, PaymentUI, StandardPaymentError } from "@fire-spark/payments";
|
|
2
|
-
import { CLISITEF_MODALITY, ClisitefClient, ClisitefConfigureParams, ClisitefFinishParams, ClisitefStartParams } from "@fire-spark/payments-clisitef-client";
|
|
1
|
+
import { DeviceField, PaymentAdapter, PaymentAdapterCapabilities, PaymentErrorEntry, PaymentMetadata, PaymentResult, PaymentStorage, PaymentUI, StandardPaymentError } from "@fire-spark/payments";
|
|
2
|
+
import { CLISITEF_MODALITY, ClisitefClient, ClisitefConfigureParams, ClisitefFinishParams, ClisitefMenuOption, ClisitefStartParams } from "@fire-spark/payments-clisitef-client";
|
|
3
3
|
import { TenderDetails } from "@fire-spark/types";
|
|
4
4
|
//#region src/adapter.d.ts
|
|
5
5
|
/** Confirmed in the act (`finishTransaction(1)`), never captured later. */
|
|
@@ -24,10 +24,11 @@ type ClisitefPinPadOptions = {
|
|
|
24
24
|
timeoutMs?: number;
|
|
25
25
|
};
|
|
26
26
|
/**
|
|
27
|
-
* CliSiTef (Software Express) on the kiosk pinpad, Brazil.
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* the 30 s library
|
|
27
|
+
* CliSiTef (Software Express) on the kiosk pinpad, Brazil. The payment lists
|
|
28
|
+
* its `modalities` (DEBIT / CREDIT / VOUCHER); with more than one the
|
|
29
|
+
* customer picks it before the pinpad starts. The pinpad waits on the
|
|
30
|
+
* customer, so the deadline is `timeoutMs` instead of the 30 s library
|
|
31
|
+
* default.
|
|
31
32
|
*/
|
|
32
33
|
declare const clisitefPinPadPayments: (options?: ClisitefPinPadOptions) => PaymentAdapter;
|
|
33
34
|
//#endregion
|
|
@@ -35,8 +36,8 @@ declare const clisitefPinPadPayments: (options?: ClisitefPinPadOptions) => Payme
|
|
|
35
36
|
/**
|
|
36
37
|
* `onData` commands handled by the adapter (Fiserv "Tabela de códigos de
|
|
37
38
|
* comando"). Not handled, so they abort the transaction: 29 (silent field),
|
|
38
|
-
* 31 (check), 35 (barcode)
|
|
39
|
-
* `ItemMenuIdentificado`)
|
|
39
|
+
* 31 (check), 35 (barcode) and 42 (identified menu, only with
|
|
40
|
+
* `ItemMenuIdentificado`).
|
|
40
41
|
*/
|
|
41
42
|
declare const CLISITEF_COMMAND: {
|
|
42
43
|
readonly STORE_FIELD: 0;
|
|
@@ -57,6 +58,9 @@ declare const CLISITEF_COMMAND: {
|
|
|
57
58
|
readonly READ_FIELD: 30;
|
|
58
59
|
readonly READ_AMOUNT: 34;
|
|
59
60
|
readonly READ_MASKED: 41;
|
|
61
|
+
/** PIX: show the QR (`fieldId` 584 carries the copy-and-paste payload). */
|
|
62
|
+
readonly QR_SHOW: 50;
|
|
63
|
+
readonly QR_HIDE: 51;
|
|
60
64
|
readonly FOOTER: 52;
|
|
61
65
|
};
|
|
62
66
|
/** `continueTransaction` answers to `CONFIRM` (20). */
|
|
@@ -74,9 +78,17 @@ declare const CLISITEF_FIELD: {
|
|
|
74
78
|
readonly AUTHORIZATION_CODE: 135;
|
|
75
79
|
readonly CARD_BIN: 136;
|
|
76
80
|
readonly INSTITUTION_NAME: 156;
|
|
81
|
+
readonly QR_PAYLOAD: 584;
|
|
77
82
|
readonly LAST4: 1190;
|
|
78
83
|
readonly ENTRY_MODE: 2090;
|
|
79
84
|
};
|
|
85
|
+
/** Fields a void asks for (`READ_*` commands), answered without the UI. */
|
|
86
|
+
declare const CLISITEF_VOID_FIELD: {
|
|
87
|
+
readonly AMOUNT: 146;
|
|
88
|
+
readonly SUPERVISOR_PASSWORD: 500;
|
|
89
|
+
readonly ORIGINAL_DATE: 515;
|
|
90
|
+
readonly ORIGINAL_HOST_NSU: 516;
|
|
91
|
+
};
|
|
80
92
|
/** Fields that prove the card was read: an error after them is ambiguous. */
|
|
81
93
|
declare const CLISITEF_CAPTURE_FIELDS: ReadonlySet<number>;
|
|
82
94
|
/** Operator, pinpad or automation cancelled (ficha §11). */
|
|
@@ -94,6 +106,12 @@ declare const CLISITEF_PAYMENT_TIMEOUT_MS = 180000;
|
|
|
94
106
|
declare const CLISITEF_DEFAULT_OPERATOR = "KIOSKO_BR";
|
|
95
107
|
/** Device-wide record of the last transaction, to undo it after a crash. */
|
|
96
108
|
declare const CLISITEF_STORAGE_KEY = "clisitef:transaction:v1";
|
|
109
|
+
/** Device-wide record of the last refund, apart from the charge one. */
|
|
110
|
+
declare const CLISITEF_REFUND_STORAGE_KEY = "clisitef:refund:v1";
|
|
111
|
+
/** Device-wide queue of voids that did not complete, retried later. */
|
|
112
|
+
declare const CLISITEF_REVERSALS_KEY = "clisitef:reversals:v1";
|
|
113
|
+
/** Device-wide record of completed voids, by attempt reference. */
|
|
114
|
+
declare const CLISITEF_REFUNDS_KEY = "clisitef:refunds:v1";
|
|
97
115
|
//#endregion
|
|
98
116
|
//#region src/errors.d.ts
|
|
99
117
|
/**
|
|
@@ -123,23 +141,55 @@ declare const clisitefPinPadErrors: Readonly<Record<string, PaymentErrorEntry>>
|
|
|
123
141
|
"-50": PaymentErrorEntry;
|
|
124
142
|
"-100": PaymentErrorEntry;
|
|
125
143
|
CLISITEF_TIMEOUT: PaymentErrorEntry;
|
|
144
|
+
FINANCING_ONLY: PaymentErrorEntry;
|
|
126
145
|
};
|
|
127
146
|
//#endregion
|
|
128
147
|
//#region src/settings.d.ts
|
|
129
148
|
declare const CLISITEF_PINPAD_TYPES: readonly ["ANDROID_USB", "ANDROID_BT", "ANDROID_AUTO"];
|
|
130
|
-
/**
|
|
149
|
+
/**
|
|
150
|
+
* Ficha §6: filled per kiosk in the device settings. SiTef IP, store code
|
|
151
|
+
* and store CNPJ come from the payment's store settings (`config.stores`);
|
|
152
|
+
* the device values only override them.
|
|
153
|
+
*/
|
|
131
154
|
declare const clisitefPinPadDeviceFields: DeviceField[];
|
|
155
|
+
declare const redactSecrets: (values?: Record<string, unknown>) => {
|
|
156
|
+
[k: string]: unknown;
|
|
157
|
+
};
|
|
132
158
|
type ClisitefModality = keyof typeof CLISITEF_MODALITY;
|
|
159
|
+
declare const CLISITEF_MODALITIES: readonly ClisitefModality[];
|
|
133
160
|
type ClisitefPinPadSettings = {
|
|
134
161
|
configure: ClisitefConfigureParams;
|
|
135
|
-
|
|
162
|
+
/** Asked to the customer when there is more than one. */
|
|
163
|
+
modalities: ClisitefModality[];
|
|
136
164
|
operator: string;
|
|
137
|
-
restrictions: string
|
|
165
|
+
restrictions: Partial<Record<ClisitefModality, string>>;
|
|
138
166
|
terminalNumber: string;
|
|
167
|
+
/** Field 500 of a void: device secret, else the store one. */
|
|
168
|
+
supervisorPassword: string;
|
|
139
169
|
};
|
|
170
|
+
declare const isClisitefModality: (value: unknown) => value is ClisitefModality;
|
|
140
171
|
/** `payments.config` (merchant) + device settings; throws when incomplete. */
|
|
141
172
|
declare const readClisitefPinPadSettings: (config: Record<string, unknown>, device: Record<string, unknown>) => ClisitefPinPadSettings;
|
|
142
173
|
//#endregion
|
|
174
|
+
//#region src/menu.d.ts
|
|
175
|
+
type ClisitefMenuPurpose = "charge" | "void";
|
|
176
|
+
type ClisitefMenuDecision = {
|
|
177
|
+
kind: "pick";
|
|
178
|
+
value: string;
|
|
179
|
+
} | {
|
|
180
|
+
kind: "ask";
|
|
181
|
+
options: ClisitefMenuOption[];
|
|
182
|
+
} | {
|
|
183
|
+
kind: "abort";
|
|
184
|
+
message: string;
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* Command 21. Labels compare without accents and in upper case. A void
|
|
188
|
+
* picks the original modality when one option matches it; a charge does it
|
|
189
|
+
* only for debit and credit, then drops the financing options.
|
|
190
|
+
*/
|
|
191
|
+
declare const resolveClisitefMenu: (options: ClisitefMenuOption[], modality: ClisitefModality, purpose: ClisitefMenuPurpose) => ClisitefMenuDecision;
|
|
192
|
+
//#endregion
|
|
143
193
|
//#region src/metadata.d.ts
|
|
144
194
|
type ClisitefFields = ReadonlyMap<number, string>;
|
|
145
195
|
/** Last 4 digits of the masked PAN printed on the receipt. */
|
|
@@ -152,10 +202,81 @@ type MetadataInput = {
|
|
|
152
202
|
fiscalCoupon: string;
|
|
153
203
|
fiscalDate: string;
|
|
154
204
|
};
|
|
205
|
+
/** `provider` section: the Spark modality and the CliSiTef function used. */
|
|
206
|
+
type ClisitefProviderMetadata = {
|
|
207
|
+
modality: ClisitefModality;
|
|
208
|
+
function: number;
|
|
209
|
+
};
|
|
155
210
|
declare const clisitefMetadata: (input: MetadataInput) => PaymentMetadata;
|
|
211
|
+
type VoidMetadataInput = {
|
|
212
|
+
fields: ClisitefFields;
|
|
213
|
+
function: number;
|
|
214
|
+
fiscalCoupon: string;
|
|
215
|
+
fiscalDate: string;
|
|
216
|
+
};
|
|
217
|
+
/** Void data kept under `provider.void`, next to the charge's metadata. */
|
|
218
|
+
declare const clisitefVoidMetadata: (input: VoidMetadataInput) => {
|
|
219
|
+
function: number;
|
|
220
|
+
provider_transaction_id: string | null;
|
|
221
|
+
reference: string | null;
|
|
222
|
+
ticket_number: string;
|
|
223
|
+
transaction_date: string;
|
|
224
|
+
receipt: {
|
|
225
|
+
customer: string | null;
|
|
226
|
+
merchant: string | null;
|
|
227
|
+
format: "text";
|
|
228
|
+
} | null;
|
|
229
|
+
};
|
|
230
|
+
/** Spark modality of a charge; older charges only kept `card_type`. */
|
|
231
|
+
declare const clisitefModalityOf: (metadata: PaymentMetadata) => ClisitefModality | null;
|
|
156
232
|
/** PIN_PAD tender details; `null` without brand and last 4 (schema minimum). */
|
|
157
233
|
declare const clisitefDetails: (metadata: PaymentMetadata) => TenderDetails | null;
|
|
158
234
|
//#endregion
|
|
235
|
+
//#region src/refund.d.ts
|
|
236
|
+
type ClisitefVoidDeps = {
|
|
237
|
+
client: ClisitefClient;
|
|
238
|
+
now: () => Date;
|
|
239
|
+
timeZone?: string;
|
|
240
|
+
confirmationTimeoutMs: number;
|
|
241
|
+
};
|
|
242
|
+
type ClisitefVoidContext = {
|
|
243
|
+
ui: PaymentUI;
|
|
244
|
+
signal: AbortSignal;
|
|
245
|
+
storage: PaymentStorage;
|
|
246
|
+
settings: ClisitefPinPadSettings;
|
|
247
|
+
attempt: number;
|
|
248
|
+
/** The pinpad could not be prepared: queue the void without starting it. */
|
|
249
|
+
unavailable?: StandardPaymentError | null;
|
|
250
|
+
};
|
|
251
|
+
/**
|
|
252
|
+
* Voids a confirmed charge with its cancellation function (credit 210,
|
|
253
|
+
* debit and voucher 211, PIX 123). `REFUNDED` only after `stage 2` = 0;
|
|
254
|
+
* any other end keeps the charge `PAID` with `needs_review`, and a
|
|
255
|
+
* retryable one goes to the pending queue.
|
|
256
|
+
*/
|
|
257
|
+
declare const runClisitefVoid: (deps: ClisitefVoidDeps, ctx: ClisitefVoidContext, result: PaymentResult) => Promise<PaymentResult>;
|
|
258
|
+
//#endregion
|
|
259
|
+
//#region src/reversals.d.ts
|
|
260
|
+
/** A void that did not complete; retried from the operator panel. */
|
|
261
|
+
type ClisitefPendingReversal = {
|
|
262
|
+
attemptReference: string;
|
|
263
|
+
amount: number;
|
|
264
|
+
transactionDate: string;
|
|
265
|
+
hostNsu: string;
|
|
266
|
+
modality: ClisitefModality;
|
|
267
|
+
reason: string;
|
|
268
|
+
attempts: number;
|
|
269
|
+
createdAt: number;
|
|
270
|
+
/** The `PAID` result to void again. */
|
|
271
|
+
result: PaymentResult;
|
|
272
|
+
};
|
|
273
|
+
declare const readPendingReversals: (storage: PaymentStorage) => Promise<ClisitefPendingReversal[]>;
|
|
274
|
+
/** Adds the void or bumps its attempts. */
|
|
275
|
+
declare const queueReversal: (storage: PaymentStorage, entry: Omit<ClisitefPendingReversal, "attempts" | "createdAt">, now: number) => Promise<void>;
|
|
276
|
+
declare const dropReversal: (storage: PaymentStorage, attemptReference: string) => Promise<void>;
|
|
277
|
+
declare const readRefund: (storage: PaymentStorage, attemptReference: string) => Promise<PaymentResult | null>;
|
|
278
|
+
declare const writeRefund: (storage: PaymentStorage, attemptReference: string, result: PaymentResult) => Promise<void>;
|
|
279
|
+
//#endregion
|
|
159
280
|
//#region src/store.d.ts
|
|
160
281
|
/**
|
|
161
282
|
* `started`: `startTransaction` called. `approved`: `finishTransaction(1)`
|
|
@@ -176,8 +297,8 @@ type ClisitefTransactionRecord = {
|
|
|
176
297
|
details?: TenderDetails | null;
|
|
177
298
|
error?: StandardPaymentError;
|
|
178
299
|
};
|
|
179
|
-
declare const readTransaction: (storage: PaymentStorage) => Promise<ClisitefTransactionRecord | null>;
|
|
180
|
-
declare const writeTransaction: (storage: PaymentStorage, record: ClisitefTransactionRecord) => Promise<void>;
|
|
300
|
+
declare const readTransaction: (storage: PaymentStorage, key?: string) => Promise<ClisitefTransactionRecord | null>;
|
|
301
|
+
declare const writeTransaction: (storage: PaymentStorage, record: ClisitefTransactionRecord, key?: string) => Promise<void>;
|
|
181
302
|
declare const isOpen: (record: ClisitefTransactionRecord) => boolean;
|
|
182
303
|
//#endregion
|
|
183
304
|
//#region src/transaction.d.ts
|
|
@@ -194,6 +315,8 @@ type ClisitefOutcome = {
|
|
|
194
315
|
message: string | null;
|
|
195
316
|
fields: ClisitefFields;
|
|
196
317
|
aborted: boolean;
|
|
318
|
+
/** The card was read, a receipt arrived or the PIX QR was shown. */
|
|
319
|
+
evidence: boolean;
|
|
197
320
|
/** Error thrown by `ctx.ui` (e.g. the customer did not answer). */
|
|
198
321
|
error?: unknown;
|
|
199
322
|
};
|
|
@@ -204,8 +327,13 @@ type ClisitefTransactionInput = {
|
|
|
204
327
|
start: ClisitefStartParams;
|
|
205
328
|
finish: Omit<ClisitefFinishParams, "confirm">;
|
|
206
329
|
confirmationTimeoutMs: number;
|
|
330
|
+
/** Spark modality of the charge, or of the charge a void undoes. */
|
|
331
|
+
modality: ClisitefModality;
|
|
332
|
+
purpose: ClisitefMenuPurpose;
|
|
207
333
|
/** Runs before `finishTransaction(1)`, to persist the approval. */
|
|
208
334
|
onApproved: (fields: ClisitefFields) => Promise<void>;
|
|
335
|
+
/** Answer for a `READ_*` field without the UI; `null` asks `ui.input`. */
|
|
336
|
+
answerField?: (fieldId: number) => string | null;
|
|
209
337
|
};
|
|
210
338
|
/**
|
|
211
339
|
* One CliSiTef transaction: `startTransaction`, the `onData` loop answered
|
|
@@ -214,4 +342,4 @@ type ClisitefTransactionInput = {
|
|
|
214
342
|
*/
|
|
215
343
|
declare const runClisitefTransaction: (input: ClisitefTransactionInput) => Promise<ClisitefOutcome>;
|
|
216
344
|
//#endregion
|
|
217
|
-
export { CLISITEF_CANCEL_CODES, CLISITEF_CAPTURE_FIELDS, CLISITEF_COMMAND, CLISITEF_CONFIRMATION_TIMEOUT_MS, CLISITEF_DEFAULT_OPERATOR, CLISITEF_FIELD, CLISITEF_INCONCLUSIVE_CODES, CLISITEF_NO, CLISITEF_PAYMENT_TIMEOUT_MS, CLISITEF_PINPAD_TYPES, CLISITEF_STORAGE_KEY, CLISITEF_YES, ClisitefFields, ClisitefModality, ClisitefOutcome, ClisitefOutcomeStatus, ClisitefPinPadOptions, ClisitefPinPadSettings, ClisitefTransactionInput, ClisitefTransactionRecord, ClisitefTransactionState, clisitefDetails, clisitefLast4, clisitefMetadata, clisitefPinPadCapabilities, clisitefPinPadDeviceFields, clisitefPinPadErrors, clisitefPinPadPayments, isOpen, readClisitefPinPadSettings, readTransaction, runClisitefTransaction, writeTransaction };
|
|
345
|
+
export { CLISITEF_CANCEL_CODES, CLISITEF_CAPTURE_FIELDS, CLISITEF_COMMAND, CLISITEF_CONFIRMATION_TIMEOUT_MS, CLISITEF_DEFAULT_OPERATOR, CLISITEF_FIELD, CLISITEF_INCONCLUSIVE_CODES, CLISITEF_MODALITIES, CLISITEF_NO, CLISITEF_PAYMENT_TIMEOUT_MS, CLISITEF_PINPAD_TYPES, CLISITEF_REFUNDS_KEY, CLISITEF_REFUND_STORAGE_KEY, CLISITEF_REVERSALS_KEY, CLISITEF_STORAGE_KEY, CLISITEF_VOID_FIELD, CLISITEF_YES, ClisitefFields, ClisitefMenuDecision, ClisitefMenuPurpose, ClisitefModality, ClisitefOutcome, ClisitefOutcomeStatus, ClisitefPendingReversal, ClisitefPinPadOptions, ClisitefPinPadSettings, ClisitefProviderMetadata, ClisitefTransactionInput, ClisitefTransactionRecord, ClisitefTransactionState, ClisitefVoidContext, ClisitefVoidDeps, clisitefDetails, clisitefLast4, clisitefMetadata, clisitefModalityOf, clisitefPinPadCapabilities, clisitefPinPadDeviceFields, clisitefPinPadErrors, clisitefPinPadPayments, clisitefVoidMetadata, dropReversal, isClisitefModality, isOpen, queueReversal, readClisitefPinPadSettings, readPendingReversals, readRefund, readTransaction, redactSecrets, resolveClisitefMenu, runClisitefTransaction, runClisitefVoid, writeRefund, writeTransaction };
|