A SDK é tipada em TypeScript. Os tipos abaixo refletem src/@types/api.ts.
Enums
PaymentStatus
enum PaymentStatus {
CREATED = "created",
PENDING = "pending",
CANCELLED = "cancelled",
CONFIRMED = "confirmed",
}
A SDK (frontend) usa estes valores textuais. A API usa os códigos curtos
PEN / CON / CAN (ver API Reference).
PaymentMethod
enum PaymentMethod {
FPMCXEXPRSS = "FPMCXEXPRSS", // Multicaixa Express
FPSOLPG = "FPSOLPG", // FaciPay (directo) — sempre disponível
FPSOLPGEXT = "FPSOLPGEXT", // Referência EMIS
}
Default em constants.js: allowedPaymentMethods = ["FPMCXEXPRSS","FPSOLPGEXT","FPSOLPG"],
defaultPaymentMethod = "FPMCXEXPRSS". Confirma os labels exatos com a equipa (há divergência
entre material web e mobile).
PaymentType
enum PaymentType { DIR = "dir", MCX = "mcx", REF = "ref" }
enum Theme { LIGHT = "light", DARK = "dark" }
enum ButtonShape { RECT = "rect", PILL = "pill" }
enum Language { PT = "pt", EN = "en" }
ApiKeyStatus
type ApiKeyStatus = 'idle' | 'loading' | 'valid' | 'invalid' | 'empty';
Dados dos callbacks
PaymentApprovalData
interface PaymentApprovalData {
transactionId: string;
externalTransactionId: string;
status: PaymentStatus.CONFIRMED;
amount: number;
currency: string; // "AOA"
paymentMethod: PaymentMethod;
timestamp: string;
}
PaymentPendingData
interface PaymentPendingData {
transactionId: string;
externalTransactionId: string;
status: PaymentStatus.PENDING;
amount: number;
currency: string;
paymentMethod: PaymentMethod;
timestamp: string;
}
PaymentCancelData
interface PaymentCancelData {
transactionId?: string;
externalTransactionId?: string;
status: PaymentStatus.CANCELLED;
reason?: string;
timestamp: string;
}
PaymentError
interface PaymentError {
code: string;
message: string;
details?: Record<string, unknown>;
timestamp: string;
}
Configuração
interface ButtonOptions {
style?: { width?: string | number; shape?: ButtonShape };
config?: { lang?: Language; showAmount?: boolean };
paymentConfig?: PaymentConfig;
}
interface PaymentConfig {
theme?: Theme;
defaultPaymentMethod?: PaymentMethod;
allowedPaymentMethods?: PaymentMethod[];
showUIOfProcessingInfo?: boolean;
referencePaymentLifeSpan?: number; // minutos
customerInfo?: { name?: string; phone?: string; email?: string };
}
interface GenerateButtonParams {
createOrder?: () => Promise<string | null>;
onApprove?: (data: PaymentApprovalData, actions) => Promise<void>;
onCancel?: (data: PaymentCancelData) => Promise<void>;
onError?: (error: PaymentError) => Promise<void>;
onPending?: (data: PaymentPendingData, actions) => Promise<void>;
onInit?: (actions) => Promise<void>;
onClick?: (data) => Promise<void>;
options?: ButtonOptions;
}
Estas definições derivam dos ficheiros TypeScript do repositório, que estão
desatualizados. A implementação JavaScript (Button.js) é a fonte autoritativa: por
exemplo, onApprove/onPending recebem { payment: { orderId, status, type, data } } e o
2.º argumento actions só expõe onPopupWindowClosed. Ver Callbacks e
Objeto Button para o contrato real.