export type DetachPaymentMethodPaymentSource = {paymentMethod?: ({sourceId?: string | undefined}) | undefined}; export type DeleteApiV1ShoppersMeCartsActiveApplyPaymentMethodArgs = {token?: string | undefined, body: DetachPaymentMethodPaymentSource}; export type DeleteApiV1ShoppersMeCartsActiveApplyPaymentMethodOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Detach a payment source from the cart * * DELETE /v1/shoppers/me/carts/active/apply-payment-method */ export const deleteApiV1ShoppersMeCartsActiveApplyPaymentMethod = async (args: DeleteApiV1ShoppersMeCartsActiveApplyPaymentMethodArgs, options?: DeleteApiV1ShoppersMeCartsActiveApplyPaymentMethodOptions) => { const {baseUrl = "https://api.digitalriver.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.token != null) query.append("token", String(args.token)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/shoppers/me/carts/active/apply-payment-method${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", 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 };