Skip to content

Improve KYC warning display and handle Didit verification decline#2044

Merged
MusabShakeel576 merged 1 commit into
qafrom
claude/fix-rain-api-token-rKsRJ
May 4, 2026
Merged

Improve KYC warning display and handle Didit verification decline#2044
MusabShakeel576 merged 1 commit into
qafrom
claude/fix-rain-api-token-rKsRJ

Conversation

@MusabShakeel576
Copy link
Copy Markdown
Contributor

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 KycWarning type: Replaced simple string array with a structured interface that mirrors Didit's warning shape, including risk tag, short_description, long_description, and metadata fields.

  • Enhanced warning formatting: Updated formatDiditWarning() to accept KycWarning objects and implement a priority-based fallback chain:

    1. Custom override descriptions (DIDIT_WARNING_DESCRIPTIONS)
    2. Didit's short_description
    3. Didit's long_description
    4. Formatted risk tag as fallback
  • New onVerificationDeclined() handler: Distinct from generic errors, this callback redirects to /card/activate?kycStatus=rejected so 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 kycWarnings parameter type from string[] to KycWarning[] across getStepDescription(), buildCardSteps(), and related functions.

Implementation Details

  • The formatKycWarnings() function now filters out empty formatted warnings to prevent blank lines in the output.
  • Both web (kyc.tsx) and native (kyc.native.tsx) implementations updated consistently to use the new onVerificationDeclined() callback.
  • Polling logic in useDiditSession() now calls onVerificationDeclined() when status is "Declined" instead of treating it as a generic error.

https://claude.ai/code/session_01DAk1pR6NuGujs24TQ7TFwm

…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
@vercel
Copy link
Copy Markdown

vercel Bot commented May 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
solid-app Ignored Ignored May 4, 2026 1:17pm
solid-app-staging Ignored Ignored May 4, 2026 1:17pm

Request Review

@MusabShakeel576 MusabShakeel576 merged commit 2a1b5e3 into qa May 4, 2026
4 of 5 checks passed
@MusabShakeel576 MusabShakeel576 deleted the claude/fix-rain-api-token-rKsRJ branch May 4, 2026 13:26
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.

2 participants