/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; 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"; import { Airline, Airline$inboundSchema } from "./airline.js"; import { CartItem, CartItem$inboundSchema } from "./cartitem.js"; import { CheckoutSessionPaymentMethod, CheckoutSessionPaymentMethod$inboundSchema, } from "./checkoutsessionpaymentmethod.js"; import { GuestBuyer, GuestBuyer$inboundSchema } from "./guestbuyer.js"; export type CheckoutSession = { /** * An array of cart items that represents the line items of a transaction. */ cartItems?: Array | null | undefined; /** * Any additional information about the transaction that you would like to store as key-value pairs. This data is passed to payment service providers that support it. */ metadata?: { [k: string]: string } | null | undefined; /** * Provide buyer details for the transaction. No buyer resource will be created on Gr4vy when used. */ buyer?: GuestBuyer | null | undefined; /** * The airline addendum data which describes the airline booking associated with this transaction. */ airline?: Airline | null | undefined; /** * The total amount for this transaction. */ amount?: number | null | undefined; /** * The currency code for this transaction. */ currency?: string | null | undefined; /** * The unique identifier of an existing payment service. When provided, the created transaction will be processed by the given payment service and any routing rules will be skipped. */ paymentServiceId?: string | null | undefined; /** * Always `checkout-session` */ type: "checkout-session"; /** * The ID for the checkout session. */ id: string; /** * The date and time when this checkout session expires. */ expiresAt: Date; /** * Information about the payment method stored on the checkout session. */ paymentMethod?: CheckoutSessionPaymentMethod | null | undefined; }; /** @internal */ export const CheckoutSession$inboundSchema: z.ZodType< CheckoutSession, z.ZodTypeDef, unknown > = z.object({ cart_items: z.nullable(z.array(CartItem$inboundSchema)).optional(), metadata: z.nullable(z.record(z.string())).optional(), buyer: z.nullable(GuestBuyer$inboundSchema).optional(), airline: z.nullable(Airline$inboundSchema).optional(), amount: z.nullable(z.number().int()).optional(), currency: z.nullable(z.string()).optional(), payment_service_id: z.nullable(z.string()).optional(), type: z.literal("checkout-session").default("checkout-session"), id: z.string(), expires_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), payment_method: z.nullable(CheckoutSessionPaymentMethod$inboundSchema) .optional(), }).transform((v) => { return remap$(v, { "cart_items": "cartItems", "payment_service_id": "paymentServiceId", "expires_at": "expiresAt", "payment_method": "paymentMethod", }); }); export function checkoutSessionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CheckoutSession$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CheckoutSession' from JSON`, ); }