export type CreateApiAdminPaymentSimulatorJsonArgs = {body: {x_account_id: string, x_amount: number, x_currency: string, x_reference: string, x_shop_name: string, x_signature: string, x_test: boolean, x_url_callback: string, x_url_cancel: string, x_url_complete: string, x_customer_billing_address_1?: string | undefined, x_customer_billing_address_2?: string | undefined, x_customer_billing_city?: string | undefined, x_customer_billing_company?: string | undefined, x_customer_billing_country?: string | undefined, x_customer_billing_phone?: string | undefined, x_customer_billing_state?: string | undefined, x_customer_billing_zip?: string | undefined, x_customer_email?: string | undefined, x_customer_first_name?: string | undefined, x_customer_last_name?: string | undefined, x_customer_phone?: string | undefined, x_customer_shipping_address_1?: string | undefined, x_customer_shipping_address_2?: string | undefined, x_customer_shipping_city?: string | undefined, x_customer_shipping_company?: string | undefined, x_customer_shipping_country?: string | undefined, x_customer_shipping_first_name?: string | undefined, x_customer_shipping_last_name?: string | undefined, x_customer_shipping_phone?: string | undefined, x_customer_shipping_state?: string | undefined, x_customer_shipping_zip?: string | undefined}}; export type CreateApiAdminPaymentSimulatorJsonOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Payment redirect handler * * POST /admin/payment-simulator.json */ export const createApiAdminPaymentSimulatorJson = async (args: CreateApiAdminPaymentSimulatorJsonArgs, options?: CreateApiAdminPaymentSimulatorJsonOptions) => { const {baseUrl = "https://shop-name.onshopbase.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/x-www-form-urlencoded") const url = `${baseUrl.replace(/\/+$/, '')}/admin/payment-simulator.json${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: new URLSearchParams(Object.entries(args.body).flatMap(([key, value]) => (value == null ? [] : [[key, String(value)]])))}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };