/*
 * 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 { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

/**
 * Response after confirming a retry payment.
 */
export type CustomerOrderPaymentConfirmation = {
  /**
   * Payment status after confirmation.
   */
  status: string;
  /**
   * Client secret for handling additional actions.
   */
  clientSecret?: string | null | undefined;
  /**
   * Error message if confirmation failed.
   */
  error?: string | null | undefined;
};

/** @internal */
export const CustomerOrderPaymentConfirmation$inboundSchema: z.ZodMiniType<
  CustomerOrderPaymentConfirmation,
  unknown
> = z.pipe(
  z.object({
    status: z.string(),
    client_secret: z.optional(z.nullable(z.string())),
    error: z.optional(z.nullable(z.string())),
  }),
  z.transform((v) => {
    return remap$(v, {
      "client_secret": "clientSecret",
    });
  }),
);

export function customerOrderPaymentConfirmationFromJSON(
  jsonString: string,
): SafeParseResult<CustomerOrderPaymentConfirmation, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => CustomerOrderPaymentConfirmation$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'CustomerOrderPaymentConfirmation' from JSON`,
  );
}
