Skip to content

Commit 8c228cc

Browse files
authored
Merge pull request Expensify#68457 from Expensify/rodrigo-improve-retrypaymnet
[NO QA] Fix Retry Payment when failed for authentication
2 parents af66079 + 360d91e commit 8c228cc

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/CONST/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6980,6 +6980,7 @@ const CONST = {
69806980

69816981
BILLING: {
69826982
TYPE_FAILED_2018: 'failed_2018',
6983+
TYPE_STRIPE_FAILED_AUTHENTICATION: 'failed_stripe_authentication',
69836984
},
69846985

69856986
ONBOARDING_HELP: {

src/pages/settings/Subscription/CardSection/CardSection.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ function CardSection() {
5959
const {isOffline} = useNetwork();
6060
const defaultCard = useMemo(() => Object.values(fundList ?? {}).find((card) => card.accountData?.additionalData?.isBillingCard), [fundList]);
6161
const cardMonth = useMemo(() => DateUtils.getMonthNames()[(defaultCard?.accountData?.cardMonth ?? 1) - 1], [defaultCard?.accountData?.cardMonth]);
62+
const hasFailedLastBilling = useMemo(
63+
() => purchaseList?.[0]?.message.billingType === CONST.BILLING.TYPE_STRIPE_FAILED_AUTHENTICATION || purchaseList?.[0]?.message.billingType === CONST.BILLING.TYPE_FAILED_2018,
64+
[purchaseList],
65+
);
6266

6367
const requestRefund = useCallback(() => {
6468
requestRefundByUser();
@@ -102,11 +106,11 @@ function CardSection() {
102106
};
103107

104108
useEffect(() => {
105-
if (!authenticationLink || privateStripeCustomerID?.status !== CONST.STRIPE_SCA_AUTH_STATUSES.CARD_AUTHENTICATION_REQUIRED) {
109+
if (!authenticationLink || (privateStripeCustomerID?.status !== CONST.STRIPE_SCA_AUTH_STATUSES.CARD_AUTHENTICATION_REQUIRED && !hasFailedLastBilling)) {
106110
return;
107111
}
108112
Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION_ADD_PAYMENT_CARD);
109-
}, [authenticationLink, privateStripeCustomerID?.status]);
113+
}, [authenticationLink, privateStripeCustomerID?.status, hasFailedLastBilling]);
110114

111115
const handleAuthenticatePayment = () => {
112116
verifySetupIntent(session?.accountID ?? CONST.DEFAULT_NUMBER_ID, false);

0 commit comments

Comments
 (0)