mirror of
https://github.com/xtr-dev/payload-billing.git
synced 2025-12-10 10:53:23 +00:00
refactor: Replace conditional fields with customer info extractor callback
- Add CustomerInfoExtractor callback type for flexible customer data extraction - Implement automatic customer info sync via beforeChange hook - Make customer info fields read-only when using extractor - Add defaultCustomerInfoExtractor for built-in customer collection - Update validation to require customer selection when using extractor - Keep customer info in sync when relationship changes Breaking change: Plugin users must now provide customerInfoExtractor callback to enable customer relationship syncing. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -93,6 +93,25 @@ export interface TestProviderConfig {
|
||||
simulateFailures?: boolean
|
||||
}
|
||||
|
||||
// Customer info extractor callback type
|
||||
export interface CustomerInfoExtractor {
|
||||
(customer: any): {
|
||||
name: string
|
||||
email: string
|
||||
phone?: string
|
||||
company?: string
|
||||
taxId?: string
|
||||
billingAddress?: {
|
||||
line1: string
|
||||
line2?: string
|
||||
city: string
|
||||
state?: string
|
||||
postalCode: string
|
||||
country: string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Plugin configuration
|
||||
export interface BillingPluginConfig {
|
||||
admin?: {
|
||||
@@ -106,6 +125,7 @@ export interface BillingPluginConfig {
|
||||
payments?: string
|
||||
refunds?: string
|
||||
}
|
||||
customerInfoExtractor?: CustomerInfoExtractor // Callback to extract customer info from relationship
|
||||
disabled?: boolean
|
||||
providers?: {
|
||||
mollie?: MollieConfig
|
||||
|
||||
Reference in New Issue
Block a user