Fix virtual account and KYC flow routing for Wirex users - #2520
Merged
Merged
Conversation
The virtual-account pitch gated on `rainApplicationStatus === APPROVED` and
sent everyone else to /kyc. A Wirex user has no Rain application and never
will, so they always took that branch — and the backend then refused a new
Didit session with 409 KYC_ALREADY_EXISTS, because their verification was
already on file. The KYC screen bounced them straight back out onto the card
review page. From the outside, "Verify now" spun and returned without ever
opening a verification.
The same 409 waits for any Rain user who already has a consumer: a missing
`rainApplicationStatus` is not evidence that no application exists. This is
the rule the card flow already encodes in resolveRainKycAction, and the
virtual-account flow never got it.
The decision moves into resolveVirtualAccountApplyAction, a pure function
beside the modal, so the routing is testable without mounting it:
- Wirex issues the account -> their own bank screen, which owns activation
- Rain approved -> the terms step
- an application exists -> the page showing its state, not a new check
- nothing on file -> identity verification
DepositTypeSelection — the main Add-funds screen, and the entry point Wirex
users actually came through — now routes on the provider too. The other two
entry points already did, which is why this only ever reproduced from here.
Alongside it, the buy-crypto verification screen stops dead-ending:
- the exhausted state offers the partner's own hosted verification once a
profile exists, instead of only "try again" on a share that has already
been refused three times
- a terminal rejection says the partner's decision is final and points to
support, rather than "please try again later" — which read as a wait that
would clear, so users kept coming back to the same screen
- the pending spinner stops promising "under a minute" indefinitely
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PPtSeJ6KiwabgmJ1S5v4Uc
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
…vestigation-do57kq
Both buttons on that screen fire their own request, and neither was guarded against the other being in flight. "Try again" also calls setExhausted(false), so a hosted-retry landing after it would set a verification URL on a screen that had already moved on — two concurrent requests and a state that agrees with neither. Disable both while either is running. Reported by Seer on #2520; the race only existed because this commit's parent gave the screen a second action. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PPtSeJ6KiwabgmJ1S5v4Uc
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 fixes critical routing issues in the virtual account and KYC flows that were causing Wirex users to be incorrectly sent through Rain's KYC verification process, resulting in 409 errors and broken user experiences. It also improves messaging and UX in the TransFi KYC pending screen.
Key Changes
Virtual Account Apply Action Logic
virtualAccountApplyAction.ts- Extracted pure decision logic for determining what action the "Verify now" button should takevirtualAccountApplyAction.test.ts- Comprehensive test coverage documenting the routing rules and failure casesrainApplicationStatusby checkingkycApplicationEstablishedflagVirtualAccountApplyModal Updates
useVirtualAccountProviderhook to determine the account issuerresolveVirtualAccountApplyActionfunction for consistent routing logicDepositTypeSelection Updates
TransFi KYC Pending Screen Improvements
can_sharestatus (not justrejected), preventing users from being stranded with the modal already openNotable Implementation Details
resolveVirtualAccountApplyActionfunction is kept pure and testable, following the same pattern asresolveRainKycActionkycApplicationEstablishedflag is used as a signal that a consumer exists, preventing unnecessary new KYC attemptshttps://claude.ai/code/session_01PPtSeJ6KiwabgmJ1S5v4Uc