@paykit-sdk/core
Version:
The Payment Toolkit for Typescript
401 lines (398 loc) • 12.9 kB
TypeScript
import { z } from 'zod';
import { OverrideProps } from '../types.js';
import { BillingInfo } from './billing.js';
import { Payee } from './customer.js';
import { PaykitMetadata } from './metadata.js';
/**
* @description Payment statuses
* PENDING - Payment is created but awaiting processing
* PROCESSING - Payment is being processed by the provider,
* REQUIRES_ACTION - Requires user action (3DS, bank verification, etc.)
* REQUIRES_CAPTURE - Authorized, awaiting manual capture
* SUCCEEDED - Payment completed successfully
* CANCELED - Payment canceled before completion
* FAILED - Payment attempt failed
*/
declare const paymentStatusSchema: z.ZodEnum<["pending", "processing", "requires_action", "requires_capture", "succeeded", "canceled", "failed"]>;
type PaymentStatus = z.infer<typeof paymentStatusSchema>;
interface Payment {
/**
* The unique identifier of the payment.
*/
id: string;
/**
* The amount of the payment.
*/
amount: number;
/**
* The currency of the payment.
*/
currency: string;
/**
* The payee of the payment.
*/
customer: Payee | null;
/**
* The status of the payment.
*/
status: PaymentStatus;
/**
* The metadata of the payment.
*/
metadata: PaykitMetadata;
/**
* The item ID of the payment.
*/
item_id: string | null;
/**
*
* Whether the payment requires action.
*/
requires_action: boolean;
/**
* Whether the payment requires capture.
*/
payment_url: string | null;
}
declare const paymentSchema: z.ZodObject<{
id: z.ZodString;
amount: z.ZodNumber;
currency: z.ZodString;
customer: z.ZodNullable<z.ZodUnion<[z.ZodObject<{
email: z.ZodString;
}, "strip", z.ZodTypeAny, {
email: string;
}, {
email: string;
}>, z.ZodObject<{
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
}, "strip", z.ZodTypeAny, {
id: string | number;
}, {
id: string | number;
}>]>>;
status: z.ZodEnum<["pending", "processing", "requires_action", "requires_capture", "succeeded", "canceled", "failed"]>;
metadata: z.ZodRecord<z.ZodString, z.ZodString>;
item_id: z.ZodNullable<z.ZodString>;
requires_action: z.ZodBoolean;
payment_url: z.ZodNullable<z.ZodString>;
}, "strip", z.ZodTypeAny, {
status: "canceled" | "pending" | "requires_action" | "processing" | "requires_capture" | "succeeded" | "failed";
currency: string;
id: string;
metadata: Record<string, string>;
customer: {
email: string;
} | {
id: string | number;
} | null;
amount: number;
item_id: string | null;
requires_action: boolean;
payment_url: string | null;
}, {
status: "canceled" | "pending" | "requires_action" | "processing" | "requires_capture" | "succeeded" | "failed";
currency: string;
id: string;
metadata: Record<string, string>;
customer: {
email: string;
} | {
id: string | number;
} | null;
amount: number;
item_id: string | null;
requires_action: boolean;
payment_url: string | null;
}>;
interface CreatePaymentSchema<TProviderMetadata = Record<string, unknown>> extends OverrideProps<Omit<Payment, 'id' | 'status' | 'requires_action' | 'payment_url'>, {
metadata?: Record<string, unknown>;
}> {
/**
* The provider specific params of the payment.
*/
provider_metadata?: TProviderMetadata;
/**
* The shipping info of the payment.
*/
billing?: BillingInfo;
/**
* The capture method of the payment.
*/
capture_method: 'automatic' | 'manual';
}
declare const createPaymentSchema: z.ZodObject<Omit<{
id: z.ZodString;
amount: z.ZodNumber;
currency: z.ZodString;
customer: z.ZodNullable<z.ZodUnion<[z.ZodObject<{
email: z.ZodString;
}, "strip", z.ZodTypeAny, {
email: string;
}, {
email: string;
}>, z.ZodObject<{
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
}, "strip", z.ZodTypeAny, {
id: string | number;
}, {
id: string | number;
}>]>>;
status: z.ZodEnum<["pending", "processing", "requires_action", "requires_capture", "succeeded", "canceled", "failed"]>;
metadata: z.ZodRecord<z.ZodString, z.ZodString>;
item_id: z.ZodNullable<z.ZodString>;
requires_action: z.ZodBoolean;
payment_url: z.ZodNullable<z.ZodString>;
}, "status" | "id" | "metadata" | "requires_action" | "payment_url"> & {
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
provider_metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
billing: z.ZodOptional<z.ZodObject<{
address: z.ZodObject<{
name: z.ZodString;
line1: z.ZodString;
line2: z.ZodOptional<z.ZodDefault<z.ZodString>>;
city: z.ZodString;
state: z.ZodOptional<z.ZodString>;
postal_code: z.ZodString;
country: z.ZodString;
phone: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
name: string;
line1: string;
city: string;
postal_code: string;
country: string;
line2?: string | undefined;
state?: string | undefined;
phone?: string | undefined;
}, {
name: string;
line1: string;
city: string;
postal_code: string;
country: string;
line2?: string | undefined;
state?: string | undefined;
phone?: string | undefined;
}>;
carrier: z.ZodOptional<z.ZodString>;
currency: z.ZodString;
}, "strip", z.ZodTypeAny, {
address: {
name: string;
line1: string;
city: string;
postal_code: string;
country: string;
line2?: string | undefined;
state?: string | undefined;
phone?: string | undefined;
};
currency: string;
carrier?: string | undefined;
}, {
address: {
name: string;
line1: string;
city: string;
postal_code: string;
country: string;
line2?: string | undefined;
state?: string | undefined;
phone?: string | undefined;
};
currency: string;
carrier?: string | undefined;
}>>;
capture_method: z.ZodEnum<["automatic", "manual"]>;
}, "strip", z.ZodTypeAny, {
currency: string;
customer: {
email: string;
} | {
id: string | number;
} | null;
amount: number;
item_id: string | null;
capture_method: "manual" | "automatic";
metadata?: Record<string, unknown> | undefined;
billing?: {
address: {
name: string;
line1: string;
city: string;
postal_code: string;
country: string;
line2?: string | undefined;
state?: string | undefined;
phone?: string | undefined;
};
currency: string;
carrier?: string | undefined;
} | undefined;
provider_metadata?: Record<string, unknown> | undefined;
}, {
currency: string;
customer: {
email: string;
} | {
id: string | number;
} | null;
amount: number;
item_id: string | null;
capture_method: "manual" | "automatic";
metadata?: Record<string, unknown> | undefined;
billing?: {
address: {
name: string;
line1: string;
city: string;
postal_code: string;
country: string;
line2?: string | undefined;
state?: string | undefined;
phone?: string | undefined;
};
currency: string;
carrier?: string | undefined;
} | undefined;
provider_metadata?: Record<string, unknown> | undefined;
}>;
interface UpdatePaymentSchema<TProviderMetadata = Record<string, unknown>> extends Partial<Omit<Payment, 'id' | 'status'>> {
provider_metadata?: TProviderMetadata;
}
declare const updatePaymentSchema: z.ZodObject<{
id: z.ZodOptional<z.ZodString>;
amount: z.ZodOptional<z.ZodNumber>;
currency: z.ZodOptional<z.ZodString>;
customer: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodObject<{
email: z.ZodString;
}, "strip", z.ZodTypeAny, {
email: string;
}, {
email: string;
}>, z.ZodObject<{
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
}, "strip", z.ZodTypeAny, {
id: string | number;
}, {
id: string | number;
}>]>>>;
status: z.ZodOptional<z.ZodEnum<["pending", "processing", "requires_action", "requires_capture", "succeeded", "canceled", "failed"]>>;
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
item_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
requires_action: z.ZodOptional<z.ZodBoolean>;
payment_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
} & {
provider_metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
}, "strip", z.ZodTypeAny, {
status?: "canceled" | "pending" | "requires_action" | "processing" | "requires_capture" | "succeeded" | "failed" | undefined;
currency?: string | undefined;
id?: string | undefined;
metadata?: Record<string, string> | undefined;
provider_metadata?: Record<string, unknown> | undefined;
customer?: {
email: string;
} | {
id: string | number;
} | null | undefined;
amount?: number | undefined;
item_id?: string | null | undefined;
requires_action?: boolean | undefined;
payment_url?: string | null | undefined;
}, {
status?: "canceled" | "pending" | "requires_action" | "processing" | "requires_capture" | "succeeded" | "failed" | undefined;
currency?: string | undefined;
id?: string | undefined;
metadata?: Record<string, string> | undefined;
provider_metadata?: Record<string, unknown> | undefined;
customer?: {
email: string;
} | {
id: string | number;
} | null | undefined;
amount?: number | undefined;
item_id?: string | null | undefined;
requires_action?: boolean | undefined;
payment_url?: string | null | undefined;
}>;
interface RetrievePaymentSchema {
/**
* The unique identifier of the payment.
*/
id: string;
}
declare const retrievePaymentSchema: z.ZodObject<Pick<{
id: z.ZodString;
amount: z.ZodNumber;
currency: z.ZodString;
customer: z.ZodNullable<z.ZodUnion<[z.ZodObject<{
email: z.ZodString;
}, "strip", z.ZodTypeAny, {
email: string;
}, {
email: string;
}>, z.ZodObject<{
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
}, "strip", z.ZodTypeAny, {
id: string | number;
}, {
id: string | number;
}>]>>;
status: z.ZodEnum<["pending", "processing", "requires_action", "requires_capture", "succeeded", "canceled", "failed"]>;
metadata: z.ZodRecord<z.ZodString, z.ZodString>;
item_id: z.ZodNullable<z.ZodString>;
requires_action: z.ZodBoolean;
payment_url: z.ZodNullable<z.ZodString>;
}, "id">, "strip", z.ZodTypeAny, {
id: string;
}, {
id: string;
}>;
interface DeletePaymentSchema {
/**
* The unique identifier of the payment.
*/
id: string;
}
declare const deletePaymentSchema: z.ZodObject<Pick<{
id: z.ZodString;
amount: z.ZodNumber;
currency: z.ZodString;
customer: z.ZodNullable<z.ZodUnion<[z.ZodObject<{
email: z.ZodString;
}, "strip", z.ZodTypeAny, {
email: string;
}, {
email: string;
}>, z.ZodObject<{
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
}, "strip", z.ZodTypeAny, {
id: string | number;
}, {
id: string | number;
}>]>>;
status: z.ZodEnum<["pending", "processing", "requires_action", "requires_capture", "succeeded", "canceled", "failed"]>;
metadata: z.ZodRecord<z.ZodString, z.ZodString>;
item_id: z.ZodNullable<z.ZodString>;
requires_action: z.ZodBoolean;
payment_url: z.ZodNullable<z.ZodString>;
}, "id">, "strip", z.ZodTypeAny, {
id: string;
}, {
id: string;
}>;
interface CapturePaymentSchema {
/**
* The amount to capture.
*/
amount: number;
}
declare const capturePaymentSchema: z.ZodObject<{
amount: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
amount: number;
}, {
amount: number;
}>;
export { type CapturePaymentSchema, type CreatePaymentSchema, type DeletePaymentSchema, type Payment, type PaymentStatus, type RetrievePaymentSchema, type UpdatePaymentSchema, capturePaymentSchema, createPaymentSchema, deletePaymentSchema, paymentSchema, paymentStatusSchema, retrievePaymentSchema, updatePaymentSchema };