@finspringinnovations/fixeddepositsdk 1.0.2 → 1.0.4

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.
Files changed (50) hide show
  1. package/lib/api/customerApi.js +1 -0
  2. package/lib/api/fdApi.d.ts +401 -1
  3. package/lib/api/fdApi.js +24 -2
  4. package/lib/components/PendingFDBottomSheet.js +27 -18
  5. package/lib/config/appDataConfig.js +3 -2
  6. package/lib/config/workflowConstants.d.ts +40 -30
  7. package/lib/config/workflowConstants.js +35 -24
  8. package/lib/constants/strings/fd.d.ts +2 -2
  9. package/lib/constants/strings/fd.js +2 -2
  10. package/lib/navigation/RootNavigator.js +167 -196
  11. package/lib/navigation/types.d.ts +4 -1
  12. package/lib/navigation/workflowNavigator.d.ts +1 -1
  13. package/lib/navigation/workflowNavigator.js +107 -26
  14. package/lib/screens/AadhaarVerification.js +1 -11
  15. package/lib/screens/AddBankAccount.js +1 -11
  16. package/lib/screens/BankDetail.js +1 -11
  17. package/lib/screens/Employee.js +1 -11
  18. package/lib/screens/FDCalculator.js +2 -12
  19. package/lib/screens/FDList.js +531 -417
  20. package/lib/screens/FindIFSC.js +1 -11
  21. package/lib/screens/NomineeDetail.js +12 -22
  22. package/lib/screens/PayNow.js +1 -11
  23. package/lib/screens/Payment.js +2 -11
  24. package/lib/screens/PaymentStatus.js +24 -21
  25. package/lib/screens/ReviewKYC.js +3 -12
  26. package/lib/types/workflowTypes.d.ts +1 -1
  27. package/package.json +50 -50
  28. package/src/api/customerApi.ts +1 -0
  29. package/src/api/fdApi.ts +28 -1
  30. package/src/components/PendingFDBottomSheet.tsx +151 -123
  31. package/src/config/appDataConfig.ts +245 -242
  32. package/src/config/workflowConstants.ts +51 -39
  33. package/src/constants/strings/bank.ts +80 -80
  34. package/src/constants/strings/fd.ts +2 -2
  35. package/src/navigation/RootNavigator.tsx +667 -651
  36. package/src/navigation/types.ts +4 -1
  37. package/src/navigation/workflowNavigator.ts +170 -107
  38. package/src/screens/AadhaarVerification.tsx +1 -15
  39. package/src/screens/AddBankAccount.tsx +2 -16
  40. package/src/screens/BankDetail.tsx +1 -15
  41. package/src/screens/Employee.tsx +1 -15
  42. package/src/screens/FDCalculator.tsx +4 -18
  43. package/src/screens/FDList.tsx +2311 -2170
  44. package/src/screens/FindIFSC.tsx +2 -16
  45. package/src/screens/NomineeDetail.tsx +762 -775
  46. package/src/screens/PayNow.tsx +2 -16
  47. package/src/screens/Payment.tsx +190 -203
  48. package/src/screens/PaymentStatus.tsx +574 -576
  49. package/src/screens/ReviewKYC.tsx +2 -15
  50. package/src/types/workflowTypes.ts +1 -10
@@ -145,22 +145,8 @@ const PayNow: React.FC<PayNowProps> = ({ onGoBack, onConfirm, fdData }) => {
145
145
  }
146
146
  };
147
147
 
148
- // Handle Android hardware back button
149
- useEffect(() => {
150
- if (Platform.OS !== 'android') return;
151
-
152
- const onHardwareBackPress = () => {
153
- handleBackPress();
154
- return true; // Prevent default behavior
155
- };
156
-
157
- const backHandler = BackHandler.addEventListener(
158
- 'hardwareBackPress',
159
- onHardwareBackPress
160
- );
161
-
162
- return () => backHandler.remove();
163
- }, [defaultProviderId, workflowInstanceId, applicationId, entityId]);
148
+ // Removed screen-level hardware back handler to allow only header back button navigation
149
+
164
150
 
165
151
  return (
166
152
  <SafeAreaWrapper
@@ -1,223 +1,210 @@
1
- import React, { useRef, useState, useEffect } from 'react';
2
- import { View, StyleSheet, ActivityIndicator, BackHandler, Platform, StatusBar } from 'react-native';
1
+ import React, { useRef, useState } from 'react';
2
+ import { ActivityIndicator, Platform, StatusBar, StyleSheet, View } from 'react-native';
3
3
  import { WebView } from 'react-native-webview';
4
4
  import SafeAreaWrapper from '../components/SafeAreaWrapper';
5
+ import { getEncryptionConfig } from '../config/encryptionConfig';
5
6
  import { useColors } from '../theme/ThemeContext';
6
7
  import { decryptResponse } from '../utils/encryption';
7
- import { getEncryptionConfig } from '../config/encryptionConfig';
8
8
 
9
9
  export interface PaymentProps {
10
- onGoBack?: () => void;
11
- onPaymentSuccess?: (data?: any) => void;
12
- onPaymentFailure?: (error?: any) => void;
13
- paymentUrl: string;
14
- successUrl?: string;
15
- failureUrl?: string;
10
+ onGoBack?: () => void;
11
+ onPaymentSuccess?: (data?: any) => void;
12
+ onPaymentFailure?: (error?: any) => void;
13
+ paymentUrl: string;
14
+ successUrl?: string;
15
+ failureUrl?: string;
16
16
  }
17
17
 
18
18
  const Payment: React.FC<PaymentProps> = ({
19
- onGoBack,
20
- onPaymentSuccess,
21
- onPaymentFailure,
22
- paymentUrl,
23
- successUrl = 'payment/success',
24
- failureUrl = 'payment/failure',
19
+ onGoBack,
20
+ onPaymentSuccess,
21
+ onPaymentFailure,
22
+ paymentUrl,
23
+ successUrl = 'payment/success',
24
+ failureUrl = 'payment/failure',
25
25
  }) => {
26
- const colors = useColors();
27
- const styles = createStyles(colors);
28
- const webViewRef = useRef<WebView>(null);
29
- const [loading, setLoading] = useState(true);
30
-
31
- const handleNavigationStateChange = async (navState: any) => {
32
- const { url } = navState;
33
-
34
- if (url.includes('payment/status')) {
35
- await handlePaymentStatusPage();
36
- return;
37
- }
38
-
39
- if (url.includes(successUrl)) {
40
- setLoading(false);
41
- onPaymentSuccess?.(navState);
42
- return;
43
- }
44
-
45
- if (url.includes(failureUrl)) {
46
- setLoading(false);
47
- onPaymentFailure?.(navState);
48
- return;
49
- }
50
- };
51
-
52
- const handleWebViewError = (syntheticEvent: any) => {
53
- const { nativeEvent } = syntheticEvent;
54
- setLoading(false);
55
- onPaymentFailure?.(nativeEvent);
56
- };
57
-
58
- const handleLoadStart = () => {
59
- setLoading(true);
60
- };
61
-
62
- const handleLoadEnd = () => {
63
- setLoading(false);
64
- };
65
-
66
- const handleMessage = async (event: any) => {
67
- try {
68
- const dataString = event.nativeEvent.data;
69
-
70
- // Check if data is empty or null
71
- if (!dataString || dataString.trim() === '') {
72
- return;
73
- }
74
-
75
- // Check if data looks like JSON
76
- const trimmedData = dataString.trim();
77
- if (!trimmedData.startsWith('{') && !trimmedData.startsWith('[') && !trimmedData.startsWith('"')) {
78
- return;
79
- }
80
-
81
- const cleaned =
82
- dataString.startsWith('"') && dataString.endsWith('"')
83
- ? dataString.substring(1, dataString.length - 1).replaceAll('\\"', '"')
84
- : dataString;
85
-
86
- const parsed = JSON.parse(cleaned);
87
-
88
- let response;
89
-
90
- // Handle both encrypted and non-encrypted responses using the same method as API responses
91
- if (parsed.encryptedResponse) {
92
- const encryptionConfig = getEncryptionConfig();
93
- try {
94
- // Use the same decryptResponse function used for API responses
95
- const decrypted = await decryptResponse({ encryptedResponse: parsed.encryptedResponse }, encryptionConfig);
96
- response = decrypted;
97
- } catch (error) {
98
- response = parsed;
99
- }
100
- } else {
101
- response = parsed;
102
- }
103
-
104
- // Check for success status
105
- if (response.status?.toLowerCase() === 'success') {
106
- // Check payment status in data
107
- const paymentStatus = response.data?.paymentStatus?.toLowerCase();
108
-
109
- if (paymentStatus === 'success') {
110
- onPaymentSuccess?.(response);
111
- } else if (paymentStatus === 'failed') {
112
- onPaymentFailure?.(response);
113
- } else {
114
- onPaymentFailure?.(response);
115
- }
116
- } else {
117
- onPaymentFailure?.(response);
118
- }
119
-
120
- setLoading(false);
121
- } catch (error) {
122
- onPaymentFailure?.(error);
123
- setLoading(false);
124
- }
125
- };
126
-
127
- const handlePaymentStatusPage = async () => {
128
- try {
129
- setLoading(true);
130
- webViewRef.current?.injectJavaScript(`
26
+ const colors = useColors();
27
+ const styles = createStyles(colors);
28
+ const webViewRef = useRef < WebView > (null);
29
+ const [loading, setLoading] = useState(true);
30
+
31
+ const handleNavigationStateChange = async (navState: any) => {
32
+ const { url } = navState;
33
+
34
+ if (url.includes('payment/status')) {
35
+ await handlePaymentStatusPage();
36
+ return;
37
+ }
38
+
39
+ if (url.includes(successUrl)) {
40
+ setLoading(false);
41
+ onPaymentSuccess?.(navState);
42
+ return;
43
+ }
44
+
45
+ if (url.includes(failureUrl)) {
46
+ setLoading(false);
47
+ onPaymentFailure?.(navState);
48
+ return;
49
+ }
50
+ };
51
+
52
+ const handleWebViewError = (syntheticEvent: any) => {
53
+ const { nativeEvent } = syntheticEvent;
54
+ setLoading(false);
55
+ onPaymentFailure?.(nativeEvent);
56
+ };
57
+
58
+ const handleLoadStart = () => {
59
+ setLoading(true);
60
+ };
61
+
62
+ const handleLoadEnd = () => {
63
+ setLoading(false);
64
+ };
65
+
66
+ const handleMessage = async (event: any) => {
67
+ try {
68
+ const dataString = event.nativeEvent.data;
69
+
70
+ // Check if data is empty or null
71
+ if (!dataString || dataString.trim() === '') {
72
+ return;
73
+ }
74
+
75
+ // Check if data looks like JSON
76
+ const trimmedData = dataString.trim();
77
+ if (!trimmedData.startsWith('{') && !trimmedData.startsWith('[') && !trimmedData.startsWith('"')) {
78
+ return;
79
+ }
80
+
81
+ const cleaned =
82
+ dataString.startsWith('"') && dataString.endsWith('"')
83
+ ? dataString.substring(1, dataString.length - 1).replaceAll('\\"', '"')
84
+ : dataString;
85
+
86
+ const parsed = JSON.parse(cleaned);
87
+
88
+ let response;
89
+
90
+ // Handle both encrypted and non-encrypted responses using the same method as API responses
91
+ if (parsed.encryptedResponse) {
92
+ const encryptionConfig = getEncryptionConfig();
93
+ try {
94
+ // Use the same decryptResponse function used for API responses
95
+ const decrypted = await decryptResponse({ encryptedResponse: parsed.encryptedResponse }, encryptionConfig);
96
+ response = decrypted;
97
+ } catch (error) {
98
+ response = parsed;
99
+ }
100
+ } else {
101
+ response = parsed;
102
+ }
103
+
104
+ // Check for success status
105
+ if (response.status?.toLowerCase() === 'success') {
106
+ // Check payment status in data
107
+ const paymentStatus = response.data?.paymentStatus?.toLowerCase();
108
+
109
+ if (paymentStatus === 'success') {
110
+ onPaymentSuccess?.(response);
111
+ } else if (paymentStatus === 'failed') {
112
+ onPaymentFailure?.(response);
113
+ } else {
114
+ onPaymentFailure?.(response);
115
+ }
116
+ } else {
117
+ onPaymentFailure?.(response);
118
+ }
119
+
120
+ setLoading(false);
121
+ } catch (error) {
122
+ onPaymentFailure?.(error);
123
+ setLoading(false);
124
+ }
125
+ };
126
+
127
+ const handlePaymentStatusPage = async () => {
128
+ try {
129
+ setLoading(true);
130
+ webViewRef.current?.injectJavaScript(`
131
131
  (function() {
132
132
  window.ReactNativeWebView.postMessage(document.body.innerText);
133
133
  })();
134
134
  `);
135
- } catch (err) {
136
- setLoading(false);
137
- onPaymentFailure?.(err);
138
- }
139
- };
140
-
141
- // Disable hardware back button on Payment screen
142
- useEffect(() => {
143
- if (Platform.OS !== 'android') return;
144
-
145
- const onBackPress = () => {
146
- // Return true to prevent default behavior (block back button)
147
- return true;
148
- };
149
-
150
- const backHandler = BackHandler.addEventListener(
151
- 'hardwareBackPress',
152
- onBackPress
153
- );
154
-
155
- return () => backHandler.remove();
156
- }, []);
157
-
158
- return (
159
- <SafeAreaWrapper
160
- includeTop={false}
161
- bottomPadding={0}
162
- statusBarColor="#000000"
163
- statusBarStyle="light-content"
164
- >
165
- {Platform.OS === 'ios' && <StatusBar barStyle="light-content" />}
166
-
167
- <View style={styles.container}>
168
- {loading && (
169
- <View style={styles.loadingContainer}>
170
- <ActivityIndicator size="large" color={colors.primary} />
171
- </View>
172
- )}
173
-
174
- <WebView
175
- ref={webViewRef}
176
- source={{ uri: paymentUrl }}
177
- style={styles.webView}
178
- onNavigationStateChange={handleNavigationStateChange}
179
- onError={handleWebViewError}
180
- onLoadStart={handleLoadStart}
181
- onLoadEnd={handleLoadEnd}
182
- onMessage={handleMessage}
183
- javaScriptEnabled={true}
184
- domStorageEnabled={false}
185
- startInLoadingState={true}
186
- scalesPageToFit={true}
187
- mixedContentMode="never"
188
- allowsInlineMediaPlayback={false}
189
- mediaPlaybackRequiresUserAction={false}
190
- sharedCookiesEnabled={false}
191
- thirdPartyCookiesEnabled={false}
192
- cacheEnabled={false}
193
- originWhitelist={['*']}
194
- />
195
- </View>
196
- </SafeAreaWrapper>
197
- );
135
+ } catch (err) {
136
+ setLoading(false);
137
+ onPaymentFailure?.(err);
138
+ }
139
+ };
140
+
141
+ // Disable hardware back button on Payment screen
142
+ // Removed screen-level hardware back handler to allow only header back button navigation
143
+
144
+
145
+ return (
146
+ <SafeAreaWrapper
147
+ includeTop={false}
148
+ bottomPadding={0}
149
+ statusBarColor="#000000"
150
+ statusBarStyle="light-content"
151
+ >
152
+ {Platform.OS === 'ios' && <StatusBar barStyle="light-content" />}
153
+
154
+ <View style={styles.container}>
155
+ {loading && (
156
+ <View style={styles.loadingContainer}>
157
+ <ActivityIndicator size="large" color={colors.primary} />
158
+ </View>
159
+ )}
160
+
161
+ <WebView
162
+ ref={webViewRef}
163
+ source={{ uri: paymentUrl }}
164
+ style={styles.webView}
165
+ onNavigationStateChange={handleNavigationStateChange}
166
+ onError={handleWebViewError}
167
+ onLoadStart={handleLoadStart}
168
+ onLoadEnd={handleLoadEnd}
169
+ onMessage={handleMessage}
170
+ javaScriptEnabled={true}
171
+ domStorageEnabled={false}
172
+ startInLoadingState={true}
173
+ scalesPageToFit={true}
174
+ mixedContentMode="never"
175
+ allowsInlineMediaPlayback={false}
176
+ mediaPlaybackRequiresUserAction={false}
177
+ sharedCookiesEnabled={false}
178
+ thirdPartyCookiesEnabled={false}
179
+ cacheEnabled={false}
180
+ originWhitelist={['*']}
181
+ />
182
+ </View>
183
+ </SafeAreaWrapper>
184
+ );
198
185
  };
199
186
 
200
187
  const createStyles = (colors: any) => StyleSheet.create({
201
- container: {
202
- flex: 1,
203
- backgroundColor: colors.background,
204
- },
205
- webView: {
206
- flex: 1,
207
- backgroundColor: colors.background,
208
- marginTop: Platform.OS === 'ios' ? 15 : 0,
209
- },
210
- loadingContainer: {
211
- position: 'absolute',
212
- top: 0,
213
- left: 0,
214
- right: 0,
215
- bottom: 0,
216
- alignItems: 'center',
217
- justifyContent: 'center',
218
- backgroundColor: colors.background,
219
- zIndex: 1,
220
- },
188
+ container: {
189
+ flex: 1,
190
+ backgroundColor: colors.background,
191
+ },
192
+ webView: {
193
+ flex: 1,
194
+ backgroundColor: colors.background,
195
+ marginTop: Platform.OS === 'ios' ? 15 : 0,
196
+ },
197
+ loadingContainer: {
198
+ position: 'absolute',
199
+ top: 0,
200
+ left: 0,
201
+ right: 0,
202
+ bottom: 0,
203
+ alignItems: 'center',
204
+ justifyContent: 'center',
205
+ backgroundColor: colors.background,
206
+ zIndex: 1,
207
+ },
221
208
  });
222
209
 
223
210
  export default Payment;