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,77 @@
<?php
use App\Services\Payments\ProviderRegistry;
use App\Services\Payments\Providers\StripeProvider;
test('can register payment provider', function () {
$registry = new ProviderRegistry;
$provider = new StripeProvider;
$registry->register('stripe', $provider);
expect($registry->has('stripe'))->toBeTrue();
expect($registry->get('stripe'))->toBe($provider);
});
test('can get all providers', function () {
$registry = new ProviderRegistry;
$stripeProvider = new StripeProvider;
$registry->register('stripe', $stripeProvider);
$providers = $registry->getAllProviders();
expect($providers)->toHaveCount(1);
expect($providers->get('stripe'))->toBe($stripeProvider);
});
test('can get active providers only', function () {
$registry = new ProviderRegistry;
$stripeProvider = new StripeProvider;
$registry->register('stripe', $stripeProvider);
$activeProviders = $registry->getActiveProviders();
expect($activeProviders)->toHaveCount(0); // Stripe is inactive without API key
});
test('can unregister provider', function () {
$registry = new ProviderRegistry;
$provider = new StripeProvider;
$registry->register('stripe', $provider);
expect($registry->has('stripe'))->toBeTrue();
$result = $registry->unregister('stripe');
expect($result)->toBeTrue();
expect($registry->has('stripe'))->toBeFalse();
});
test('can validate providers', function () {
$registry = new ProviderRegistry;
$stripeProvider = new StripeProvider;
$registry->register('stripe', $stripeProvider);
$results = $registry->validateProviders();
expect($results)->toHaveKey('stripe');
expect($results['stripe']['active'])->toBeFalse();
expect($results['stripe']['supports_recurring'])->toBeTrue();
expect($results['stripe']['supports_one_time'])->toBeTrue();
});
test('can get provider statistics', function () {
$registry = new ProviderRegistry;
$stripeProvider = new StripeProvider;
$registry->register('stripe', $stripeProvider);
$stats = $registry->getProviderStats();
expect($stats['total_providers'])->toBe(1);
expect($stats['active_providers'])->toBe(0);
expect($stats['recurring_providers'])->toBe(0);
expect($stats['one_time_providers'])->toBe(0);
});