diff --git a/app/(protected)/(tabs)/card/_layout.tsx b/app/(protected)/(tabs)/card/_layout.tsx
index 8fa95b20a..129ef17ce 100644
--- a/app/(protected)/(tabs)/card/_layout.tsx
+++ b/app/(protected)/(tabs)/card/_layout.tsx
@@ -7,9 +7,11 @@ export default function CardLayout() {
- {/* Rain sunset: the move to the new card, and emptying the closing one. */}
+ {/* Rain sunset: the move to the new card, emptying the closing one, and the
+ card the sunset closed. */}
+
{/* No screen animation: the card hero overlay plus the screen's own staggered
diff --git a/app/(protected)/(tabs)/card/activate.tsx b/app/(protected)/(tabs)/card/activate.tsx
index c1e2a0fa6..1d1f39d14 100644
--- a/app/(protected)/(tabs)/card/activate.tsx
+++ b/app/(protected)/(tabs)/card/activate.tsx
@@ -25,7 +25,7 @@ import { BASE_SPEND_DEPLOYMENT } from '@/constants/spendModuleDeployments';
import { useActivateCard } from '@/hooks/useActivateCard';
import { useCardStatus } from '@/hooks/useCardStatus';
import { useCardSpendDeployments } from '@/hooks/useEuroSpendEnablement';
-import { routesToNewCard } from '@/lib/utils/rainSunset';
+import { routesToClosedCard, routesToNewCard } from '@/lib/utils/rainSunset';
export default function ActivateMobile() {
const router = useRouter();
@@ -59,6 +59,10 @@ export default function ActivateMobile() {
if (routesToNewCard(cardStatus)) {
return ;
}
+ // A card the sunset closed is not one to activate.
+ if (routesToClosedCard(cardStatus)) {
+ return ;
+ }
if (isCardStatusLoading || isCheckingCountry || isResolvingWirexFlow) {
return (
diff --git a/app/(protected)/(tabs)/card/closed.tsx b/app/(protected)/(tabs)/card/closed.tsx
new file mode 100644
index 000000000..a8c3bb890
--- /dev/null
+++ b/app/(protected)/(tabs)/card/closed.tsx
@@ -0,0 +1,6 @@
+import { RainCardClosedScreen } from '@/components/Card/RainSunset/RainCardClosedScreen';
+
+/** Rain sunset: the card the sunset closed, and what its holder can still do. */
+export default function ClosedCardRoute() {
+ return ;
+}
diff --git a/app/(protected)/(tabs)/card/index.tsx b/app/(protected)/(tabs)/card/index.tsx
index f7e6b507f..d444f2d9e 100644
--- a/app/(protected)/(tabs)/card/index.tsx
+++ b/app/(protected)/(tabs)/card/index.tsx
@@ -13,7 +13,7 @@ import {
hasPendingCard,
} from '@/lib/utils';
import { isKycAwaitingDecision } from '@/lib/utils/kyc/verificationProgress';
-import { routesToNewCard } from '@/lib/utils/rainSunset';
+import { routesToClosedCard, routesToNewCard } from '@/lib/utils/rainSunset';
/**
* `/card` is deprecated as a destination — it used to render the standalone card
@@ -36,6 +36,12 @@ export default function Card() {
return ;
}
+ // Rain sunset: a card the sunset closed, with no new card to send them to.
+ // Read as "no card", it would land in the issuance flow offering to activate it.
+ if (routesToClosedCard(cardStatus)) {
+ return ;
+ }
+
// BD users who haven't met the minimum card deposit are sent to the issuance
// flow (activate) to complete the deposit step; everyone else goes straight
// to card details.
diff --git a/components/Card/NewCardDetails/CardDetailsPane.tsx b/components/Card/NewCardDetails/CardDetailsPane.tsx
index 52e059185..92c8cd7d1 100644
--- a/components/Card/NewCardDetails/CardDetailsPane.tsx
+++ b/components/Card/NewCardDetails/CardDetailsPane.tsx
@@ -112,7 +112,11 @@ const CardDetailsPane = () => {
const { data: cardStatus } = useCardStatus();
// Rain sunset: the card-closing notice under the card art.
const { sunset: rainSunset } = useRainSunset();
- const showsClosingNotice = Boolean(rainSunset?.notice && rainSunset.hasRainCard);
+ // A card the sunset already closed gets the closed notice, and no actions: it
+ // cannot be funded, frozen or spent from any more.
+ const cardClosedBySunset = Boolean(rainSunset?.cardClosed);
+ const showsClosingNotice =
+ cardClosedBySunset || Boolean(rainSunset?.notice && rainSunset.hasRainCard);
const { data: customer } = useCustomer();
const { provider } = useCardProvider();
// Either read: the status names the issuer from KYC on, so the card-live popup is never preceded
@@ -365,16 +369,18 @@ const CardDetailsPane = () => {
) : null}
-
-
-
+ {cardClosedBySunset ? null : (
+
+
+
+ )}
{/* In the spend-mode row's place, which cannot show at the same time: that row needs
card spending to be on, and this one is only here while it is off. */}
{showsEnableSpending ? (
diff --git a/components/Card/RainSunset/RainCardClosedScreen.tsx b/components/Card/RainSunset/RainCardClosedScreen.tsx
new file mode 100644
index 000000000..9a43e1ed3
--- /dev/null
+++ b/components/Card/RainSunset/RainCardClosedScreen.tsx
@@ -0,0 +1,113 @@
+import { ActivityIndicator, StyleSheet, View } from 'react-native';
+import { Image } from 'expo-image';
+import { Redirect, useRouter } from 'expo-router';
+
+import { WirexOnboardingLayout } from '@/components/Card/WirexOnboarding/WirexOnboardingLayout';
+import { Button } from '@/components/ui/button';
+import { Text } from '@/components/ui/text';
+import { COUNTRIES } from '@/constants/countries';
+import { path } from '@/constants/path';
+import { useRainSunset } from '@/hooks/useRainSunset';
+import { getAsset } from '@/lib/assets';
+import {
+ closedCardCopy,
+ formatClosingBalance,
+ hasClosingBalance,
+ isClosingBalanceUnknown,
+} from '@/lib/utils/rainSunset';
+
+/**
+ * The card the Rain sunset closed: why it no longer works, the way to whatever
+ * was left on it, and the way to the new card where there is one.
+ *
+ * Without this screen a closed card reads as "no card": the card flow offered
+ * to activate it, and the card screen drew it as if it still worked. Reached
+ * from `/card`, the activate screen, Home's card and the closed-card banner.
+ */
+export function RainCardClosedScreen() {
+ const router = useRouter();
+ const { sunset, cardStatus, isLoading, balanceUsd, isBalanceLoading } = useRainSunset();
+
+ if (isLoading) {
+ return (
+
+
+
+ );
+ }
+
+ // Not (or no longer) a closed card — moved to the new card, say: the card
+ // flow knows where they belong.
+ if (!sunset?.cardClosed) return ;
+
+ const countryName = COUNTRIES.find(
+ country => country.code === cardStatus?.country?.toUpperCase(),
+ )?.name;
+ const { title, message } = closedCardCopy(sunset, balanceUsd, countryName);
+ // A read that failed still offers the withdrawal (its screen re-reads); one
+ // still in flight waits rather than flashing a button that may go away.
+ const balanceUnknown = isClosingBalanceUnknown(balanceUsd);
+ const hasBalance = hasClosingBalance(balanceUsd) || (balanceUnknown && !isBalanceLoading);
+ const newCard = sunset.newCardAvailable || Boolean(sunset.migration);
+
+ const goHome = () => router.replace(path.HOME);
+
+ return (
+
+ {hasBalance ? (
+
+ ) : null}
+ {newCard ? (
+
+ ) : null}
+ {!hasBalance && !newCard ? (
+
+ ) : null}
+
+ }
+ >
+
+
+
+
+ {title}
+
+ {message}
+
+
+
+ );
+}
+
+const styles = StyleSheet.create({
+ loading: { flex: 1, alignItems: 'center', justifyContent: 'center', backgroundColor: '#111111' },
+ buttons: { gap: 10 },
+ art: { width: 120, height: 120 },
+});
diff --git a/components/Card/RainSunset/RainClosingCardNotice.tsx b/components/Card/RainSunset/RainClosingCardNotice.tsx
index 35851e16b..4e4d0f06a 100644
--- a/components/Card/RainSunset/RainClosingCardNotice.tsx
+++ b/components/Card/RainSunset/RainClosingCardNotice.tsx
@@ -8,6 +8,7 @@ import { path } from '@/constants/path';
import { useRainSunset } from '@/hooks/useRainSunset';
import {
cardNoticeCopy,
+ closedCardCopy,
formatClosingBalance,
hasClosingBalance,
isClosingBalanceUnknown,
@@ -57,12 +58,16 @@ const RainClosingCardNotice = () => {
const { sunset, cardStatus, balanceUsd, isBalanceLoading } = useRainSunset();
const openSheet = useRainSunsetStore(state => state.setSheetOpen);
- if (!sunset?.notice || !sunset.hasRainCard) return null;
+ const closed = Boolean(sunset?.cardClosed);
+ if (!sunset || (!closed && (!sunset.notice || !sunset.hasRainCard))) return null;
const countryName = COUNTRIES.find(
country => country.code === cardStatus?.country?.toUpperCase(),
)?.name;
- const { title, message } = cardNoticeCopy(sunset, balanceUsd, countryName);
+ // A card the sunset already closed: why it no longer works, and what is left.
+ const { title, message } = closed
+ ? closedCardCopy(sunset, balanceUsd, countryName)
+ : cardNoticeCopy(sunset, balanceUsd, countryName);
// A read that failed still offers the withdrawal (its screen re-reads); one
// still in flight waits rather than flashing a button that may go away.
const balanceUnknown = isClosingBalanceUnknown(balanceUsd);
@@ -73,6 +78,9 @@ const RainClosingCardNotice = () => {
const goToNewCard = () => router.push(path.CARD_NEW_CARD);
const goToWithdraw = () => router.push(path.CARD_CLOSING_WITHDRAW);
+ // A closed card whose holder already started the move offers to continue
+ // it, as its copy and the closed-card screen do.
+ const offersNewCard = sunset.newCardAvailable || (closed && Boolean(sunset.migration));
return (
@@ -82,14 +90,14 @@ const RainClosingCardNotice = () => {
- Card closing
+ {closed ? 'Card closed' : 'Card closing'}
{title}{message}
- {sunset.newCardAvailable ? (
+ {offersNewCard ? (
<>
{
const openSheet = useRainSunsetStore(state => state.setSheetOpen);
if (!sunset) return null;
- if (sunset.hasRainCard && isBalanceLoading) return null;
+ if (holdsClosingCard(sunset) && isBalanceLoading) return null;
const state = rainClosingBannerState(sunset, balanceUsd);
if (!state) return null;
@@ -75,6 +79,8 @@ const RainClosingHomeBanner = ({ className }: { className?: string }) => {
'new-card': true,
'closing-balance': false,
'closing-empty': true,
+ 'closed-balance': false,
+ 'closed-empty': true,
};
if (closable[state] && dismissed.includes(key)) return null;
@@ -101,10 +107,17 @@ const RainClosingHomeBanner = ({ className }: { className?: string }) => {
onPress={goToNewCard}
/>
) : null}
- {state === 'closing-balance' ? (
+ {state === 'closing-balance' || state === 'closed-balance' ? (
) : null}
- {state !== 'new-card' ? (
+ {state === 'closed-balance' && (sunset.newCardAvailable || sunset.migration) ? (
+
+ ) : null}
+ {state === 'closing-balance' || state === 'closing-empty' ? (
router.replace(path.CARD_INFO);
+ // A card the sunset closed has no card screen to go back to; its own does.
+ const goToCard = () => router.replace(sunset?.cardClosed ? path.CARD_CLOSED : path.CARD_INFO);
/**
* Withdraw every token from `start` on. A retry after a failure resumes at
@@ -288,9 +289,11 @@ export function RainClosingWithdraw() {
tokens.length > 1
? `You'll confirm with your passkey, once for each of the ${tokens.length} tokens.`
: "You'll confirm with your passkey.";
- const stays = closesOn
- ? ` Your card keeps working until ${closesOn.long}.`
- : ' Your card keeps working until it closes.';
+ const stays = sunset?.cardClosed
+ ? ' Your card is closed, but what was left on it is still yours.'
+ : closesOn
+ ? ` Your card keeps working until ${closesOn.long}.`
+ : ' Your card keeps working until it closes.';
return (
diff --git a/components/Card/RainSunset/RainNewCardScreen.tsx b/components/Card/RainSunset/RainNewCardScreen.tsx
index 53d6249d9..d135615e7 100644
--- a/components/Card/RainSunset/RainNewCardScreen.tsx
+++ b/components/Card/RainSunset/RainNewCardScreen.tsx
@@ -60,6 +60,7 @@ const BENEFITS: { icon: AssetPath; title: string; description: string }[] = [
*/
function NewCardIntro({
hasCurrentCard,
+ cardClosed,
closesAt,
resuming,
balanceUsd,
@@ -69,6 +70,8 @@ function NewCardIntro({
}: {
/** They still hold the closing card; a Rain applicant with no card does not. */
hasCurrentCard: boolean;
+ /** The sunset already closed their card. */
+ cardClosed: boolean;
closesAt: string | null;
resuming: boolean;
balanceUsd: number | null;
@@ -101,12 +104,14 @@ function NewCardIntro({
- {hasCurrentCard ? 'Get your new Solid card' : 'Get your Solid card'}
+ {hasCurrentCard || cardClosed ? 'Get your new Solid card' : 'Get your Solid card'}
- {hasCurrentCard
- ? `Your current card closes ${closesPhrase(closesAt, 'long')}. Your new card comes from our new card partner, Wirex, so you'll verify your identity once more.`
- : "Solid cards now come from our new card partner, Wirex, so you'll verify your identity with them. It takes a few minutes."}
+ {cardClosed
+ ? "Your previous card was closed. Your new card comes from our new card partner, Wirex, so you'll verify your identity once more."
+ : hasCurrentCard
+ ? `Your current card closes ${closesPhrase(closesAt, 'long')}. Your new card comes from our new card partner, Wirex, so you'll verify your identity once more.`
+ : "Solid cards now come from our new card partner, Wirex, so you'll verify your identity with them. It takes a few minutes."}
@@ -128,7 +133,9 @@ function NewCardIntro({
{blocked && balanceUsd != null ? (
- {`Withdraw the ${formatClosingBalance(balanceUsd)} on your current card before your new card is issued.`}
+ {cardClosed
+ ? `Withdraw the ${formatClosingBalance(balanceUsd)} left on your previous card before your new card is issued.`
+ : `Withdraw the ${formatClosingBalance(balanceUsd)} on your current card before your new card is issued.`}
) : null}
@@ -183,10 +190,11 @@ export function RainNewCardScreen() {
// Nothing to move: already moved (the status no longer carries the block), or
// no new card where they live. Their card screen says why.
if (!sunset || (!sunset.newCardAvailable && !migration)) {
- return ;
+ return ;
}
- const goToCard = () => router.replace(path.CARD_INFO);
+ // A card the sunset closed has no card screen; Home is where "not now" goes.
+ const goToCard = () => router.replace(sunset.cardClosed ? path.HOME : path.CARD_INFO);
const startKyc = () => {
track(TRACKING_EVENTS.CARD_ONBOARDING_CTA_PRESSED, { step: 'rain_sunset_verify' });
setKycFlow('card_migration');
@@ -243,6 +251,7 @@ export function RainNewCardScreen() {
return (
state.isOpen);
const openCardPaneWalletGuide = useCardPaneStore(state => state.openWalletGuide);
+ // Rain sunset: a card the sunset closed has no details to show — the pane
+ // would draw it as if it still worked. Its own screen says why instead.
+ const cardClosedBySunset = Boolean(cardStatus?.rainSunset?.cardClosed);
+
useEffect(() => {
if (screenParam !== CARD_INFO_SCREEN) return;
+ // Keep the link until the card's status is in: only then is it known
+ // whether the card is one the sunset closed, which goes to its own screen.
+ if (isCardStatusLoading) return;
+ if (cardClosedBySunset) {
+ router.setParams({ screen: undefined, [CARD_INFO_WALLET_PARAM]: undefined });
+ router.push(path.CARD_CLOSED);
+ return;
+ }
// `&wallet=apple|google` asks for the "Add to Wallet" guide on top of the
// pane, on that wallet's tab — the addressable form of the popup, which is
// what lets the home "Add to Apple Pay" banner be nothing but a redirect.
@@ -130,7 +142,14 @@ export default function HomeScreenNew() {
openCardPane();
}
router.setParams({ screen: undefined, [CARD_INFO_WALLET_PARAM]: undefined });
- }, [screenParam, walletParam, openCardPane, openCardPaneWalletGuide]);
+ }, [
+ screenParam,
+ walletParam,
+ openCardPane,
+ openCardPaneWalletGuide,
+ cardClosedBySunset,
+ isCardStatusLoading,
+ ]);
// `?whatsNew=`, `?deposit=` and `?spendMode=` open what a push or link was
// about over this screen (`constants/homeLinkParams`).
diff --git a/components/Home/NewHome/HomeWalletCard.tsx b/components/Home/NewHome/HomeWalletCard.tsx
index 1d5cf7196..e5982ffb9 100644
--- a/components/Home/NewHome/HomeWalletCard.tsx
+++ b/components/Home/NewHome/HomeWalletCard.tsx
@@ -28,6 +28,7 @@ import { track } from '@/lib/analytics';
import { getAsset } from '@/lib/assets';
import { canReplaceClosedCard } from '@/lib/utils/cardStatusRouting';
import { isKycAwaitingDecision } from '@/lib/utils/kyc/verificationProgress';
+import { routesToNewCard } from '@/lib/utils/rainSunset';
import { useCardHeroStore } from '@/store/useCardHeroStore';
import { useCardPaneStore } from '@/store/useCardPaneStore';
@@ -130,14 +131,21 @@ const HomeWalletCard = ({
const awaitingKycDecision = isKycAwaitingDecision(cardStatus);
// The card was closed and its holder can order the next one themselves.
const replacingClosedCard = canReplaceClosedCard(cardStatus);
+ // Rain sunset: the sunset closed their card. Its screens (the new card, or why
+ // it closed) are where a tap goes, not the "Your card is waiting" prompt.
+ const closedBySunset = Boolean(cardStatus?.rainSunset?.cardClosed);
// What the cardless card says it does. A closed card's holder is not getting
// their first card, so "Get your card" would misdescribe the replacement
// flow the tap opens — and it is the whole label for a screen reader.
- const cardlessLabel = replacingClosedCard
- ? 'Get a new card'
- : awaitingKycDecision
- ? 'Your card is on its way'
- : 'Get your card';
+ const cardlessLabel = closedBySunset
+ ? routesToNewCard(cardStatus)
+ ? 'Get your new card'
+ : 'Card closed'
+ : replacingClosedCard
+ ? 'Get a new card'
+ : awaitingKycDecision
+ ? 'Your card is on its way'
+ : 'Get your card';
const card = ;
@@ -153,6 +161,10 @@ const HomeWalletCard = ({
* activate step orders the replacement.
*/
const handleCardlessPress = () => {
+ if (closedBySunset) {
+ router.push(routesToNewCard(cardStatus) ? path.CARD_NEW_CARD : path.CARD_CLOSED);
+ return;
+ }
if (awaitingKycDecision || replacingClosedCard) {
track(TRACKING_EVENTS.CARD_GET_CARD_PRESSED, {
source: 'home_wallet_card',
diff --git a/constants/path.ts b/constants/path.ts
index 02a91ab5d..22ed297dd 100644
--- a/constants/path.ts
+++ b/constants/path.ts
@@ -95,6 +95,8 @@ type Path = {
CARD_NEW_CARD: Href;
/** Rain sunset: withdraw the whole balance on a closing card to the wallet. */
CARD_CLOSING_WITHDRAW: Href;
+ /** Rain sunset: the card the sunset closed, for a holder with no new card to go to. */
+ CARD_CLOSED: Href;
CARD_COUNTRY_SELECTION: Href;
EARN: Href;
SETTINGS: Href;
@@ -180,6 +182,7 @@ export const path: Path = {
CARD_ACTIVATE: '/card/activate',
CARD_NEW_CARD: '/card/new-card' as Href,
CARD_CLOSING_WITHDRAW: '/card/closing-withdraw' as Href,
+ CARD_CLOSED: '/card/closed' as Href,
CARD_COUNTRY_SELECTION: '/card-onboard/country_selection',
EARN: '/earn',
SETTINGS: '/settings',
diff --git a/hooks/useCardCollateralAvailable.ts b/hooks/useCardCollateralAvailable.ts
index 2d2c8c215..e8f0bbed2 100644
--- a/hooks/useCardCollateralAvailable.ts
+++ b/hooks/useCardCollateralAvailable.ts
@@ -5,6 +5,7 @@ import { CardProvider } from '@/lib/types';
import { withRefreshToken } from '@/lib/utils';
import { useCardProvider } from './useCardProvider';
+import { useCardStatus } from './useCardStatus';
const CARD_COLLATERAL_AVAILABLE_KEY = 'cardCollateralAvailable';
@@ -26,11 +27,15 @@ const CARD_COLLATERAL_AVAILABLE_KEY = 'cardCollateralAvailable';
*/
export function useCardCollateralAvailable(tokenAddress?: string) {
const { provider } = useCardProvider();
+ // A card the Rain sunset closed no longer counts as "a card", so the
+ // provider may not resolve for it; what is left on it is still withdrawable.
+ const { data: cardStatus } = useCardStatus();
+ const closedRainCard = Boolean(cardStatus?.rainSunset?.cardClosed);
return useQuery({
queryKey: [CARD_COLLATERAL_AVAILABLE_KEY, tokenAddress ?? null],
queryFn: () => withRefreshToken(() => getCardCollateralAvailable({ tokenAddress })),
- enabled: provider === CardProvider.RAIN,
+ enabled: provider === CardProvider.RAIN || closedRainCard,
// Collateral moves when deposits settle and when charges are swept, so the
// withdraw screen re-reads it on the same cadence as the card balance.
refetchInterval: 5000,
diff --git a/hooks/useRainSunset.ts b/hooks/useRainSunset.ts
index 33352c35d..b9154cda7 100644
--- a/hooks/useRainSunset.ts
+++ b/hooks/useRainSunset.ts
@@ -3,7 +3,7 @@ import { useQuery } from '@tanstack/react-query';
import { useCardStatus } from '@/hooks/useCardStatus';
import { getCardCollateralAvailable } from '@/lib/api';
import { withRefreshToken } from '@/lib/utils';
-import { rainSunsetOf } from '@/lib/utils/rainSunset';
+import { holdsClosingCard, rainSunsetOf } from '@/lib/utils/rainSunset';
export const RAIN_SUNSET_BALANCE_KEY = 'rainSunsetBalance';
@@ -14,16 +14,18 @@ export const RAIN_SUNSET_BALANCE_KEY = 'rainSunsetBalance';
* The balance is the card's on-chain collateral summed over every token — the
* same read the withdraw screen uses, because that is what can actually be
* moved to the wallet. Read only for someone still holding the closing card,
- * and on a slow cadence: this backs a banner, not a form.
+ * or whose card the sunset closed (what was left on it is still theirs), and
+ * on a slow cadence: this backs a banner, not a form.
*/
export function useRainSunset() {
const { data: cardStatus, isLoading: isStatusLoading } = useCardStatus();
const sunset = rainSunsetOf(cardStatus);
+ const holdsCard = holdsClosingCard(sunset);
const balance = useQuery({
queryKey: [RAIN_SUNSET_BALANCE_KEY],
queryFn: () => withRefreshToken(() => getCardCollateralAvailable({})),
- enabled: Boolean(sunset?.hasRainCard),
+ enabled: holdsCard,
staleTime: 30_000,
refetchInterval: 60_000,
retry: 1,
@@ -34,7 +36,7 @@ export function useRainSunset() {
sunset,
isLoading: isStatusLoading,
/** Total balance left on the closing card, in dollars; null until read. */
- balanceUsd: sunset?.hasRainCard ? (balance.data?.totalCollateralUsd ?? null) : 0,
+ balanceUsd: holdsCard ? (balance.data?.totalCollateralUsd ?? null) : 0,
collateral: balance.data ?? null,
isBalanceLoading: balance.isLoading,
refetchBalance: balance.refetch,
diff --git a/lib/types.ts b/lib/types.ts
index 0d6338bb4..a5507930e 100644
--- a/lib/types.ts
+++ b/lib/types.ts
@@ -924,6 +924,15 @@ export interface CardActivationFailure {
export interface RainSunsetStatus {
/** They still hold the closing card (active, frozen or pending). */
hasRainCard: boolean;
+ /**
+ * Their card was closed for good by the sunset (they never got the new
+ * card). The top-level status reads `inactive`; this says why, so the app
+ * shows "your card was closed" — with the way to a new card and to any money
+ * left on it — instead of a card that no longer works.
+ */
+ cardClosed?: boolean;
+ /** When that card was closed (ISO). */
+ cardClosedAt?: string;
/** Show the closing notice on Home and the card screen. */
notice: boolean;
/** The day the closing cards stop working (YYYY-MM-DD), or null if not announced. */
diff --git a/lib/utils/__tests__/homePromptStep.test.ts b/lib/utils/__tests__/homePromptStep.test.ts
index a4be39987..e5c13b36e 100644
--- a/lib/utils/__tests__/homePromptStep.test.ts
+++ b/lib/utils/__tests__/homePromptStep.test.ts
@@ -89,6 +89,26 @@ describe('resolveHomePromptStep — the pre-card rungs', () => {
);
});
+ it('offers nothing for a card the Rain sunset closed: its own banner speaks', () => {
+ expect(
+ step({
+ ...noCard,
+ cardStatus: {
+ status: CardStatus.INACTIVE,
+ kycStatus: KycStatus.APPROVED,
+ rainSunset: {
+ hasRainCard: false,
+ cardClosed: true,
+ notice: false,
+ closesAt: null,
+ newCardAvailable: false,
+ maxLeftoverUsd: 1,
+ },
+ },
+ }),
+ ).toBeNull();
+ });
+
it('keeps offering activation for a closed card support has to replace', () => {
expect(
step({
diff --git a/lib/utils/__tests__/rainSunset.test.ts b/lib/utils/__tests__/rainSunset.test.ts
index 46f288160..38fad6933 100644
--- a/lib/utils/__tests__/rainSunset.test.ts
+++ b/lib/utils/__tests__/rainSunset.test.ts
@@ -1,15 +1,18 @@
import {
blocksNewCard,
cardNoticeCopy,
+ closedCardCopy,
closesPhrase,
floorCents,
formatClosingBalance,
formatClosingDate,
hasClosingBalance,
+ holdsClosingCard,
homeBannerCopy,
isClosingBalanceUnknown,
rainClosingBannerState,
remainderCents,
+ routesToClosedCard,
routesToNewCard,
tokenWithdrawal,
unitsToCents,
@@ -222,4 +225,66 @@ describe('rainSunset', () => {
expect(routesToNewCard(status())).toBe(false);
});
});
+
+ /**
+ * The sunset's bulk cancel closed the card of a holder who never moved. The
+ * app says so, offers what was left on it, and the new card where there is
+ * one — never the old card as if it worked, nor "activate your card".
+ */
+ describe('a card the sunset closed', () => {
+ const closed = (overrides: Partial = {}) =>
+ sunset({ hasRainCard: false, notice: false, cardClosed: true, ...overrides });
+ const status = (rainSunset?: RainSunsetStatus): CardStatusResponse => ({ rainSunset });
+
+ it('still reads the balance on it', () => {
+ expect(holdsClosingCard(closed())).toBe(true);
+ expect(holdsClosingCard(sunset())).toBe(true);
+ expect(holdsClosingCard(sunset({ hasRainCard: false }))).toBe(false);
+ expect(holdsClosingCard(null)).toBe(false);
+ });
+
+ it('asks for the withdrawal first while money is left, even with a new card available', () => {
+ expect(rainClosingBannerState(closed(), 12.5)).toBe('closed-balance');
+ expect(rainClosingBannerState(closed({ newCardAvailable: true }), 12.5)).toBe(
+ 'closed-balance',
+ );
+ // A balance that could not be read is never shown as empty.
+ expect(rainClosingBannerState(closed(), null)).toBe('closed-balance');
+ });
+
+ it('offers the new card once nothing is left, or says cards are gone', () => {
+ expect(rainClosingBannerState(closed({ newCardAvailable: true }), 0)).toBe('new-card');
+ expect(rainClosingBannerState(closed(), 0)).toBe('closed-empty');
+ });
+
+ it('words the banner for a card that is already closed', () => {
+ expect(homeBannerCopy('closed-balance', closed(), 12.5)).toEqual({
+ title: 'Your card was closed',
+ message: 'Withdraw the $12.50 left on it to your wallet.',
+ });
+ expect(homeBannerCopy('new-card', closed({ newCardAvailable: true }), 0).message).toBe(
+ 'Your previous card was closed. A new one takes a few minutes.',
+ );
+ expect(homeBannerCopy('closed-empty', closed(), 0).title).toBe('Your card was closed');
+ });
+
+ it('explains the closed card, with the new card only where there is one', () => {
+ const withNewCard = closedCardCopy(closed({ newCardAvailable: true }), 3, 'Kenya');
+ expect(withNewCard.message).toContain('Get your new Solid card');
+ expect(withNewCard.message).toContain('The $3.00 left on it is still yours');
+
+ const noNewCard = closedCardCopy(closed(), 0, 'Kenya');
+ expect(noNewCard.message).toContain("aren't available in Kenya");
+ expect(noNewCard.message).not.toContain('withdraw');
+ expect(`${noNewCard.title} ${noNewCard.message}`).not.toMatch(/rain/i);
+ });
+
+ it('routes the card flow to the new card, else to the closed card', () => {
+ expect(routesToNewCard(status(closed({ newCardAvailable: true })))).toBe(true);
+ expect(routesToClosedCard(status(closed({ newCardAvailable: true })))).toBe(false);
+ expect(routesToClosedCard(status(closed()))).toBe(true);
+ expect(routesToClosedCard(status(sunset()))).toBe(false);
+ expect(routesToClosedCard(status())).toBe(false);
+ });
+ });
});
diff --git a/lib/utils/homePromptStep.ts b/lib/utils/homePromptStep.ts
index a3c6b3b90..fe1727eb3 100644
--- a/lib/utils/homePromptStep.ts
+++ b/lib/utils/homePromptStep.ts
@@ -87,6 +87,11 @@ export function resolveHomePromptStep({
holdsUnusableEurc = false,
holdsUnreachableBase = false,
}: HomePromptStepInput): HomePromptKey | null {
+ // Rain sunset: the sunset closed their card. Its own banner says so and offers
+ // the withdrawal or the new card; read as "no card", the ladder would offer to
+ // activate the card that was just closed.
+ if (cardStatus?.rainSunset?.cardClosed) return null;
+
// Verified long ago and spent on a card that is now gone: "Your Solid card is
// ready! Activate" would be the wrong news, and was all this user was shown.
if (canReplaceClosedCard(cardStatus)) return 'replace-card';
diff --git a/lib/utils/rainSunset.ts b/lib/utils/rainSunset.ts
index 1b0a21457..0af2302e5 100644
--- a/lib/utils/rainSunset.ts
+++ b/lib/utils/rainSunset.ts
@@ -98,6 +98,19 @@ export function hasStartedNewCard(sunset: RainSunsetStatus | null | undefined):
return Boolean(sunset?.migration);
}
+/** The sunset closed their card (they never got the new one). */
+export function isClosedCard(sunset: RainSunsetStatus | null | undefined): boolean {
+ return Boolean(sunset?.cardClosed);
+}
+
+/**
+ * Whether money can still be on their old card: they hold it, or the sunset
+ * closed it — a closed card's balance stays theirs to withdraw.
+ */
+export function holdsClosingCard(sunset: RainSunsetStatus | null | undefined): boolean {
+ return Boolean(sunset?.hasRainCard || sunset?.cardClosed);
+}
+
/**
* Which Home banner (Figma "Rain closing / Home banner") the user gets.
*
@@ -106,14 +119,30 @@ export function hasStartedNewCard(sunset: RainSunsetStatus | null | undefined):
* - `closing-balance`: no new card for them yet, and money left on the card —
* or a balance that could not be read, which is never shown as empty.
* - `closing-empty`: no new card for them yet and nothing left to withdraw.
+ * - `closed-balance`: the card was closed and money is still on it (or its
+ * balance could not be read). Ahead of the new card: the money is theirs,
+ * and the new card is issued only once it is withdrawn.
+ * - `closed-empty`: the card was closed, nothing is left on it and no new card
+ * is available where they live.
*/
-export type RainClosingBannerState = 'new-card' | 'closing-balance' | 'closing-empty';
+export type RainClosingBannerState =
+ | 'new-card'
+ | 'closing-balance'
+ | 'closing-empty'
+ | 'closed-balance'
+ | 'closed-empty';
export function rainClosingBannerState(
sunset: RainSunsetStatus | null | undefined,
balanceUsd: number | null | undefined,
): RainClosingBannerState | null {
if (!sunset) return null;
+ if (sunset.cardClosed) {
+ if (isClosingBalanceUnknown(balanceUsd) || hasClosingBalance(balanceUsd)) {
+ return 'closed-balance';
+ }
+ return sunset.newCardAvailable ? 'new-card' : 'closed-empty';
+ }
if (sunset.newCardAvailable) return 'new-card';
if (!sunset.notice) return null;
if (isClosingBalanceUnknown(balanceUsd)) return 'closing-balance';
@@ -138,6 +167,17 @@ export function homeBannerCopy(
const closes = closesPhrase(sunset.closesAt, 'short');
switch (state) {
case 'new-card':
+ if (sunset.cardClosed) {
+ return hasStartedNewCard(sunset)
+ ? {
+ title: 'Finish getting your new card',
+ message: 'Your previous card was closed. Pick up where you left off.',
+ }
+ : {
+ title: 'Get your new Solid card',
+ message: 'Your previous card was closed. A new one takes a few minutes.',
+ };
+ }
// A Rain applicant who never got a card has no "current card" to close.
if (!sunset.hasRainCard) {
return hasStartedNewCard(sunset)
@@ -171,9 +211,50 @@ export function homeBannerCopy(
title: `Your card closes ${closes}`,
message: 'Nothing to withdraw. Move any subscriptions to another card before then.',
};
+ case 'closed-balance':
+ return {
+ title: 'Your card was closed',
+ message: isClosingBalanceUnknown(balanceUsd)
+ ? 'Withdraw what was left on it to your wallet.'
+ : `Withdraw the ${formatClosingBalance(balanceUsd ?? 0)} left on it to your wallet.`,
+ };
+ case 'closed-empty':
+ return {
+ title: 'Your card was closed',
+ message:
+ "Solid cards aren't available where you live right now. Your Solid account keeps working as usual.",
+ };
}
}
+/** Copy for a card the sunset closed, on its own screen and the card notice. */
+export function closedCardCopy(
+ sunset: RainSunsetStatus,
+ balanceUsd: number | null | undefined,
+ countryName?: string | null,
+): { title: string; message: string } {
+ const balance = isClosingBalanceUnknown(balanceUsd)
+ ? ' Withdraw whatever is left on it to your wallet.'
+ : hasClosingBalance(balanceUsd)
+ ? ` The ${formatClosingBalance(balanceUsd ?? 0)} left on it is still yours: withdraw it to your wallet.`
+ : '';
+ if (sunset.newCardAvailable || sunset.migration) {
+ return {
+ title: 'Your card was closed',
+ message:
+ "We've moved Solid cards to a new card partner, and your previous card can't be used any more." +
+ `${balance} Get your new Solid card, it takes a few minutes.`,
+ };
+ }
+ const where = countryName ? ` in ${countryName}` : ' where you live';
+ return {
+ title: 'Your card was closed',
+ message:
+ `Solid cards aren't available${where} right now, and your previous card can't be used any more.` +
+ `${balance} Your Solid account keeps working as usual.`,
+ };
+}
+
/** Copy for the card-screen notice (Figma "Rain closing / Card notice"). */
export function cardNoticeCopy(
sunset: RainSunsetStatus,
@@ -221,6 +302,15 @@ export function routesToNewCard(cardStatus: CardStatusResponse | null | undefine
return sunset.newCardAvailable || Boolean(sunset.migration);
}
+/**
+ * Whether the card flow should show the closed-card screen: the sunset closed
+ * their card and there is no new card to send them to. Without it, the closed
+ * card reads as "no card" and the issuance flow offers to activate it.
+ */
+export function routesToClosedCard(cardStatus: CardStatusResponse | null | undefined): boolean {
+ return Boolean(cardStatus?.rainSunset?.cardClosed) && !routesToNewCard(cardStatus);
+}
+
/**
* Whole cents in a dollar figure, rounded down, read from the number's own
* decimal digits — never `usd * 100`, which floating point can push across a