v2.0.0
⚠ Break changes ⚠
Hear ye, hear ye!
This is a new major version v2.0.0 of our api-client. This package uses Semantic Versioning, which means a major version is released only when there are breaking changes present. If you are upgrading your integration from v1.* to the v2.0.0 version, you must update your code accordingly, to accomodate these breaking changes. We recommend using Phpstan, Psalm or a similar static analyzer for automated detection of such changes.
Following is the list of changes in the interface:
PHP requirement change
You must upgrade your PHP version to 7.4 or higher!
We use new PHP syntax (which is really cute 😍), so we highly recommend you try it out as well!
New composer packages requirement
The class ThePay\ApiClient\Exception\CurlException
and all classes in namespace ThePay\ApiClient\Http
were removed and replaced with composer packages psr/http-client, psr/http-factory, psr/http-message (PSR interfaces). This will reduce the overall maintenance of HTTP communication in the future.
You must use some form of PSR-18 implementation. If you do not use any yet, we suggest the composer package Guzzle:
composer require guzzlehttp/guzzle
Example usage is shown further below.
TheClient and ApiService interface changes
The constructors for \ThePay\ApiClient\Service\ApiService
and for the main class \ThePay\ApiClient\TheClient
were changed due to the usage of PSR.
You must update the creation of TheClient instance in your integration and inject some PSR HTTP client implementation into TheClient dependencies.
From old code:
/** @var \ThePay\ApiClient\TheConfig $theConfig */
$thePayClient = new TheClient($theConfig);
To new code:
/** @var \ThePay\ApiClient\TheConfig $theConfig */
$signatureService = new \ThePay\ApiClient\Service\SignatureService($theConfig);
/** @var \Psr\Http\Client\ClientInterface $httpClient some PSR-18 implementation */
/** @var \Psr\Http\Message\RequestFactoryInterface $requestFactory some PSR-17 implementation */
/** @var \Psr\Http\Message\StreamFactoryInterface $streamFactory some PSR-17 implementation */
// if you install suggested guzzle implementation you can use this:
// $httpClient = new \GuzzleHttp\Client();
// $requestFactory = $streamFactory = new \GuzzleHttp\Psr7\HttpFactory();
$apiService = new \ThePay\ApiClient\Service\ApiService(
$theConfig,
$signatureService,
$httpClient,
$requestFactory,
$streamFactory
);
$thePayClient = new \ThePay\ApiClient\TheClient(
$theConfig,
$apiService
);
ApiService, ApiServiceInterface and TheClient were also changed - either method parameters or the return type might now have more concrete definition. For example int
changed into int<1, max>
or string
into non-empty-string
, StringValue
into native string
etc.
You should check your TheClient methods calls, if you pass the exact types and correct values. Otherwise the SDK could throw some new Exceptions.
Changed method list:
\ThePay\ApiClient\Service\ApiServiceInterface::getPayments
\ThePay\ApiClient\Service\ApiServiceInterface::getAccountTransactionHistory
\ThePay\ApiClient\Service\ApiServiceInterface::createPayment
\ThePay\ApiClient\Service\ApiServiceInterface::changePaymentMethod
\ThePay\ApiClient\Service\ApiServiceInterface::createPaymentRefund
\ThePay\ApiClient\Service\ApiService::getPayments
\ThePay\ApiClient\Service\ApiService::getAccountTransactionHistory
\ThePay\ApiClient\Service\ApiService::createPayment
\ThePay\ApiClient\Service\ApiService::changePaymentMethod
\ThePay\ApiClient\Service\ApiService::createPaymentRefund
\ThePay\ApiClient\TheClient::createPayment
\ThePay\ApiClient\TheClient::changePaymentMethod
\ThePay\ApiClient\TheClient::realizePreauthorizedPayment
\ThePay\ApiClient\TheClient::cancelPreauthorizedPayment
\ThePay\ApiClient\TheClient::generatePaymentConfirmationPdf
Removed methods and classes
We removed some functionality which was no longer needed or could potentionally lead into wrong usage of our SDK. For example, in the past, the enum of payment methods was often used as method list instead of call API endpoint TheClient::getActivePaymentMethods
, which woudn't give you an up to date method list in case of their update (which happens frequently).
The full list of affected classes:
\ThePay\ApiClient\Filter\PaymentsFilter
\ThePay\ApiClient\Model\CreatePaymentParams
\ThePay\ApiClient\Model\PaymentMethod
\ThePay\ApiClient\Service\SignatureService
\ThePay\ApiClient\ValueObject\PaymentMethodCode
You must find the usage of removed methods or classes in your integration and resolve them in accordance to the changes. A few examples:
\ThePay\ApiClient\ValueObject\PaymentMethodCode
was completely removed. Just change the type into non-empty-string
as seen in the \ThePay\ApiClient\Filter\PaymentsFilter::__construct
parameter.
From old code:
function someMethod(\ThePay\ApiClient\ValueObject\PaymentMethodCode $methodCode): void
To new code:
/**
* @param non-empty-string $methodCode
*/
function someMethod(string $methodCode): void
From \ThePay\ApiClient\Model\CreatePaymentParams
the isRecurring
and setIsRecurring
methods were removed. We changed the naming convention from recurring payments into save authorization, as it better represents the real business usage of those methods. Again, it can be resolved just by calling the new methods as shown in the following example.
From old code:
/** @var \ThePay\ApiClient\Model\CreatePaymentParams $params */
$params->setIsRecurring(true);
$params->isRecurring();
To new code:
/** @var \ThePay\ApiClient\Model\CreatePaymentParams $params */
$params->setSaveAuthorization(true);
$params->getSaveAuthorization();
In \ThePay\ApiClient\Model\PaymentMethod
the TAG_*
constants were removed. This was an unnecessary duplication, since these tags already exist in the \ThePay\ApiClient\ValueObject\PaymentMethodTag
enum.
From old code:
$tagCard = \ThePay\ApiClient\Model\PaymentMethod::TAG_CARD;
To new code:
$tagCard = \ThePay\ApiClient\ValueObject\PaymentMethodTag::CARD;
\ThePay\ApiClient\Service\SignatureService
contained some unused functionality, which was removed. The following methods are not present anymore.
Removed methods: signGateRequest
, getBase64FromParameters
, getSignatureForBase64
What's Changed
- v1.x -> v2.x by @Triplkrypl in #43
- 1951 old PHP sintax removed from fixer rules by @Triplkrypl in #45
- deprecated php versions removed and phpunit update by @Triplkrypl in #44
- 4648 PaymentMethodCode enum removed by @Triplkrypl in #46
- v1.x -> v2.x by @Triplkrypl in #48
- 4650 ThePay\ApiClient\Http replaced by PSR standarts by @Triplkrypl in #49
- 4647 removing all deprecated code by @Triplkrypl in #50
- 4651 all todos are resolved by @Triplkrypl in #51
- V2.x 4729 merge v1.x by @Triplkrypl in #53
- V2.x 4729 merge v1.x by @Triplkrypl in #57
- Version update to 2.0.0 by @Triplkrypl in #58
Full Changelog: v1.7.0...v2.0.0