feat: implement comprehensive multi-provider payment processing system

- 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
This commit is contained in:
idevakk
2025-11-19 09:37:00 -08:00
parent 0560016f33
commit 27ac13948c
83 changed files with 15613 additions and 103 deletions

View File

@@ -0,0 +1,140 @@
<?php
namespace App\Filament\Resources\Coupons\Schemas;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\KeyValue;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Schemas\Components\Grid;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
use Illuminate\Support\Str;
class CouponForm
{
public static function configure(Schema $schema): Schema
{
return $schema
->components([
Section::make('Basic Information')
->schema([
Grid::make(2)
->schema([
TextInput::make('code')
->label('Coupon Code')
->required()
->unique(ignoreRecord: true)
->formatStateUsing(fn ($state) => Str::upper($state))
->helperText('This code will be entered by customers to apply the discount'),
TextInput::make('name')
->label('Display Name')
->required()
->helperText('Internal name for this coupon'),
]),
Textarea::make('description')
->label('Description')
->rows(2)
->helperText('Optional description for internal reference'),
Grid::make(2)
->schema([
Select::make('type')
->label('Discount Type')
->options([
'percentage' => 'Percentage',
'fixed' => 'Fixed Amount',
])
->required()
->reactive()
->afterStateUpdated(fn ($state, callable $set) => $set('value', $state === 'percentage' ? 10 : 10.00)
),
TextInput::make('value')
->label('Discount Value')
->required()
->numeric()
->step(fn ($get) => $get('type') === 'percentage' ? 1 : 0.01)
->suffix(fn ($get) => $get('type') === 'percentage' ? '%' : '$')
->helperText(fn ($get) => $get('type') === 'percentage'
? 'Percentage discount (e.g., 10 for 10%)'
: 'Fixed amount discount in USD'
),
]),
]),
Section::make('Usage Limits')
->schema([
Grid::make(2)
->schema([
TextInput::make('max_uses')
->label('Maximum Uses')
->numeric()
->helperText('Leave blank for unlimited uses'),
TextInput::make('max_uses_per_user')
->label('Max Uses Per User')
->numeric()
->helperText('Limit how many times one user can use this coupon'),
]),
Grid::make(2)
->schema([
TextInput::make('minimum_amount')
->label('Minimum Order Amount')
->numeric()
->step(0.01)
->prefix('$')
->helperText('Minimum order amount required to use this coupon'),
TextInput::make('uses_count')
->label('Current Uses')
->numeric()
->default(0)
->disabled()
->helperText('Number of times this coupon has been used'),
]),
])
->collapsible(),
Section::make('Schedule')
->schema([
Grid::make(2)
->schema([
DateTimePicker::make('starts_at')
->label('Start Date')
->helperText('When this coupon becomes active'),
DateTimePicker::make('expires_at')
->label('Expiration Date')
->helperText('When this coupon expires'),
]),
])
->collapsible(),
Section::make('Settings')
->schema([
Toggle::make('is_active')
->label('Active')
->default(true)
->helperText('Only active coupons can be used'),
])
->collapsible(),
Section::make('Metadata')
->schema([
KeyValue::make('metadata')
->label('Custom Metadata')
->addActionLabel('Add metadata')
->keyLabel('Key')
->valueLabel('Value')
->helperText('Additional key-value data for this coupon'),
])
->collapsible(),
]);
}
}