Improve KYC warning display and handle Didit verification decline#2044
Merged
Conversation
…r structured warnings
Two fixes for the Rain-via-Didit decline path so users get an
actionable next step instead of a generic dead end:
- Switch CardStatusResponse.kycWarnings from string[] to KycWarning[]
to match the backend's structured shape ({risk, short_description,
long_description, ...}). Update the step-1 description formatter to
prefer DIDIT_WARNING_DESCRIPTIONS overrides, fall back to Didit's
short_description, then long_description, then the formatted risk
tag — so warnings we haven't enumerated (e.g. BARCODE_NOT_DETECTED)
still display human-readable copy instead of [object Object].
- Add onVerificationDeclined to useDiditSession that toasts and
redirects to /card/activate?kycStatus=rejected, mirroring the
existing onVerificationPending pattern. Wire it into the Declined
branches of the web SDK onComplete + status_updated event, the
native SDK callback, and the polling loop. Previously Declined fell
into onVerificationError, leaving the user on /kyc with a generic
"Try again" button that just looped a fresh session against the same
bad document.
https://claude.ai/code/session_01DAk1pR6NuGujs24TQ7TFwm
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR enhances KYC warning handling and improves the user experience when Didit verification is declined. Instead of showing a generic error message, users are now redirected to the card activation page where they can see specific warnings (e.g., DOCUMENT_EXPIRED, DATE_OF_BIRTH_NOT_DETECTED) and retry with a fresh KYC session.
Key Changes
New
KycWarningtype: Replaced simple string array with a structured interface that mirrors Didit's warning shape, includingrisktag,short_description,long_description, and metadata fields.Enhanced warning formatting: Updated
formatDiditWarning()to acceptKycWarningobjects and implement a priority-based fallback chain:short_descriptionlong_descriptionNew
onVerificationDeclined()handler: Distinct from generic errors, this callback redirects to/card/activate?kycStatus=rejectedso users see specific warnings instead of a generic error with a retry button that loops the same broken document.Improved error handling: Separated "Declined" (KYC outcome with warnings) from "Error" (network/system failures) in both web and native KYC flows.
Refactored
formatRiskTag(): Extracted tag formatting logic into a reusable utility function for consistent SCREAMING_SNAKE_CASE to Title Case conversion.Updated type signatures: Changed
kycWarningsparameter type fromstring[]toKycWarning[]acrossgetStepDescription(),buildCardSteps(), and related functions.Implementation Details
formatKycWarnings()function now filters out empty formatted warnings to prevent blank lines in the output.kyc.tsx) and native (kyc.native.tsx) implementations updated consistently to use the newonVerificationDeclined()callback.useDiditSession()now callsonVerificationDeclined()when status is "Declined" instead of treating it as a generic error.https://claude.ai/code/session_01DAk1pR6NuGujs24TQ7TFwm