fix(abdm): distinguish ABHA Number vs ABHA Address in lookup error messages and logs
This commit is contained in:
parent
7c1f0df410
commit
5cc4486d9a
|
|
@ -1714,7 +1714,10 @@ class Abha extends BaseController
|
|||
if (is_string($candidate) && trim($candidate) !== '') {
|
||||
$trimmed = trim($candidate);
|
||||
if (stripos($trimmed, 'preferredAbhaAddress') !== false || (stripos($trimmed, 'Unknown column') !== false && stripos($trimmed, 'where clause') !== false)) {
|
||||
return 'ABHA Address does not exist or was not found in the ABDM registry.';
|
||||
$isNumberLookup = (($result['type'] ?? '') === 'abha-number')
|
||||
|| (isset($result['abha_id']) && !isset($result['abha_address']))
|
||||
|| (isset($result['value']) && !str_contains((string) $result['value'], '@') && ctype_digit(str_replace(['-', ' '], '', (string) $result['value'])));
|
||||
return ($isNumberLookup ? 'ABHA Number' : 'ABHA Address') . ' does not exist or was not found in the ABDM registry.';
|
||||
}
|
||||
if (stripos($trimmed, 'loginHint') !== false && stripos($trimmed, 'invalid') !== false) {
|
||||
return 'ABDM gateway rejected login hint: OTP verification by ABHA Address is not supported directly by ABDM. Please verify using the 14-digit ABHA Number or Find ABHA via Mobile.';
|
||||
|
|
@ -2862,8 +2865,9 @@ class Abha extends BaseController
|
|||
$errorText .= ' (Ref: ' . $requestId . ')';
|
||||
}
|
||||
|
||||
$entityName = $isAddress ? 'ABHA Address' : 'ABHA Number';
|
||||
if (stripos($errorText, 'Unknown column') !== false || stripos($errorText, 'preferredAbhaAddress') !== false || stripos($errorText, 'not found') !== false || stripos($errorText, 'does not exist') !== false) {
|
||||
$errorText = 'ABHA Address does not exist or was not found in the ABDM registry.';
|
||||
$errorText = $entityName . ' does not exist or was not found in the ABDM registry.';
|
||||
} elseif (stripos($errorText, 'Please make a valid request.') !== false) {
|
||||
$errorText = 'Bridge validation rejected this request. Please contact bridge support with the reference shown. '
|
||||
. $errorText;
|
||||
|
|
|
|||
|
|
@ -499,15 +499,19 @@ class EAtriaBridgeConnector implements AbdmConnectorInterface
|
|||
}
|
||||
}
|
||||
|
||||
$targetVal = (string) ($body['value'] ?? $body['abha_address'] ?? $body['abha_id'] ?? '');
|
||||
$isNumberLookup = (($body['type'] ?? '') === 'abha-number')
|
||||
|| (isset($body['abha_id']) && !isset($body['abha_address']))
|
||||
|| (!str_contains($targetVal, '@') && $targetVal !== '' && ctype_digit(str_replace(['-', ' '], '', $targetVal)));
|
||||
$entityLabel = $isNumberLookup ? 'ABHA Number' : 'ABHA Address';
|
||||
|
||||
// Normalise technical MySQL database errors from the bridge when an ABHA is not found
|
||||
if (stripos($extractedErr, 'preferredAbhaAddress') !== false ||
|
||||
(stripos($extractedErr, 'Unknown column') !== false && stripos($extractedErr, 'where clause') !== false)) {
|
||||
$targetVal = (string) ($body['value'] ?? $body['abha_address'] ?? $body['abha_id'] ?? '');
|
||||
$decoded['raw_bridge_error'] = $extractedErr;
|
||||
$extractedErr = 'ABHA Address does not exist or was not found in ABDM registry' . ($targetVal !== '' ? ' (' . $targetVal . ')' : '');
|
||||
} elseif (stripos($extractedErr, 'Invalid Login Hint') !== false && stripos($extractedErr, 'ABHA Address') === false) {
|
||||
$targetVal = (string) ($body['value'] ?? $body['abha_address'] ?? $body['abha_id'] ?? '');
|
||||
$extractedErr = 'ABHA Address does not exist or was not found in ABDM registry' . ($targetVal !== '' ? ' (' . $targetVal . ')' : '');
|
||||
$extractedErr = $entityLabel . ' does not exist or was not found in ABDM registry' . ($targetVal !== '' ? ' (' . $targetVal . ')' : '');
|
||||
} elseif (stripos($extractedErr, 'Invalid Login Hint') !== false || stripos($extractedErr, 'rejected login hint') !== false) {
|
||||
$extractedErr = $entityLabel . ' does not exist or was not found in ABDM registry' . ($targetVal !== '' ? ' (' . $targetVal . ')' : '');
|
||||
}
|
||||
|
||||
if ($extractedErr !== '') {
|
||||
|
|
|
|||
|
|
@ -97,6 +97,20 @@ final class AbhaOtpErrorHandlingTest extends CIUnitTestCase
|
|||
$this->assertStringContainsString('ABHA Address does not exist or was not found in the ABDM registry', $result);
|
||||
}
|
||||
|
||||
public function testExtractBridgeErrorTextNormalizesUnknownColumnForAbhaNumber(): void
|
||||
{
|
||||
$payload = [
|
||||
'ok' => 0,
|
||||
'type' => 'abha-number',
|
||||
'value' => '91987654321032',
|
||||
'error' => "Unknown column 'preferredAbhaAddress' in 'where clause'",
|
||||
'request_id' => 'REQ-20261001181024-934fd7ae',
|
||||
];
|
||||
|
||||
$result = $this->extractMethod->invoke($this->controller, $payload, 'ABHA validation failed');
|
||||
$this->assertStringContainsString('ABHA Number does not exist or was not found in the ABDM registry', $result);
|
||||
}
|
||||
|
||||
public function testExtractBridgeErrorTextPreservesGenericWhenNoFieldErrors(): void
|
||||
{
|
||||
$payload = [
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user