Update PayPal references and tests

This commit is contained in:
Codex Agent
2026-02-04 12:43:40 +01:00
parent fc5dfb272c
commit 239f55f9c5
18 changed files with 655 additions and 729 deletions

View File

@@ -7,6 +7,7 @@ use Illuminate\Http\Client\Factory as HttpFactory;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Http\Client\RequestException;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
class LemonSqueezyClient
{
@@ -68,7 +69,7 @@ class LemonSqueezyClient
throw new LemonSqueezyException('Lemon Squeezy API key is not configured.');
}
$baseUrl = rtrim((string) config('lemonsqueezy.base_url'), '/');
$baseUrl = $this->normalizeBaseUrl((string) config('lemonsqueezy.base_url'));
return $this->http
->baseUrl($baseUrl)
@@ -81,4 +82,30 @@ class LemonSqueezyClient
->acceptJson()
->asJson();
}
protected function normalizeBaseUrl(string $baseUrl): string
{
$baseUrl = trim($baseUrl);
if ($baseUrl === '') {
$baseUrl = 'https://api.lemonsqueezy.com/v1';
}
if (! Str::startsWith($baseUrl, ['http://', 'https://'])) {
$baseUrl = 'https://api.lemonsqueezy.com/'.ltrim($baseUrl, '/');
}
$parsedHost = parse_url($baseUrl, PHP_URL_HOST);
if (! is_string($parsedHost) || $parsedHost === '' || ! Str::endsWith($parsedHost, 'lemonsqueezy.com')) {
$baseUrl = 'https://api.lemonsqueezy.com/v1';
}
$baseUrl = rtrim($baseUrl, '/');
if (! Str::endsWith($baseUrl, '/v1')) {
$baseUrl .= '/v1';
}
return $baseUrl;
}
}