/* * 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 { CartItem, CartItem$inboundSchema } from "./cartitem.js"; import { PaymentLinkStatus, PaymentLinkStatus$inboundSchema, } from "./paymentlinkstatus.js"; import { ShippingDetails, ShippingDetails$inboundSchema, } from "./shippingdetails.js"; import { StatementDescriptor, StatementDescriptor$inboundSchema, } from "./statementdescriptor.js"; import { TransactionBuyer, TransactionBuyer$inboundSchema, } from "./transactionbuyer.js"; import { TransactionIntent, TransactionIntent$inboundSchema, } from "./transactionintent.js"; import { TransactionPaymentSource, TransactionPaymentSource$inboundSchema, } from "./transactionpaymentsource.js"; export type PaymentLink = { /** * The unique identifier for the payment link. */ id: string; /** * Always `payment-link`. */ type: "payment-link"; /** * The URL for the payment link. */ url: string; /** * The expiration date and time for the payment link. */ expiresAt?: Date | null | undefined; /** * The merchant reference for the payment link. */ externalIdentifier?: string | null | undefined; /** * The statement descriptor for the payment link. */ statementDescriptor?: StatementDescriptor | null | undefined; /** * The locale for the payment link. */ locale?: string | null | undefined; /** * The merchant's display name. */ merchantName?: string | null | undefined; /** * The merchant's website URL. */ merchantUrl?: string | null | undefined; /** * The merchant's banner image URL. */ merchantBannerUrl?: string | null | undefined; /** * The merchant's brand color. */ merchantColor?: string | null | undefined; /** * A message from the merchant. */ merchantMessage?: string | null | undefined; /** * URL to the merchant's terms and conditions. */ merchantTermsAndConditionsUrl?: string | null | undefined; /** * URL to the merchant's favicon. */ merchantFaviconUrl?: string | null | undefined; /** * The amount for the payment link. */ amount: number; /** * The country code for the payment link. */ country: string; /** * The currency code for the payment link. */ currency: string; intent: TransactionIntent; /** * The return URL after payment completion. */ returnUrl?: string | null | undefined; /** * The cart items for the payment link. */ cartItems: Array | null; /** * Arbitrary metadata for the payment link. */ metadata?: { [k: string]: any } | null | undefined; /** * The way payment method information made it to this transaction. */ paymentSource: TransactionPaymentSource; /** * The date and time the payment link was created. */ createdAt: Date; /** * The date and time the payment link was last updated. */ updatedAt: Date; status: PaymentLinkStatus; /** * The buyer associated with the payment link. */ buyer?: TransactionBuyer | null | undefined; /** * The shipping details for the payment link. */ shippingDetails?: ShippingDetails | null | undefined; /** * The connection options for the payment link. */ connectionOptions?: { [k: string]: { [k: string]: any } } | null | undefined; /** * Whether the payment method was stored. */ store: boolean; /** * The ID of the buyer to associate with the stored payment method. */ buyerId?: string | null | undefined; /** * The number of installments a buyer is required to make. */ installmentCount?: number | null | undefined; }; /** @internal */ export const PaymentLink$inboundSchema: z.ZodType< PaymentLink, z.ZodTypeDef, unknown > = z.object({ id: z.string(), type: z.literal("payment-link").default("payment-link"), url: z.string(), expires_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), external_identifier: z.nullable(z.string()).optional(), statement_descriptor: z.nullable(StatementDescriptor$inboundSchema) .optional(), locale: z.nullable(z.string()).optional(), merchant_name: z.nullable(z.string()).optional(), merchant_url: z.nullable(z.string()).optional(), merchant_banner_url: z.nullable(z.string()).optional(), merchant_color: z.nullable(z.string()).optional(), merchant_message: z.nullable(z.string()).optional(), merchant_terms_and_conditions_url: z.nullable(z.string()).optional(), merchant_favicon_url: z.nullable(z.string()).optional(), amount: z.number().int(), country: z.string(), currency: z.string(), intent: TransactionIntent$inboundSchema, return_url: z.nullable(z.string()).optional(), cart_items: z.nullable(z.array(CartItem$inboundSchema)), metadata: z.nullable(z.record(z.any())).optional(), payment_source: TransactionPaymentSource$inboundSchema, created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), updated_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), status: PaymentLinkStatus$inboundSchema, buyer: z.nullable(TransactionBuyer$inboundSchema).optional(), shipping_details: z.nullable(ShippingDetails$inboundSchema).optional(), connection_options: z.nullable(z.record(z.record(z.any()))).optional(), store: z.boolean().default(false), buyer_id: z.nullable(z.string()).optional(), installment_count: z.nullable(z.number().int()).optional(), }).transform((v) => { return remap$(v, { "expires_at": "expiresAt", "external_identifier": "externalIdentifier", "statement_descriptor": "statementDescriptor", "merchant_name": "merchantName", "merchant_url": "merchantUrl", "merchant_banner_url": "merchantBannerUrl", "merchant_color": "merchantColor", "merchant_message": "merchantMessage", "merchant_terms_and_conditions_url": "merchantTermsAndConditionsUrl", "merchant_favicon_url": "merchantFaviconUrl", "return_url": "returnUrl", "cart_items": "cartItems", "payment_source": "paymentSource", "created_at": "createdAt", "updated_at": "updatedAt", "shipping_details": "shippingDetails", "connection_options": "connectionOptions", "buyer_id": "buyerId", "installment_count": "installmentCount", }); }); export function paymentLinkFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PaymentLink$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PaymentLink' from JSON`, ); }