-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44321 from waterim/feat-42432-Implement_3ds_flow
- Loading branch information
Showing
14 changed files
with
172 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
type VerifySetupIntentParams = { | ||
accountID: number; | ||
isVerifying: boolean; | ||
}; | ||
export default VerifySetupIntentParams; |
This file contains 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
This file contains 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
This file contains 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
96 changes: 96 additions & 0 deletions
96
src/pages/settings/Subscription/CardAuthenticationModal/index.tsx
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import React, {useCallback, useEffect, useState} from 'react'; | ||
import {View} from 'react-native'; | ||
import {useOnyx} from 'react-native-onyx'; | ||
import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; | ||
import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
import Modal from '@components/Modal'; | ||
import ScreenWrapper from '@components/ScreenWrapper'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
import * as PaymentMethods from '@userActions/PaymentMethods'; | ||
import CONST from '@src/CONST'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import ROUTES from '@src/ROUTES'; | ||
|
||
type CardAuthenticationModalProps = { | ||
/** Title shown in the header of the modal */ | ||
headerTitle?: string; | ||
}; | ||
function CardAuthenticationModal({headerTitle}: CardAuthenticationModalProps) { | ||
const styles = useThemeStyles(); | ||
const [authenticationLink] = useOnyx(ONYXKEYS.VERIFY_3DS_SUBSCRIPTION); | ||
const [session] = useOnyx(ONYXKEYS.SESSION); | ||
const [privateStripeCustomerID] = useOnyx(ONYXKEYS.NVP_PRIVATE_STRIPE_CUSTOMER_ID); | ||
const [isLoading, setIsLoading] = useState(true); | ||
|
||
useEffect(() => { | ||
if (privateStripeCustomerID?.status !== CONST.STRIPE_GBP_AUTH_STATUSES.SUCCEEDED) { | ||
return; | ||
} | ||
PaymentMethods.clearPaymentCard3dsVerification(); | ||
Navigation.navigate(ROUTES.SETTINGS_SUBSCRIPTION); | ||
}, [privateStripeCustomerID]); | ||
|
||
const handleGBPAuthentication = useCallback( | ||
(event: MessageEvent<string>) => { | ||
const message = event.data; | ||
if (message === CONST.GBP_AUTHENTICATION_COMPLETE) { | ||
PaymentMethods.verifySetupIntent(session?.accountID ?? -1, true); | ||
} | ||
}, | ||
[session?.accountID], | ||
); | ||
|
||
useEffect(() => { | ||
window.addEventListener('message', handleGBPAuthentication); | ||
return () => { | ||
window.removeEventListener('message', handleGBPAuthentication); | ||
}; | ||
}, [handleGBPAuthentication]); | ||
|
||
const onModalClose = () => { | ||
PaymentMethods.clearPaymentCard3dsVerification(); | ||
}; | ||
|
||
return ( | ||
<Modal | ||
type={CONST.MODAL.MODAL_TYPE.CENTERED_UNSWIPEABLE} | ||
isVisible={!!authenticationLink} | ||
onClose={onModalClose} | ||
onModalHide={onModalClose} | ||
> | ||
<ScreenWrapper | ||
style={styles.pb0} | ||
includePaddingTop={false} | ||
includeSafeAreaPaddingBottom={false} | ||
testID={CardAuthenticationModal.displayName} | ||
> | ||
<HeaderWithBackButton | ||
title={headerTitle} | ||
shouldShowBorderBottom | ||
shouldShowCloseButton | ||
onCloseButtonPress={onModalClose} | ||
shouldShowBackButton={false} | ||
/> | ||
{isLoading && <FullScreenLoadingIndicator />} | ||
<View style={[styles.flex1]}> | ||
<iframe | ||
src={authenticationLink} | ||
title="Statements" | ||
height="100%" | ||
width="100%" | ||
seamless | ||
style={{border: 'none'}} | ||
onLoad={() => { | ||
setIsLoading(false); | ||
}} | ||
/> | ||
</View> | ||
</ScreenWrapper> | ||
</Modal> | ||
); | ||
} | ||
|
||
CardAuthenticationModal.displayName = 'CardAuthenticationModal'; | ||
|
||
export default CardAuthenticationModal; |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** Model of private stripe customer ID */ | ||
type PrivateStripeCustomer = { | ||
/** Currency of the stripe payment */ | ||
[currency: string]: string; | ||
/** paymentMethodID of the stripe payment */ | ||
paymentMethodID: string; | ||
/** Status of the stripe payment */ | ||
status: string; | ||
}; | ||
|
||
export default PrivateStripeCustomer; |