/* * 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 { ApprovalTarget, ApprovalTarget$inboundSchema, } from "./approvaltarget.js"; import { CardScheme, CardScheme$inboundSchema } from "./cardscheme.js"; import { Method, Method$inboundSchema } from "./method.js"; import { Mode, Mode$inboundSchema } from "./mode.js"; import { PaymentMethodDetailsCard, PaymentMethodDetailsCard$inboundSchema, } from "./paymentmethoddetailscard.js"; export type TransactionPaymentMethod = { /** * Always `payment-method`. */ type: "payment-method"; /** * The optional URL that the buyer needs to be redirected to to further authorize their payment. */ approvalUrl?: string | null | undefined; /** * The 2-letter ISO code of the country this payment method can be used for. If this value is null the payment method may be used in multiple countries. */ country?: string | null | undefined; /** * The ISO-4217 currency code that this payment method can be used for. If this value is null the payment method may be used for multiple currencies. */ currency?: string | null | undefined; /** * Details for credit or debit card payment method. */ details?: PaymentMethodDetailsCard | null | undefined; /** * The expiration date for the payment method. */ expirationDate?: string | null | undefined; /** * The unique hash derived from the payment method identifier (e.g. card number). */ fingerprint?: string | null | undefined; /** * A label for the card or the account. For a paypal payment method this is the user's email address. For a card it is the last 4 digits of the card. */ label?: string | null | undefined; /** * The date and time when this card was last replaced by the account updater. */ lastReplacedAt?: Date | null | undefined; method: Method; /** * The mode to use with this payment method. */ mode?: Mode | null | undefined; /** * The scheme of the card. Only applies to card payments. */ scheme?: CardScheme | null | undefined; /** * The ID of the payment method. */ id?: string | null | undefined; /** * The browser target that an approval URL must be opened in. If any or null, then there is no specific requirement. */ approvalTarget?: ApprovalTarget | null | undefined; /** * An external identifier that can be used to match the payment method against your own records. */ externalIdentifier?: string | null | undefined; /** * The payment account reference (PAR) returned by the card scheme. This is a unique reference to the underlying account that has been used to fund this payment method. */ paymentAccountReference?: string | null | undefined; }; /** @internal */ export const TransactionPaymentMethod$inboundSchema: z.ZodType< TransactionPaymentMethod, z.ZodTypeDef, unknown > = z.object({ type: z.literal("payment-method").default("payment-method"), approval_url: z.nullable(z.string()).optional(), country: z.nullable(z.string()).optional(), currency: z.nullable(z.string()).optional(), details: z.nullable(PaymentMethodDetailsCard$inboundSchema).optional(), expiration_date: z.nullable(z.string()).optional(), fingerprint: z.nullable(z.string()).optional(), label: z.nullable(z.string()).optional(), last_replaced_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), method: Method$inboundSchema, mode: z.nullable(Mode$inboundSchema).optional(), scheme: z.nullable(CardScheme$inboundSchema).optional(), id: z.nullable(z.string()).optional(), approval_target: z.nullable(ApprovalTarget$inboundSchema).optional(), external_identifier: z.nullable(z.string()).optional(), payment_account_reference: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "approval_url": "approvalUrl", "expiration_date": "expirationDate", "last_replaced_at": "lastReplacedAt", "approval_target": "approvalTarget", "external_identifier": "externalIdentifier", "payment_account_reference": "paymentAccountReference", }); }); export function transactionPaymentMethodFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TransactionPaymentMethod$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TransactionPaymentMethod' from JSON`, ); }