- Add unified payment provider architecture with contract-based design - Implement 6 payment providers: Stripe, Lemon Squeezy, Polar, Oxapay, Crypto, Activation Keys - Create subscription management with lifecycle handling (create, cancel, pause, resume, update) - Add coupon system with usage tracking and trial extensions - Build Filament admin resources for payment providers, subscriptions, coupons, and trials - Implement payment orchestration service with provider registry and configuration management - Add comprehensive payment logging and webhook handling for all providers - Create customer analytics dashboard with revenue, churn, and lifetime value metrics - Add subscription migration service for provider switching - Include extensive test coverage for all payment functionality
124 lines
5.3 KiB
PHP
124 lines
5.3 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\PaymentProviders\Schemas;
|
|
|
|
use Filament\Schemas\Components\Grid;
|
|
use Filament\Forms\Components\KeyValue;
|
|
use Filament\Schemas\Components\Section;
|
|
use Filament\Forms\Components\Textarea;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Components\Toggle;
|
|
use Filament\Schemas\Schema;
|
|
|
|
class PaymentProviderForm
|
|
{
|
|
public static function configure(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
Section::make('Basic Information')
|
|
->schema([
|
|
Grid::make(2)
|
|
->schema([
|
|
TextInput::make('name')
|
|
->label('Provider Name')
|
|
->required()
|
|
->unique(ignoreRecord: true)
|
|
->helperText('Internal identifier for the provider'),
|
|
|
|
TextInput::make('display_name')
|
|
->label('Display Name')
|
|
->required()
|
|
->helperText('Name shown to users'),
|
|
]),
|
|
|
|
Textarea::make('description')
|
|
->label('Description')
|
|
->rows(3)
|
|
->helperText('Brief description of the payment provider')
|
|
->columnSpanFull(),
|
|
]),
|
|
|
|
Section::make('Capabilities')
|
|
->schema([
|
|
Grid::make(3)
|
|
->schema([
|
|
Toggle::make('is_active')
|
|
->label('Active')
|
|
->default(true)
|
|
->helperText('Enable this provider for use'),
|
|
|
|
Toggle::make('supports_recurring')
|
|
->label('Supports Recurring')
|
|
->default(false)
|
|
->helperText('Can handle subscription payments'),
|
|
|
|
Toggle::make('supports_one_time')
|
|
->label('Supports One-Time')
|
|
->default(true)
|
|
->helperText('Can handle single payments'),
|
|
]),
|
|
|
|
Grid::make(2)
|
|
->schema([
|
|
TextInput::make('priority')
|
|
->label('Priority')
|
|
->numeric()
|
|
->default(0)
|
|
->helperText('Higher priority = shown first'),
|
|
|
|
Toggle::make('is_fallback')
|
|
->label('Fallback Provider')
|
|
->default(false)
|
|
->helperText('Default provider when others fail'),
|
|
]),
|
|
]),
|
|
|
|
Section::make('Configuration')
|
|
->schema([
|
|
KeyValue::make('configuration')
|
|
->label('Provider Configuration')
|
|
->addActionLabel('Add configuration')
|
|
->keyLabel('Key')
|
|
->valueLabel('Value')
|
|
->helperText('API keys and other provider-specific settings')
|
|
->columnSpanFull(),
|
|
|
|
KeyValue::make('supported_currencies')
|
|
->label('Supported Currencies')
|
|
->addActionLabel('Add currency')
|
|
->keyLabel('Currency Code')
|
|
->valueLabel('Display Name')
|
|
->default(['USD' => 'US Dollar'])
|
|
->helperText('Currencies this provider supports')
|
|
->columnSpanFull(),
|
|
|
|
KeyValue::make('fee_structure')
|
|
->label('Fee Structure')
|
|
->addActionLabel('Add fee setting')
|
|
->keyLabel('Fee Type')
|
|
->valueLabel('Value')
|
|
->helperText('Example: fixed_fee, percentage_fee')
|
|
->columnSpanFull(),
|
|
]),
|
|
|
|
Section::make('Webhook Settings')
|
|
->schema([
|
|
Grid::make(2)
|
|
->schema([
|
|
TextInput::make('webhook_url')
|
|
->label('Webhook URL')
|
|
->url()
|
|
->helperText('Endpoint for provider webhooks'),
|
|
|
|
TextInput::make('webhook_secret')
|
|
->label('Webhook Secret')
|
|
->password()
|
|
->helperText('Secret for webhook validation'),
|
|
]),
|
|
])
|
|
->collapsible(),
|
|
]);
|
|
}
|
|
}
|