Files
payload-billing/dev/payload.config.ts
Bas van den Aakster c561dcb026 feat: Add embedded customer info to invoices with configurable relationship
- Add customerInfo and billingAddress fields to invoice collection
- Make customer relationship optional and configurable via plugin config
- Update TypeScript types to reflect new invoice structure
- Allow disabling customer relationship with customerRelation: false

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-15 20:55:25 +02:00

76 lines
1.8 KiB
TypeScript

import { sqliteAdapter } from '@payloadcms/db-sqlite'
import { lexicalEditor } from '@payloadcms/richtext-lexical'
import path from 'path'
import { buildConfig } from 'payload'
import { billingPlugin } from '../dist/index.js'
import sharp from 'sharp'
import { fileURLToPath } from 'url'
import { testEmailAdapter } from './helpers/testEmailAdapter'
import { seed } from './seed'
const filename = fileURLToPath(import.meta.url)
const dirname = path.dirname(filename)
if (!process.env.ROOT_DIR) {
process.env.ROOT_DIR = dirname
}
const buildConfigWithSQLite = () => {
return buildConfig({
admin: {
importMap: {
baseDir: path.resolve(dirname),
},
},
collections: [
{
slug: 'posts',
fields: [],
},
{
slug: 'media',
fields: [],
upload: {
staticDir: path.resolve(dirname, 'media'),
},
},
],
db: sqliteAdapter({
client: {
url: `file:${path.resolve(dirname, 'payload.sqlite')}`,
},
}),
editor: lexicalEditor(),
email: testEmailAdapter,
onInit: async (payload) => {
await seed(payload)
},
plugins: [
billingPlugin({
providers: {
test: {
enabled: true,
autoComplete: true,
}
},
collections: {
payments: 'payments',
customers: 'customers',
invoices: 'invoices',
refunds: 'refunds',
// customerRelation: false, // Set to false to disable customer relationship in invoices
// customerRelation: 'clients', // Or set to a custom collection slug
}
}),
],
secret: process.env.PAYLOAD_SECRET || 'test-secret_key',
sharp,
typescript: {
outputFile: path.resolve(dirname, 'payload-types.ts'),
},
})
}
export default buildConfigWithSQLite()