/* * 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 { RefundReason, RefundReason$outboundSchema } from "./refundreason.js"; export type RefundCreateMetadata = string | number | number | boolean; export type RefundCreate = { /** * 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; orderId: string; reason: RefundReason; /** * Amount to refund in cents. Minimum is 1. */ amount: number; /** * An internal comment about the refund. */ comment?: string | null | undefined; /** * Should this refund trigger the associated customer benefits to be revoked? * * @remarks * * **Note:** * Only allowed in case the `order` is a one-time purchase. * Subscriptions automatically revoke customer benefits once the * subscription itself is revoked, i.e fully canceled. */ revokeBenefits?: boolean | undefined; }; /** @internal */ export type RefundCreateMetadata$Outbound = string | number | number | boolean; /** @internal */ export const RefundCreateMetadata$outboundSchema: z.ZodMiniType< RefundCreateMetadata$Outbound, RefundCreateMetadata > = smartUnion([z.string(), z.int(), z.number(), z.boolean()]); export function refundCreateMetadataToJSON( refundCreateMetadata: RefundCreateMetadata, ): string { return JSON.stringify( RefundCreateMetadata$outboundSchema.parse(refundCreateMetadata), ); } /** @internal */ export type RefundCreate$Outbound = { metadata?: { [k: string]: string | number | number | boolean } | undefined; order_id: string; reason: string; amount: number; comment?: string | null | undefined; revoke_benefits: boolean; }; /** @internal */ export const RefundCreate$outboundSchema: z.ZodMiniType< RefundCreate$Outbound, RefundCreate > = z.pipe( z.object({ metadata: z.optional( z.record( z.string(), smartUnion([z.string(), z.int(), z.number(), z.boolean()]), ), ), orderId: z.string(), reason: RefundReason$outboundSchema, amount: z.int(), comment: z.optional(z.nullable(z.string())), revokeBenefits: z._default(z.boolean(), false), }), z.transform((v) => { return remap$(v, { orderId: "order_id", revokeBenefits: "revoke_benefits", }); }), ); export function refundCreateToJSON(refundCreate: RefundCreate): string { return JSON.stringify(RefundCreate$outboundSchema.parse(refundCreate)); }