@paykit-sdk/core
Version:
The Payment Toolkit for Typescript
726 lines (723 loc) • 22 kB
TypeScript
import { z } from 'zod';
import { BillingInfo } from './billing.js';
import { Payee } from './customer.js';
import { PaykitMetadata } from './metadata.js';
import { SubscriptionBillingInterval } from './subscription.js';
import '../types.js';
interface CheckoutSubscription {
/**
* The billing interval.
*/
billing_interval: SubscriptionBillingInterval;
/**
* The billing interval count.
*/
billing_interval_count: number;
}
declare const checkoutSubscriptionSchema: z.ZodObject<{
billing_interval: z.ZodUnion<[z.ZodEnum<["day", "week", "month", "year"]>, z.ZodObject<{
type: z.ZodLiteral<"custom">;
durationMs: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
type: "custom";
durationMs: number;
}, {
type: "custom";
durationMs: number;
}>]>;
billing_interval_count: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
billing_interval: "day" | "week" | "month" | "year" | {
type: "custom";
durationMs: number;
};
billing_interval_count: number;
}, {
billing_interval: "day" | "week" | "month" | "year" | {
type: "custom";
durationMs: number;
};
billing_interval_count: number;
}>;
declare const billingModeSchema: z.ZodEnum<["one_time", "recurring"]>;
type BillingMode = z.infer<typeof billingModeSchema>;
interface Checkout {
/**
* The ID of the checkout.
*/
id: string;
/**
* The payee of the checkout.
*/
customer: Payee | null;
/**
* The payment URL of the checkout.
*/
payment_url: string;
/**
* The metadata of the checkout.
*/
metadata: PaykitMetadata | null;
/**
* The mode of the checkout.
*/
session_type: BillingMode;
/**
* The products of the checkout.
*/
products: Array<{
id: string;
quantity: number;
}>;
/**
* The currency of the checkout.
*/
currency: string;
/**
* The amount of the checkout.
*/
amount: number;
/**
* The subscription specification of the checkout.
*/
subscription?: CheckoutSubscription | null;
}
declare const checkoutSchema: z.ZodObject<{
id: 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;
}>]>>;
payment_url: z.ZodString;
metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>;
session_type: z.ZodEnum<["one_time", "recurring"]>;
products: z.ZodArray<z.ZodObject<{
id: z.ZodString;
quantity: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
id: string;
quantity: number;
}, {
id: string;
quantity: number;
}>, "many">;
currency: z.ZodString;
amount: z.ZodNumber;
subscription: z.ZodOptional<z.ZodNullable<z.ZodObject<{
billing_interval: z.ZodUnion<[z.ZodEnum<["day", "week", "month", "year"]>, z.ZodObject<{
type: z.ZodLiteral<"custom">;
durationMs: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
type: "custom";
durationMs: number;
}, {
type: "custom";
durationMs: number;
}>]>;
billing_interval_count: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
billing_interval: "day" | "week" | "month" | "year" | {
type: "custom";
durationMs: number;
};
billing_interval_count: number;
}, {
billing_interval: "day" | "week" | "month" | "year" | {
type: "custom";
durationMs: number;
};
billing_interval_count: number;
}>>>;
}, "strip", z.ZodTypeAny, {
currency: string;
id: string;
metadata: Record<string, string> | null;
customer: {
email: string;
} | {
id: string | number;
} | null;
amount: number;
payment_url: string;
session_type: "one_time" | "recurring";
products: {
id: string;
quantity: number;
}[];
subscription?: {
billing_interval: "day" | "week" | "month" | "year" | {
type: "custom";
durationMs: number;
};
billing_interval_count: number;
} | null | undefined;
}, {
currency: string;
id: string;
metadata: Record<string, string> | null;
customer: {
email: string;
} | {
id: string | number;
} | null;
amount: number;
payment_url: string;
session_type: "one_time" | "recurring";
products: {
id: string;
quantity: number;
}[];
subscription?: {
billing_interval: "day" | "week" | "month" | "year" | {
type: "custom";
durationMs: number;
};
billing_interval_count: number;
} | null | undefined;
}>;
interface CreateCheckoutBaseSchema<TProviderMetadata = Record<string, unknown>> extends Pick<Checkout, 'metadata'> {
customer: Payee;
/**
* The item ID of the checkout.
*/
item_id: string;
/**
* The quantity of the checkout.
*/
quantity: number;
/**
* Extra information to be sent to the provider e.g tax, trial days, etc.
*/
provider_metadata?: TProviderMetadata;
/**
* The shipping information of the checkout.
*/
billing?: BillingInfo;
/**
* The success URL of the checkout.
*/
success_url: string;
/**
* The cancel URL of the checkout.
*/
cancel_url: string;
}
declare const createCheckoutBaseSchema: z.ZodObject<{
customer: 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;
}>]>;
metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>;
item_id: z.ZodString;
quantity: z.ZodNumber;
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;
}>>;
success_url: z.ZodString;
cancel_url: z.ZodString;
}, "strip", z.ZodTypeAny, {
metadata: Record<string, string> | null;
customer: {
email: string;
} | {
id: string | number;
};
item_id: string;
quantity: number;
success_url: string;
cancel_url: string;
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;
}, {
metadata: Record<string, string> | null;
customer: {
email: string;
} | {
id: string | number;
};
item_id: string;
quantity: number;
success_url: string;
cancel_url: string;
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 CreateOneTimeCheckoutSchema<TProviderMetadata = Record<string, unknown>> extends CreateCheckoutBaseSchema<TProviderMetadata> {
/**
* The session type of the checkout.
*/
session_type: typeof billingModeSchema.enum.one_time;
/**
* The subscription specification of the checkout.
*/
subscription?: CheckoutSubscription;
}
interface CreateRecurringCheckoutSchema<TProviderMetadata = Record<string, unknown>> extends Omit<CreateCheckoutBaseSchema<TProviderMetadata>, 'success_url' | 'cancel_url'> {
/**
* The session type of the checkout.
*/
session_type: typeof billingModeSchema.enum.recurring;
/**
* The subscription specification of the checkout.
*/
subscription: CheckoutSubscription;
}
type CreateCheckoutSchema<TProviderMetadata = Record<string, unknown>> = CreateOneTimeCheckoutSchema<TProviderMetadata> | CreateRecurringCheckoutSchema<TProviderMetadata>;
declare const createCheckoutSchema: z.ZodObject<{
customer: 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;
}>]>;
metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>;
session_type: z.ZodLiteral<"one_time">;
item_id: z.ZodString;
quantity: z.ZodNumber;
subscription: z.ZodOptional<z.ZodObject<{
billing_interval: z.ZodUnion<[z.ZodEnum<["day", "week", "month", "year"]>, z.ZodObject<{
type: z.ZodLiteral<"custom">;
durationMs: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
type: "custom";
durationMs: number;
}, {
type: "custom";
durationMs: number;
}>]>;
billing_interval_count: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
billing_interval: "day" | "week" | "month" | "year" | {
type: "custom";
durationMs: number;
};
billing_interval_count: number;
}, {
billing_interval: "day" | "week" | "month" | "year" | {
type: "custom";
durationMs: number;
};
billing_interval_count: number;
}>>;
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;
}>>;
success_url: z.ZodString;
cancel_url: z.ZodString;
}, "strip", z.ZodTypeAny, {
metadata: Record<string, string> | null;
customer: {
email: string;
} | {
id: string | number;
};
item_id: string;
quantity: number;
session_type: "one_time";
success_url: string;
cancel_url: string;
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;
subscription?: {
billing_interval: "day" | "week" | "month" | "year" | {
type: "custom";
durationMs: number;
};
billing_interval_count: number;
} | undefined;
}, {
metadata: Record<string, string> | null;
customer: {
email: string;
} | {
id: string | number;
};
item_id: string;
quantity: number;
session_type: "one_time";
success_url: string;
cancel_url: string;
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;
subscription?: {
billing_interval: "day" | "week" | "month" | "year" | {
type: "custom";
durationMs: number;
};
billing_interval_count: number;
} | undefined;
}>;
type UpdateCheckoutSchema<TProviderMetadata = Record<string, unknown>> = Partial<CreateCheckoutSchema<TProviderMetadata>>;
declare const updateCheckoutSchema: z.ZodObject<{
customer: z.ZodOptional<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;
}>]>>;
metadata: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
session_type: z.ZodOptional<z.ZodLiteral<"one_time">>;
item_id: z.ZodOptional<z.ZodString>;
quantity: z.ZodOptional<z.ZodNumber>;
subscription: z.ZodOptional<z.ZodOptional<z.ZodObject<{
billing_interval: z.ZodUnion<[z.ZodEnum<["day", "week", "month", "year"]>, z.ZodObject<{
type: z.ZodLiteral<"custom">;
durationMs: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
type: "custom";
durationMs: number;
}, {
type: "custom";
durationMs: number;
}>]>;
billing_interval_count: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
billing_interval: "day" | "week" | "month" | "year" | {
type: "custom";
durationMs: number;
};
billing_interval_count: number;
}, {
billing_interval: "day" | "week" | "month" | "year" | {
type: "custom";
durationMs: number;
};
billing_interval_count: number;
}>>>;
provider_metadata: z.ZodOptional<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
billing: z.ZodOptional<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;
}>>>;
success_url: z.ZodOptional<z.ZodString>;
cancel_url: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
metadata?: Record<string, string> | null | 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;
customer?: {
email: string;
} | {
id: string | number;
} | undefined;
item_id?: string | undefined;
quantity?: number | undefined;
session_type?: "one_time" | undefined;
subscription?: {
billing_interval: "day" | "week" | "month" | "year" | {
type: "custom";
durationMs: number;
};
billing_interval_count: number;
} | undefined;
success_url?: string | undefined;
cancel_url?: string | undefined;
}, {
metadata?: Record<string, string> | null | 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;
customer?: {
email: string;
} | {
id: string | number;
} | undefined;
item_id?: string | undefined;
quantity?: number | undefined;
session_type?: "one_time" | undefined;
subscription?: {
billing_interval: "day" | "week" | "month" | "year" | {
type: "custom";
durationMs: number;
};
billing_interval_count: number;
} | undefined;
success_url?: string | undefined;
cancel_url?: string | undefined;
}>;
interface RetrieveCheckoutParams {
id: string;
}
declare const retrieveCheckoutSchema: z.ZodObject<{
id: z.ZodString;
}, "strip", z.ZodTypeAny, {
id: string;
}, {
id: string;
}>;
export { type BillingMode, type Checkout, type CheckoutSubscription, type CreateCheckoutSchema, type CreateOneTimeCheckoutSchema, type CreateRecurringCheckoutSchema, type RetrieveCheckoutParams, type UpdateCheckoutSchema, billingModeSchema, checkoutSchema, checkoutSubscriptionSchema, createCheckoutBaseSchema, createCheckoutSchema, retrieveCheckoutSchema, updateCheckoutSchema };