@finspringinnovations/fixeddepositsdk 1.0.0

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 (311) hide show
  1. package/README.md +128 -0
  2. package/lib/api/applicationApi.d.ts +1 -0
  3. package/lib/api/applicationApi.js +11 -0
  4. package/lib/api/bankApi.d.ts +352 -0
  5. package/lib/api/bankApi.js +54 -0
  6. package/lib/api/baseApi.d.ts +6 -0
  7. package/lib/api/baseApi.js +406 -0
  8. package/lib/api/customerApi.d.ts +855 -0
  9. package/lib/api/customerApi.js +241 -0
  10. package/lib/api/fdApi.d.ts +979 -0
  11. package/lib/api/fdApi.js +112 -0
  12. package/lib/api/fdCalculatorApi.d.ts +179 -0
  13. package/lib/api/fdCalculatorApi.js +36 -0
  14. package/lib/api/index.d.ts +14 -0
  15. package/lib/api/index.js +45 -0
  16. package/lib/api/interestRateApi.d.ts +585 -0
  17. package/lib/api/interestRateApi.js +101 -0
  18. package/lib/api/kycApi.d.ts +486 -0
  19. package/lib/api/kycApi.js +71 -0
  20. package/lib/api/masterDataApi.d.ts +158 -0
  21. package/lib/api/masterDataApi.js +35 -0
  22. package/lib/api/nomineeApi.d.ts +325 -0
  23. package/lib/api/nomineeApi.js +46 -0
  24. package/lib/api/onboardingApi.d.ts +192 -0
  25. package/lib/api/onboardingApi.js +41 -0
  26. package/lib/api/panApi.d.ts +0 -0
  27. package/lib/api/panApi.js +23 -0
  28. package/lib/api/paymentApi.d.ts +325 -0
  29. package/lib/api/paymentApi.js +46 -0
  30. package/lib/api/workflowApi.d.ts +654 -0
  31. package/lib/api/workflowApi.js +90 -0
  32. package/lib/assets/images/images.d.ts +6 -0
  33. package/lib/assets/images/images.js +12 -0
  34. package/lib/components/AadhaarInput.d.ts +13 -0
  35. package/lib/components/AadhaarInput.js +47 -0
  36. package/lib/components/ActionButton.d.ts +12 -0
  37. package/lib/components/ActionButton.js +87 -0
  38. package/lib/components/ActiveFDCard.d.ts +18 -0
  39. package/lib/components/ActiveFDCard.js +116 -0
  40. package/lib/components/AmountInput.d.ts +20 -0
  41. package/lib/components/AmountInput.js +142 -0
  42. package/lib/components/CheckboxOption.d.ts +11 -0
  43. package/lib/components/CheckboxOption.js +41 -0
  44. package/lib/components/CompanyHeader.d.ts +7 -0
  45. package/lib/components/CompanyHeader.js +59 -0
  46. package/lib/components/DropdownSelector.d.ts +9 -0
  47. package/lib/components/DropdownSelector.js +49 -0
  48. package/lib/components/EmptyState.d.ts +17 -0
  49. package/lib/components/EmptyState.js +44 -0
  50. package/lib/components/ErrorDisplay.d.ts +17 -0
  51. package/lib/components/ErrorDisplay.js +69 -0
  52. package/lib/components/FAQItem.d.ts +9 -0
  53. package/lib/components/FAQItem.js +52 -0
  54. package/lib/components/FDCard.d.ts +23 -0
  55. package/lib/components/FDCard.js +116 -0
  56. package/lib/components/FormDropdown.d.ts +18 -0
  57. package/lib/components/FormDropdown.js +155 -0
  58. package/lib/components/FormSection.d.ts +14 -0
  59. package/lib/components/FormSection.js +38 -0
  60. package/lib/components/Header.d.ts +14 -0
  61. package/lib/components/Header.js +52 -0
  62. package/lib/components/IFSCSearchResultCard.d.ts +13 -0
  63. package/lib/components/IFSCSearchResultCard.js +70 -0
  64. package/lib/components/InfoBox.d.ts +8 -0
  65. package/lib/components/InfoBox.js +39 -0
  66. package/lib/components/InterestRateCard.d.ts +8 -0
  67. package/lib/components/InterestRateCard.js +46 -0
  68. package/lib/components/LoadingIndicator.d.ts +12 -0
  69. package/lib/components/LoadingIndicator.js +30 -0
  70. package/lib/components/OTPInput.d.ts +17 -0
  71. package/lib/components/OTPInput.js +144 -0
  72. package/lib/components/PaymentDetailsCard.d.ts +20 -0
  73. package/lib/components/PaymentDetailsCard.js +68 -0
  74. package/lib/components/PendingFDBottomSheet.d.ts +19 -0
  75. package/lib/components/PendingFDBottomSheet.js +122 -0
  76. package/lib/components/SafeAreaWrapper.d.ts +13 -0
  77. package/lib/components/SafeAreaWrapper.js +41 -0
  78. package/lib/components/ScreenHeader.d.ts +11 -0
  79. package/lib/components/ScreenHeader.js +46 -0
  80. package/lib/components/StatusDisplay.d.ts +15 -0
  81. package/lib/components/StatusDisplay.js +88 -0
  82. package/lib/components/TextFieldWithLabel.d.ts +46 -0
  83. package/lib/components/TextFieldWithLabel.js +326 -0
  84. package/lib/components/TrustBox.d.ts +8 -0
  85. package/lib/components/TrustBox.js +46 -0
  86. package/lib/components/ValidationErrorAlert.d.ts +23 -0
  87. package/lib/components/ValidationErrorAlert.js +39 -0
  88. package/lib/components/ValidationMessage.d.ts +9 -0
  89. package/lib/components/ValidationMessage.js +98 -0
  90. package/lib/components/index.d.ts +35 -0
  91. package/lib/components/index.js +64 -0
  92. package/lib/config/apiConfig.d.ts +34 -0
  93. package/lib/config/apiConfig.js +158 -0
  94. package/lib/config/appDataConfig.d.ts +159 -0
  95. package/lib/config/appDataConfig.js +310 -0
  96. package/lib/config/encryptionConfig.d.ts +21 -0
  97. package/lib/config/encryptionConfig.js +61 -0
  98. package/lib/config/workflowConstants.d.ts +62 -0
  99. package/lib/config/workflowConstants.js +63 -0
  100. package/lib/constants/strings/bank.d.ts +72 -0
  101. package/lib/constants/strings/bank.js +86 -0
  102. package/lib/constants/strings/base64Images.d.ts +26 -0
  103. package/lib/constants/strings/base64Images.js +29 -0
  104. package/lib/constants/strings/common.d.ts +53 -0
  105. package/lib/constants/strings/common.js +62 -0
  106. package/lib/constants/strings/employee.d.ts +61 -0
  107. package/lib/constants/strings/employee.js +77 -0
  108. package/lib/constants/strings/faq.d.ts +14 -0
  109. package/lib/constants/strings/faq.js +20 -0
  110. package/lib/constants/strings/fd.d.ts +122 -0
  111. package/lib/constants/strings/fd.js +151 -0
  112. package/lib/constants/strings/home.d.ts +49 -0
  113. package/lib/constants/strings/home.js +62 -0
  114. package/lib/constants/strings/index.d.ts +16 -0
  115. package/lib/constants/strings/index.js +44 -0
  116. package/lib/constants/strings/kyc.d.ts +80 -0
  117. package/lib/constants/strings/kyc.js +94 -0
  118. package/lib/constants/strings/nominee.d.ts +64 -0
  119. package/lib/constants/strings/nominee.js +81 -0
  120. package/lib/hooks/useAuth.d.ts +25 -0
  121. package/lib/hooks/useAuth.js +39 -0
  122. package/lib/hooks/useFDData.d.ts +11 -0
  123. package/lib/hooks/useFDData.js +40 -0
  124. package/lib/index.d.ts +48 -0
  125. package/lib/index.js +161 -0
  126. package/lib/navigation/RootNavigator.d.ts +9 -0
  127. package/lib/navigation/RootNavigator.js +459 -0
  128. package/lib/navigation/SimpleNavigator.d.ts +11 -0
  129. package/lib/navigation/SimpleNavigator.js +114 -0
  130. package/lib/navigation/helpers.d.ts +11 -0
  131. package/lib/navigation/helpers.js +83 -0
  132. package/lib/navigation/index.d.ts +17 -0
  133. package/lib/navigation/index.js +42 -0
  134. package/lib/navigation/types.d.ts +139 -0
  135. package/lib/navigation/types.js +2 -0
  136. package/lib/navigation/workflowNavigator.d.ts +22 -0
  137. package/lib/navigation/workflowNavigator.js +104 -0
  138. package/lib/providers/ApiProvider.d.ts +7 -0
  139. package/lib/providers/ApiProvider.js +16 -0
  140. package/lib/providers/MasterDataProvider.d.ts +10 -0
  141. package/lib/providers/MasterDataProvider.js +54 -0
  142. package/lib/screens/AadhaarVerification.d.ts +7 -0
  143. package/lib/screens/AadhaarVerification.js +627 -0
  144. package/lib/screens/AddBankAccount.d.ts +22 -0
  145. package/lib/screens/AddBankAccount.js +381 -0
  146. package/lib/screens/BankDetail.d.ts +16 -0
  147. package/lib/screens/BankDetail.js +596 -0
  148. package/lib/screens/Employee.d.ts +18 -0
  149. package/lib/screens/Employee.js +594 -0
  150. package/lib/screens/FDCalculator.d.ts +18 -0
  151. package/lib/screens/FDCalculator.js +767 -0
  152. package/lib/screens/FDList.d.ts +28 -0
  153. package/lib/screens/FDList.js +1853 -0
  154. package/lib/screens/FindIFSC.d.ts +16 -0
  155. package/lib/screens/FindIFSC.js +248 -0
  156. package/lib/screens/NomineeDetail.d.ts +17 -0
  157. package/lib/screens/NomineeDetail.js +592 -0
  158. package/lib/screens/PayNow.d.ts +14 -0
  159. package/lib/screens/PayNow.js +230 -0
  160. package/lib/screens/Payment.d.ts +11 -0
  161. package/lib/screens/Payment.js +191 -0
  162. package/lib/screens/PaymentStatus.d.ts +16 -0
  163. package/lib/screens/PaymentStatus.js +431 -0
  164. package/lib/screens/ReviewKYC.d.ts +23 -0
  165. package/lib/screens/ReviewKYC.js +727 -0
  166. package/lib/state/paymentSession.d.ts +8 -0
  167. package/lib/state/paymentSession.js +13 -0
  168. package/lib/store/fdListSelectedSlice.d.ts +21 -0
  169. package/lib/store/fdListSelectedSlice.js +26 -0
  170. package/lib/store/hooks.d.ts +8 -0
  171. package/lib/store/hooks.js +8 -0
  172. package/lib/store/index.d.ts +3 -0
  173. package/lib/store/index.js +8 -0
  174. package/lib/store/onboardingSlice.d.ts +12 -0
  175. package/lib/store/onboardingSlice.js +32 -0
  176. package/lib/store/store.d.ts +13 -0
  177. package/lib/store/store.js +27 -0
  178. package/lib/theme/ThemeContext.d.ts +210 -0
  179. package/lib/theme/ThemeContext.js +92 -0
  180. package/lib/theme/colors.d.ts +80 -0
  181. package/lib/theme/colors.js +85 -0
  182. package/lib/theme/index.d.ts +35 -0
  183. package/lib/theme/index.js +78 -0
  184. package/lib/theme/shadows.d.ts +53 -0
  185. package/lib/theme/shadows.js +58 -0
  186. package/lib/theme/typography.d.ts +134 -0
  187. package/lib/theme/typography.js +143 -0
  188. package/lib/types/dataTypes.d.ts +34 -0
  189. package/lib/types/dataTypes.js +2 -0
  190. package/lib/types/workflowTypes.d.ts +2 -0
  191. package/lib/types/workflowTypes.js +2 -0
  192. package/lib/utils/apiLogger.d.ts +48 -0
  193. package/lib/utils/apiLogger.js +105 -0
  194. package/lib/utils/encryption.d.ts +28 -0
  195. package/lib/utils/encryption.js +113 -0
  196. package/lib/utils/getFDData.d.ts +48 -0
  197. package/lib/utils/getFDData.js +145 -0
  198. package/lib/utils/globalData.d.ts +2 -0
  199. package/lib/utils/globalData.js +10 -0
  200. package/package.json +51 -0
  201. package/src/api/applicationApi.ts +12 -0
  202. package/src/api/bankApi.ts +42 -0
  203. package/src/api/baseApi.ts +463 -0
  204. package/src/api/customerApi.ts +324 -0
  205. package/src/api/fdApi.ts +150 -0
  206. package/src/api/fdCalculatorApi.ts +41 -0
  207. package/src/api/index.ts +29 -0
  208. package/src/api/interestRateApi.ts +143 -0
  209. package/src/api/kycApi.ts +63 -0
  210. package/src/api/masterDataApi.ts +37 -0
  211. package/src/api/nomineeApi.ts +34 -0
  212. package/src/api/onboardingApi.ts +64 -0
  213. package/src/api/panApi.ts +25 -0
  214. package/src/api/paymentApi.ts +34 -0
  215. package/src/api/workflowApi.ts +94 -0
  216. package/src/assets/images/Mahindra.png +0 -0
  217. package/src/assets/images/arrow-filled.png +0 -0
  218. package/src/assets/images/arrow-left.png +0 -0
  219. package/src/assets/images/backicon.png +0 -0
  220. package/src/assets/images/calendar.png +0 -0
  221. package/src/assets/images/chevron-down.png +0 -0
  222. package/src/assets/images/chevron-down@2x.png +0 -0
  223. package/src/assets/images/chevron-down@3x.png +0 -0
  224. package/src/assets/images/images.js +10 -0
  225. package/src/assets/images/shriram_logo.png +0 -0
  226. package/src/components/AadhaarInput.tsx +91 -0
  227. package/src/components/ActionButton.tsx +129 -0
  228. package/src/components/ActiveFDCard.tsx +188 -0
  229. package/src/components/AmountInput.tsx +217 -0
  230. package/src/components/CheckboxOption.tsx +93 -0
  231. package/src/components/CompanyHeader.tsx +80 -0
  232. package/src/components/DropdownSelector.tsx +77 -0
  233. package/src/components/EmptyState.tsx +109 -0
  234. package/src/components/ErrorDisplay.tsx +135 -0
  235. package/src/components/FAQItem.tsx +90 -0
  236. package/src/components/FDCard.tsx +186 -0
  237. package/src/components/FormDropdown.tsx +214 -0
  238. package/src/components/FormSection.tsx +86 -0
  239. package/src/components/Header.tsx +110 -0
  240. package/src/components/IFSCSearchResultCard.tsx +139 -0
  241. package/src/components/InfoBox.tsx +55 -0
  242. package/src/components/InterestRateCard.tsx +77 -0
  243. package/src/components/LoadingIndicator.tsx +63 -0
  244. package/src/components/OTPInput.tsx +213 -0
  245. package/src/components/PaymentDetailsCard.tsx +120 -0
  246. package/src/components/PendingFDBottomSheet.tsx +237 -0
  247. package/src/components/README.md +210 -0
  248. package/src/components/SafeAreaWrapper.tsx +68 -0
  249. package/src/components/ScreenHeader.tsx +83 -0
  250. package/src/components/StatusDisplay.tsx +139 -0
  251. package/src/components/TextFieldWithLabel.tsx +502 -0
  252. package/src/components/TrustBox.tsx +63 -0
  253. package/src/components/ValidationErrorAlert.tsx +57 -0
  254. package/src/components/ValidationMessage.tsx +134 -0
  255. package/src/components/index.tsx +47 -0
  256. package/src/config/apiConfig.ts +217 -0
  257. package/src/config/appDataConfig.ts +358 -0
  258. package/src/config/encryptionConfig.ts +65 -0
  259. package/src/config/workflowConstants.ts +70 -0
  260. package/src/constants/strings/README.md +146 -0
  261. package/src/constants/strings/bank.ts +92 -0
  262. package/src/constants/strings/base64Images.ts +31 -0
  263. package/src/constants/strings/common.ts +63 -0
  264. package/src/constants/strings/employee.ts +85 -0
  265. package/src/constants/strings/faq.ts +23 -0
  266. package/src/constants/strings/fd.ts +172 -0
  267. package/src/constants/strings/home.ts +67 -0
  268. package/src/constants/strings/index.ts +21 -0
  269. package/src/constants/strings/kyc.ts +100 -0
  270. package/src/constants/strings/nominee.ts +90 -0
  271. package/src/hooks/useAuth.ts +42 -0
  272. package/src/hooks/useFDData.ts +48 -0
  273. package/src/index.tsx +139 -0
  274. package/src/navigation/RootNavigator.tsx +687 -0
  275. package/src/navigation/SimpleNavigator.tsx +123 -0
  276. package/src/navigation/helpers.ts +85 -0
  277. package/src/navigation/index.tsx +84 -0
  278. package/src/navigation/types.ts +146 -0
  279. package/src/navigation/workflowNavigator.ts +131 -0
  280. package/src/providers/ApiProvider.tsx +23 -0
  281. package/src/providers/MasterDataProvider.tsx +30 -0
  282. package/src/screens/AadhaarVerification.tsx +809 -0
  283. package/src/screens/AddBankAccount.tsx +541 -0
  284. package/src/screens/BankDetail.tsx +826 -0
  285. package/src/screens/Employee.tsx +822 -0
  286. package/src/screens/FDCalculator.tsx +1002 -0
  287. package/src/screens/FDList.tsx +2199 -0
  288. package/src/screens/FindIFSC.tsx +332 -0
  289. package/src/screens/NomineeDetail.tsx +800 -0
  290. package/src/screens/PayNow.tsx +282 -0
  291. package/src/screens/Payment.tsx +224 -0
  292. package/src/screens/PaymentStatus.tsx +595 -0
  293. package/src/screens/ReviewKYC.tsx +1062 -0
  294. package/src/state/paymentSession.ts +13 -0
  295. package/src/store/fdListSelectedSlice.ts +42 -0
  296. package/src/store/hooks.ts +6 -0
  297. package/src/store/index.ts +3 -0
  298. package/src/store/onboardingSlice.ts +37 -0
  299. package/src/store/store.ts +27 -0
  300. package/src/theme/ThemeContext.tsx +84 -0
  301. package/src/theme/colors.ts +90 -0
  302. package/src/theme/index.ts +85 -0
  303. package/src/theme/shadows.ts +61 -0
  304. package/src/theme/typography.ts +151 -0
  305. package/src/types/dataTypes.ts +37 -0
  306. package/src/types/env.d.ts +93 -0
  307. package/src/types/workflowTypes.ts +12 -0
  308. package/src/utils/apiLogger.ts +166 -0
  309. package/src/utils/encryption.ts +159 -0
  310. package/src/utils/getFDData.ts +165 -0
  311. package/src/utils/globalData.ts +7 -0
@@ -0,0 +1,595 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import { View, Text, StyleSheet, ScrollView, Alert, Image, BackHandler, Platform, StatusBar } from 'react-native';
3
+ import Icon from 'react-native-vector-icons/Ionicons';
4
+ import { base64Images } from '../constants/strings/base64Images';
5
+ import SafeAreaWrapper from '../components/SafeAreaWrapper';
6
+ import { PaymentDetailsCard } from '../components';
7
+ import ActionButton from '../components/ActionButton';
8
+ import { useColors, useTypography, useTheme } from '../theme/ThemeContext';
9
+ import { usePaymentReverseFeedMutation, usePaymentRetryMutation } from '../api/fdApi';
10
+ import { useGetCustomerApplicationsMutation } from '../api/customerApi';
11
+ import { useAppSelector } from '../store';
12
+ import { getUserInfoForAPI } from '../config/appDataConfig';
13
+ import { navigate } from '../navigation/helpers';
14
+ import { setPaymentSession, getPaymentSession } from '../state/paymentSession';
15
+ import { useRoute } from '@react-navigation/native';
16
+ import { BANK_STRINGS } from '../constants/strings/bank';
17
+ import { COMMON_STRINGS } from '../constants/strings/common';
18
+ import { getApiConfig } from '../config/apiConfig';
19
+
20
+ export interface PaymentStatusProps {
21
+ onRetry?: () => void;
22
+ onContinue?: (fdDetails?: any) => void; // Callback when user clicks Continue on success - should redirect to main app with FD details
23
+ status: 'success' | 'failed' | 'pending';
24
+ transactionId?: string;
25
+ fdData?: {
26
+ companyName: string;
27
+ amount: number;
28
+ fdRate: string;
29
+ tenure: string;
30
+ interestPayout: string;
31
+ };
32
+ }
33
+
34
+ const PaymentStatus: React.FC<PaymentStatusProps> = ({
35
+ onRetry,
36
+ onContinue,
37
+ status,
38
+ transactionId,
39
+ fdData
40
+ }) => {
41
+ const colors = useColors();
42
+ const typography = useTypography();
43
+ const { themeName } = useTheme();
44
+
45
+ // Local state to track current status (can be updated from API responses)
46
+ const [currentStatus, setCurrentStatus] = useState<'success' | 'failed' | 'pending'>(status);
47
+
48
+ const styles = createStyles(colors, typography, currentStatus);
49
+ const route = useRoute();
50
+
51
+ // Get transaction ID from navigation props (route params)
52
+ const navigationTransactionId = (route.params as any)?.transactionId;
53
+
54
+ // Fallback: Get transaction ID from payment session if not in navigation params
55
+ const paymentSession = getPaymentSession();
56
+ const sessionTransactionId = paymentSession.transactionId;
57
+
58
+ const finalTransactionId = navigationTransactionId || sessionTransactionId || transactionId || "";
59
+
60
+ // Redux selectors
61
+ const workflowInstanceId = useAppSelector((state: any) => state?.onboarding?.workflowInstanceId);
62
+ const applicationId = useAppSelector((state: any) => state?.onboarding?.applicationId);
63
+ const entityId = useAppSelector((state: any) => state?.onboarding?.entityid);
64
+ const providerId = useAppSelector((state: any) => state?.onboarding?.providerId);
65
+
66
+ // Payment Reverse Feed API
67
+ const [paymentReverseFeed, {
68
+ data: paymentReverseFeedResponse,
69
+ error: paymentReverseFeedError,
70
+ isLoading: isLoadingPaymentReverseFeed,
71
+ }] = usePaymentReverseFeedMutation();
72
+
73
+ // Payment Retry API
74
+ const [paymentRetry, {
75
+ data: paymentRetryResponse,
76
+ error: paymentRetryError,
77
+ isLoading: isLoadingPaymentRetry,
78
+ }] = usePaymentRetryMutation();
79
+
80
+ // Get Customer Applications API
81
+ const [getCustomerApplications, {
82
+ isLoading: isLoadingCustomerApplications,
83
+ }] = useGetCustomerApplicationsMutation();
84
+
85
+ // Pull FD data: fdListSelected > fdData prop > default
86
+ const fdListSelectedData = useAppSelector((state: any) => state?.fdListSelected);
87
+
88
+ const displayData = fdListSelectedData ? {
89
+ companyName: fdListSelectedData.companyName,
90
+ amount: fdListSelectedData.amount,
91
+ fdRate: fdListSelectedData.fdRate,
92
+ tenure: fdListSelectedData.tenure,
93
+ interestPayout: fdListSelectedData.interestPayout,
94
+ } : fdData || {
95
+ companyName: '',
96
+ amount: 0,
97
+ fdRate: '',
98
+ tenure: '',
99
+ interestPayout: '',
100
+ };
101
+
102
+ const displayTransactionId = finalTransactionId || '';
103
+
104
+ const formatAmount = (amount: number): string => {
105
+ return amount.toLocaleString('en-IN');
106
+ };
107
+
108
+ // Handle payment reverse feed API call for pending status
109
+ const handlePaymentReverseFeed = async () => {
110
+
111
+ try {
112
+
113
+ // Get user info from app data
114
+ const userInfo = getUserInfoForAPI();
115
+
116
+ // Prepare the API request
117
+ const paymentReverseFeedRequest = {
118
+ // Headers
119
+ providerId: providerId,
120
+ workflowInstanceId: workflowInstanceId,
121
+ userreferenceid: userInfo.id,
122
+ applicationid: applicationId,
123
+ entityid: entityId,
124
+ // Body
125
+ transactionId: finalTransactionId,
126
+ };
127
+
128
+ const response = await paymentReverseFeed(paymentReverseFeedRequest).unwrap();
129
+
130
+ // Handle the response based on payment status
131
+ if (response?.data?.paymentStatus?.toLowerCase() === 'success') {
132
+ setCurrentStatus('success');
133
+
134
+ } else if (response?.data?.paymentStatus?.toLowerCase() === 'failed') {
135
+ setCurrentStatus('failed');
136
+
137
+ }
138
+
139
+ } catch (error) {
140
+
141
+ // Alert.alert(COMMON_STRINGS.ERROR, BANK_STRINGS.PAYMENT_GATEWAY_ERROR, [
142
+ // { text: COMMON_STRINGS.OK }
143
+ // ]);
144
+ }
145
+ };
146
+
147
+ // Handle payment retry when status is failed
148
+ const handlePaymentRetry = async () => {
149
+ if (!finalTransactionId) {
150
+ Alert.alert(COMMON_STRINGS.ERROR, BANK_STRINGS.PAYMENT_GATEWAY_ERROR);
151
+ return;
152
+ }
153
+
154
+ const userInfo = getUserInfoForAPI();
155
+ const userRefId = userInfo?.userReferenceId ?? (userInfo as any)?.id;
156
+ const paymentRetryRequest = {
157
+ providerId,
158
+ workflowInstanceId,
159
+ userreferenceid: userRefId,
160
+ applicationid: applicationId,
161
+ entityid: entityId,
162
+ transactionId: finalTransactionId,
163
+ };
164
+
165
+ try {
166
+ console.log('[FDSDK][PaymentStatus] Retry API calling...');
167
+ const response = await paymentRetry(paymentRetryRequest).unwrap();
168
+ console.log('[FDSDK][PaymentStatus] Retry API success, parsing response');
169
+
170
+ const payload: any = Array.isArray((response as any)?.data)
171
+ ? (response as any).data[0]
172
+ : (response as any)?.data ?? (response as any);
173
+
174
+ const newPaymentUrl: string | undefined =
175
+ payload?.PaymentUrl || payload?.paymentUrl || (payload as any)?.payment_url;
176
+ const newTransactionId: string | undefined =
177
+ payload?.Transactionid || payload?.transactionId || (payload as any)?.transaction_id || finalTransactionId;
178
+
179
+ console.log('[FDSDK][PaymentStatus] Retry response:', {
180
+ hasPaymentUrl: Boolean(newPaymentUrl),
181
+ paymentUrlLength: newPaymentUrl?.length ?? 0,
182
+ applicationId: applicationId?.slice(0, 8) + '...',
183
+ });
184
+
185
+ if (newPaymentUrl) {
186
+ setPaymentSession({ paymentUrl: newPaymentUrl, transactionId: newTransactionId });
187
+ console.log('[FDSDK][PaymentStatus] NAV_TO_PAYMENT: success_with_new_url');
188
+ navigate('Payment', {
189
+ paymentUrl: newPaymentUrl,
190
+ transactionId: newTransactionId,
191
+ applicationId,
192
+ workflowInstanceId,
193
+ entityId,
194
+ providerId,
195
+ } as any);
196
+ } else {
197
+ console.log('[FDSDK][PaymentStatus] No payment URL in response, showing alert');
198
+ Alert.alert(BANK_STRINGS.PAYMENT_FAILED, BANK_STRINGS.PAYMENT_GATEWAY_ERROR);
199
+ }
200
+ } catch (error: any) {
201
+ console.log('[FDSDK][PaymentStatus] Retry catch:', error?.message ?? String(error));
202
+ const session = getPaymentSession();
203
+ if (session.paymentUrl) {
204
+ console.log('[FDSDK][PaymentStatus] NAV_TO_PAYMENT: catch_with_session');
205
+ navigate('Payment', {
206
+ paymentUrl: session.paymentUrl,
207
+ transactionId: session.transactionId,
208
+ applicationId,
209
+ workflowInstanceId,
210
+ entityId,
211
+ providerId,
212
+ } as any);
213
+ } else if (onRetry) {
214
+ console.log('[FDSDK][PaymentStatus] NAV_TO_PAYMENT: catch_calling_onRetry');
215
+ onRetry();
216
+ } else {
217
+ console.log('[FDSDK][PaymentStatus] NAV_TO_PAYMENT: catch_navigate_no_params');
218
+ navigate('Payment');
219
+ }
220
+ }
221
+ };
222
+
223
+ // Handle exit button click - fetch FD details and pass to main app
224
+ const handleExit = async () => {
225
+ try {
226
+ // Get user info from app data
227
+ const userInfo = getUserInfoForAPI();
228
+
229
+ // Get API configuration
230
+ const apiConfig = getApiConfig();
231
+
232
+ // Prepare request payload
233
+ const requestPayload = {
234
+ userReferenceId: userInfo.id
235
+ };
236
+
237
+ // Call API to get customer applications
238
+ const response = await getCustomerApplications(requestPayload).unwrap();
239
+
240
+ // Extract applications from response (handle different response structures)
241
+ let applications: any[] = [];
242
+ if (Array.isArray(response)) {
243
+ applications = response;
244
+ } else if (response?.data && Array.isArray(response.data)) {
245
+ applications = response.data;
246
+ } else if (response?.applications && Array.isArray(response.applications)) {
247
+ applications = response.applications;
248
+ }
249
+
250
+ // Find the currently booked FD - search by transaction_id first (most specific)
251
+ let bookedFD: any = null;
252
+
253
+ // Priority 1: Match by transaction_id from payment
254
+ if (finalTransactionId) {
255
+ bookedFD = applications.find((app: any) =>
256
+ app?.transactionId === finalTransactionId ||
257
+ app?.transaction_id === finalTransactionId ||
258
+ app?.Transactionid === finalTransactionId ||
259
+ app?.TransactionId === finalTransactionId
260
+ );
261
+
262
+ if (__DEV__ && bookedFD) {
263
+ console.log('═══════════════════════════════════════════════════════════════');
264
+ console.log('✅ [PaymentStatus] Found FD by Transaction ID');
265
+ console.log('───────────────────────────────────────────────────────────────');
266
+ console.log('🔍 Searched Transaction ID:', finalTransactionId);
267
+ console.log('📋 Found Application:', bookedFD);
268
+ console.log('═══════════════════════════════════════════════════════════════');
269
+ }
270
+ }
271
+
272
+ // Priority 2: Match by applicationId (fallback)
273
+ if (!bookedFD && applicationId) {
274
+ bookedFD = applications.find((app: any) =>
275
+ app?.applicationId === applicationId ||
276
+ app?.applicationid === applicationId ||
277
+ app?.id === applicationId
278
+ );
279
+
280
+ if (__DEV__ && bookedFD) {
281
+ console.log('═══════════════════════════════════════════════════════════════');
282
+ console.log('✅ [PaymentStatus] Found FD by Application ID');
283
+ console.log('───────────────────────────────────────────────────────────────');
284
+ console.log('🔍 Searched Application ID:', applicationId);
285
+ console.log('📋 Found Application:', bookedFD);
286
+ console.log('═══════════════════════════════════════════════════════════════');
287
+ }
288
+ }
289
+
290
+ // Priority 3: Get the most recent one (last resort)
291
+ if (!bookedFD && applications.length > 0) {
292
+ const sortedApps = [...applications].sort((a: any, b: any) => {
293
+ const dateA = a?.createdDate || a?.created_date || a?.createdAt || 0;
294
+ const dateB = b?.createdDate || b?.created_date || b?.createdAt || 0;
295
+ return new Date(dateB).getTime() - new Date(dateA).getTime();
296
+ });
297
+ bookedFD = sortedApps[0];
298
+
299
+ if (__DEV__ && bookedFD) {
300
+ console.log('═══════════════════════════════════════════════════════════════');
301
+ console.log('⚠️ [PaymentStatus] Using Most Recent FD (fallback)');
302
+ console.log('───────────────────────────────────────────────────────────────');
303
+ console.log('📋 Found Application:', bookedFD);
304
+ console.log('═══════════════════════════════════════════════════════════════');
305
+ }
306
+ }
307
+
308
+ if (__DEV__) {
309
+ console.log('═══════════════════════════════════════════════════════════════');
310
+ console.log('📤 [PaymentStatus] Passing FD Data to Main App');
311
+ console.log('───────────────────────────────────────────────────────────────');
312
+ console.log('💳 Transaction ID:', finalTransactionId);
313
+ console.log('📋 FD Data:', bookedFD);
314
+ console.log('═══════════════════════════════════════════════════════════════');
315
+ }
316
+
317
+ // Pass FD details to main app via onContinue callback
318
+ if (onContinue) {
319
+ onContinue(bookedFD || null);
320
+ }
321
+ } catch (error) {
322
+ if (__DEV__) {
323
+ console.log('═══════════════════════════════════════════════════════════════');
324
+ console.log('❌ [PaymentStatus] Error Fetching FD Data');
325
+ console.log('───────────────────────────────────────────────────────────────');
326
+ console.log('⚠️ Error:', error);
327
+ console.log('═══════════════════════════════════════════════════════════════');
328
+ }
329
+
330
+ // If API call fails, still call onContinue but without FD details
331
+ if (onContinue) {
332
+ onContinue(null);
333
+ }
334
+ }
335
+ };
336
+
337
+ // Disable hardware back button on PaymentStatus screen
338
+ useEffect(() => {
339
+ if (Platform.OS !== 'android') return;
340
+
341
+ const onBackPress = () => {
342
+ // Return true to prevent default behavior (block back button)
343
+ return true;
344
+ };
345
+
346
+ const backHandler = BackHandler.addEventListener(
347
+ 'hardwareBackPress',
348
+ onBackPress
349
+ );
350
+
351
+ return () => backHandler.remove();
352
+ }, []);
353
+
354
+ return (
355
+ <SafeAreaWrapper
356
+ includeTop={true}
357
+ bottomPadding={0}
358
+ statusBarColor="#000000"
359
+ statusBarStyle="light-content"
360
+ >
361
+ {Platform.OS === 'ios' && <StatusBar barStyle="light-content" />}
362
+
363
+ <View style={styles.container}>
364
+ {/* <Text style={styles.headerTitle}>
365
+ {status === 'success' ? 'PAYMENT SUCCESSFUL' : 'PAYMENT FAILED'}
366
+ </Text> */}
367
+
368
+ <ScrollView
369
+ showsVerticalScrollIndicator={false}
370
+ contentContainerStyle={styles.scrollContent}
371
+ >
372
+ {/* Status Icon */}
373
+ <View style={styles.iconContainer}>
374
+ <View style={styles.iconCircleOuter}>
375
+ <View style={styles.iconCircleInner}>
376
+ {currentStatus === 'success' && (
377
+ <Image
378
+ source={{ uri: base64Images.successBig }}
379
+ style={{ width: 60, height: 60 }}
380
+ resizeMode="contain"
381
+ />
382
+ )}
383
+ {currentStatus === 'failed' && (
384
+ <Image
385
+ source={{ uri: base64Images.error }}
386
+ style={{ width: 48, height: 48 }}
387
+ resizeMode="contain"
388
+ />
389
+ )}
390
+ {currentStatus === 'pending' && (
391
+ <Image
392
+ source={{ uri: base64Images.pending }}
393
+ style={{ width: 48, height: 48 }}
394
+ resizeMode="contain"
395
+ />
396
+ )}
397
+ </View>
398
+ </View>
399
+ </View>
400
+
401
+ {/* Status Title */}
402
+ <Text style={styles.statusTitle}>
403
+ {currentStatus === 'success' && BANK_STRINGS.PAYMENT_STATUS_SUCCESS}
404
+ {currentStatus === 'failed' && BANK_STRINGS.PAYMENT_STATUS_FAILED}
405
+ {currentStatus === 'pending' && BANK_STRINGS.PAYMENT_STATUS_PENDING}
406
+ </Text>
407
+
408
+ {/* Pending Status Subtitle */}
409
+ {currentStatus === 'pending' && (
410
+ <Text style={styles.pendingSubtitle}>
411
+ {BANK_STRINGS.PAYMENT_STATUS_PROCESSING}
412
+ </Text>
413
+ )}
414
+
415
+ {/* Transaction ID */}
416
+ <Text style={styles.transactionLabel}>
417
+ Transaction ID
418
+ </Text>
419
+ <Text style={styles.transactionId}>{displayTransactionId}</Text>
420
+
421
+ {/* Details Card */}
422
+ <PaymentDetailsCard
423
+ companyName={displayData.companyName}
424
+ amount={displayData.amount}
425
+ fdRate={displayData.fdRate}
426
+ tenure={displayData.tenure}
427
+ interestPayout={displayData.interestPayout}
428
+ />
429
+
430
+ {/* Success Disclaimer */}
431
+ {currentStatus === 'success' && (
432
+ <View style={styles.disclaimerContainer}>
433
+ {Platform.OS === 'android' && (
434
+ <Icon name="information-circle-outline" size={20} color={colors.textSecondary} style={styles.disclaimerIcon} />
435
+ )}
436
+ <Text style={styles.disclaimerText}>
437
+ {BANK_STRINGS.PAYMENT_SUCCESS_DISCLAIMER}
438
+ </Text>
439
+ </View>
440
+ )}
441
+
442
+ </ScrollView>
443
+
444
+ {/* Action Button */}
445
+ <View style={styles.footer}>
446
+ {currentStatus === 'success' && (
447
+ <ActionButton
448
+ title={isLoadingCustomerApplications ? COMMON_STRINGS.LOADING : COMMON_STRINGS.EXIT}
449
+ onPress={handleExit}
450
+ disabled={isLoadingCustomerApplications}
451
+ />
452
+ )}
453
+ {currentStatus === 'failed' && (
454
+ <ActionButton
455
+ title={isLoadingPaymentRetry ? COMMON_STRINGS.RETRYING : BANK_STRINGS.RETRY_PAYMENT_BUTTON}
456
+ onPress={handlePaymentRetry}
457
+ disabled={isLoadingPaymentRetry}
458
+ />
459
+ )}
460
+ {currentStatus === 'pending' && (
461
+ <ActionButton
462
+ title={isLoadingPaymentReverseFeed ? COMMON_STRINGS.CHECKING : BANK_STRINGS.REFRESH_STATUS_BUTTON}
463
+ onPress={handlePaymentReverseFeed}
464
+ disabled={isLoadingPaymentReverseFeed}
465
+ />
466
+ )}
467
+ </View>
468
+ </View>
469
+ </SafeAreaWrapper>
470
+ );
471
+ };
472
+
473
+ const createStyles = (colors: any, typography: any, status: 'success' | 'failed' | 'pending') => {
474
+ const statusColor = status === 'success' ? '#4CAF50' : status === 'failed' ? '#F44336' : '#FF9800';
475
+ const cardBgColor = status === 'success' ? '#E8F5F0' : status === 'failed' ? '#FFF3F3' : '#FFF8E1';
476
+
477
+ return StyleSheet.create({
478
+ container: {
479
+ flex: 1,
480
+ backgroundColor: colors.background,
481
+ },
482
+ headerTitle: {
483
+ fontSize: 14,
484
+ fontWeight: '600',
485
+ color: colors.textLight,
486
+ textAlign: 'center',
487
+ paddingVertical: 16,
488
+ letterSpacing: 1,
489
+ },
490
+ scrollContent: {
491
+ flexGrow: 1,
492
+ paddingHorizontal: 24,
493
+ paddingBottom: 120,
494
+ },
495
+ iconContainer: {
496
+ alignItems: 'center',
497
+ marginTop: 40,
498
+ marginBottom: 32,
499
+ },
500
+ iconCircleOuter: {
501
+ width: 120,
502
+ height: 120,
503
+ borderRadius: 60,
504
+ backgroundColor: status === 'success' ? '#e8f5e9' : status === 'failed' ? 'rgba(244, 67, 54, 0.1)' : 'rgba(255, 152, 0, 0.1)',
505
+ alignItems: 'center',
506
+ justifyContent: 'center',
507
+ },
508
+ iconCircleInner: {
509
+ width: 60,
510
+ height: 60,
511
+ borderRadius: 30,
512
+ backgroundColor: status === 'success' ? '#ffffff' : status === 'failed' ? 'rgba(244, 67, 54, 0.0)' : 'rgba(255, 152, 0, 0.2)',
513
+ alignItems: 'center',
514
+ justifyContent: 'center',
515
+ },
516
+ statusTitle: {
517
+ ...typography.styles.h1,
518
+ color: colors.text,
519
+ textAlign: 'center',
520
+ marginBottom: 32,
521
+ letterSpacing: 0.5,
522
+ },
523
+ pendingSubtitle: {
524
+ ...typography.styles.bodyMedium,
525
+ color: colors.textSecondary,
526
+ textAlign: 'center',
527
+ marginBottom: 30,
528
+ marginTop: -30,
529
+
530
+ },
531
+ transactionLabel: {
532
+ ...typography.styles.bodyMedium,
533
+ color: colors.textLight,
534
+ textAlign: 'center',
535
+ marginBottom: 8,
536
+ },
537
+ transactionId: {
538
+ ...typography.styles.h2,
539
+ color: colors.text,
540
+ textAlign: 'center',
541
+ marginBottom: 32,
542
+ letterSpacing: 1,
543
+ },
544
+ avatarContainer: {
545
+ alignItems: 'center',
546
+ marginTop: -28,
547
+ marginBottom: 24,
548
+ },
549
+ avatar: {
550
+ width: 56,
551
+ height: 56,
552
+ borderRadius: 28,
553
+ backgroundColor: '#5F9E8F',
554
+ alignItems: 'center',
555
+ justifyContent: 'center',
556
+ borderWidth: 4,
557
+ borderColor: colors.background,
558
+ },
559
+ avatarText: {
560
+ fontSize: 24,
561
+ fontWeight: '600',
562
+ color: 'white',
563
+ },
564
+ footer: {
565
+ position: 'absolute',
566
+ bottom: 0,
567
+ left: 0,
568
+ right: 0,
569
+ backgroundColor: colors.background,
570
+ paddingTop: 16,
571
+ },
572
+ disclaimerContainer: {
573
+ flexDirection: 'row',
574
+ backgroundColor: 'transparent',
575
+ borderRadius: 8,
576
+ padding: 16,
577
+ marginTop: 24,
578
+ marginBottom: 16,
579
+ alignItems: 'flex-start',
580
+ },
581
+ disclaimerIcon: {
582
+ marginRight: 12,
583
+ marginTop: 2,
584
+ },
585
+ disclaimerText: {
586
+ ...typography.styles.bodySmall,
587
+ color: colors.textSecondary,
588
+ flex: 1,
589
+ lineHeight: 18,
590
+ },
591
+ });
592
+ };
593
+
594
+ export default PaymentStatus;
595
+