/* * 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 { smartUnion } from "../../types/smartUnion.js"; import { TrialInterval, TrialInterval$outboundSchema, } from "./trialinterval.js"; export type CheckoutLinkUpdateMetadata = string | number | number | boolean; /** * Schema to update an existing checkout link. */ export type CheckoutLinkUpdate = { /** * The interval unit for the trial period. */ trialInterval?: TrialInterval | null | undefined; /** * The number of interval units for the trial period. */ trialIntervalCount?: number | null | undefined; /** * Key-value object allowing you to store additional information. * * @remarks * * The key must be a string with a maximum length of **40 characters**. * The value must be either: * * * A string with a maximum length of **500 characters** * * An integer * * A floating-point number * * A boolean * * You can store up to **50 key-value pairs**. */ metadata?: { [k: string]: string | number | number | boolean } | undefined; /** * List of products that will be available to select at checkout. */ products?: Array | null | undefined; label?: string | null | undefined; /** * Whether to allow the customer to apply discount codes. If you apply a discount through `discount_id`, it'll still be applied, but the customer won't be able to change it. */ allowDiscountCodes?: boolean | null | undefined; /** * Whether to require the customer to fill their full billing address, instead of just the country. Customers in the US will always be required to fill their full address, regardless of this setting. */ requireBillingAddress?: boolean | null | undefined; /** * ID of the discount to apply to the checkout. If the discount is not applicable anymore when opening the checkout link, it'll be ignored. */ discountId?: string | null | undefined; /** * URL where the customer will be redirected after a successful payment.You can add the `checkout_id={CHECKOUT_ID}` query parameter to retrieve the checkout session id. */ successUrl?: string | null | undefined; /** * When set, a back button will be shown in the checkout to return to this URL. */ returnUrl?: string | null | undefined; }; /** @internal */ export type CheckoutLinkUpdateMetadata$Outbound = | string | number | number | boolean; /** @internal */ export const CheckoutLinkUpdateMetadata$outboundSchema: z.ZodMiniType< CheckoutLinkUpdateMetadata$Outbound, CheckoutLinkUpdateMetadata > = smartUnion([z.string(), z.int(), z.number(), z.boolean()]); export function checkoutLinkUpdateMetadataToJSON( checkoutLinkUpdateMetadata: CheckoutLinkUpdateMetadata, ): string { return JSON.stringify( CheckoutLinkUpdateMetadata$outboundSchema.parse(checkoutLinkUpdateMetadata), ); } /** @internal */ export type CheckoutLinkUpdate$Outbound = { trial_interval?: string | null | undefined; trial_interval_count?: number | null | undefined; metadata?: { [k: string]: string | number | number | boolean } | undefined; products?: Array | null | undefined; label?: string | null | undefined; allow_discount_codes?: boolean | null | undefined; require_billing_address?: boolean | null | undefined; discount_id?: string | null | undefined; success_url?: string | null | undefined; return_url?: string | null | undefined; }; /** @internal */ export const CheckoutLinkUpdate$outboundSchema: z.ZodMiniType< CheckoutLinkUpdate$Outbound, CheckoutLinkUpdate > = z.pipe( z.object({ trialInterval: z.optional(z.nullable(TrialInterval$outboundSchema)), trialIntervalCount: z.optional(z.nullable(z.int())), metadata: z.optional( z.record( z.string(), smartUnion([z.string(), z.int(), z.number(), z.boolean()]), ), ), products: z.optional(z.nullable(z.array(z.string()))), label: z.optional(z.nullable(z.string())), allowDiscountCodes: z.optional(z.nullable(z.boolean())), requireBillingAddress: z.optional(z.nullable(z.boolean())), discountId: z.optional(z.nullable(z.string())), successUrl: z.optional(z.nullable(z.string())), returnUrl: z.optional(z.nullable(z.string())), }), z.transform((v) => { return remap$(v, { trialInterval: "trial_interval", trialIntervalCount: "trial_interval_count", allowDiscountCodes: "allow_discount_codes", requireBillingAddress: "require_billing_address", discountId: "discount_id", successUrl: "success_url", returnUrl: "return_url", }); }), ); export function checkoutLinkUpdateToJSON( checkoutLinkUpdate: CheckoutLinkUpdate, ): string { return JSON.stringify( CheckoutLinkUpdate$outboundSchema.parse(checkoutLinkUpdate), ); }