Skip to content

Releases: ThePay/api-client

v2.1.0

27 Feb 12:06
1ae5de9
Compare
Choose a tag to compare

What's Changed

Non final class ThePay\ApiClient\Model\SimplePayment has new method getCard returning information about PaymentCard if payment was paid by method with PaymentMethodTag card.

Full Changelog: v2.0.0...v2.1.0

v2.0.0

28 Aug 12:53
d1de343
Compare
Choose a tag to compare

⚠ 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

Full Changelog: v1.7.0...v2.0.0

v1.7.0

17 Aug 09:49
8e94f74
Compare
Choose a tag to compare

What's Changed

Full Changelog: v1.6.0...v1.7.0

v1.6.0

30 Mar 09:32
928fda0
Compare
Choose a tag to compare

What's Changed

Full Changelog: v1.5.1...v1.6.0

v1.5.1

12 Oct 10:25
df83110
Compare
Choose a tag to compare

What's Changed

Full Changelog: v1.5.0...v1.5.1

v1.5.0

06 Oct 13:31
9f39e41
Compare
Choose a tag to compare

What's Changed

Full Changelog: v1.4.3...v1.5.0

v1.4.3

12 Sep 10:37
beb32e7
Compare
Choose a tag to compare

What's Changed

Full Changelog: v1.4.2...v1.4.3

v1.4.2

31 Aug 11:13
8f22968
Compare
Choose a tag to compare

What's Changed

Full Changelog: v1.4.1...v1.4.2

v1.4.1

29 Aug 12:32
0d69ccd
Compare
Choose a tag to compare

Merge pull request #22 from ThePay/1951-update-version-for-bugfix-release

VERSION constant update

v1.4

20 May 10:23
3f747a3
Compare
Choose a tag to compare
Merge pull request #15 from ThePay/v1.x-spring1

V1.x spring backup because, v1.x-spring original branch is complete fuck-up