import { z } from 'zod'; import { timestampSchema } from './common.schemas'; import { subscriptionTierEnum } from './shopkeeper.schemas'; export const subscriptionSchema = z .object({ id: z.string().uuid(), tier: subscriptionTierEnum, status: z.enum(['active', 'past_due', 'cancelled', 'expired']), billingCycle: z.enum(['daily', 'weekly', 'monthly', 'annual']), amount: z.number(), currency: z.string(), paymentMethod: z.string().nullable(), currentPeriodStart: z.coerce.date(), currentPeriodEnd: z.coerce.date(), cancelledAt: z.coerce.date().nullable(), }) .merge(timestampSchema); export const createSubscriptionSchema = z.object({ tier: subscriptionTierEnum, billingCycle: z.enum(['daily', 'weekly', 'monthly', 'annual']), paymentMethod: z .enum(['paystack', 'card', 'bank', 'mobile_money', 'momo', 'opay']) .optional(), paymentRef: z.string().optional(), }); export const paymentSchema = z.object({ id: z.string().uuid(), amount: z.number(), currency: z.string(), provider: z.string(), providerRef: z.string().nullable(), status: z.enum(['pending', 'success', 'failed']), paidAt: z.coerce.date().nullable(), createdAt: z.coerce.date(), }); export const verifyPaymentSchema = z.object({ provider: z.enum(['paystack']), transactionRef: z.string(), }); export type Subscription = z.infer; export type CreateSubscriptionInput = z.infer; export type Payment = z.infer; export type VerifyPaymentInput = z.infer;