/* * 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 CheckoutLinkCreateProductsMetadata = | string | number | number | boolean; /** * Schema to create a new checkout link. */ export type CheckoutLinkCreateProducts = { /** * 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; /** * The interval unit for the trial period. */ trialInterval?: TrialInterval | null | undefined; /** * The number of interval units for the trial period. */ trialIntervalCount?: number | null | undefined; /** * Payment processor to use. Currently only Stripe is supported. */ paymentProcessor: "stripe"; /** * Optional label to distinguish links internally */ 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 | 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 | 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; /** * List of products that will be available to select at checkout. */ products: Array; }; /** @internal */ export type CheckoutLinkCreateProductsMetadata$Outbound = | string | number | number | boolean; /** @internal */ export const CheckoutLinkCreateProductsMetadata$outboundSchema: z.ZodMiniType< CheckoutLinkCreateProductsMetadata$Outbound, CheckoutLinkCreateProductsMetadata > = smartUnion([z.string(), z.int(), z.number(), z.boolean()]); export function checkoutLinkCreateProductsMetadataToJSON( checkoutLinkCreateProductsMetadata: CheckoutLinkCreateProductsMetadata, ): string { return JSON.stringify( CheckoutLinkCreateProductsMetadata$outboundSchema.parse( checkoutLinkCreateProductsMetadata, ), ); } /** @internal */ export type CheckoutLinkCreateProducts$Outbound = { metadata?: { [k: string]: string | number | number | boolean } | undefined; trial_interval?: string | null | undefined; trial_interval_count?: number | null | undefined; payment_processor: "stripe"; label?: string | null | undefined; allow_discount_codes: boolean; require_billing_address: boolean; discount_id?: string | null | undefined; success_url?: string | null | undefined; return_url?: string | null | undefined; products: Array; }; /** @internal */ export const CheckoutLinkCreateProducts$outboundSchema: z.ZodMiniType< CheckoutLinkCreateProducts$Outbound, CheckoutLinkCreateProducts > = z.pipe( z.object({ metadata: z.optional( z.record( z.string(), smartUnion([z.string(), z.int(), z.number(), z.boolean()]), ), ), trialInterval: z.optional(z.nullable(TrialInterval$outboundSchema)), trialIntervalCount: z.optional(z.nullable(z.int())), paymentProcessor: z.literal("stripe"), label: z.optional(z.nullable(z.string())), allowDiscountCodes: z._default(z.boolean(), true), requireBillingAddress: z._default(z.boolean(), false), discountId: z.optional(z.nullable(z.string())), successUrl: z.optional(z.nullable(z.string())), returnUrl: z.optional(z.nullable(z.string())), products: z.array(z.string()), }), z.transform((v) => { return remap$(v, { trialInterval: "trial_interval", trialIntervalCount: "trial_interval_count", paymentProcessor: "payment_processor", allowDiscountCodes: "allow_discount_codes", requireBillingAddress: "require_billing_address", discountId: "discount_id", successUrl: "success_url", returnUrl: "return_url", }); }), ); export function checkoutLinkCreateProductsToJSON( checkoutLinkCreateProducts: CheckoutLinkCreateProducts, ): string { return JSON.stringify( CheckoutLinkCreateProducts$outboundSchema.parse(checkoutLinkCreateProducts), ); }