mirror of
https://github.com/xtr-dev/payload-billing.git
synced 2025-12-10 10:53:23 +00:00
chore: Remove unused billing-related collections, types, and utility modules
- Drop `customers` collection and associated types (`types/index.ts`, `payload.ts`) - Remove generated `payload-types.ts` file - Clean up unused exports and dependencies across modules - Streamline codebase by eliminating redundant billing logic
This commit is contained in:
@@ -1,12 +1,5 @@
|
||||
import type { CollectionConfig } from 'payload'
|
||||
|
||||
import type {
|
||||
AccessArgs,
|
||||
CollectionAfterChangeHook,
|
||||
CollectionBeforeChangeHook,
|
||||
PaymentData,
|
||||
PaymentDocument
|
||||
} from '../types/payload'
|
||||
import { AccessArgs, CollectionAfterChangeHook, CollectionBeforeChangeHook, CollectionConfig } from 'payload'
|
||||
import { Payment } from '@/plugin/types'
|
||||
|
||||
export function createPaymentsCollection(slug: string = 'payments'): CollectionConfig {
|
||||
return {
|
||||
@@ -131,21 +124,14 @@ export function createPaymentsCollection(slug: string = 'payments'): CollectionC
|
||||
},
|
||||
],
|
||||
hooks: {
|
||||
afterChange: [
|
||||
({ doc, operation, req }: CollectionAfterChangeHook<PaymentDocument>) => {
|
||||
if (operation === 'create') {
|
||||
req.payload.logger.info(`Payment created: ${doc.id} (${doc.provider})`)
|
||||
}
|
||||
},
|
||||
],
|
||||
beforeChange: [
|
||||
({ data, operation }: CollectionBeforeChangeHook<PaymentData>) => {
|
||||
({ data, operation }) => {
|
||||
if (operation === 'create') {
|
||||
// Validate amount format
|
||||
if (data.amount && !Number.isInteger(data.amount)) {
|
||||
throw new Error('Amount must be an integer (in cents)')
|
||||
}
|
||||
|
||||
|
||||
// Validate currency format
|
||||
if (data.currency) {
|
||||
data.currency = data.currency.toUpperCase()
|
||||
@@ -155,8 +141,8 @@ export function createPaymentsCollection(slug: string = 'payments'): CollectionC
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
] satisfies CollectionBeforeChangeHook<Payment>[],
|
||||
},
|
||||
timestamps: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user