Skip to content

Log license fetch failures and surface honest warning toast on save#324

Merged
TLabutis merged 1 commit into
SL-358/payment-fieldfrom
INTERNAL/license-fetch-warning-toast
May 15, 2026
Merged

Log license fetch failures and surface honest warning toast on save#324
TLabutis merged 1 commit into
SL-358/payment-fieldfrom
INTERNAL/license-fetch-warning-toast

Conversation

@TLabutis

@TLabutis TLabutis commented May 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • When the Saferpay Management API license lookup fails on credentials save, log the error to the SaferPay module Logs tab via LoggerInterface instead of swallowing it silently
  • Replace the misleading green success toast (which told merchants to "verify credentials" they had just validated) with an amber warning toast and a clearer message pointing to the Logs
  • Return a warning flag from ajaxProcessSaveCredentials so the React layer can render the new variant

Test plan

  • Force a license fetch exception → save credentials → amber warning toast renders with new copy
  • Restore valid license fetch → save credentials → green success toast renders normally
  • Verify the failure path writes an entry to the SaferPay module Logs tab (not the generic PrestaShop log)

When the Saferpay Management API license lookup fails during credentials
save, the previous flow showed a misleading green success toast that
asked merchants to verify credentials they had just successfully validated.

- Log the underlying error to the SaferPay module Logs tab via LoggerInterface
- Return a 'warning' flag in the save credentials response
- Render an amber warning toast with a clearer message that points to the Logs

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances the credential saving process by implementing error handling for license retrieval failures. It introduces server-side logging for these errors and adds a new 'warning' toast variant to the frontend to inform users when settings are saved but license verification could not be completed. A review comment suggests refactoring the logging context to adhere to PSR-3 standards by removing a redundant 'context' key in the array.

Comment on lines +235 to +237
$logger->error('License fetch failed on credentials save: ' . $e->getMessage(), [
'context' => ['exception_class' => get_class($e)],
]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The LoggerInterface extends \Psr\Log\LoggerInterface, which follows the PSR-3 standard. In PSR-3, the second argument to logging methods is the context array itself. Wrapping the context data in a redundant 'context' key is unnecessary and may lead to nested structures in the log output (e.g., context.context.exception_class instead of context.exception_class).

                $logger->error('License fetch failed on credentials save: ' . $e->getMessage(), [
                    'exception_class' => get_class($e),
                ]);

@TLabutis TLabutis merged commit 1c91872 into SL-358/payment-field May 15, 2026
1 of 3 checks passed
@TLabutis TLabutis deleted the INTERNAL/license-fetch-warning-toast branch May 15, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant