diff --git a/controllers/admin/AdminSaferPayOfficialSettingsController.php b/controllers/admin/AdminSaferPayOfficialSettingsController.php index 71ffd95e..0e5883c4 100755 --- a/controllers/admin/AdminSaferPayOfficialSettingsController.php +++ b/controllers/admin/AdminSaferPayOfficialSettingsController.php @@ -40,6 +40,7 @@ use Invertus\SaferPay\Service\SaferPayRestrictionCreator; use Invertus\SaferPay\Exception\Api\SaferPayApiException; use Invertus\SaferPay\Exception\Restriction\RestrictionException; +use Invertus\SaferPay\Logger\LoggerInterface; require_once dirname(__FILE__) . '/../../vendor/autoload.php'; @@ -209,8 +210,8 @@ public function ajaxProcessSaveCredentials() // Auto-detect license features from Saferpay Management API $suffix = $isTestMode ? SaferPayConfig::TEST_SUFFIX : ''; - $licenseMessage = ''; $hasBusinessLicense = false; + $licenseFetchFailed = false; if (!empty($activeUsername) && !empty($activePassword) && !empty($activeCustomerId)) { try { @@ -227,18 +228,28 @@ public function ajaxProcessSaveCredentials() $configuration->set(SaferPayConfig::BUSINESS_LICENSE . $suffix, $hasBusinessLicense ? 1 : 0); } catch (\Exception $e) { $configuration->set(SaferPayConfig::BUSINESS_LICENSE . $suffix, 0); + $licenseFetchFailed = true; - $licenseMessage = ' ' . $this->module->l('Could not retrieve license information. Please verify your credentials.', self::FILE_NAME); + /** @var LoggerInterface $logger */ + $logger = $this->module->getService(LoggerInterface::class); + $logger->error('License fetch failed on credentials save: ' . $e->getMessage(), [ + 'context' => ['exception_class' => get_class($e)], + ]); } } else { $configuration->set(SaferPayConfig::BUSINESS_LICENSE . $suffix, 0); } + $message = $licenseFetchFailed + ? $this->module->l('Settings saved, but Saferpay Fields availability could not be confirmed. Please try again later or check the module Logs for details.', self::FILE_NAME) + : $this->module->l('Settings saved successfully.', self::FILE_NAME); + $this->ajaxResponse( true, - $this->module->l('Settings saved successfully.', self::FILE_NAME) . $licenseMessage, + $message, [ 'hasBusinessLicense' => $hasBusinessLicense, + 'warning' => $licenseFetchFailed, ] ); } diff --git a/views/js/admin/settings-app/src/components/settings/toast-container.tsx b/views/js/admin/settings-app/src/components/settings/toast-container.tsx index 39d96074..0b5f905d 100644 --- a/views/js/admin/settings-app/src/components/settings/toast-container.tsx +++ b/views/js/admin/settings-app/src/components/settings/toast-container.tsx @@ -15,7 +15,9 @@ export function ToastContainer() { className={`sp-rounded-lg sp-border sp-px-4 sp-py-3 sp-shadow-lg sp-text-sm sp-animate-in sp-slide-in-from-bottom-2 ${ t.variant === 'destructive' ? 'sp-bg-destructive sp-text-destructive-foreground sp-border-destructive' - : 'sp-bg-emerald-600 sp-text-white sp-border-emerald-700' + : t.variant === 'warning' + ? 'sp-bg-amber-500 sp-text-white sp-border-amber-600' + : 'sp-bg-emerald-600 sp-text-white sp-border-emerald-700' }`} > {t.title &&