Fix Saferpay Fields visibility per active environment license#323
Conversation
The Saferpay Fields section was driven by a single hasBusinessLicense flag derived from the active environment's stored license at page load. Switching environments client-side did not re-evaluate it, so the section stayed visible after switching to an environment with no validated business license. Expose testHasBusinessLicense and liveHasBusinessLicense separately from the controller (initial payload and save response), and pick the active one in api-credentials.tsx based on testMode.
There was a problem hiding this comment.
Code Review
This pull request updates the SaferPay settings to manage business license detection independently for test and live environments, adding backend logging for fetch failures and updating the UI to display per-environment statuses. Feedback highlights that the new frontend validation logic is overly restrictive, as the required attributes and the save button's disabled state prevent users from clearing credentials or saving settings if background validation fails.
| <Button | ||
| className="sp-min-w-[120px]" | ||
| onClick={saveCredentials} | ||
| disabled={saving || !hasCredentials || credentialStatus === 'invalid' || credentialStatus === 'checking'} |
There was a problem hiding this comment.
The disabled condition is too restrictive. Blocking the save when credentialStatus === 'invalid' or !hasCredentials prevents users from saving their settings if the background validation fails (e.g., due to transient network issues) or if they wish to clear the credentials. Since the backend performs its own validation upon saving, the frontend should ideally only provide feedback rather than blocking the action entirely.
| disabled={saving || !hasCredentials || credentialStatus === 'invalid' || credentialStatus === 'checking'} | |
| disabled={saving || credentialStatus === 'checking'} |
| onChange={(e) => setField('username', e.target.value)} | ||
| required | ||
| aria-required="true" | ||
| /> |
There was a problem hiding this comment.
The required and aria-required attributes prevent the form from being submitted if the field is empty. This prevents users from clearing credentials to reset or disable the module configuration. Since the backend already handles empty values and performs validation, these restrictions should be removed to allow for more flexibility in managing settings.
| onChange={(e) => setField('username', e.target.value)} | |
| required | |
| aria-required="true" | |
| /> | |
| onChange={(e) => setField('username', e.target.value)} | |
| /> |
| className="sp-pr-10" | ||
| required | ||
| aria-required="true" | ||
| /> |
There was a problem hiding this comment.
0fd7498
into
SL-346/accessibility-eaa-compliance
Summary
hasBusinessLicenseflag tied to the active environment at page load. Switching environments client-side never re-evaluated it, so the section remained visible after flipping to an env with no validated business license.testHasBusinessLicenseandliveHasBusinessLicenseseparately (initial payload and save response).api-credentials.tsxderives the active flag fromisTestand gates the Saferpay Fields card on it.Test plan