@jackiemacklein/nettz-utils
Version:
Serviços de imagem, e-mail, códigos de barras, utilitários numéricos e componentes React para apps Node.js com TypeScript
134 lines (133 loc) • 4.35 kB
TypeScript
/**
* @author Jackiê Macklein
* @company Onside tecnologia/Nettz
* @copyright Todos direitos reservados.
* @description Tipos da API SuperTEF (POS / pagamentos). Referência: https://supertef.apidog.io/
*/
/** Produção: https://api.supertef.com.br/api */
export declare const SUPERTEF_DEFAULT_BASE_URL = "https://api.supertef.com.br/api";
/**
* transaction_type na API (string na requisição).
* 0 Todos — 1 Débito — 2 Crédito — 3 Pix — 4 Voucher (v94+)
*/
export declare const SuperTefTransactionType: {
readonly ALL: "0";
readonly DEBIT: "1";
readonly CREDIT: "2";
readonly PIX: "3";
readonly VOUCHER: "4";
};
export type SuperTefTransactionTypeCode = (typeof SuperTefTransactionType)[keyof typeof SuperTefTransactionType];
/**
* payment_status (documentação: monitoramento).
* 1 Solicitado — 4 Pago — 5 Cancelado/Erro
*/
export declare const SuperTefPaymentStatus: {
readonly REQUESTED: 1;
readonly PAID: 4;
readonly CANCELLED_OR_ERROR: 5;
};
export type SuperTefPaymentStatusCode = (typeof SuperTefPaymentStatus)[keyof typeof SuperTefPaymentStatus];
/** 1 ou 2 parcelado loja (juros); 3 parcelado cliente (juros). */
export type SuperTefInstallmentType = 1 | 2 | 3;
export interface SuperTefClientConfig {
/** Token Bearer da softhouse (painel SuperTEF). */
token: string;
/**
* Base da API, sem barra final.
* @default https://api.supertef.com.br/api
*/
baseUrl?: string;
/** Timeout em ms para cada requisição HTTP. @default 30000 */
timeoutMs?: number;
/** `fetch` customizado (testes ou proxy). */
fetchImpl?: typeof fetch;
/**
* Como montar a URL de consulta por `payment_uniqueid`.
* `true`: `GET .../pagamentos/by-uniqueid?payment_uniqueid=` (parâmetro na query).
* `false`: `GET .../pagamentos/by-uniqueid/{id}` (segmento de path).
* @default true
*/
paymentLookupUsesQueryParam?: boolean;
}
export interface SuperTefListPosParams {
/** Filtra POS pela chave do cliente. */
cliente_chave?: string;
page?: string | number;
}
export interface SuperTefPosRecord {
id: number;
status: number;
nome: string;
marca: string | null;
modelo: string | null;
banco: string | null;
chave: string;
token: string | null;
cliente_id: number;
softhouse_id: number;
created_at: string;
updated_at: string;
date_ativacao: string | null;
}
export interface SuperTefListPosResponse {
total: number;
per_page: number;
current_page: number;
last_page: number;
to: number;
data: SuperTefPosRecord[];
}
export interface SuperTefPaymentOrder {
pos_id: number;
installment_type: number;
transaction_type: number;
installment_count: number;
amount: string;
order_id: string;
description: string;
print_receipt?: boolean;
}
export interface SuperTefPaymentData {
pos_id: number;
id_payment: string | null;
cardholder_name: string | null;
brand: string | null;
nsu: string | null;
authorization_code: string | null;
authorization_date_time: string | null;
acquirer_banco: string | null;
acquirer_cnpj: string | null;
}
export interface SuperTefPaymentDetail {
payment_uniqueid: number;
created_at: string;
payment_status: number;
payment_message: string;
payment_order: SuperTefPaymentOrder;
payment_data: SuperTefPaymentData;
}
export interface SuperTefRequestPaymentBody {
cliente_chave: string;
/**
* ID da POS destino; use `null` para enviar a todas (comportamento da API).
*/
pos_id: number | null;
transaction_type: SuperTefTransactionTypeCode;
installment_count: number;
installment_type: SuperTefInstallmentType;
/** Valor (centavos ou formato esperado pela API — doc usa exemplo 10 para R$ contexto PDV). */
amount: number;
order_id: string;
description: string;
print_receipt: boolean;
}
export interface SuperTefPollPaymentOptions {
/** Intervalo entre consultas. Doc recomenda ~4s. @default 4000 */
intervalMs?: number;
/** Máximo de tentativas após a primeira leitura. @default 120 (~8 min com 4s) */
maxAttempts?: number;
/** Considera sucesso só quando `payment_status === 4`. @default true */
requirePaid?: boolean;
signal?: AbortSignal;
}