/* * 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 CheckoutLinkCreateProductMetadata = | string | number | number | boolean; /** * Schema to create a new checkout link from a a single product. * * @remarks * * **Deprecated**: Use `CheckoutLinkCreateProducts` instead. */ export type CheckoutLinkCreateProduct = { /** * 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; productId: string; }; /** @internal */ export type CheckoutLinkCreateProductMetadata$Outbound = | string | number | number | boolean; /** @internal */ export const CheckoutLinkCreateProductMetadata$outboundSchema: z.ZodMiniType< CheckoutLinkCreateProductMetadata$Outbound, CheckoutLinkCreateProductMetadata > = smartUnion([z.string(), z.int(), z.number(), z.boolean()]); export function checkoutLinkCreateProductMetadataToJSON( checkoutLinkCreateProductMetadata: CheckoutLinkCreateProductMetadata, ): string { return JSON.stringify( CheckoutLinkCreateProductMetadata$outboundSchema.parse( checkoutLinkCreateProductMetadata, ), ); } /** @internal */ export type CheckoutLinkCreateProduct$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; product_id: string; }; /** @internal */ export const CheckoutLinkCreateProduct$outboundSchema: z.ZodMiniType< CheckoutLinkCreateProduct$Outbound, CheckoutLinkCreateProduct > = 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())), productId: 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", productId: "product_id", }); }), ); export function checkoutLinkCreateProductToJSON( checkoutLinkCreateProduct: CheckoutLinkCreateProduct, ): string { return JSON.stringify( CheckoutLinkCreateProduct$outboundSchema.parse(checkoutLinkCreateProduct), ); }