export type Currency = string; export type Money = {amount?: number | undefined, currency?: Currency | undefined}; export type Transaction = {type: 'PAYMENT' | 'RECURRING', amount?: Money | undefined, cardId: string, cardNumber: string, deviceChannel: 'APP' | 'BROWSER' | 'REQUESTOR_INITIATED', timestamp: string}; export type Country = string; export type Merchant = {id?: string | undefined, acquirerId?: string | undefined, country?: Country | undefined, city?: string | undefined, name?: string | undefined, mcc?: string | undefined, subMerchantId?: string | undefined}; export type InitiateAuthenticationBody = {callbackUrl: string, transaction?: Transaction | undefined, merchant?: Merchant | undefined}; export type CreateApiV1AuthenticateCustomerNumberSessionIdArgs = {customerNumber: string, sessionId: string, body: InitiateAuthenticationBody}; export type CreateApiV1AuthenticateCustomerNumberSessionIdOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * OOB Webhook Notification * * POST /v1/authenticate/{customerNumber}/{sessionId} */ export const createApiV1AuthenticateCustomerNumberSessionId = async (args: CreateApiV1AuthenticateCustomerNumberSessionIdArgs, options: CreateApiV1AuthenticateCustomerNumberSessionIdOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v1/authenticate/${encodeURIComponent(String(args.customerNumber))}/${encodeURIComponent(String(args.sessionId))}${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 undefined };