Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4647 removing all deprecated code #50

Merged
merged 1 commit into from
Jul 13, 2023
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
24 changes: 0 additions & 24 deletions src/Model/CreatePaymentParams.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,27 +316,6 @@ public function addItem(CreatePaymentItem $item)
$this->items[] = $item;
}

/**
* @deprecated use $this->getSaveAuthorization()
*
* @return bool
*/
public function isRecurring()
{
return $this->getSaveAuthorization();
}

/**
* @deprecated use $this->setSaveAuthorization()
*
* @param bool $isRecurring
* @return void
*/
public function setIsRecurring($isRecurring)
{
$this->setSaveAuthorization($isRecurring);
}

/**
* @return bool
*/
Expand Down Expand Up @@ -372,8 +351,6 @@ public function setCanCustomerChangeMethod($canCustomerChangeMethod)
}

/**
* @deprecated 'is_recurring' key will be removed use 'save_authorization'
*
* @return array<string, mixed>
*/
public function toArray()
Expand Down Expand Up @@ -442,7 +419,6 @@ public function toArray()
$result['subscription'] = $this->subscription->toArray();
}

$result['is_recurring'] = $this->getSaveAuthorization();
$result['is_deposit'] = $this->isDeposit();

$result['save_authorization'] = $this->getSaveAuthorization();
Expand Down
29 changes: 0 additions & 29 deletions src/Model/PaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,6 @@

class PaymentMethod implements IPaymentMethod
{
/**
* @deprecated use ThePay\ApiClient\ValueObject\PaymentMethodTag::CARD
*/
public const TAG_CARD = 'card';
/**
* @deprecated use ThePay\ApiClient\ValueObject\PaymentMethodTag::ONLINE
*/
public const TAG_ONLINE = 'online';
/**
* @deprecated use ThePay\ApiClient\ValueObject\PaymentMethodTag::PRE_AUTHORIZATION
*/
public const TAG_PRE_AUTHORIZATION = 'pre_authorization';
/**
* @deprecated use ThePay\ApiClient\ValueObject\PaymentMethodTag::RETURNABLE
*/
public const TAG_RETURNABLE = 'returnable';
/**
* @deprecated use ThePay\ApiClient\ValueObject\PaymentMethodTag::ACCESS_ACCOUNT_OWNER
*/
public const TAG_ACCESS_ACOUNT_OWNER = 'access_account_owner';
/**
* @deprecated use ThePay\ApiClient\ValueObject\PaymentMethodTag::RECURRING_PAYMENTS
*/
public const TAG_RECURRING_PAYMENTS = 'recurring_payments';
/**
* @deprecated use ThePay\ApiClient\ValueObject\PaymentMethodTag::ALTERNATIVE_METHOD
*/
public const TAG_ALTERNATIVE_METHOD = 'alternative_method';

/** @var string */
private $code;

Expand Down
81 changes: 21 additions & 60 deletions src/Service/SignatureService.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,13 @@ class SignatureService
{
public const FORMAT_RFC7231 = 'D, d M Y H:i:s \G\M\T';

/** @var TheConfig */
private $config;
private TheConfig $config;

/**
* SignatureService constructor.
*
* @param TheConfig $config
*/
public function __construct(TheConfig $config)
{
$this->config = $config;
}

/**
* @deprecated this sign algorithm is not implemented in ThePay system anymore, will be removed
*
* @param string $query
* @return string
*/
public function signGateRequest($query)
{
$query = 'merchant_id=' . $this->config->getMerchantId() . $query;
return $this->getSignatureHashForQuery($query);
}

/**
* @throws \Exception
*/
Expand All @@ -51,42 +33,6 @@ public function getSignatureForApi(): ApiSignature
);
}

/**
* @deprecated method is used only in this service, the method will be private or removed
*
* @param array<string, mixed> $data
* @return string
*/
public function getBase64FromParameters(array $data)
{
$toEncode = $data;

$toEncode['merchant_id'] = $this->config->getMerchantId();
$toEncode['project_id'] = $this->config->getProjectId();

if (empty($toEncode['language_code'])) {
$toEncode['language_code'] = $this->config->getLanguage();
}

$toEncode = array_filter($toEncode, function ($entry) {
return $entry !== null;
});

return base64_encode(json_encode($toEncode));
}

/**
* @deprecated method is used only in this service, the method will be private or removed
*
* @param string $base64
*
* @return string
*/
public function getSignatureForBase64($base64)
{
return hash('sha256', $base64 . $this->config->getPassword());
}

/**
* @return SignedData
*/
Expand Down Expand Up @@ -117,14 +63,29 @@ public function getSignedDataForGate(CreatePaymentParams $params)
);
}

private function getSignatureForBase64(string $base64): string
{
return hash('sha256', $base64 . $this->config->getPassword());
}

/**
* @param string $query
* @return string
* @param array<string, mixed> $data
*/
private function getSignatureHashForQuery($query)
private function getBase64FromParameters(array $data): string
{
$query .= '&password=' . $this->config->getPassword();
$toEncode = $data;

return hash('sha256', $query);
$toEncode['merchant_id'] = $this->config->getMerchantId();
$toEncode['project_id'] = $this->config->getProjectId();

if (empty($toEncode['language_code'])) {
$toEncode['language_code'] = $this->config->getLanguage();
}

$toEncode = array_filter($toEncode, function ($entry) {
return $entry !== null;
});

return base64_encode(json_encode($toEncode));
}
}
8 changes: 4 additions & 4 deletions tests/CreatePaymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ public static function createButtonProvider(): array
return [
[
new CreatePaymentParams(100, 'CZK', '202001010001'),
'eyJhbW91bnQiOjEwMCwiY3VycmVuY3lfY29kZSI6IkNaSyIsInVpZCI6IjIwMjAwMTAxMDAwMSIsImxhbmd1YWdlX2NvZGUiOiJjcyIsImlzX3JlY3VycmluZyI6ZmFsc2UsImlzX2RlcG9zaXQiOnRydWUsInNhdmVfYXV0aG9yaXphdGlvbiI6ZmFsc2UsImNhbl9jdXN0b21lcl9jaGFuZ2VfbWV0aG9kIjp0cnVlLCJtZXJjaGFudF9pZCI6Ijg2YTNlZWQwLTk1YTQtMTFlYS1hYzlmLTM3MWYzNDg4ZTBmYSIsInByb2plY3RfaWQiOjF9',
'99e8b5f1bb32cd6937af1ebbcc7d3b337b7f5524f244a5d694c930afef1a16a9',
'eyJhbW91bnQiOjEwMCwiY3VycmVuY3lfY29kZSI6IkNaSyIsInVpZCI6IjIwMjAwMTAxMDAwMSIsImxhbmd1YWdlX2NvZGUiOiJjcyIsImlzX2RlcG9zaXQiOnRydWUsInNhdmVfYXV0aG9yaXphdGlvbiI6ZmFsc2UsImNhbl9jdXN0b21lcl9jaGFuZ2VfbWV0aG9kIjp0cnVlLCJtZXJjaGFudF9pZCI6Ijg2YTNlZWQwLTk1YTQtMTFlYS1hYzlmLTM3MWYzNDg4ZTBmYSIsInByb2plY3RfaWQiOjF9',
Triplkrypl marked this conversation as resolved.
Show resolved Hide resolved
'1b3e432dec35da90a62653e2cb8ce2d75e4204a32d360c6366afd24509f5178c',
],
[
new CreatePaymentParams(100, 'EUR', '202001010002'),
'eyJhbW91bnQiOjEwMCwiY3VycmVuY3lfY29kZSI6IkVVUiIsInVpZCI6IjIwMjAwMTAxMDAwMiIsImxhbmd1YWdlX2NvZGUiOiJjcyIsImlzX3JlY3VycmluZyI6ZmFsc2UsImlzX2RlcG9zaXQiOnRydWUsInNhdmVfYXV0aG9yaXphdGlvbiI6ZmFsc2UsImNhbl9jdXN0b21lcl9jaGFuZ2VfbWV0aG9kIjp0cnVlLCJtZXJjaGFudF9pZCI6Ijg2YTNlZWQwLTk1YTQtMTFlYS1hYzlmLTM3MWYzNDg4ZTBmYSIsInByb2plY3RfaWQiOjF9',
'03e61b053d5b0ccd17a2913a5b005e35fd499b74472adec92e792eecdd123895',
'eyJhbW91bnQiOjEwMCwiY3VycmVuY3lfY29kZSI6IkVVUiIsInVpZCI6IjIwMjAwMTAxMDAwMiIsImxhbmd1YWdlX2NvZGUiOiJjcyIsImlzX2RlcG9zaXQiOnRydWUsInNhdmVfYXV0aG9yaXphdGlvbiI6ZmFsc2UsImNhbl9jdXN0b21lcl9jaGFuZ2VfbWV0aG9kIjp0cnVlLCJtZXJjaGFudF9pZCI6Ijg2YTNlZWQwLTk1YTQtMTFlYS1hYzlmLTM3MWYzNDg4ZTBmYSIsInByb2plY3RfaWQiOjF9',
'b97e2a7c037c5d31a7db734d1ca84e06f53db5841fe9e56bdc701a833208f987',
],
];
}
Expand Down
3 changes: 0 additions & 3 deletions tests/TheClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
use ThePay\ApiClient\Service\ApiServiceInterface;
use ThePay\ApiClient\TheClient;

/**
* @deprecated Remove when tests will be splitted
*/
class TheClientTest extends BaseTestCase
{
public function testPaymentMethods(): void
Expand Down