boxpay-checkout-reactnative-sdk 1.0.9 → 1.0.11-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/module/interface.js +13 -0
- package/lib/module/interface.js.map +1 -1
- package/lib/module/navigation.js +11 -10
- package/lib/module/navigation.js.map +1 -1
- package/lib/module/postRequest/fetchPaymentMethods.js +6 -1
- package/lib/module/postRequest/fetchPaymentMethods.js.map +1 -1
- package/lib/module/screens/addressScreen.js +7 -3
- package/lib/module/screens/addressScreen.js.map +1 -1
- package/lib/module/screens/bnplScreen.js +10 -3
- package/lib/module/screens/bnplScreen.js.map +1 -1
- package/lib/module/screens/cardScreen.js +359 -348
- package/lib/module/screens/cardScreen.js.map +1 -1
- package/lib/module/screens/emiScreen.js +14 -5
- package/lib/module/screens/emiScreen.js.map +1 -1
- package/lib/module/screens/mainScreen.js +17 -5
- package/lib/module/screens/mainScreen.js.map +1 -1
- package/lib/module/screens/netBankingScreen.js +10 -3
- package/lib/module/screens/netBankingScreen.js.map +1 -1
- package/lib/module/screens/walletScreen.js +10 -3
- package/lib/module/screens/walletScreen.js.map +1 -1
- package/lib/module/sdk-version.json +1 -1
- package/lib/module/sharedContext/handleAutoNavigation.js +33 -0
- package/lib/module/sharedContext/handleAutoNavigation.js.map +1 -0
- package/lib/module/sharedContext/handlePaymentResponseHandler.js +7 -5
- package/lib/module/sharedContext/handlePaymentResponseHandler.js.map +1 -1
- package/lib/module/styles/screens/cardScreenStyles.js +14 -7
- package/lib/module/styles/screens/cardScreenStyles.js.map +1 -1
- package/lib/typescript/src/interface.d.ts +28 -0
- package/lib/typescript/src/interface.d.ts.map +1 -1
- package/lib/typescript/src/navigation.d.ts.map +1 -1
- package/lib/typescript/src/postRequest/fetchPaymentMethods.d.ts.map +1 -1
- package/lib/typescript/src/screens/addressScreen.d.ts +1 -1
- package/lib/typescript/src/screens/addressScreen.d.ts.map +1 -1
- package/lib/typescript/src/screens/bnplScreen.d.ts +4 -2
- package/lib/typescript/src/screens/bnplScreen.d.ts.map +1 -1
- package/lib/typescript/src/screens/cardScreen.d.ts.map +1 -1
- package/lib/typescript/src/screens/emiScreen.d.ts +4 -2
- package/lib/typescript/src/screens/emiScreen.d.ts.map +1 -1
- package/lib/typescript/src/screens/mainScreen.d.ts.map +1 -1
- package/lib/typescript/src/screens/netBankingScreen.d.ts +4 -2
- package/lib/typescript/src/screens/netBankingScreen.d.ts.map +1 -1
- package/lib/typescript/src/screens/walletScreen.d.ts +4 -2
- package/lib/typescript/src/screens/walletScreen.d.ts.map +1 -1
- package/lib/typescript/src/sharedContext/handleAutoNavigation.d.ts +3 -0
- package/lib/typescript/src/sharedContext/handleAutoNavigation.d.ts.map +1 -0
- package/lib/typescript/src/sharedContext/handlePaymentResponseHandler.d.ts.map +1 -1
- package/lib/typescript/src/styles/screens/cardScreenStyles.d.ts +14 -7
- package/lib/typescript/src/styles/screens/cardScreenStyles.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/interface.ts +41 -1
- package/src/navigation.tsx +11 -10
- package/src/postRequest/fetchPaymentMethods.ts +15 -4
- package/src/screens/addressScreen.tsx +10 -5
- package/src/screens/bnplScreen.tsx +12 -5
- package/src/screens/cardScreen.tsx +19 -9
- package/src/screens/emiScreen.tsx +17 -7
- package/src/screens/mainScreen.tsx +18 -5
- package/src/screens/netBankingScreen.tsx +12 -5
- package/src/screens/walletScreen.tsx +11 -5
- package/src/sdk-version.json +1 -1
- package/src/sharedContext/handleAutoNavigation.ts +50 -0
- package/src/sharedContext/handlePaymentResponseHandler.ts +10 -7
- package/src/styles/screens/cardScreenStyles.ts +11 -7
|
@@ -4,7 +4,8 @@ import {
|
|
|
4
4
|
Image,
|
|
5
5
|
BackHandler,
|
|
6
6
|
Pressable,
|
|
7
|
-
TouchableOpacity
|
|
7
|
+
TouchableOpacity,
|
|
8
|
+
ScrollView
|
|
8
9
|
} from 'react-native';
|
|
9
10
|
import { useEffect, useRef, useState } from 'react';
|
|
10
11
|
import Header from '../components/header';
|
|
@@ -53,6 +54,7 @@ const CardScreen = ({ route, navigation }: Props) => {
|
|
|
53
54
|
percent,
|
|
54
55
|
cardType,
|
|
55
56
|
issuerBrand,
|
|
57
|
+
isAutoNavigationEnabled
|
|
56
58
|
} = route.params as CardScreenParams || {};
|
|
57
59
|
const durationNumber = Array.isArray(duration) ? duration[0] : duration;
|
|
58
60
|
const bankNameStr = Array.isArray(bankName) ? bankName[0] : bankName;
|
|
@@ -123,7 +125,7 @@ const CardScreen = ({ route, navigation }: Props) => {
|
|
|
123
125
|
const [sessionExpireModalOpen, setSessionExppireModalState] = useState(false);
|
|
124
126
|
const [successfulTimeStamp, setSuccessfulTimeStamp] = useState('');
|
|
125
127
|
|
|
126
|
-
const [status, setStatus] = useState<string
|
|
128
|
+
const [status, setStatus] = useState<string>("NOACTION");
|
|
127
129
|
const [transactionId, setTransactionId] = useState<string | null>(null);
|
|
128
130
|
|
|
129
131
|
const backgroundApiInterval = useRef<NodeJS.Timeout | null>(null);
|
|
@@ -457,8 +459,13 @@ const CardScreen = ({ route, navigation }: Props) => {
|
|
|
457
459
|
};
|
|
458
460
|
|
|
459
461
|
const onProceedBack = () => {
|
|
460
|
-
|
|
461
|
-
|
|
462
|
+
if (isAutoNavigationEnabled) {
|
|
463
|
+
onExitCheckout();
|
|
464
|
+
return true;
|
|
465
|
+
} else {
|
|
466
|
+
navigation.goBack()
|
|
467
|
+
return true;
|
|
468
|
+
}
|
|
462
469
|
};
|
|
463
470
|
|
|
464
471
|
const callFetchStatusApi = async () => {
|
|
@@ -589,7 +596,11 @@ const CardScreen = ({ route, navigation }: Props) => {
|
|
|
589
596
|
<Text>Loading...</Text>
|
|
590
597
|
</View>
|
|
591
598
|
) : (
|
|
592
|
-
|
|
599
|
+
<View style= {{flex:1}}>
|
|
600
|
+
<ScrollView
|
|
601
|
+
contentContainerStyle={styles.screenView}
|
|
602
|
+
keyboardShouldPersistTaps="handled"
|
|
603
|
+
>
|
|
593
604
|
<Header
|
|
594
605
|
onBackPress={onProceedBack}
|
|
595
606
|
showDesc={true}
|
|
@@ -1031,9 +1042,8 @@ const CardScreen = ({ route, navigation }: Props) => {
|
|
|
1031
1042
|
}}
|
|
1032
1043
|
/>
|
|
1033
1044
|
)}
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
>
|
|
1045
|
+
</ScrollView>
|
|
1046
|
+
<View>
|
|
1037
1047
|
{cardValid ? (
|
|
1038
1048
|
<Pressable
|
|
1039
1049
|
style={[
|
|
@@ -1056,7 +1066,7 @@ const CardScreen = ({ route, navigation }: Props) => {
|
|
|
1056
1066
|
</Pressable>
|
|
1057
1067
|
)}
|
|
1058
1068
|
</View>
|
|
1059
|
-
|
|
1069
|
+
</View>
|
|
1060
1070
|
)}
|
|
1061
1071
|
{failedModalOpen && (
|
|
1062
1072
|
<PaymentFailed
|
|
@@ -13,7 +13,8 @@ import {
|
|
|
13
13
|
type Emi,
|
|
14
14
|
type PaymentResultObject,
|
|
15
15
|
type PaymentMethod,
|
|
16
|
-
APIStatus
|
|
16
|
+
APIStatus,
|
|
17
|
+
type EmiScreenParams
|
|
17
18
|
} from '../interface';
|
|
18
19
|
import { checkoutDetailsHandler, setCheckOutDetailsHandlerToDefault } from '../sharedContext/checkoutDetailsHandler';
|
|
19
20
|
import fetchPaymentMethods from '../postRequest/fetchPaymentMethods';
|
|
@@ -35,16 +36,20 @@ import Toast from 'react-native-toast-message'
|
|
|
35
36
|
import styles from '../styles/screens/emiScreenStyles';
|
|
36
37
|
import { handleFetchStatusResponseHandler, handlePaymentResponse } from '../sharedContext/handlePaymentResponseHandler';
|
|
37
38
|
import type { CheckoutStackParamList } from '../navigation';
|
|
38
|
-
import type { NavigationProp } from '@react-navigation/native';
|
|
39
|
+
import type { NavigationProp, RouteProp } from '@react-navigation/native';
|
|
39
40
|
import { setUserDataHandlerToDefault } from '../sharedContext/userdataHandler';
|
|
40
41
|
|
|
42
|
+
type EmiScreenRouteProp = RouteProp<CheckoutStackParamList, 'EmiScreen'>;
|
|
43
|
+
|
|
41
44
|
type EmiScreenNavigationProp = NavigationProp<CheckoutStackParamList, 'EmiScreen'>;
|
|
42
45
|
|
|
43
46
|
interface Props {
|
|
44
47
|
navigation: EmiScreenNavigationProp;
|
|
48
|
+
route: EmiScreenRouteProp;
|
|
45
49
|
}
|
|
46
50
|
|
|
47
|
-
const EmiScreen = ({ navigation }: Props) => {
|
|
51
|
+
const EmiScreen = ({ navigation, route }: Props) => {
|
|
52
|
+
const { isAutoNavigationEnabled } = route.params as EmiScreenParams || {};
|
|
48
53
|
const [emiBankList, setEmiBankList] = useState<ChooseEmiModel>({ cards: [] });
|
|
49
54
|
const [defaultEmiBankList, setDefaultEmiBankList] = useState<ChooseEmiModel>({
|
|
50
55
|
cards: [],
|
|
@@ -77,8 +82,8 @@ const EmiScreen = ({ navigation }: Props) => {
|
|
|
77
82
|
const [sessionExpireModalOpen, setSessionExppireModalOpen] = useState(false);
|
|
78
83
|
const [successfulTimeStamp, setSuccessfulTimeStamp] = useState('');
|
|
79
84
|
|
|
80
|
-
const [status, setStatus] = useState(
|
|
81
|
-
const [transactionId, setTransactionId] = useState(
|
|
85
|
+
const [status, setStatus] = useState<string>("NOACTION");
|
|
86
|
+
const [transactionId, setTransactionId] = useState<string | null>(null);
|
|
82
87
|
|
|
83
88
|
const [paymentHtml, setPaymentHtml] = useState('');
|
|
84
89
|
const [paymentUrl, setPaymentUrl] = useState('');
|
|
@@ -371,8 +376,13 @@ const EmiScreen = ({ navigation }: Props) => {
|
|
|
371
376
|
};
|
|
372
377
|
|
|
373
378
|
const onProceedBack = () => {
|
|
374
|
-
|
|
375
|
-
|
|
379
|
+
if (isAutoNavigationEnabled) {
|
|
380
|
+
onExitCheckout();
|
|
381
|
+
return true;
|
|
382
|
+
} else {
|
|
383
|
+
navigation.goBack()
|
|
384
|
+
return true;
|
|
385
|
+
}
|
|
376
386
|
};
|
|
377
387
|
|
|
378
388
|
useEffect(() => {
|
|
@@ -15,7 +15,7 @@ import type { CheckoutStackParamList } from '../navigation';
|
|
|
15
15
|
import { paymentHandler, setPaymentHandler } from "../sharedContext/paymentStatusHandler";
|
|
16
16
|
import { loadBoxpayFonts } from '../components/fontFamily';
|
|
17
17
|
import { setUserDataHandler, setUserDataHandlerToDefault, userDataHandler } from '../sharedContext/userdataHandler';
|
|
18
|
-
import { type PaymentResultObject, type PaymentClass, type InstrumentDetails, type PaymentMethod, type OrderItem, APIStatus, AnalyticsEvents, type DeliveryAddress, type BoxpayCheckoutProps, type GetInstantOffersResponse, UIConfigurationOptions } from '../interface';
|
|
18
|
+
import { type PaymentResultObject, type PaymentClass, type InstrumentDetails, type PaymentMethod, type OrderItem, APIStatus, AnalyticsEvents, type DeliveryAddress, type BoxpayCheckoutProps, type GetInstantOffersResponse, UIConfigurationOptions, TransactionStatus } from '../interface';
|
|
19
19
|
import { checkoutDetailsHandler, setCheckoutDetailsHandler, setCheckOutDetailsHandlerToDefault } from '../sharedContext/checkoutDetailsHandler';
|
|
20
20
|
import WebViewScreen from '../screens/webViewScreen';
|
|
21
21
|
import styles from '../styles/indexStyles';
|
|
@@ -34,6 +34,7 @@ import { formatAddress, getPhoneNumberCodeAndCountryName, useCountdown } from '.
|
|
|
34
34
|
import fetchSurCharge from '../postRequest/fetchSurcharge';
|
|
35
35
|
import fetchInstantOffer from '../postRequest/fetchInstantOffer';
|
|
36
36
|
import ApplyCouponCard from '../components/applyCouponCard';
|
|
37
|
+
import { handleAutoNavigation } from '../sharedContext/handleAutoNavigation';
|
|
37
38
|
|
|
38
39
|
type MainScreenRouteProp = RouteProp<CheckoutStackParamList, 'MainScreen'>;
|
|
39
40
|
|
|
@@ -218,7 +219,6 @@ const MainScreen = ({route, navigation} : MainScreenProps) => {
|
|
|
218
219
|
setUpiInstrumentList : setSavedUpiArray,
|
|
219
220
|
setCardInstrumentList : setSavedCardArray
|
|
220
221
|
});
|
|
221
|
-
setIsFirstLoading(false)
|
|
222
222
|
};
|
|
223
223
|
|
|
224
224
|
useEffect(() => {
|
|
@@ -486,9 +486,10 @@ const MainScreen = ({route, navigation} : MainScreenProps) => {
|
|
|
486
486
|
if (['APPROVED', 'SUCCESS', 'PAID'].includes(response.data.status)) {
|
|
487
487
|
setSuccessfulTimeStamp(response.data.lastPaidAtTimestampLocale);
|
|
488
488
|
setTransactionId(response.data.lastTransactionId);
|
|
489
|
-
setStatus(
|
|
489
|
+
setStatus(TransactionStatus.Success);
|
|
490
490
|
setSuccessModalState(true);
|
|
491
491
|
} else if (['EXPIRED'].includes(response.data.status)) {
|
|
492
|
+
setStatus(TransactionStatus.Expired);
|
|
492
493
|
setSessionExppireModalState(true);
|
|
493
494
|
}
|
|
494
495
|
|
|
@@ -581,7 +582,7 @@ const MainScreen = ({route, navigation} : MainScreenProps) => {
|
|
|
581
582
|
isEmiMethodEnabled : methodFlags.isEMIVisible,
|
|
582
583
|
isBnplMethodEnabled : methodFlags.isBNPLVisible,
|
|
583
584
|
isUPIOtmCollectMethodEnabled : methodFlags.isUPIOtmCollectVisible,
|
|
584
|
-
isUPIOtmIntentMethodEnabled : methodFlags.
|
|
585
|
+
isUPIOtmIntentMethodEnabled : methodFlags.isUPIOtmIntentVisible,
|
|
585
586
|
isUPIOtmQRMethodEnabled : methodFlags.isUPIOtmQRVisible,
|
|
586
587
|
isOrderItemDetailsVisible : isFieldEnabled('ORDER_ITEM_DETAILS'),
|
|
587
588
|
isSICheckboxVisible : configurationOptions?.SHOW_SI_CHECKBOX ? true : false,
|
|
@@ -688,9 +689,21 @@ const MainScreen = ({route, navigation} : MainScreenProps) => {
|
|
|
688
689
|
|
|
689
690
|
const callRecommendedOrStopLoding =async() => {
|
|
690
691
|
if(shopperToken != null && shopperToken != "") {
|
|
691
|
-
getRecommendedInstruments()
|
|
692
|
+
await getRecommendedInstruments()
|
|
693
|
+
checkAutoNavigation()
|
|
692
694
|
} else {
|
|
695
|
+
checkAutoNavigation()
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
const checkAutoNavigation = () => {
|
|
700
|
+
const targetScreen = handleAutoNavigation(
|
|
701
|
+
savedCardArray
|
|
702
|
+
)
|
|
703
|
+
if (!targetScreen) {
|
|
693
704
|
setIsFirstLoading(false)
|
|
705
|
+
} else {
|
|
706
|
+
navigation.navigate(targetScreen, {isAutoNavigationEnabled : true})
|
|
694
707
|
}
|
|
695
708
|
}
|
|
696
709
|
|
|
@@ -11,7 +11,7 @@ import { checkoutDetailsHandler, setCheckOutDetailsHandlerToDefault } from '../s
|
|
|
11
11
|
import LottieView from 'lottie-react-native';
|
|
12
12
|
import Header from '../components/header';
|
|
13
13
|
import { TextInput } from 'react-native-paper';
|
|
14
|
-
import type { PaymentClass, PaymentResultObject } from '../interface';
|
|
14
|
+
import type { NetBankingScreenParams, PaymentClass, PaymentResultObject } from '../interface';
|
|
15
15
|
import ShimmerView from '../components/shimmerView';
|
|
16
16
|
import PaymentSuccess from '../components/paymentSuccess';
|
|
17
17
|
import SessionExpire from '../components/sessionExpire';
|
|
@@ -24,16 +24,20 @@ import PaymentSelectorView from '../components/paymentSelector';
|
|
|
24
24
|
import { fetchPaymentMethodHandler, handleFetchStatusResponseHandler, handlePaymentResponse } from '../sharedContext/handlePaymentResponseHandler';
|
|
25
25
|
import styles from '../styles/screens/netBankingScreenStyles';
|
|
26
26
|
import type { CheckoutStackParamList } from '../navigation';
|
|
27
|
-
import type { NavigationProp } from '@react-navigation/native';
|
|
27
|
+
import type { NavigationProp, RouteProp } from '@react-navigation/native';
|
|
28
28
|
import { setUserDataHandlerToDefault } from '../sharedContext/userdataHandler';
|
|
29
29
|
|
|
30
|
+
type NetBankingScreenRouteProp = RouteProp<CheckoutStackParamList, 'NetBankingScreen'>;
|
|
31
|
+
|
|
30
32
|
type NetBankingScreenNavigationProp = NavigationProp<CheckoutStackParamList, 'NetBankingScreen'>;
|
|
31
33
|
|
|
32
34
|
interface Props {
|
|
33
35
|
navigation: NetBankingScreenNavigationProp;
|
|
36
|
+
route: NetBankingScreenRouteProp;
|
|
34
37
|
}
|
|
35
38
|
|
|
36
|
-
const NetBankingScreen = ({ navigation }: Props) => {
|
|
39
|
+
const NetBankingScreen = ({ navigation, route }: Props) => {
|
|
40
|
+
const { isAutoNavigationEnabled } = route.params as NetBankingScreenParams || {};
|
|
37
41
|
const [netBankingList, setNetBankingList] = useState<PaymentClass[]>([]);
|
|
38
42
|
const [defaultNetBankingList, setDefaultNetBankingList] = useState<
|
|
39
43
|
PaymentClass[]
|
|
@@ -72,7 +76,7 @@ const NetBankingScreen = ({ navigation }: Props) => {
|
|
|
72
76
|
const [sessionExpireModalOpen, setSessionExppireModalState] = useState(false);
|
|
73
77
|
const [successfulTimeStamp, setSuccessfulTimeStamp] = useState('');
|
|
74
78
|
|
|
75
|
-
const [status, setStatus] = useState<string
|
|
79
|
+
const [status, setStatus] = useState<string>("NOACTION");
|
|
76
80
|
const [transactionId, setTransactionId] = useState<string | null>(null);
|
|
77
81
|
|
|
78
82
|
const backgroundApiInterval = useRef<NodeJS.Timeout | null>(null);
|
|
@@ -80,9 +84,12 @@ const NetBankingScreen = ({ navigation }: Props) => {
|
|
|
80
84
|
const [searchTextFocused, setSearchTextFocused] = useState(false);
|
|
81
85
|
|
|
82
86
|
const onProceedBack = () => {
|
|
83
|
-
if (!loading) {
|
|
87
|
+
if (!loading && !isAutoNavigationEnabled) {
|
|
84
88
|
navigation.goBack()
|
|
85
89
|
return true;
|
|
90
|
+
} else if (!loading && isAutoNavigationEnabled) {
|
|
91
|
+
onExitCheckout();
|
|
92
|
+
return true;
|
|
86
93
|
}
|
|
87
94
|
return false;
|
|
88
95
|
};
|
|
@@ -11,7 +11,7 @@ import { checkoutDetailsHandler, setCheckOutDetailsHandlerToDefault } from '../s
|
|
|
11
11
|
import LottieView from 'lottie-react-native';
|
|
12
12
|
import Header from '../components/header';
|
|
13
13
|
import { TextInput } from 'react-native-paper';
|
|
14
|
-
import type { PaymentClass, PaymentResultObject } from '../interface';
|
|
14
|
+
import type { PaymentClass, PaymentResultObject, WalletScreenParams } from '../interface';
|
|
15
15
|
import PaymentSelectorView from '../components/paymentSelector';
|
|
16
16
|
import PaymentSuccess from '../components/paymentSuccess';
|
|
17
17
|
import SessionExpire from '../components/sessionExpire';
|
|
@@ -24,16 +24,19 @@ import { fetchPaymentMethodHandler, handleFetchStatusResponseHandler, handlePaym
|
|
|
24
24
|
import ShimmerView from '../components/shimmerView';
|
|
25
25
|
import styles from '../styles/screens/walletScreenStyles';
|
|
26
26
|
import type { CheckoutStackParamList } from '../navigation';
|
|
27
|
-
import type { NavigationProp } from '@react-navigation/native';
|
|
27
|
+
import type { NavigationProp, RouteProp } from '@react-navigation/native';
|
|
28
28
|
import { setUserDataHandlerToDefault } from '../sharedContext/userdataHandler';
|
|
29
29
|
|
|
30
|
+
type WalletScreenRouteProp = RouteProp<CheckoutStackParamList, 'WalletScreen'>;
|
|
30
31
|
type WalletScreenNavigationProp = NavigationProp<CheckoutStackParamList, 'WalletScreen'>;
|
|
31
32
|
|
|
32
33
|
interface Props {
|
|
33
34
|
navigation: WalletScreenNavigationProp;
|
|
35
|
+
route: WalletScreenRouteProp;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
const WalletScreen = ({ navigation }: Props) => {
|
|
38
|
+
const WalletScreen = ({ navigation, route }: Props) => {
|
|
39
|
+
const { isAutoNavigationEnabled } = route.params as WalletScreenParams || {};
|
|
37
40
|
const [walletList, setWalletList] = useState<PaymentClass[]>([]);
|
|
38
41
|
const screenHeight = Dimensions.get('window').height;
|
|
39
42
|
const [defaultWalletList, setDefaultWalletList] = useState<PaymentClass[]>(
|
|
@@ -57,7 +60,7 @@ const WalletScreen = ({ navigation }: Props) => {
|
|
|
57
60
|
const [sessionExpireModalOpen, setSessionExppireModalState] = useState(false);
|
|
58
61
|
const [successfulTimeStamp, setSuccessfulTimeStamp] = useState('');
|
|
59
62
|
|
|
60
|
-
const [status, setStatus] = useState<string
|
|
63
|
+
const [status, setStatus] = useState<string>("NOACTION");
|
|
61
64
|
const [transactionId, setTransactionId] = useState<string | null>(null);
|
|
62
65
|
|
|
63
66
|
const backgroundApiInterval = useRef<NodeJS.Timeout | null>(null);
|
|
@@ -68,9 +71,12 @@ const WalletScreen = ({ navigation }: Props) => {
|
|
|
68
71
|
const [checkedOnce, setCheckedOnce] = useState(false);
|
|
69
72
|
|
|
70
73
|
const onProceedBack = () => {
|
|
71
|
-
if (!loading) {
|
|
74
|
+
if (!loading && !isAutoNavigationEnabled) {
|
|
72
75
|
navigation.goBack()
|
|
73
76
|
return true;
|
|
77
|
+
} else if (!loading && isAutoNavigationEnabled) {
|
|
78
|
+
onExitCheckout();
|
|
79
|
+
return true;
|
|
74
80
|
}
|
|
75
81
|
return false;
|
|
76
82
|
};
|
package/src/sdk-version.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{ "version": "1.0.
|
|
1
|
+
{ "version": "1.0.11-beta" }
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ScreenRouteMap, type AutoNavigationScreen, type PaymentClass } from '../interface';
|
|
2
|
+
import { checkoutDetailsHandler } from './checkoutDetailsHandler';
|
|
3
|
+
import { userDataHandler } from './userdataHandler';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export const handleAutoNavigation = (
|
|
7
|
+
savedCardArray : PaymentClass[]
|
|
8
|
+
) : AutoNavigationScreen | null => {
|
|
9
|
+
const {checkoutDetails} = checkoutDetailsHandler
|
|
10
|
+
const {userData} = userDataHandler
|
|
11
|
+
|
|
12
|
+
if (checkoutDetails.isOrderItemDetailsVisible) return null;
|
|
13
|
+
|
|
14
|
+
if (savedCardArray.length > 0) return null;
|
|
15
|
+
|
|
16
|
+
const isPersonalDataMissing =
|
|
17
|
+
(checkoutDetails.isFullNameEnabled && (!userData.firstName || userData.firstName.trim() === "")) ||
|
|
18
|
+
(checkoutDetails.isEmailEnabled && (!userData.email || userData.email.trim() === "")) ||
|
|
19
|
+
(checkoutDetails.isPhoneEnabled && (!userData.completePhoneNumber || userData.completePhoneNumber.trim() === ""));
|
|
20
|
+
|
|
21
|
+
if (isPersonalDataMissing) return null;
|
|
22
|
+
|
|
23
|
+
const isShippingDataMissing = checkoutDetails.isShippingAddressEnabled && (!userData.address1 || !userData.city || !userData.pincode);
|
|
24
|
+
|
|
25
|
+
if (isShippingDataMissing) return null;
|
|
26
|
+
|
|
27
|
+
const isUPIEnabled = checkoutDetails.isUpiCollectMethodEnabled ||
|
|
28
|
+
checkoutDetails.isUPIOtmCollectMethodEnabled ||
|
|
29
|
+
checkoutDetails.isUPIOtmIntentMethodEnabled ||
|
|
30
|
+
checkoutDetails.isUpiIntentMethodEnabled ||
|
|
31
|
+
checkoutDetails.isUpiQRMethodEnabled ||
|
|
32
|
+
checkoutDetails.isUPIOtmQRMethodEnabled
|
|
33
|
+
|
|
34
|
+
const enabledMethods: (keyof typeof ScreenRouteMap & (
|
|
35
|
+
'CARD' | 'WALLET' | 'NETBANKING' | 'EMI' | 'BNPL'
|
|
36
|
+
))[] = [];
|
|
37
|
+
if (checkoutDetails.isCardMethodEnabled) enabledMethods.push('CARD');
|
|
38
|
+
if (checkoutDetails.isWalletMethodEnabled) enabledMethods.push('WALLET');
|
|
39
|
+
if (checkoutDetails.isNetBankingMethodEnabled) enabledMethods.push('NETBANKING');
|
|
40
|
+
if (checkoutDetails.isEmiMethodEnabled) enabledMethods.push('EMI');
|
|
41
|
+
if (checkoutDetails.isBnplMethodEnabled) enabledMethods.push('BNPL');
|
|
42
|
+
|
|
43
|
+
if (enabledMethods.length === 1 && !isUPIEnabled) {
|
|
44
|
+
const method = enabledMethods[0];
|
|
45
|
+
if (!method) return null
|
|
46
|
+
return ScreenRouteMap[method];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
@@ -28,11 +28,11 @@ export function handlePaymentResponse({
|
|
|
28
28
|
const actionsArray = apidata.actions || [];
|
|
29
29
|
const txnStatus = status.toUpperCase() as TransactionStatus;
|
|
30
30
|
|
|
31
|
-
onSetStatus(status);
|
|
32
31
|
onSetTransactionId(apidata.transactionId);
|
|
33
32
|
|
|
34
33
|
switch (txnStatus) {
|
|
35
34
|
case TransactionStatus.RequiresAction: {
|
|
35
|
+
onSetStatus(TransactionStatus.RequiresAction);
|
|
36
36
|
if (actionsArray.length > 0) {
|
|
37
37
|
const action = actionsArray[0];
|
|
38
38
|
|
|
@@ -75,6 +75,7 @@ export function handlePaymentResponse({
|
|
|
75
75
|
}
|
|
76
76
|
case TransactionStatus.Failed:
|
|
77
77
|
case TransactionStatus.Rejected: {
|
|
78
|
+
onSetStatus(TransactionStatus.Failed);
|
|
78
79
|
const fallback = checkoutDetailsErrorMessage;
|
|
79
80
|
const errorMessage =
|
|
80
81
|
reasonCode?.startsWith('UF')
|
|
@@ -84,11 +85,8 @@ export function handlePaymentResponse({
|
|
|
84
85
|
: fallback;
|
|
85
86
|
|
|
86
87
|
if(onSetFailedMessage && onShowFailedModal) {
|
|
87
|
-
onSetFailedMessage(errorMessage);
|
|
88
|
-
onSetFailedMessage(errorMessage);
|
|
89
|
-
onSetStatus(TransactionStatus.Failed);
|
|
90
88
|
onSetFailedMessage(errorMessage);
|
|
91
|
-
|
|
89
|
+
onSetStatus(TransactionStatus.Failed);
|
|
92
90
|
onShowFailedModal();
|
|
93
91
|
}
|
|
94
92
|
setLoading(false);
|
|
@@ -98,6 +96,7 @@ export function handlePaymentResponse({
|
|
|
98
96
|
case TransactionStatus.Approved:
|
|
99
97
|
case TransactionStatus.Success:
|
|
100
98
|
case TransactionStatus.Paid: {
|
|
99
|
+
onSetStatus(TransactionStatus.Success);
|
|
101
100
|
if(onShowSuccessModal) {
|
|
102
101
|
onShowSuccessModal(apidata.transactionTimestampLocale ?? '');
|
|
103
102
|
}
|
|
@@ -106,6 +105,7 @@ export function handlePaymentResponse({
|
|
|
106
105
|
}
|
|
107
106
|
|
|
108
107
|
case TransactionStatus.Expired:{
|
|
108
|
+
onSetStatus(TransactionStatus.Expired);
|
|
109
109
|
if(onShowSessionExpiredModal) {
|
|
110
110
|
onShowSessionExpiredModal();
|
|
111
111
|
}
|
|
@@ -115,7 +115,8 @@ export function handlePaymentResponse({
|
|
|
115
115
|
|
|
116
116
|
default:
|
|
117
117
|
{
|
|
118
|
-
break;
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
122
|
break;
|
|
@@ -151,12 +152,12 @@ export function handleFetchStatusResponseHandler({
|
|
|
151
152
|
const reason = apidata.reason
|
|
152
153
|
const txnStatus = status.toUpperCase() as TransactionStatus;
|
|
153
154
|
|
|
154
|
-
onSetStatus(status);
|
|
155
155
|
onSetTransactionId(apidata.transactionId);
|
|
156
156
|
|
|
157
157
|
switch (txnStatus) {
|
|
158
158
|
case TransactionStatus.Failed:
|
|
159
159
|
case TransactionStatus.Rejected:
|
|
160
|
+
onSetStatus(TransactionStatus.Failed);
|
|
160
161
|
{const fallback = checkoutDetailsErrorMessage;
|
|
161
162
|
const errorMessage =
|
|
162
163
|
reasonCode?.startsWith('UF')
|
|
@@ -175,6 +176,7 @@ export function handleFetchStatusResponseHandler({
|
|
|
175
176
|
case TransactionStatus.Approved:
|
|
176
177
|
case TransactionStatus.Success:
|
|
177
178
|
case TransactionStatus.Paid:
|
|
179
|
+
onSetStatus(TransactionStatus.Success);
|
|
178
180
|
{onSetStatus(TransactionStatus.Success);
|
|
179
181
|
onShowSuccessModal(apidata.transactionTimestampLocale ?? '');
|
|
180
182
|
stopBackgroundApiTask?.();
|
|
@@ -182,6 +184,7 @@ export function handleFetchStatusResponseHandler({
|
|
|
182
184
|
break;}
|
|
183
185
|
|
|
184
186
|
case TransactionStatus.Expired:
|
|
187
|
+
onSetStatus(TransactionStatus.Expired);
|
|
185
188
|
{onSetStatus(TransactionStatus.Expired);
|
|
186
189
|
onShowSessionExpiredModal();
|
|
187
190
|
stopBackgroundApiTask?.();
|
|
@@ -118,13 +118,6 @@ const styles = StyleSheet.create({
|
|
|
118
118
|
fontSize: 12,
|
|
119
119
|
textDecorationLine: 'underline',
|
|
120
120
|
},
|
|
121
|
-
pressableContainer : {
|
|
122
|
-
position: 'absolute',
|
|
123
|
-
bottom: 0,
|
|
124
|
-
left: 0,
|
|
125
|
-
right: 0,
|
|
126
|
-
paddingBottom: 16,
|
|
127
|
-
},
|
|
128
121
|
webViewContainer : {
|
|
129
122
|
position: 'absolute',
|
|
130
123
|
top: 0,
|
|
@@ -148,6 +141,17 @@ const styles = StyleSheet.create({
|
|
|
148
141
|
fontWeight: 'bold',
|
|
149
142
|
lineHeight: 16,
|
|
150
143
|
},
|
|
144
|
+
footerContainer : {
|
|
145
|
+
justifyContent: 'center',
|
|
146
|
+
alignItems: 'flex-end',
|
|
147
|
+
flexDirection: 'row',
|
|
148
|
+
},
|
|
149
|
+
footerText : {
|
|
150
|
+
fontSize: 12,
|
|
151
|
+
color: '#888888',
|
|
152
|
+
marginBottom: 13,
|
|
153
|
+
},
|
|
154
|
+
footerImage : { height: 50, width: 50 },
|
|
151
155
|
})
|
|
152
156
|
|
|
153
157
|
export default styles
|