/* * 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 { GiftCardRedemption, GiftCardRedemption$inboundSchema, } from "./giftcardredemption.js"; import { GiftCardService, GiftCardService$inboundSchema, } from "./giftcardservice.js"; import { InstrumentType, InstrumentType$inboundSchema, } from "./instrumenttype.js"; import { Method, Method$inboundSchema } from "./method.js"; import { ShippingDetails, ShippingDetails$inboundSchema, } from "./shippingdetails.js"; import { TransactionBuyer, TransactionBuyer$inboundSchema, } from "./transactionbuyer.js"; import { TransactionIntent, TransactionIntent$inboundSchema, } from "./transactionintent.js"; import { TransactionPaymentMethod, TransactionPaymentMethod$inboundSchema, } from "./transactionpaymentmethod.js"; import { TransactionPaymentService, TransactionPaymentService$inboundSchema, } from "./transactionpaymentservice.js"; import { TransactionStatus, TransactionStatus$inboundSchema, } from "./transactionstatus.js"; /** * A transaction, summarised */ export type TransactionSummary = { /** * Always `transaction`. */ type: "transaction"; /** * The ID for the transaction. */ id: string; /** * The base62 encoded transaction ID. This represents a shorter version of this transaction's `id` which is sent to payment services, anti-fraud services, and other connectors. You can use this ID to reconcile a payment service's transaction against our system. This ID is sent instead of the transaction ID because not all services support 36 digit identifiers. */ reconciliationId: string; /** * The ID of the merchant account this transaction belongs to. */ merchantAccountId: string; /** * The currency code for this transaction. */ currency: string; /** * The total amount for this transaction across all funding sources including gift cards. */ amount: number; status: TransactionStatus; /** * The amount for this transaction that has been authorized for the `payment_method`. This can be less than the `amount` if gift cards were used. */ authorizedAmount: number; /** * The total amount captured for this transaction, in the smallest currency unit (for example, cents or pence). This can be the full value of the `authorized_amount` or less. */ capturedAmount: number; /** * The total amount refunded for this transaction, in the smallest currency unit (for example, cents or pence). This can be the full value of the `captured_amount` or less. */ refundedAmount: number; /** * The ISO 4217 currency code of this transaction's settlement. */ settledCurrency?: string | null | undefined; /** * The net amount settled for this transaction, in the smallest currency unit (for example, cents or pence). */ settledAmount: number; /** * Indicates whether this transaction has been settled. */ settled: boolean; /** * The 2-letter ISO 3166-1 alpha-2 country code for the transaction. Used to filter payment services for processing. */ country?: string | null | undefined; /** * An external identifier that can be used to match the transaction against your own records. */ externalIdentifier?: string | null | undefined; intent: TransactionIntent; /** * The payment method used for this transaction. */ paymentMethod?: TransactionPaymentMethod | null | undefined; /** * The method used for the transaction. */ method?: Method | null | undefined; /** * The name of the instrument used to process the transaction. */ instrumentType?: InstrumentType | null | undefined; /** * The standardized error code set by Gr4vy. */ errorCode?: string | null | undefined; /** * The payment service used for this transaction. */ paymentService?: TransactionPaymentService | null | undefined; /** * Whether a manual anti fraud review is pending with an anti fraud service. */ pendingReview: boolean; /** * The buyer used for this transaction. */ buyer?: TransactionBuyer | null | undefined; /** * 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 | undefined; /** * 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 | undefined; /** * The shipping details associated with the transaction. */ shippingDetails?: ShippingDetails | null | undefined; /** * The identifier for the checkout session this transaction is associated with. */ checkoutSessionId?: string | null | undefined; /** * The gift cards redeemed for this transaction. */ giftCardRedemptions: Array; /** * The gift card service used for this transaction. */ giftCardService?: GiftCardService | null | undefined; /** * The date and time when the transaction was created, in ISO 8601 format. */ createdAt: Date; /** * The date and time when the transaction was last updated, in ISO 8601 format. */ updatedAt: Date; /** * Indicates whether this transaction has been disputed. */ disputed: boolean; /** * The identifier of the transaction from which this transaction was reauthorized. */ reauthorizedFromTransactionId?: string | null | undefined; }; /** @internal */ export const TransactionSummary$inboundSchema: z.ZodType< TransactionSummary, z.ZodTypeDef, unknown > = z.object({ type: z.literal("transaction").default("transaction"), id: z.string(), reconciliation_id: z.string(), merchant_account_id: z.string(), currency: z.string(), amount: z.number().int(), status: TransactionStatus$inboundSchema, authorized_amount: z.number().int(), captured_amount: z.number().int(), refunded_amount: z.number().int(), settled_currency: z.nullable(z.string()).optional(), settled_amount: z.number().int(), settled: z.boolean(), country: z.nullable(z.string()).optional(), external_identifier: z.nullable(z.string()).optional(), intent: TransactionIntent$inboundSchema, payment_method: z.nullable(TransactionPaymentMethod$inboundSchema).optional(), method: z.nullable(Method$inboundSchema).optional(), instrument_type: z.nullable(InstrumentType$inboundSchema).optional(), error_code: z.nullable(z.string()).optional(), payment_service: z.nullable(TransactionPaymentService$inboundSchema) .optional(), pending_review: z.boolean().default(false), buyer: z.nullable(TransactionBuyer$inboundSchema).optional(), raw_response_code: z.nullable(z.string()).optional(), raw_response_description: z.nullable(z.string()).optional(), shipping_details: z.nullable(ShippingDetails$inboundSchema).optional(), checkout_session_id: z.nullable(z.string()).optional(), gift_card_redemptions: z.array(GiftCardRedemption$inboundSchema), gift_card_service: z.nullable(GiftCardService$inboundSchema).optional(), created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), updated_at: z.string().datetime({ offset: true }).transform(v => new Date(v)), disputed: z.boolean(), reauthorized_from_transaction_id: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "reconciliation_id": "reconciliationId", "merchant_account_id": "merchantAccountId", "authorized_amount": "authorizedAmount", "captured_amount": "capturedAmount", "refunded_amount": "refundedAmount", "settled_currency": "settledCurrency", "settled_amount": "settledAmount", "external_identifier": "externalIdentifier", "payment_method": "paymentMethod", "instrument_type": "instrumentType", "error_code": "errorCode", "payment_service": "paymentService", "pending_review": "pendingReview", "raw_response_code": "rawResponseCode", "raw_response_description": "rawResponseDescription", "shipping_details": "shippingDetails", "checkout_session_id": "checkoutSessionId", "gift_card_redemptions": "giftCardRedemptions", "gift_card_service": "giftCardService", "created_at": "createdAt", "updated_at": "updatedAt", "reauthorized_from_transaction_id": "reauthorizedFromTransactionId", }); }); export function transactionSummaryFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TransactionSummary$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TransactionSummary' from JSON`, ); }