Skip to content

Commit

Permalink
release v2.3.0 (#30)
Browse files Browse the repository at this point in the history
* PLUG-131: PHPStan (#26)
* PLUG-152: Add release channel config option (#29)
* PLUG-151: Settings visibility 

---------

Co-authored-by: artyom-jaksov-tl <[email protected]>
  • Loading branch information
lighe and artyom-jaksov-tl authored Sep 26, 2024
1 parent 5bc230d commit ea749b5
Show file tree
Hide file tree
Showing 26 changed files with 198 additions and 85 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
- name: Create branch for Composer and remove version from composer.json
run: git checkout -b continuous-integration-test-branch && sed -i '/version/d' ./composer.json

- name: Remove PHPStan duplicate include
run: sed -i '/vendor\/bitexpert/d' ./phpstan.neon

- name: Upload our code into the docker container
run: docker cp $(pwd) magento-project-community-edition:/data/extensions/

Expand Down
10 changes: 10 additions & 0 deletions Api/Config/System/SettingInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface SettingInterface
public const XML_PATH_SEND_ORDER_EMAIL = 'payment/truelayer/send_order_email';
public const XML_PATH_SEND_INVOICE_EMAIL = 'payment/truelayer/send_invoice_email';
public const XML_PATH_BANKING_PROVIDERS = 'payment/truelayer/banking_providers';
public const XML_PATH_RELEASE_CHANNEL = 'payment/truelayer/release_channel';
public const XML_PATH_PAYMENT_PAGE_PRIMARY_COLOR = 'payment/truelayer/payment_page_primary_color';
public const XML_PATH_PAYMENT_PAGE_SECONDARY_COLOR = 'payment/truelayer/payment_page_secondary_color';
public const XML_PATH_PAYMENT_PAGE_TERTIARY_COLOR = 'payment/truelayer/payment_page_tertiary_color';
Expand Down Expand Up @@ -48,6 +49,15 @@ public function getMaximumOrderTotal(): float;
*/
public function getBankingProviders(?int $storeId = null): array;

/**
* Get associated array of credentials
*
* @param int|null $storeId
*
* @return string
*/
public function getReleaseChannel(?int $storeId = null): string;

/**
* Get payment page primary color
*
Expand Down
4 changes: 2 additions & 2 deletions Api/Log/LogServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ interface LogServiceInterface
* @param string $type
* @param mixed $data
*/
public function error(string $type, $data): LogServiceInterface;
public function error(string $type, $data = ''): LogServiceInterface;

/**
* Add record to debug log
*
* @param string $type
* @param mixed $data
*/
public function debug(string $type, $data): LogServiceInterface;
public function debug(string $type, $data = ''): LogServiceInterface;

/**
* @param string|int $prefix
Expand Down
8 changes: 4 additions & 4 deletions Block/Adminhtml/System/Config/Button/Credentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ public function getApiCheckUrl(): string
public function getButtonHtml(): string
{
try {
return $this->getLayout()
->createBlock(Button::class)
->setData(['id' => 'truelayer-button_credentials', 'label' => __('Check Credentials')])
->toHtml();
/** @var \Magento\Framework\View\Element\AbstractBlock $block */
$block = $this->getLayout()->createBlock(Button::class);
$block->setData(['id' => 'truelayer-button_credentials', 'label' => __('Check Credentials')]);
return $block->toHtml();
} catch (Exception $e) {
$this->logger->error('Credentials check', $e->getMessage());
return '';
Expand Down
13 changes: 7 additions & 6 deletions Block/Adminhtml/System/Config/Button/DebugCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ public function getDebugCheckUrl(): string
public function getButtonHtml(): string
{
try {
return $this->getLayout()
->createBlock(Button::class)
->setData([
'id' => 'truelayer-button_debug',
'label' => __('Check last 100 debug log records')
])->toHtml();
/** @var \Magento\Framework\View\Element\AbstractBlock $block */
$block = $this->getLayout()->createBlock(Button::class);
$block->setData([
'id' => 'truelayer-button_debug',
'label' => __('Check last 100 debug log records')
]);
return $block->toHtml();
} catch (Exception $e) {
return '';
}
Expand Down
13 changes: 7 additions & 6 deletions Block/Adminhtml/System/Config/Button/ErrorCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@ public function getErrorCheckUrl(): string
public function getButtonHtml(): string
{
try {
return $this->getLayout()
->createBlock(Button::class)
->setData([
'id' => 'truelayer-button_error',
'label' => __('Check last 100 error log records')
])->toHtml();
/** @var \Magento\Framework\View\Element\AbstractBlock $block */
$block = $this->getLayout()->createBlock(Button::class);
$block->setData([
'id' => 'truelayer-button_error',
'label' => __('Check last 100 error log records')
]);
return $block->toHtml();
} catch (Exception $e) {
return '';
}
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v2.3.0] - 2024-09-20

### Added

- Release channel configuration option
- Fix settings visibility based on scopes

### Changed

- Stricter PHPStan rules

## [v2.2.0] - 2024-09-02

### Added
Expand Down
1 change: 0 additions & 1 deletion Gateway/Command/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ protected function getOrder(array $subject): OrderInterface

/**
* @param array $subject
* @return mixed
*/
abstract protected function executeCommand(array $subject): void;
}
34 changes: 34 additions & 0 deletions Model/Config/Source/ReleaseChannel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* Copyright © TrueLayer Ltd. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace TrueLayer\Connect\Model\Config\Source;

use Magento\Framework\Data\OptionSourceInterface;

/**
* ReleaseChannel Options Source model
*/
class ReleaseChannel implements OptionSourceInterface
{
public const GENERAL_AVAILABILITY = 'general_availability';
public const PUBLIC_BETA = 'public_beta';
public const PRIVATE_BETA = 'private_beta';

/**
* Returns mode option source array
*
* @return array
*/
public function toOptionArray(): array
{
return [
['value' => self::GENERAL_AVAILABILITY, 'label' => __('General Availability')],
['value' => self::PUBLIC_BETA, 'label' => __('Public Beta')],
['value' => self::PRIVATE_BETA, 'label' => __('Private Beta')]
];
}
}
9 changes: 9 additions & 0 deletions Model/Config/System/SettingsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace TrueLayer\Connect\Model\Config\System;

use TrueLayer\Connect\Api\Config\System\SettingInterface;
use TrueLayer\Connect\Model\Config\Source\ReleaseChannel;

/**
* Debug provider class
Expand Down Expand Up @@ -43,6 +44,14 @@ public function getBankingProviders(?int $storeId = null): array
}
}

/**
* @inheritDoc
*/
public function getReleaseChannel(?int $storeId = null): string
{
return $this->getStoreValue(self::XML_PATH_RELEASE_CHANNEL, $storeId) ?: ReleaseChannel::GENERAL_AVAILABILITY;
}

/**
* @inheritDoc
*/
Expand Down
26 changes: 20 additions & 6 deletions Model/Transaction/Payment/PaymentTransactionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function create(): PaymentTransactionDataInterface

/**
* @inheritDoc
* @return PaymentTransactionDataModel
*/
public function get(int $entityId): PaymentTransactionDataInterface
{
Expand All @@ -64,12 +65,16 @@ public function get(int $entityId): PaymentTransactionDataInterface
$exceptionMsg = self::NO_SUCH_ENTITY_EXCEPTION;
throw new NoSuchEntityException(__($exceptionMsg, $entityId));
}
return $this->dataFactory->create()
->load($entityId);

/** @var PaymentTransactionDataModel $transaction */
$transaction = $this->dataFactory->create();
$this->resource->load($transaction, $entityId);
return $transaction;
}

/**
* @inheritDoc
* @return PaymentTransactionDataModel
*/
public function getByOrderId(int $orderId): PaymentTransactionDataInterface
{
Expand All @@ -79,12 +84,16 @@ public function getByOrderId(int $orderId): PaymentTransactionDataInterface
} elseif (!$this->resource->isOrderIdExists($orderId)) {
throw new NoSuchEntityException(__('No record found for OrderID: %1.', $orderId));
}
return $this->dataFactory->create()
->load($orderId, 'order_id');

/** @var PaymentTransactionDataModel $transaction */
$transaction = $this->dataFactory->create();
$this->resource->load($transaction, $orderId, 'order_id');
return $transaction;
}

/**
* @inheritDoc
* @return PaymentTransactionDataModel
*/
public function getByPaymentUuid(string $uuid): PaymentTransactionDataInterface
{
Expand All @@ -95,12 +104,17 @@ public function getByPaymentUuid(string $uuid): PaymentTransactionDataInterface
throw new NoSuchEntityException(__('No record found for uuid: %1.', $uuid));
}

return $this->dataFactory->create()
->load($uuid, 'uuid');
$transaction = $this->dataFactory->create();
/** @var PaymentTransactionDataModel $transaction */
$this->resource->load($transaction, $uuid, 'uuid');
return $transaction;

}

/**
* @inheritDoc
* @param PaymentTransactionDataModel $entity
* @return PaymentTransactionDataModel
*/
public function save(PaymentTransactionDataInterface $entity): PaymentTransactionDataInterface
{
Expand Down
3 changes: 3 additions & 0 deletions Model/Transaction/Refund/RefundCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;

/**
* @method RefundTransactionDataModel getFirstItem()
*/
class RefundCollection extends AbstractCollection
{
/**
Expand Down
11 changes: 7 additions & 4 deletions Model/Transaction/Refund/RefundTransactionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public function getByCreditMemoId(int $id): RefundTransactionDataInterface

/**
* @inheritDoc
* @param \TrueLayer\Connect\Model\Transaction\Refund\RefundTransactionDataModel $entity
*/
public function save(RefundTransactionDataInterface $entity): RefundTransactionDataInterface
{
Expand All @@ -116,13 +117,14 @@ public function save(RefundTransactionDataInterface $entity): RefundTransactionD
/**
* @param string $col
* @param $value
* @return RefundTransactionDataInterface
* @return RefundTransactionDataModel
* @throws NoSuchEntityException
*/
private function getByColumn(string $col, $value): RefundTransactionDataInterface
{
/** @var RefundTransactionDataInterface $transaction */
$transaction = $this->dataFactory->create()->load($value, $col);
/** @var RefundTransactionDataModel $transaction */
$transaction = $this->dataFactory->create();
$this->resource->load($transaction, $value, $col);

if (!$transaction->getEntityId()) {
$this->logger->error('Refund transaction not found', $value);
Expand All @@ -135,10 +137,11 @@ private function getByColumn(string $col, $value): RefundTransactionDataInterfac
/**
* @param array $cols
* @param array $sort
* @return RefundTransactionDataInterface
* @return RefundTransactionDataModel
*/
public function getOneByColumns(array $cols, array $sort = []): RefundTransactionDataInterface
{

$collection = $this->collectionFactory->create();

foreach ($cols as $col => $value) {
Expand Down
2 changes: 1 addition & 1 deletion Model/Ui/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(
/**
* Get config
*
* @return \array[][]
* @return array{payment:array{truelayer:array{description:string|null}}}
*/
public function getConfig(): array
{
Expand Down
2 changes: 1 addition & 1 deletion Model/User/ResourceModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function set(string $email, string $userId): bool
}

/**
* @param string $uuid
* @param string $userId
* @return mixed
*/
public function getByTruelayerId(string $userId)
Expand Down
2 changes: 1 addition & 1 deletion Plugin/Payment/MethodList.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(
/**
* @param Subject $subject
* @param $availableMethods
* @param CartInterface|null $quote
* @param \Magento\Quote\Model\Quote|null $quote
* @return mixed
*/
public function afterGetAvailableMethods(
Expand Down
Loading

0 comments on commit ea749b5

Please sign in to comment.