/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { BasicPaymentMethod, BasicPaymentMethod$inboundSchema, BasicPaymentMethod$Outbound, BasicPaymentMethod$outboundSchema, } from "./basicpaymentmethod.js"; import { CardAccountUpdater, CardAccountUpdater$inboundSchema, CardAccountUpdater$Outbound, CardAccountUpdater$outboundSchema, } from "./cardaccountupdater.js"; import { CardAddress, CardAddress$inboundSchema, CardAddress$Outbound, CardAddress$outboundSchema, } from "./cardaddress.js"; import { CardBrand, CardBrand$inboundSchema, CardBrand$outboundSchema, } from "./cardbrand.js"; import { CardExpiration, CardExpiration$inboundSchema, CardExpiration$Outbound, CardExpiration$outboundSchema, } from "./cardexpiration.js"; import { CardType, CardType$inboundSchema, CardType$outboundSchema, } from "./cardtype.js"; import { CardVerification, CardVerification$inboundSchema, CardVerification$Outbound, CardVerification$outboundSchema, } from "./cardverification.js"; import { DomesticPullFromCard, DomesticPullFromCard$inboundSchema, DomesticPullFromCard$outboundSchema, } from "./domesticpullfromcard.js"; import { DomesticPushToCard, DomesticPushToCard$inboundSchema, DomesticPushToCard$outboundSchema, } from "./domesticpushtocard.js"; /** * Describes a card on a Moov account. */ export type Card = { /** * ID of the card. */ cardID: string; /** * Uniquely identifies a linked payment card or token. * * @remarks * For Apple Pay, the fingerprint is based on the tokenized card number and may vary based on the user's device. * This field can be used to identify specific payment methods across multiple accounts on your platform. */ fingerprint: string; /** * The card brand. */ brand: CardBrand; /** * The type of the card. */ cardType: CardType; /** * The category or level of the card defined by the issuer. * * @remarks * Examples include, but not limited to, "REWARDS", "TRADITIONAL REWARDS", "CLASSIC", and "CORPORATE PURCHASING". */ cardCategory?: string | undefined; /** * Last four digits of the card number */ lastFourCardNumber: string; /** * The first six to eight digits of the card number, which identifies the financial institution that issued the card. */ bin: string; /** * The expiration date of the card or token. */ expiration: CardExpiration; /** * The name of the cardholder as it appears on the card. */ holderName?: string | undefined; billingAddress: CardAddress; /** * The results of submitting cardholder data to a card network for verification. */ cardVerification: CardVerification; /** * Financial institution that issued the card. */ issuer?: string | undefined; /** * Country where the card was issued. */ issuerCountry?: string | undefined; /** * URL of the issuer. */ issuerURL?: string | undefined; /** * Phone number of the issuer. */ issuerPhone?: string | undefined; /** * If true, the card is for commercial use, or associated with a business. * * @remarks * If false, the card is associated with a general consumer. */ commercial?: boolean | undefined; /** * If true, the card issuing bank is regulated, and the scheme fees for debit transactions will be limited based on the Durbin Amendment. * * @remarks * If false, the card issuing bank is not regulated, and the scheme fees will not be limited. */ regulated?: boolean | undefined; /** * Indicates cardholder has authorized card to be stored for future payments. */ cardOnFile?: boolean | undefined; merchantAccountID?: string | undefined; /** * The results of the most recent card update request. */ cardAccountUpdater?: CardAccountUpdater | undefined; /** * Indicates which level of domestic push-to-card transfer is supported by the card, if any. */ domesticPushToCard?: DomesticPushToCard | undefined; /** * Indicates if the card supports domestic pull-from-card transfer. */ domesticPullFromCard?: DomesticPullFromCard | undefined; /** * Includes any payment methods created as a result of linking a card with the `x-wait-for` header set to `payment-method`. * * @remarks * * Only returned by the link card endpoint; not included when getting or listing cards. */ paymentMethods?: Array | undefined; }; /** @internal */ export const Card$inboundSchema: z.ZodType = z .object({ cardID: z.string(), fingerprint: z.string(), brand: CardBrand$inboundSchema, cardType: CardType$inboundSchema, cardCategory: z.string().optional(), lastFourCardNumber: z.string(), bin: z.string(), expiration: CardExpiration$inboundSchema, holderName: z.string().optional(), billingAddress: CardAddress$inboundSchema, cardVerification: CardVerification$inboundSchema, issuer: z.string().optional(), issuerCountry: z.string().optional(), issuerURL: z.string().optional(), issuerPhone: z.string().optional(), commercial: z.boolean().optional(), regulated: z.boolean().optional(), cardOnFile: z.boolean().optional(), merchantAccountID: z.string().optional(), cardAccountUpdater: CardAccountUpdater$inboundSchema.optional(), domesticPushToCard: DomesticPushToCard$inboundSchema.optional(), domesticPullFromCard: DomesticPullFromCard$inboundSchema.optional(), paymentMethods: z.array(BasicPaymentMethod$inboundSchema).optional(), }); /** @internal */ export type Card$Outbound = { cardID: string; fingerprint: string; brand: string; cardType: string; cardCategory?: string | undefined; lastFourCardNumber: string; bin: string; expiration: CardExpiration$Outbound; holderName?: string | undefined; billingAddress: CardAddress$Outbound; cardVerification: CardVerification$Outbound; issuer?: string | undefined; issuerCountry?: string | undefined; issuerURL?: string | undefined; issuerPhone?: string | undefined; commercial?: boolean | undefined; regulated?: boolean | undefined; cardOnFile?: boolean | undefined; merchantAccountID?: string | undefined; cardAccountUpdater?: CardAccountUpdater$Outbound | undefined; domesticPushToCard?: string | undefined; domesticPullFromCard?: string | undefined; paymentMethods?: Array | undefined; }; /** @internal */ export const Card$outboundSchema: z.ZodType = z.object({ cardID: z.string(), fingerprint: z.string(), brand: CardBrand$outboundSchema, cardType: CardType$outboundSchema, cardCategory: z.string().optional(), lastFourCardNumber: z.string(), bin: z.string(), expiration: CardExpiration$outboundSchema, holderName: z.string().optional(), billingAddress: CardAddress$outboundSchema, cardVerification: CardVerification$outboundSchema, issuer: z.string().optional(), issuerCountry: z.string().optional(), issuerURL: z.string().optional(), issuerPhone: z.string().optional(), commercial: z.boolean().optional(), regulated: z.boolean().optional(), cardOnFile: z.boolean().optional(), merchantAccountID: z.string().optional(), cardAccountUpdater: CardAccountUpdater$outboundSchema.optional(), domesticPushToCard: DomesticPushToCard$outboundSchema.optional(), domesticPullFromCard: DomesticPullFromCard$outboundSchema.optional(), paymentMethods: z.array(BasicPaymentMethod$outboundSchema).optional(), }); export function cardToJSON(card: Card): string { return JSON.stringify(Card$outboundSchema.parse(card)); } export function cardFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Card$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Card' from JSON`, ); }