/*
 * 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";

export type CustomerPaymentMethodCreateRequiresActionResponse = {
  status: "requires_action";
  clientSecret: string;
};

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

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