/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v4-mini";
import { remap as remap$ } from "../../lib/primitives.js";

/**
 * Schema to finalize a draft order and trigger an off-session charge.
 */
export type OrderFinalize = {
  /**
   * ID of the payment method to charge. Must belong to the order's customer. Falls back to the customer's default payment method when unset.
   */
  paymentMethodId?: string | null | undefined;
};

/** @internal */
export type OrderFinalize$Outbound = {
  payment_method_id?: string | null | undefined;
};

/** @internal */
export const OrderFinalize$outboundSchema: z.ZodMiniType<
  OrderFinalize$Outbound,
  OrderFinalize
> = z.pipe(
  z.object({
    paymentMethodId: z.optional(z.nullable(z.string())),
  }),
  z.transform((v) => {
    return remap$(v, {
      paymentMethodId: "payment_method_id",
    });
  }),
);

export function orderFinalizeToJSON(orderFinalize: OrderFinalize): string {
  return JSON.stringify(OrderFinalize$outboundSchema.parse(orderFinalize));
}
