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,53 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\SubscriptionChange>
*/
class SubscriptionChangeFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$changeType = fake()->randomElement([
'plan_change', 'cancellation', 'pause', 'resume', 'migration', 'provider_change',
]);
return [
'subscription_id' => \App\Models\Subscription::factory(),
'user_id' => \App\Models\User::factory(),
'change_type' => $changeType,
'change_description' => fake()->sentence(),
'old_values' => fake()->optional(0.7)->randomElement([
['plan_id' => fake()->numberBetween(1, 5), 'price' => fake()->randomFloat(2, 10, 100)],
['status' => 'active', 'provider' => 'stripe'],
]),
'new_values' => fake()->optional(0.7)->randomElement([
['plan_id' => fake()->numberBetween(1, 5), 'price' => fake()->randomFloat(2, 10, 100)],
['status' => 'cancelled', 'provider' => 'lemon_squeezy'],
]),
'reason' => fake()->optional(0.6)->randomElement([
'Customer request',
'Payment failure',
'Plan upgrade',
'Service downgrade',
'Technical migration',
]),
'effective_at' => fake()->dateTimeBetween('-1 month', 'now'),
'processed_at' => fake()->optional(0.8)->dateTimeBetween('-1 month', 'now'),
'is_processed' => fake()->boolean(80),
'metadata' => fake()->optional(0.2)->randomElements([
'processed_by' => fake()->name(),
'system_generated' => fake()->boolean(),
'batch_id' => fake()->uuid(),
]),
];
}
}