Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### v4.25.2 (2026-08-18)
* * *
### Bug Fixes:
- HTTP methods are now uppercased before a request is constructed, so the SDK no longer emits deprecation notices from `guzzlehttp/psr7` 2.11+ (`Passing a non-uppercase HTTP method is deprecated`) or `guzzlehttp/guzzle` 7.11+. Both libraries preserve method casing in their next major versions, where a lowercase method would have been sent on the wire as-is.

### v4.25.1 (2026-08-11)
* * *
### Bug Fixes:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.25.1
4.25.2
6 changes: 3 additions & 3 deletions src/HttpClient/GuzzleFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function create(): \Psr\Http\Client\ClientInterface

public function createRequest(ChargebeePayload $chargebeePayload): \Psr\Http\Message\RequestInterface
{
$httpMethod = $chargebeePayload->getHttpMethod();
$httpMethod = strtolower($chargebeePayload->getHttpMethod());
$params = $chargebeePayload->getSerializedParameters();
$headers = $chargebeePayload->getHeaders();

Expand All @@ -54,7 +54,7 @@ public function createRequest(ChargebeePayload $chargebeePayload): \Psr\Http\Mes
$uri = new Uri($url);
$body = null;

if ($chargebeePayload->getHttpMethod() == "get") {
if ($httpMethod == "get") {
if (!empty($params)) {
$uri = $uri->withQuery($params);
}
Expand All @@ -63,7 +63,7 @@ public function createRequest(ChargebeePayload $chargebeePayload): \Psr\Http\Mes
if ($httpMethod == "post") {
$body = $params;
}
return new \GuzzleHttp\Psr7\Request($httpMethod, $uri, $headers, $body);
return new \GuzzleHttp\Psr7\Request(strtoupper($httpMethod), $uri, $headers, $body);
}

public static function utf8($value)
Expand Down
2 changes: 1 addition & 1 deletion src/HttpClient/PsrClientAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function create(): ClientInterface

public function createRequest(ChargebeePayload $payload): RequestInterface
{
$httpMethod = $payload->getHttpMethod();
$httpMethod = strtolower($payload->getHttpMethod());
$params = $payload->getSerializedParameters();
$headers = $payload->getHeaders();

Expand Down
2 changes: 1 addition & 1 deletion src/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

final class Version
{
const VERSION = '4.25.1';
const VERSION = '4.25.2';
}

?>
57 changes: 57 additions & 0 deletions tests/Network/GuzzleFactoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace Tests\Network;

use Chargebee\Environment;
use Chargebee\HttpClient\GuzzleFactory;
use Chargebee\ValueObjects\Transporters\ChargebeePayload;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase;

#[CoversClass(GuzzleFactory::class)]
final class GuzzleFactoryTest extends TestCase
{
private function makePayload(string $method, ?string $params = null): ChargebeePayload
{
$env = new Environment('test-site', 'test-api-key');
return new ChargebeePayload(
'https://example.com/api/v2/customers',
$method,
$params,
['Authorization' => 'Basic dGVzdA=='],
$env
);
}

#[TestDox('createRequest() builds a request with an uppercase HTTP method')]
#[DataProvider('httpMethodProvider')]
public function testCreateRequestUsesUppercaseHttpMethod(string $method, string $expected): void
{
$factory = new GuzzleFactory(10, 30);

$request = $factory->createRequest($this->makePayload($method, 'limit=10'));

$this->assertSame($expected, $request->getMethod());
}

public static function httpMethodProvider(): array
{
return [
'lowercase get' => ['get', 'GET'],
'lowercase post' => ['post', 'POST'],
'uppercase get' => ['GET', 'GET'],
'uppercase post' => ['POST', 'POST'],
];
}

#[TestDox('createRequest() rejects unsupported HTTP methods')]
public function testCreateRequestRejectsUnsupportedMethod(): void
{
$factory = new GuzzleFactory(10, 30);

$this->expectException(\Exception::class);
$factory->createRequest($this->makePayload('delete'));
}
}
4 changes: 2 additions & 2 deletions tests/Network/MockGuzzleFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function sendRequest(RequestInterface $request): ResponseInterface

public function createRequest(ChargebeePayload $chargebeePayload): RequestInterface
{
$httpMethod = $chargebeePayload->getHttpMethod();
$httpMethod = strtolower($chargebeePayload->getHttpMethod());
$params = $chargebeePayload->getSerializedParameters();
$headers = $chargebeePayload->getHeaders();

Expand All @@ -152,7 +152,7 @@ public function createRequest(ChargebeePayload $chargebeePayload): RequestInterf
$body = $params;
}

return new Request($httpMethod, $uri, $headers, $body);
return new Request(strtoupper($httpMethod), $uri, $headers, $body);
}

/**
Expand Down
Loading