Skip to content

Commit

Permalink
Merge pull request #107 from bold-commerce/CHK-6253
Browse files Browse the repository at this point in the history
CHK-6253: Added additional logging PaymentBoosterConfigProvider.php and added r…
  • Loading branch information
DanielNordstrom authored Nov 1, 2024
2 parents f37f86a + d980324 commit f9f83a7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
26 changes: 25 additions & 1 deletion UI/PaymentBoosterConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Magento\Directory\Model\Country;
use Magento\Directory\Model\ResourceModel\Country\CollectionFactory;
use Magento\Config\Model\Config\Source\Nooptreq as NooptreqSource;
use Psr\Log\LoggerInterface;

/**
* Config provider for Payment Booster.
Expand All @@ -37,6 +38,11 @@ class PaymentBoosterConfigProvider implements ConfigProviderInterface
*/
private $collectionFactory;

/**
* @var LoggerInterface
*/
private $logger;

/**
* @var array
*/
Expand All @@ -52,12 +58,14 @@ public function __construct(
CheckoutData $checkoutData,
Config $config,
AllowedCountries $allowedCountries,
CollectionFactory $collectionFactory
CollectionFactory $collectionFactory,
LoggerInterface $logger
) {
$this->checkoutData = $checkoutData;
$this->config = $config;
$this->allowedCountries = $allowedCountries;
$this->collectionFactory = $collectionFactory;
$this->logger = $logger;
}

/**
Expand All @@ -66,6 +74,8 @@ public function __construct(
public function getConfig(): array
{
if (!$this->checkoutData->getPublicOrderId()) {
$errorMsg = "No public order ID.";
$this->logger->critical('Error in PaymentBoosterConfigProvider->getConfig(): '.$errorMsg);
return [];
}

Expand All @@ -77,6 +87,20 @@ public function getConfig(): array
$epsAuthToken = $this->checkoutData->getEpsAuthToken();
$epsGatewayId = $this->checkoutData->getEpsGatewayId();
if ($jwtToken === null || $epsAuthToken === null || $epsGatewayId === null) {
$errorMsgs = [];
if ($jwtToken === null) {
$errorMsgs[] = '$jwtToken is null.';
}

if ($epsAuthToken === null) {
$errorMsgs[] = '$epsAuthToken is null.';
}

if ($epsGatewayId === null) {
$errorMsgs[] = '$epsGatewayId is null.';
}

$this->logger->critical('Error in PaymentBoosterConfigProvider->getConfig(): '.implode(', ', $errorMsgs));
return [];
}
return [
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"magento/module-quote": ">=101.1.1 <101.2.8",
"magento/module-store": ">=101.0.1 <101.1.8"
},
"replace": {
"bold-commerce/module-checkout":"*"
},
"autoload": {
"files": [
"registration.php"
Expand Down

0 comments on commit f9f83a7

Please sign in to comment.