/*
 * 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";
import {
  PaymentProcessor,
  PaymentProcessor$outboundSchema,
} from "./paymentprocessor.js";

/**
 * Schema to confirm a retry payment using either a saved payment method or a new confirmation token.
 */
export type CustomerOrderConfirmPayment = {
  /**
   * ID of the Stripe confirmation token for new payment methods.
   */
  confirmationTokenId?: string | null | undefined;
  /**
   * ID of an existing saved payment method.
   */
  paymentMethodId?: string | null | undefined;
  paymentProcessor?: PaymentProcessor | undefined;
};

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

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

export function customerOrderConfirmPaymentToJSON(
  customerOrderConfirmPayment: CustomerOrderConfirmPayment,
): string {
  return JSON.stringify(
    CustomerOrderConfirmPayment$outboundSchema.parse(
      customerOrderConfirmPayment,
    ),
  );
}
