Migrate billing from Paddle to Lemon Squeezy

This commit is contained in:
Codex Agent
2026-02-03 10:59:54 +01:00
parent 2f4ebfefd4
commit a0ef90e13a
228 changed files with 4369 additions and 4067 deletions

View File

@@ -11,7 +11,7 @@ use App\Services\Checkout\CheckoutSessionService;
use App\Services\Checkout\CheckoutWebhookService;
use App\Services\Coupons\CouponRedemptionService;
use App\Services\GiftVouchers\GiftVoucherService;
use App\Services\Paddle\PaddleSubscriptionService;
use App\Services\LemonSqueezy\LemonSqueezySubscriptionService;
use Carbon\Carbon;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Mockery;
@@ -70,18 +70,19 @@ class PackageSoftDeleteTest extends TestCase
$this->assertTrue($activePackage->is($tenantPackage));
}
public function test_paddle_subscription_event_handles_soft_deleted_package(): void
public function test_lemonsqueezy_subscription_event_handles_soft_deleted_package(): void
{
$tenant = Tenant::factory()->create();
$package = Package::factory()->reseller()->create([
'price' => 29.00,
'lemonsqueezy_variant_id' => 'var_123',
]);
$package->delete();
$sessionService = Mockery::mock(CheckoutSessionService::class);
$assignmentService = Mockery::mock(CheckoutAssignmentService::class);
$subscriptionService = Mockery::mock(PaddleSubscriptionService::class);
$subscriptionService = Mockery::mock(LemonSqueezySubscriptionService::class);
$couponRedemptions = Mockery::mock(CouponRedemptionService::class);
$giftVouchers = Mockery::mock(GiftVoucherService::class);
@@ -96,20 +97,25 @@ class PackageSoftDeleteTest extends TestCase
Carbon::setTestNow(now());
$event = [
'event_type' => 'subscription.updated',
'data' => [
'id' => 'sub_123',
'status' => 'active',
'meta' => [
'event_name' => 'subscription_updated',
'custom_data' => [
'tenant_id' => $tenant->id,
'package_id' => $package->id,
],
'next_billing_date' => now()->addMonth()->toIso8601String(),
'customer_id' => 'cus_456',
],
'data' => [
'id' => 'sub_123',
'attributes' => [
'status' => 'active',
'renews_at' => now()->addMonth()->toIso8601String(),
'customer_id' => 'cus_456',
'variant_id' => 'var_123',
],
],
];
$this->assertTrue($service->handlePaddleEvent($event));
$this->assertTrue($service->handleLemonSqueezyEvent($event));
$tenantPackage = TenantPackage::where('tenant_id', $tenant->id)
->where('package_id', $package->id)
@@ -118,11 +124,11 @@ class PackageSoftDeleteTest extends TestCase
$this->assertNotNull($tenantPackage);
$this->assertNotNull($tenantPackage->package);
$this->assertTrue($tenantPackage->package->is($package));
$this->assertSame('sub_123', $tenantPackage->paddle_subscription_id);
$this->assertSame('sub_123', $tenantPackage->lemonsqueezy_subscription_id);
$this->assertTrue($tenantPackage->active);
$tenant->refresh();
$this->assertSame('active', $tenant->subscription_status);
$this->assertSame('cus_456', $tenant->paddle_customer_id);
$this->assertSame('cus_456', $tenant->lemonsqueezy_customer_id);
}
}