export type EzadminPaymentResultDTO = {chargeRef?: string | undefined, status?: string | undefined, amount?: number | undefined, paidAt?: string | undefined, failReason?: string | undefined, paid?: boolean | undefined, failed?: boolean | undefined}; export type CreateApiV1EzadminCallbackPaymentArgs = {body: EzadminPaymentResultDTO}; export type CreateApiV1EzadminCallbackPaymentOptions = {baseUrl: string, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * 추가운임 결제 결과 콜백 * * POST /v1/ezadmin/callback/payment */ export const createApiV1EzadminCallbackPayment = async (args: CreateApiV1EzadminCallbackPaymentArgs, options: CreateApiV1EzadminCallbackPaymentOptions) => { const {baseUrl, fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (ApiKey !== undefined) headers.set("Authorization", ApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v1/ezadmin/callback/payment${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() };