/* * 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 { BillingDetails, BillingDetails$inboundSchema, } from "./billingdetails.js"; import { CaptureStatus, CaptureStatus$inboundSchema } from "./capturestatus.js"; import { ShippingDetails, ShippingDetails$inboundSchema, } from "./shippingdetails.js"; import { Tracking, Tracking$inboundSchema } from "./tracking.js"; import { Transaction, Transaction$inboundSchema } from "./transaction.js"; export type TransactionCapture = { /** * Always `transaction-capture`. */ type: "transaction-capture"; status: CaptureStatus; /** * The standardized error code set by Gr4vy. */ code: string | null; /** * This is the response code received from the payment service. This can be set to any value and is not standardized across different payment services. */ rawResponseCode: string | null; /** * This is the response description received from the payment service. This can be set to any value and is not standardized across different payment services. */ rawResponseDescription: string | null; /** * A full transaction resource. */ transaction: Transaction; /** * The ID of the capture resource created for this capture. */ captureId?: string | null | undefined; /** * The payment service's unique ID for the capture. */ paymentServiceCaptureId?: string | null | undefined; /** * The external identifier for the capture. */ externalIdentifier?: string | null | undefined; /** * The billing details associated with the capture. */ billingDetails?: BillingDetails | null | undefined; /** * The shipping details associated with the catpure. */ shippingDetails?: ShippingDetails | null | undefined; /** * The shipment tracking details associated with the capture. */ tracking?: Array | null | undefined; }; /** @internal */ export const TransactionCapture$inboundSchema: z.ZodType< TransactionCapture, z.ZodTypeDef, unknown > = z.object({ type: z.literal("transaction-capture").default("transaction-capture"), status: CaptureStatus$inboundSchema, code: z.nullable(z.string()), raw_response_code: z.nullable(z.string()), raw_response_description: z.nullable(z.string()), transaction: Transaction$inboundSchema, capture_id: z.nullable(z.string()).optional(), payment_service_capture_id: z.nullable(z.string()).optional(), external_identifier: z.nullable(z.string()).optional(), billing_details: z.nullable(BillingDetails$inboundSchema).optional(), shipping_details: z.nullable(ShippingDetails$inboundSchema).optional(), tracking: z.nullable(z.array(Tracking$inboundSchema)).optional(), }).transform((v) => { return remap$(v, { "raw_response_code": "rawResponseCode", "raw_response_description": "rawResponseDescription", "capture_id": "captureId", "payment_service_capture_id": "paymentServiceCaptureId", "external_identifier": "externalIdentifier", "billing_details": "billingDetails", "shipping_details": "shippingDetails", }); }); export function transactionCaptureFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TransactionCapture$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TransactionCapture' from JSON`, ); }