export type Partner = number; export type BusinessUnitId = number; export type Value = number; export type Type = string; export type Identifier = string; export type PaymentDate = number; export type Tags = Array; export type AccountType = 'CONTA_CORRENTE_INDIVIDUAL' | 'CONTA_CORRENTE_CONJUNTA' | 'CONTA_POUPANCA_CONJUNTA' | 'CONTA_POUPANCA_INDIVIDUAL'; export type Beneficiary = {Name: string, Gender?: ('Male = 0' | 'Female = 1' | 'Other = 2') | undefined, MaritalStatus?: ('NotMarried = 0' | 'Married = 1' | 'Divorced = 2' | 'Separate = 3' | 'Widower = 4' | 'Single = 5' | 'Other = 6') | undefined, MotherName?: string | undefined, Ocuppation?: string | undefined, Nationality?: string | undefined, Country?: string | undefined, BirthCity?: string | undefined, BirthState?: string | undefined, BirthDate?: number | undefined, CompanyType?: ('SA = 0' | 'LTDA = 1' | 'MEI = 2' | 'ME = 3' | 'EIRELI = 4' | 'Condominio = 5' | 'SA_Fechada = 6' | 'EIRELI_Simples = 7' | 'Outros = 8') | undefined, CompanyActivity?: string | undefined, ConstitutionDate?: number | undefined, ContactInfo?: ({Mail?: string | undefined, Phone?: string | undefined}) | undefined, AccountInfo: {PixKey?: string | undefined, TaxNumber: string, AccountType?: AccountType | undefined, ToBankIdentifier?: string | undefined, Bank?: string | undefined, BankBranch?: string | undefined, BankAccount?: string | undefined, BankAccountDigit?: string | undefined}}; export type Payer = {TaxNumber: string, Bank?: string | undefined, BankAccount?: string | undefined, BankAccountDigit?: string | undefined, BankBranch?: string | undefined}; export type GeneratePaymentOrder = {Method: string, PartnerId: Partner, BusinessUnitId: BusinessUnitId, Value: Value, Type?: Type | undefined, Identifier: Identifier, PaymentDate: PaymentDate, Tags?: Tags | undefined, Beneficiary: Beneficiary, Payer: Payer}; export type CreateApiGeneratePaymentOrderArgs = {body: GeneratePaymentOrder}; export type CreateApiGeneratePaymentOrderOptions = {baseUrl?: string | undefined, BASE64UsernamePassword?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Generate Payment Order * * POST /GeneratePaymentOrder */ export const createApiGeneratePaymentOrder = async (args: CreateApiGeneratePaymentOrderArgs, options?: CreateApiGeneratePaymentOrderOptions) => { const {baseUrl = "https://sandboxapi.fitbank.com.br/main/execute", fetch: fetchFn = fetch, BASE64UsernamePassword} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "Success") if (BASE64UsernamePassword !== undefined) headers.set('authorization', `Basic ${btoa(`${BASE64UsernamePassword.username}:${BASE64UsernamePassword.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/GeneratePaymentOrder${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };