UNPKG

@paykit-sdk/core

Version:

The Payment Toolkit for Typescript

282 lines (279 loc) 8.89 kB
import { z } from 'zod'; import { Payee } from './customer.js'; import { PaykitMetadata } from './metadata.js'; import '../types.js'; import './billing.js'; declare const subscriptionIntervalUnitSchema: z.ZodEnum<["day", "week", "month", "year"]>; declare const subscriptionBillingIntervalSchema: 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; }>]>; type SubscriptionBillingInterval = z.infer<typeof subscriptionBillingIntervalSchema>; declare const subscriptionStatusSchema: z.ZodEnum<["active", "past_due", "canceled", "expired", "trialing", "pending"]>; type SubscriptionStatus = z.infer<typeof subscriptionStatusSchema>; interface Subscription { /** * The unique identifier of the subscription. */ id: string; /** * The payee linked to the subscription. */ customer: Payee | null; /** * The amount of the subscription. */ amount: number; /** * The currency of the subscription. */ currency: string; /** * The status of the subscription. */ status: SubscriptionStatus; /** * The start of the current billing period. */ current_period_start: Date; /** * The end of the current billing period. */ current_period_end: Date; /** * The item ID of the subscription. */ item_id: string; /** * The billing interval of the subscription. */ billing_interval: SubscriptionBillingInterval; /** * The metadata of the subscription. */ metadata: PaykitMetadata | null; /** * The custom fields of the subscription. */ custom_fields: Record<string, unknown> | null; /** * Whether the subscription requires action. */ requires_action: boolean; /** * The URL to the payment page of the subscription if requires action. */ payment_url: string | null; } declare const subscriptionSchema: 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; }>]>>; amount: z.ZodNumber; currency: z.ZodString; status: z.ZodEnum<["active", "past_due", "canceled", "expired", "trialing", "pending"]>; current_period_start: z.ZodDate; current_period_end: z.ZodDate; item_id: z.ZodString; 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; }>]>; metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>; custom_fields: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>; requires_action: z.ZodBoolean; payment_url: z.ZodNullable<z.ZodString>; }, "strip", z.ZodTypeAny, { status: "active" | "past_due" | "canceled" | "expired" | "trialing" | "pending"; currency: string; id: string; metadata: Record<string, string> | null; custom_fields: Record<string, unknown> | null; customer: { email: string; } | { id: string | number; } | null; amount: number; current_period_start: Date; current_period_end: Date; item_id: string; billing_interval: "day" | "week" | "month" | "year" | { type: "custom"; durationMs: number; }; requires_action: boolean; payment_url: string | null; }, { status: "active" | "past_due" | "canceled" | "expired" | "trialing" | "pending"; currency: string; id: string; metadata: Record<string, string> | null; custom_fields: Record<string, unknown> | null; customer: { email: string; } | { id: string | number; } | null; amount: number; current_period_start: Date; current_period_end: Date; item_id: string; billing_interval: "day" | "week" | "month" | "year" | { type: "custom"; durationMs: number; }; requires_action: boolean; payment_url: string | null; }>; interface UpdateSubscriptionSchema<TProviderMetadata = Record<string, unknown>> { /** * The metadata of the subscription. */ metadata: PaykitMetadata; /** * The provider metadata of the subscription. */ provider_metadata?: TProviderMetadata; } declare const updateSubscriptionSchema: z.ZodObject<{ metadata: z.ZodRecord<z.ZodString, z.ZodString>; provider_metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; }, "strip", z.ZodTypeAny, { metadata: Record<string, string>; provider_metadata?: Record<string, unknown> | undefined; }, { metadata: Record<string, string>; provider_metadata?: Record<string, unknown> | undefined; }>; interface RetrieveSubscriptionSchema { /** * The unique identifier of the subscription. */ id: string; } declare const retrieveSubscriptionSchema: z.ZodObject<{ id: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; }, { id: string; }>; interface DeleteSubscriptionSchema { /** * The unique identifier of the subscription. */ id: string; } declare const deleteSubscriptionSchema: z.ZodObject<{ id: z.ZodString; }, "strip", z.ZodTypeAny, { id: string; }, { id: string; }>; interface CreateSubscriptionSchema<TProviderMetadata = Record<string, unknown>> extends Omit<Subscription, 'id' | 'status' | 'custom_fields' | 'current_period_start' | 'current_period_end' | 'requires_action' | 'payment_url'> { /** * The provider metadata of the subscription. */ provider_metadata?: TProviderMetadata; /** * The quantity of the subscription. */ quantity: number; } declare const createSubscriptionSchema: z.ZodObject<Omit<{ 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; }>]>>; amount: z.ZodNumber; currency: z.ZodString; status: z.ZodEnum<["active", "past_due", "canceled", "expired", "trialing", "pending"]>; current_period_start: z.ZodDate; current_period_end: z.ZodDate; item_id: z.ZodString; 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; }>]>; metadata: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>; custom_fields: z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>; requires_action: z.ZodBoolean; payment_url: z.ZodNullable<z.ZodString>; }, "status" | "id" | "custom_fields" | "current_period_start" | "current_period_end" | "requires_action" | "payment_url"> & { provider_metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>; quantity: z.ZodNumber; }, "strip", z.ZodTypeAny, { currency: string; metadata: Record<string, string> | null; customer: { email: string; } | { id: string | number; } | null; amount: number; item_id: string; billing_interval: "day" | "week" | "month" | "year" | { type: "custom"; durationMs: number; }; quantity: number; provider_metadata?: Record<string, unknown> | undefined; }, { currency: string; metadata: Record<string, string> | null; customer: { email: string; } | { id: string | number; } | null; amount: number; item_id: string; billing_interval: "day" | "week" | "month" | "year" | { type: "custom"; durationMs: number; }; quantity: number; provider_metadata?: Record<string, unknown> | undefined; }>; export { type CreateSubscriptionSchema, type DeleteSubscriptionSchema, type RetrieveSubscriptionSchema, type Subscription, type SubscriptionBillingInterval, type SubscriptionStatus, type UpdateSubscriptionSchema, createSubscriptionSchema, deleteSubscriptionSchema, retrieveSubscriptionSchema, subscriptionBillingIntervalSchema, subscriptionIntervalUnitSchema, subscriptionSchema, subscriptionStatusSchema, updateSubscriptionSchema };