feat: implement payment service with error handling and validation
Add new payment service with repository, error handling, and validation Add exceptions package with database and validation utilities Update database package with new schema and zod types Add turbo start script for development
This commit is contained in:
20
packages/services/src/payment/errors.ts
Normal file
20
packages/services/src/payment/errors.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { AppError, createAppError } from '@repo/exceptions';
|
||||
|
||||
export enum PaymentErrorCode {
|
||||
PAYMENT_NOT_FOUND = 'PAYMENT_NOT_FOUND',
|
||||
PAYMENT_ALREADY_PROCESSED = 'PAYMENT_ALREADY_PROCESSED',
|
||||
}
|
||||
|
||||
export type PaymentError = AppError<PaymentErrorCode>;
|
||||
|
||||
export const paymentNotFound = (paymentId: string): PaymentError =>
|
||||
createAppError<PaymentErrorCode>(
|
||||
PaymentErrorCode.PAYMENT_NOT_FOUND,
|
||||
`Payment with id ${paymentId} not found`
|
||||
) as PaymentError;
|
||||
|
||||
export const paymentAlreadyProcessed = (paymentId: string): PaymentError =>
|
||||
createAppError(
|
||||
PaymentErrorCode.PAYMENT_ALREADY_PROCESSED,
|
||||
`Payment ${paymentId} has already been processed`
|
||||
) as PaymentError;
|
||||
Reference in New Issue
Block a user