pix-utils
Version:
Set of tools to parse, generate and validate payments of Brazil Instant Payment System (Pix)
59 lines (58 loc) • 2.21 kB
TypeScript
import { ValueOf } from './helpers';
import { PixDynamicFn, PixRecurrenceFn, PixStaticFn } from './pixFunctions';
export interface PixEmvMandatoryElements {
readonly merchantCategoryCode: string;
readonly transactionCurrency: string;
readonly countryCode: string;
readonly merchantName: string;
readonly merchantCity: string;
}
export interface PixEmvBasicElements extends PixEmvMandatoryElements {
readonly oneTime?: boolean;
}
export declare enum PixElementType {
DYNAMIC = "DYNAMIC",
STATIC = "STATIC",
RECURRENCE = "RECURRENCE",
INVALID = "INVALID"
}
export interface DynamicPixEmvElements extends PixEmvBasicElements {
readonly type: PixElementType.DYNAMIC;
readonly url: string;
readonly urlRec?: string;
}
export interface RecurrencePixEmvElements extends PixEmvBasicElements {
readonly type: PixElementType.RECURRENCE;
readonly url: undefined;
readonly urlRec: string;
}
export interface StaticPixEmvElements extends PixEmvBasicElements {
readonly type: PixElementType.STATIC;
readonly transactionAmount?: number;
readonly pixKey: string;
readonly txid?: string;
readonly infoAdicional?: string;
readonly fss?: string;
readonly urlRec?: string;
}
export interface InvalidPixEmvElements {
readonly type: PixElementType.INVALID;
readonly details: string;
}
export type PixElement = {
[PixElementType.DYNAMIC]: DynamicPixEmvElements;
[PixElementType.STATIC]: StaticPixEmvElements;
[PixElementType.INVALID]: InvalidPixEmvElements;
[PixElementType.RECURRENCE]: RecurrencePixEmvElements;
};
export type PixElements = StaticPixEmvElements | DynamicPixEmvElements | RecurrencePixEmvElements;
export type PixObject = {
[PixElementType.DYNAMIC]: DynamicPixEmvElements;
[PixElementType.STATIC]: StaticPixEmvElements;
[PixElementType.INVALID]: InvalidPixEmvElements;
[PixElementType.RECURRENCE]: RecurrencePixEmvElements;
};
export type PixObjects = ValueOf<PixObject>;
export type PixStaticObject = StaticPixEmvElements & PixStaticFn;
export type PixDynamicObject = DynamicPixEmvElements & PixDynamicFn;
export type PixRecurrenceObject = RecurrencePixEmvElements & PixRecurrenceFn;