feat: implements activation key as payment provider and migrate activation key to use unified payment system
This commit is contained in:
@@ -7,8 +7,12 @@ use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Infolists\Components\RepeatableEntry;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class SubscriptionForm
|
||||
@@ -144,27 +148,6 @@ class SubscriptionForm
|
||||
->collapsible()
|
||||
->visible(fn ($get) => $get('status') === 'cancelled'),
|
||||
|
||||
Section::make('Provider Information')
|
||||
->schema([
|
||||
TextInput::make('stripe_id')
|
||||
->label('Stripe ID')
|
||||
->visible(fn ($get) => $get('provider') === 'stripe'),
|
||||
|
||||
TextInput::make('stripe_status')
|
||||
->label('Stripe Status')
|
||||
->visible(fn ($get) => $get('provider') === 'stripe'),
|
||||
|
||||
TextInput::make('stripe_price')
|
||||
->label('Stripe Price')
|
||||
->visible(fn ($get) => $get('provider') === 'stripe'),
|
||||
|
||||
Textarea::make('provider_data')
|
||||
->label('Provider Data')
|
||||
->rows(3)
|
||||
->helperText('JSON data from the payment provider'),
|
||||
])
|
||||
->collapsible(),
|
||||
|
||||
Section::make('Migration Information')
|
||||
->schema([
|
||||
TextInput::make('migration_batch_id')
|
||||
@@ -178,6 +161,116 @@ class SubscriptionForm
|
||||
->rows(3),
|
||||
])
|
||||
->collapsible(),
|
||||
|
||||
Tabs::make('Provider Data')
|
||||
->tabs([
|
||||
Tab::make('Overview')
|
||||
->schema([
|
||||
Section::make('Activation Key')
|
||||
->schema([
|
||||
TextEntry::make('provider_data.activation_key')
|
||||
->label('Activation Key')
|
||||
->copyable(),
|
||||
TextEntry::make('provider_data.key_id')
|
||||
->label('Key ID'),
|
||||
TextEntry::make('provider_data.redeemed_at')
|
||||
->label('Redeemed At'),
|
||||
])
|
||||
->columns(1)
|
||||
->hidden(fn ($record) => ! data_get($record, 'provider_data.activation_key')),
|
||||
|
||||
Section::make('Plan Details')
|
||||
->schema([
|
||||
TextEntry::make('provider_data.plan_details.name')
|
||||
->label('Plan Name'),
|
||||
TextEntry::make('provider_data.plan_details.price')
|
||||
->label('Price')
|
||||
->prefix('$'),
|
||||
TextEntry::make('provider_data.plan_details.billing_cycle_display')
|
||||
->label('Billing Cycle'),
|
||||
TextEntry::make('provider_data.plan_details.plan_tier')
|
||||
->badge()
|
||||
->label('Tier'),
|
||||
TextEntry::make('provider_data.plan_details.billing_cycle_days')
|
||||
->label('Duration')
|
||||
->suffix(' days'),
|
||||
])
|
||||
->columns(2)
|
||||
->hidden(fn ($record) => ! data_get($record, 'provider_data.plan_details')),
|
||||
|
||||
Section::make('Provider Info')
|
||||
->schema([
|
||||
TextEntry::make('provider_data.provider_info.name')
|
||||
->label('Provider Name'),
|
||||
TextEntry::make('provider_data.provider_info.version')
|
||||
->label('Version'),
|
||||
TextEntry::make('provider_data.provider_info.processed_at')
|
||||
->label('Processed At'),
|
||||
])
|
||||
->columns(2)
|
||||
->hidden(fn ($record) => ! data_get($record, 'provider_data.provider_info')),
|
||||
]),
|
||||
|
||||
Tab::make('Features')
|
||||
->schema([
|
||||
RepeatableEntry::make('provider_data.plan_details.features')
|
||||
->schema([
|
||||
Section::make()
|
||||
->schema([
|
||||
TextEntry::make('feature.display_name')
|
||||
->label('Feature Name')
|
||||
->weight('bold'),
|
||||
TextEntry::make('feature.description')
|
||||
->label('Description')
|
||||
->columnSpanFull(),
|
||||
TextEntry::make('feature.category')
|
||||
->label('Category')
|
||||
->badge(),
|
||||
TextEntry::make('feature.type')
|
||||
->label('Type'),
|
||||
|
||||
Section::make('Limit Details')
|
||||
->schema([
|
||||
TextEntry::make('limit.limit_value')
|
||||
->label('Limit Value'),
|
||||
TextEntry::make('limit.trial_limit_value')
|
||||
->label('Trial Limit'),
|
||||
TextEntry::make('limit.limit_type')
|
||||
->badge()
|
||||
->label('Limit Type'),
|
||||
TextEntry::make('limit.is_enabled')
|
||||
->label('Status')
|
||||
->badge()
|
||||
->formatStateUsing(fn ($state) => $state ? 'Enabled' : 'Disabled')
|
||||
->color(fn ($state) => $state ? 'success' : 'gray'),
|
||||
])
|
||||
->columns(2)
|
||||
->collapsed(),
|
||||
])
|
||||
->columns(2),
|
||||
])
|
||||
->columnSpanFull(),
|
||||
])
|
||||
->hidden(fn ($record) => ! data_get($record, 'provider_data.plan_details.features')),
|
||||
|
||||
Tab::make('Raw JSON')
|
||||
->schema([
|
||||
TextEntry::make('provider_data')
|
||||
->formatStateUsing(function ($state) {
|
||||
if (is_string($state)) {
|
||||
$data = json_decode($state, true);
|
||||
} else {
|
||||
$data = (array) $state;
|
||||
}
|
||||
|
||||
return json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
||||
})
|
||||
->state(fn ($record) => $record->provider_data)
|
||||
->copyable()
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
])->columnSpanFull(),
|
||||
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user