Migrate billing from Paddle to Lemon Squeezy
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

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

View File

@@ -3,7 +3,7 @@
namespace Tests\Unit;
use App\Services\GiftVouchers\GiftVoucherCheckoutService;
use App\Services\Paddle\PaddleClient;
use App\Services\LemonSqueezy\LemonSqueezyCheckoutService;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Mockery;
use Tests\TestCase;
@@ -15,8 +15,8 @@ class GiftVoucherCheckoutServiceTest extends TestCase
public function test_it_lists_tiers_with_checkout_flag(): void
{
config()->set('gift-vouchers.tiers', [
['key' => 'gift-a', 'label' => 'A', 'amount' => 10, 'currency' => 'EUR', 'paddle_price_id' => 'pri_a'],
['key' => 'gift-b', 'label' => 'B', 'amount' => 20, 'currency' => 'EUR', 'paddle_price_id' => null],
['key' => 'gift-a', 'label' => 'A', 'amount' => 10, 'currency' => 'EUR', 'lemonsqueezy_variant_id' => 'pri_a'],
['key' => 'gift-b', 'label' => 'B', 'amount' => 20, 'currency' => 'EUR', 'lemonsqueezy_variant_id' => null],
]);
$service = $this->app->make(GiftVoucherCheckoutService::class);
@@ -31,26 +31,23 @@ class GiftVoucherCheckoutServiceTest extends TestCase
public function test_it_creates_checkout_link_with_metadata(): void
{
config()->set('gift-vouchers.tiers', [
['key' => 'gift-a', 'label' => 'A', 'amount' => 10, 'currency' => 'EUR', 'paddle_price_id' => 'pri_a'],
['key' => 'gift-a', 'label' => 'A', 'amount' => 10, 'currency' => 'EUR', 'lemonsqueezy_variant_id' => 'pri_a'],
]);
$client = Mockery::mock(PaddleClient::class);
$client->shouldReceive('post')
$checkoutService = Mockery::mock(LemonSqueezyCheckoutService::class);
$checkoutService->shouldReceive('createVariantCheckout')
->once()
->with('/customers', Mockery::on(function ($payload) {
return $payload['email'] === 'buyer@example.com';
}))
->andReturn(['data' => ['id' => 'ctm_123']]);
$client->shouldReceive('post')
->once()
->with('/transactions', Mockery::on(function ($payload) {
return $payload['items'][0]['price_id'] === 'pri_a'
&& $payload['customer_id'] === 'ctm_123'
&& $payload['custom_data']['type'] === 'gift_voucher';
}))
->andReturn(['data' => ['checkout' => ['url' => 'https://paddle.test/checkout/123'], 'id' => 'txn_123']]);
->with('pri_a', Mockery::on(function (array $customData) {
return ($customData['type'] ?? null) === 'gift_voucher'
&& ($customData['tier_key'] ?? null) === 'gift-a'
&& ($customData['purchaser_email'] ?? null) === 'buyer@example.com'
&& ($customData['recipient_email'] ?? null) === 'friend@example.com'
&& ($customData['recipient_name'] ?? null) === 'Friend'
&& ($customData['message'] ?? null) === 'Hi';
}), Mockery::type('array'))
->andReturn(['checkout_url' => 'https://lemonsqueezy.test/checkout/123', 'id' => 'chk_123']);
$this->app->instance(PaddleClient::class, $client);
$this->app->instance(LemonSqueezyCheckoutService::class, $checkoutService);
$service = $this->app->make(GiftVoucherCheckoutService::class);
@@ -62,7 +59,7 @@ class GiftVoucherCheckoutServiceTest extends TestCase
'message' => 'Hi',
]);
$this->assertSame('https://paddle.test/checkout/123', $checkout['checkout_url']);
$this->assertSame('txn_123', $checkout['id']);
$this->assertSame('https://lemonsqueezy.test/checkout/123', $checkout['checkout_url']);
$this->assertSame('chk_123', $checkout['id']);
}
}