Custom HTTP adapter

By default the PHP SDK uses its default HTTP Client library i. e. php-curl. The SDK serializes the resource into JSON and sends it to the API endpoint. The response is parsed and de-serialized to update the original object respectively creating an object from the response data.

If an error occurs within the communication between SDK and API, a UnzerApiException is thrown. An error on the SDK side, results in a \RuntimeException.

If you prefer using a custom adapter, you can do so by implementing the HttpAdapterInterface and injecting it via setter into the Unzer object as shown in the example below.
namespace Your\Namespace;
use UnzerSDK\Adapter\HttpAdapterInterface;

class MyHttpAdapter implements HttpAdapterInterface
{
    public function init($url, $payload = null, $httpMethod = HttpAdapterInterface::REQUEST_GET);
   
    public function execute()
    {
        // ...
    }

    public function getResponseCode(): string
    {
        // ...
    }

    public function close()
    {
        // ...
    }

    public function setHeaders(array $headers)
    {
        // ...
    }

    public function setUserAgent($userAgent)
    {
        // ...
    }
}
$unzer = new UnzerSDK\Unzer('s-priv-xxxxxxxxxx');
$unzer->setAdapter(new My\Namespace\MyHttpAdapter());