Skip to content

Commit

Permalink
Updated module warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
BitcoinMitchell committed Feb 19, 2024
1 parent 0367537 commit eda842f
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions modules/btcpay/btcpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ public function __construct()
$this->configuration = new Configuration();
$this->versioning = new Versioning();

// Process any and all warnings
$this->warnings();
// Process any and all alerts/warnings
$this->displayModuleWarnings();
}

public function install(): bool
Expand Down Expand Up @@ -515,23 +515,16 @@ private function getRepository(): ?BitcoinPaymentRepository
return $this->repository;
}

private function warnings(): void
private function displayModuleWarnings(): void
{
$warnings = [];

// Show alert if API key is missing
if (empty($this->configuration->get(Constants::CONFIGURATION_BTCPAY_API_KEY))) {
$warnings[] = $this->trans('No BTCPay Server store has been linked yet', [], 'Modules.Btcpay.Admin');
}

// Show alert for version upgrade
if (null !== ($latest = $this->versioning->latest()) && $latest->newer($this->version)) {
$warnings[] = $this->trans(\sprintf('There is a new version available for %s (%s).', $this->displayName, $latest->getTagName()), [], 'Modules.Btcpay.Admin');
}

$this->warning = \implode(' - ', $warnings);
foreach ($warnings as $warning) {
$this->adminDisplayWarning($warning);
// Try and create the client
$client = Client::createFromConfiguration($this->configuration);

// Show warning if API key is missing or if the we are not yet fully synced
if (null === $client || empty($this->configuration->get(Constants::CONFIGURATION_BTCPAY_API_KEY))) {
$this->warning = $this->trans('Your BTCPay Server store has not yet been linked, payment option is unavailable.', [], 'Modules.Btcpay.Admin');
} elseif (!$client->server()->getInfo()->isFullySynced()) {
$this->warning = $this->trans('One (or more) coins are not yet synced, payment option will be unavailable until the sync has finished.', [], 'Modules.Btcpay.Admin');
}
}
}

0 comments on commit eda842f

Please sign in to comment.