boxpay-checkout-reactnative-sdk 1.0.0-beta45 → 1.0.1-beta12

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 (183) hide show
  1. package/lib/module/components/getInstalledUPI.js +0 -2
  2. package/lib/module/components/getInstalledUPI.js.map +1 -1
  3. package/lib/module/components/savedAddressCard.js +1 -1
  4. package/lib/module/components/savedAddressCard.js.map +1 -1
  5. package/lib/module/postRequest/callUIAnalytics.js +1 -2
  6. package/lib/module/postRequest/callUIAnalytics.js.map +1 -1
  7. package/lib/module/postRequest/cardPostRequest.js +1 -5
  8. package/lib/module/postRequest/cardPostRequest.js.map +1 -1
  9. package/lib/module/postRequest/emiPostRequest.js +1 -5
  10. package/lib/module/postRequest/emiPostRequest.js.map +1 -1
  11. package/lib/module/postRequest/fetchStatus.js +0 -1
  12. package/lib/module/postRequest/fetchStatus.js.map +1 -1
  13. package/lib/module/postRequest/methodsPostRequest.js +1 -1
  14. package/lib/module/postRequest/methodsPostRequest.js.map +1 -1
  15. package/lib/module/postRequest/upiPostRequest.js +1 -1
  16. package/lib/module/postRequest/upiPostRequest.js.map +1 -1
  17. package/lib/module/screens/addressScreen.js +1 -1
  18. package/lib/module/screens/addressScreen.js.map +1 -1
  19. package/lib/module/screens/mainScreen.js +15 -36
  20. package/lib/module/screens/mainScreen.js.map +1 -1
  21. package/lib/module/screens/savedAddressScreen.js +1 -3
  22. package/lib/module/screens/savedAddressScreen.js.map +1 -1
  23. package/lib/module/screens/upiScreen.js +6 -9
  24. package/lib/module/screens/upiScreen.js.map +1 -1
  25. package/lib/module/screens/upiTimerScreen.js +19 -56
  26. package/lib/module/screens/upiTimerScreen.js.map +1 -1
  27. package/lib/module/sdk-version.json +1 -1
  28. package/lib/module/serviceRequest.js +1 -3
  29. package/lib/module/serviceRequest.js.map +1 -1
  30. package/lib/module/sharedContext/handlePaymentResponseHandler.js +1 -1
  31. package/lib/module/sharedContext/handlePaymentResponseHandler.js.map +1 -1
  32. package/lib/module/utility.js +167 -0
  33. package/lib/module/utility.js.map +1 -0
  34. package/lib/typescript/src/components/getInstalledUPI.d.ts.map +1 -1
  35. package/lib/typescript/src/postRequest/callUIAnalytics.d.ts.map +1 -1
  36. package/lib/typescript/src/postRequest/cardPostRequest.d.ts.map +1 -1
  37. package/lib/typescript/src/postRequest/emiPostRequest.d.ts.map +1 -1
  38. package/lib/typescript/src/postRequest/fetchStatus.d.ts.map +1 -1
  39. package/lib/typescript/src/screens/mainScreen.d.ts.map +1 -1
  40. package/lib/typescript/src/screens/savedAddressScreen.d.ts.map +1 -1
  41. package/lib/typescript/src/screens/upiScreen.d.ts +1 -1
  42. package/lib/typescript/src/screens/upiScreen.d.ts.map +1 -1
  43. package/lib/typescript/src/screens/upiTimerScreen.d.ts.map +1 -1
  44. package/lib/typescript/src/serviceRequest.d.ts.map +1 -1
  45. package/lib/typescript/src/{utils/listAndObjectUtils.d.ts → utility.d.ts} +17 -2
  46. package/lib/typescript/src/utility.d.ts.map +1 -0
  47. package/package.json +2 -2
  48. package/src/components/getInstalledUPI.ts +0 -2
  49. package/src/components/savedAddressCard.tsx +1 -1
  50. package/src/postRequest/callUIAnalytics.ts +1 -2
  51. package/src/postRequest/cardPostRequest.ts +1 -6
  52. package/src/postRequest/emiPostRequest.ts +1 -5
  53. package/src/postRequest/fetchStatus.tsx +0 -1
  54. package/src/postRequest/methodsPostRequest.tsx +1 -1
  55. package/src/postRequest/upiPostRequest.tsx +1 -1
  56. package/src/screens/addressScreen.tsx +1 -1
  57. package/src/screens/mainScreen.tsx +17 -40
  58. package/src/screens/savedAddressScreen.tsx +1 -3
  59. package/src/screens/upiScreen.tsx +6 -12
  60. package/src/screens/upiTimerScreen.tsx +19 -59
  61. package/src/sdk-version.json +1 -1
  62. package/src/serviceRequest.ts +1 -6
  63. package/src/sharedContext/handlePaymentResponseHandler.ts +1 -1
  64. package/src/utility.ts +193 -0
  65. package/android/build/.transforms/516dc569503728180fa99c1ae0c9eece/results.bin +0 -1
  66. package/android/build/.transforms/516dc569503728180fa99c1ae0c9eece/transformed/classes/classes_dex/classes.dex +0 -0
  67. package/android/build/generated/source/buildConfig/debug/com/reactnativemodule/BuildConfig.java +0 -10
  68. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/AndroidManifest.xml +0 -13
  69. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/output-metadata.json +0 -18
  70. package/android/build/intermediates/aar_metadata/debug/writeDebugAarMetadata/aar-metadata.properties +0 -6
  71. package/android/build/intermediates/annotation_processor_list/debug/javaPreCompileDebug/annotationProcessors.json +0 -1
  72. package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
  73. package/android/build/intermediates/compile_r_class_jar/debug/generateDebugRFile/R.jar +0 -0
  74. package/android/build/intermediates/compile_symbol_list/debug/generateDebugRFile/R.txt +0 -0
  75. package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +0 -1
  76. package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +0 -2
  77. package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +0 -2
  78. package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +0 -2
  79. package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +0 -2
  80. package/android/build/intermediates/java_res/debug/processDebugJavaRes/out/META-INF/cross_platform_sdk_react_native_plugin_debug.kotlin_module +0 -0
  81. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/reactnativemodule/BuildConfig.class +0 -0
  82. package/android/build/intermediates/local_only_symbol_list/debug/parseDebugLocalResources/R-def.txt +0 -2
  83. package/android/build/intermediates/manifest_merge_blame_file/debug/processDebugManifest/manifest-merger-blame-debug-report.txt +0 -20
  84. package/android/build/intermediates/merged_manifest/debug/processDebugManifest/AndroidManifest.xml +0 -13
  85. package/android/build/intermediates/navigation_json/debug/extractDeepLinksDebug/navigation.json +0 -1
  86. package/android/build/intermediates/nested_resources_validation_report/debug/generateDebugResources/nestedResourcesValidationReport.txt +0 -1
  87. package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
  88. package/android/build/intermediates/symbol_list_with_package_name/debug/generateDebugRFile/package-aware-r.txt +0 -1
  89. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
  90. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream +0 -0
  91. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream.len +0 -0
  92. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.len +0 -0
  93. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
  94. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i +0 -0
  95. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i.len +0 -0
  96. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
  97. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
  98. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
  99. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
  100. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
  101. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
  102. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i.len +0 -0
  103. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
  104. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
  105. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
  106. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
  107. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
  108. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
  109. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i.len +0 -0
  110. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
  111. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
  112. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
  113. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
  114. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
  115. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
  116. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i.len +0 -0
  117. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
  118. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
  119. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
  120. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
  121. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
  122. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
  123. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i.len +0 -0
  124. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
  125. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream +0 -0
  126. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream.len +0 -0
  127. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.len +0 -0
  128. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
  129. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i +0 -0
  130. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i.len +0 -0
  131. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
  132. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream +0 -0
  133. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream.len +0 -0
  134. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.len +0 -0
  135. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
  136. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i +0 -0
  137. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i.len +0 -0
  138. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
  139. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream +0 -0
  140. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream.len +0 -0
  141. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.len +0 -0
  142. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
  143. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i +0 -0
  144. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i.len +0 -0
  145. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +0 -2
  146. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
  147. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream +0 -0
  148. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream.len +0 -0
  149. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.len +0 -0
  150. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
  151. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i +0 -0
  152. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i.len +0 -0
  153. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
  154. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
  155. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
  156. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
  157. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
  158. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
  159. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i.len +0 -0
  160. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
  161. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
  162. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
  163. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
  164. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
  165. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
  166. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i.len +0 -0
  167. package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
  168. package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
  169. package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -30
  170. package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
  171. package/android/build/tmp/kotlin-classes/debug/META-INF/cross_platform_sdk_react_native_plugin_debug.kotlin_module +0 -0
  172. package/android/build/tmp/kotlin-classes/debug/com/reactnativemodule/CrossPlatform.class +0 -0
  173. package/android/build/tmp/kotlin-classes/debug/com/reactnativemodule/ReactNativeModulePackage.class +0 -0
  174. package/android/local.properties +0 -1
  175. package/lib/module/utils/listAndObjectUtils.js +0 -73
  176. package/lib/module/utils/listAndObjectUtils.js.map +0 -1
  177. package/lib/module/utils/stringUtils.js +0 -50
  178. package/lib/module/utils/stringUtils.js.map +0 -1
  179. package/lib/typescript/src/utils/listAndObjectUtils.d.ts.map +0 -1
  180. package/lib/typescript/src/utils/stringUtils.d.ts +0 -11
  181. package/lib/typescript/src/utils/stringUtils.d.ts.map +0 -1
  182. package/src/utils/listAndObjectUtils.ts +0 -83
  183. package/src/utils/stringUtils.ts +0 -64
@@ -20,6 +20,7 @@ import { checkoutDetailsHandler } from '../sharedContext/checkoutDetailsHandler'
20
20
  import { handleFetchStatusResponseHandler } from '../sharedContext/handlePaymentResponseHandler';
21
21
  import type { CheckoutStackParamList } from '../navigation';
22
22
  import type {RouteProp, NavigationProp} from '@react-navigation/native'
23
+ import { useCountdown , formatTime} from '../utility';
23
24
 
24
25
  type UpiTimerScreenRouteProp = RouteProp<CheckoutStackParamList, 'UpiTimerScreen'>;
25
26
 
@@ -39,7 +40,6 @@ const UpiTimerScreen = ({ route, navigation }: Props) => {
39
40
 
40
41
  const upiIdStr = Array.isArray(upiId) ? upiId[0] : upiId;
41
42
 
42
- const [timerValue, setTimerValue] = useState(5 * 60);
43
43
  const [cancelClicked, setCancelClicked] = useState(false);
44
44
  const [failedModalOpen, setFailedModalState] = useState(false);
45
45
  const [successModalOpen, setSuccessModalState] = useState(false);
@@ -50,36 +50,24 @@ const UpiTimerScreen = ({ route, navigation }: Props) => {
50
50
  const [successfulTimeStamp, setSuccessfulTimeStamp] = useState('');
51
51
  const [status, setStatus] = useState('');
52
52
  const [transactionId, setTransactionId] = useState('');
53
- const [isTimerRunning, setIsTimerRunning] = useState(true);
54
- const backgroundApiInterval = useRef<NodeJS.Timeout | null>(null);
55
- const timerInterval = useRef<NodeJS.Timeout | null>(null);
53
+ const {
54
+ timeRemaining: upiCollectTimerValue,
55
+ start: startCollectTimer,
56
+ stop: stopCollectTimer
57
+ } = useCountdown(300)
56
58
 
57
59
  useEffect(() => {
58
- if (isTimerRunning) {
59
- timerInterval.current = setInterval(() => {
60
- setTimerValue((prevTime) => {
61
- if (prevTime <= 1) {
62
- clearInterval(timerInterval.current!);
63
- stopBackgroundApiTask();
64
- setFailedModalState(true);
65
- return 0;
66
- }
67
- return prevTime - 1;
68
- });
69
- }, 1000);
60
+ const isUPICollectTimerRunning = upiCollectTimerValue < 300
61
+ if(isUPICollectTimerRunning && upiCollectTimerValue > 0 && upiCollectTimerValue %4 === 0) {
62
+ callFetchStatusApi();
70
63
  }
71
- return () => {
72
- if (timerInterval.current) {
73
- clearInterval(timerInterval.current);
74
- }
75
- };
76
- }, [isTimerRunning]);
64
+ },[upiCollectTimerValue]);
77
65
 
78
66
  useEffect(() => {
79
67
  if (failedModalOpen || successModalOpen || sessionExpireModalOpen) {
80
- setIsTimerRunning(false);
68
+ stopCollectTimer()
81
69
  } else {
82
- setIsTimerRunning(true);
70
+ startCollectTimer()
83
71
  }
84
72
  }, [failedModalOpen, successModalOpen, sessionExpireModalOpen]);
85
73
 
@@ -93,10 +81,7 @@ const UpiTimerScreen = ({ route, navigation }: Props) => {
93
81
 
94
82
  const onProceedBack = () => {
95
83
  if (cancelClicked) {
96
- if (timerInterval.current) {
97
- clearInterval(timerInterval.current);
98
- }
99
- stopBackgroundApiTask();
84
+ stopCollectTimer()
100
85
  navigation.goBack()
101
86
  } else {
102
87
  setCancelClicked(true);
@@ -106,10 +91,7 @@ const UpiTimerScreen = ({ route, navigation }: Props) => {
106
91
 
107
92
  const onPaymentFailed = () => {
108
93
  setFailedModalState(true);
109
- stopBackgroundApiTask();
110
- if (timerInterval.current) {
111
- clearInterval(timerInterval.current);
112
- }
94
+ stopCollectTimer()
113
95
  navigation.goBack()
114
96
  };
115
97
 
@@ -120,27 +102,6 @@ const UpiTimerScreen = ({ route, navigation }: Props) => {
120
102
  );
121
103
  }, []);
122
104
 
123
- const formatTime = () => {
124
- const minutes = Math.floor(timerValue / 60);
125
- const seconds = timerValue % 60;
126
- return `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
127
- };
128
-
129
- useEffect(() => {
130
- const startBackgroundApiTask = () => {
131
- backgroundApiInterval.current = setInterval(() => {
132
- callFetchStatusApi();
133
- }, 4000);
134
- };
135
- startBackgroundApiTask();
136
- }, []);
137
-
138
- const stopBackgroundApiTask = () => {
139
- if (backgroundApiInterval.current) {
140
- clearInterval(backgroundApiInterval.current);
141
- }
142
- };
143
-
144
105
  const callFetchStatusApi = async () => {
145
106
  const response = await fetchStatus();
146
107
  handleFetchStatusResponseHandler({
@@ -160,8 +121,7 @@ const UpiTimerScreen = ({ route, navigation }: Props) => {
160
121
  },
161
122
  onShowSessionExpiredModal: () => {
162
123
  setSessionExppireModalState(true)
163
- },
164
- stopBackgroundApiTask: stopBackgroundApiTask
124
+ }
165
125
  });
166
126
  };
167
127
 
@@ -212,12 +172,12 @@ const UpiTimerScreen = ({ route, navigation }: Props) => {
212
172
  size={150}
213
173
  strokeWidth={10}
214
174
  progressColor={
215
- timerValue <= 30 ? '#FAA4A4' : checkoutDetails.brandColor
175
+ upiCollectTimerValue <= 30 ? '#FAA4A4' : checkoutDetails.brandColor
216
176
  }
217
- progress={timerValue}
218
- formatTime={formatTime()}
177
+ progress={upiCollectTimerValue}
178
+ formatTime={formatTime(upiCollectTimerValue)}
219
179
  textColor={
220
- timerValue <= 30 ? '#F53535' : checkoutDetails.brandColor
180
+ upiCollectTimerValue <= 30 ? '#F53535' : checkoutDetails.brandColor
221
181
  }
222
182
  />
223
183
  </View>
@@ -1 +1 @@
1
- { "version": "1.0.0-beta45" }
1
+ { "version": "1.0.1-beta12" }
@@ -1,5 +1,5 @@
1
1
  import axios from 'axios';
2
- import { generateRandomAlphanumericString, getEndpoint } from './utils/stringUtils'; // adjust path accordingly
2
+ import { generateRandomAlphanumericString, getEndpoint } from './utility'; // adjust path accordingly
3
3
  import { checkoutDetailsHandler } from './sharedContext/checkoutDetailsHandler';
4
4
  import sdkVersion from './sdk-version.json'
5
5
 
@@ -19,11 +19,6 @@ api.interceptors.request.use(
19
19
  if (checkoutDetails.shopperToken) {
20
20
  config.headers['Authorization'] = `Session ${checkoutDetails.shopperToken}`;
21
21
  }
22
-
23
- console.log(config)
24
- console.log(sdkVersion.version)
25
-
26
-
27
22
  return config;
28
23
  },
29
24
  (error) => Promise.reject(error)
@@ -1,5 +1,5 @@
1
1
  import { type HandleFetchStatusOptions, type HandlePaymentOptions, type PaymentClass, type RecommendedInstruments, APIStatus, TransactionStatus } from "../interface";
2
- import { transformAndFilterList } from '../utils/listAndObjectUtils';
2
+ import { transformAndFilterList } from '../utility';
3
3
  import Toast from 'react-native-toast-message'
4
4
  import fetchPaymentMethods from '../postRequest/fetchPaymentMethods';
5
5
  import fetchRecommendedInstruments from "../postRequest/fetchRecommendedInstruments";
package/src/utility.ts ADDED
@@ -0,0 +1,193 @@
1
+ import type { PaymentMethod, PaymentClass, DeliveryAddress } from './interface';
2
+ import { Dimensions, Platform } from 'react-native';
3
+ import { userDataHandler } from './sharedContext/userdataHandler';
4
+ import { useState, useRef, useCallback, useEffect } from 'react';
5
+
6
+ export function transformAndFilterList(
7
+ data: PaymentMethod[],
8
+ filterType: string
9
+ ): PaymentClass[] {
10
+ const filteredList = data
11
+ .filter((item) => item.type === filterType)
12
+ .sort((a, b) => a.title?.trim().localeCompare(b.title?.trim() ?? ''))
13
+ .map((item) => ({
14
+ type: filterType,
15
+ id: item.id,
16
+ displayName: item.title,
17
+ displayValue: item.title,
18
+ iconUrl: item.logoUrl,
19
+ instrumentTypeValue: item.instrumentTypeValue,
20
+ isSelected: false,
21
+ }));
22
+
23
+ return filteredList;
24
+ }
25
+
26
+
27
+ export function getDeviceDetails() {
28
+ return {
29
+ browser: Platform.OS,
30
+ platformVersion: Platform.Version.toString(),
31
+ deviceType: Platform.OS === 'ios' || Platform.OS === 'android' ? 'Phone' : 'Web',
32
+ deviceName: Platform.OS === 'ios' ? 'iOS Device' : 'Android Device',
33
+ deviceBrandName: Platform.OS === 'ios' ? 'Apple' : 'Android'
34
+ };
35
+ }
36
+
37
+ export function getBrowserData() {
38
+ return {
39
+ screenHeight: height,
40
+ screenWidth: width,
41
+ acceptHeader: 'application/json',
42
+ userAgentHeader: 'Expo App',
43
+ browserLanguage: 'en_US',
44
+ ipAddress: 'null',
45
+ colorDepth: 24,
46
+ javaEnabled: true,
47
+ timeZoneOffSet: new Date().getTimezoneOffset(),
48
+ packageId: 'com.boxpay.checkout.sdk',
49
+ }
50
+ }
51
+
52
+ export function getShopperDetails() {
53
+ const { userData } = userDataHandler;
54
+ const isDeliveryAddressEmpty = (address: DeliveryAddress): boolean => {
55
+ return Object.values(address).every(
56
+ (value) => value === null || value === undefined || value === ''
57
+ );
58
+ };
59
+ const deliveryAddress = {
60
+ address1: userData.address1,
61
+ address2: userData.address2,
62
+ city: userData.city,
63
+ state: userData.state,
64
+ countryCode: userData.country,
65
+ postalCode: userData.pincode,
66
+ labelType: userData.labelType,
67
+ labelName: userData.labelName,
68
+ };
69
+ return {
70
+ email: userData.email,
71
+ firstName: userData.firstName,
72
+ gender: null,
73
+ lastName: userData.lastName,
74
+ phoneNumber: userData.phone,
75
+ uniqueReference: userData.uniqueId,
76
+ dateOfBirth: userData.dob,
77
+ panNumber: userData.pan,
78
+ deliveryAddress: isDeliveryAddressEmpty(deliveryAddress)
79
+ ? null
80
+ : deliveryAddress,
81
+ }
82
+ }
83
+
84
+ export const { height, width } = Dimensions.get("window");
85
+
86
+ export const useCountdown = (initialSeconds: number) => {
87
+ const [timeRemaining, setTimeRemaining] = useState(initialSeconds);
88
+ const timerRef = useRef<NodeJS.Timeout | null>(null);
89
+ const stop = useCallback(() => {
90
+ if (timerRef.current) {
91
+ clearInterval(timerRef.current);
92
+ timerRef.current = null;
93
+ }
94
+ }, []);
95
+ const start = useCallback(() => {
96
+ stop();
97
+ setTimeRemaining(initialSeconds);
98
+ timerRef.current = setInterval(() => {
99
+ setTimeRemaining(prevTime => {
100
+ if (prevTime <= 1) {
101
+ stop();
102
+ return 0;
103
+ }
104
+ return prevTime - 1;
105
+ });
106
+ }, 1000);
107
+ }, [initialSeconds]);
108
+ useEffect(() => {
109
+ return stop;
110
+ }, [stop]);
111
+ return { timeRemaining, start, stop };
112
+ };
113
+
114
+ const TEST_API_URL = "https://test-apis.boxpay.tech"
115
+ const PROD_API_URL = "https://apis.boxpay.in"
116
+ const ROUTE = "/v0/checkout/sessions/"
117
+
118
+ export function getEndpoint(env: string): string {
119
+ const baseUrl = env === 'test' ? TEST_API_URL : PROD_API_URL;
120
+ return `${baseUrl}${ROUTE}`;
121
+ }
122
+
123
+ export function generateRandomAlphanumericString(length: number): string {
124
+ const charPool: string[] =
125
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.split(
126
+ ''
127
+ );
128
+ let result = '';
129
+
130
+ for (let i = 0; i < length; i++) {
131
+ const randomIndex = Math.floor(Math.random() * charPool.length);
132
+ result += charPool[randomIndex];
133
+ }
134
+
135
+ return result;
136
+ }
137
+
138
+
139
+ export function getBaseURL(env: string): string {
140
+ const baseUrl = env === 'test' ? TEST_API_URL : PROD_API_URL;
141
+ return `${baseUrl}/v0`;
142
+ }
143
+
144
+ export function formatAddress(deliveryAddress : DeliveryAddress) : string {
145
+ if (deliveryAddress.address2 == null || deliveryAddress.address2 == '') {
146
+ return `${deliveryAddress.address1}, ${deliveryAddress.city}, ${deliveryAddress.state}, ${deliveryAddress.postalCode}`
147
+ } else {
148
+ return `${deliveryAddress.address1}, ${deliveryAddress.address2}, ${deliveryAddress.city}, ${deliveryAddress.state}, ${deliveryAddress.postalCode}`
149
+ }
150
+ }
151
+
152
+ export function extractNames(fullName: string): {
153
+ firstName: string;
154
+ lastName: string;
155
+ } {
156
+ const components = fullName
157
+ .trim()
158
+ .split(' ')
159
+ .filter((part) => part !== '');
160
+
161
+ if (components.length === 0) {
162
+ return { firstName: '', lastName: '' };
163
+ }
164
+
165
+ const firstName = components[0] || '';
166
+ const lastName = components.slice(1).join(' ') || '';
167
+
168
+ return { firstName, lastName };
169
+ }
170
+
171
+ export const formatTime = (timeRemaining : number) => {
172
+ const minutes = Math.floor(timeRemaining / 60);
173
+ const seconds = timeRemaining % 60;
174
+ return `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
175
+ };
176
+
177
+ export const formatExpiry = (input: string): string => {
178
+ const parts = input.split('/');
179
+ if (parts.length !== 2 || parts[0]?.length !== 2 || parts[1]?.length !== 2) {
180
+ return ''; // Return for any invalid format.
181
+ }
182
+ const [month, twoDigitYearStr] = parts;
183
+ const twoDigitYear = parseInt(twoDigitYearStr, 10);
184
+ const currentYear = new Date().getFullYear();
185
+ const century = Math.floor(currentYear / 100) * 100;
186
+ let fullYear = century + twoDigitYear;
187
+
188
+ if (fullYear < currentYear - 1) {
189
+ fullYear += 100;
190
+ }
191
+
192
+ return `${fullYear}-${month}`;
193
+ };
@@ -1,10 +0,0 @@
1
- /**
2
- * Automatically generated file. DO NOT MODIFY
3
- */
4
- package com.reactnativemodule;
5
-
6
- public final class BuildConfig {
7
- public static final boolean DEBUG = Boolean.parseBoolean("true");
8
- public static final String LIBRARY_PACKAGE_NAME = "com.reactnativemodule";
9
- public static final String BUILD_TYPE = "debug";
10
- }
@@ -1,13 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
- package="com.reactnativemodule" >
4
-
5
- <uses-sdk android:minSdkVersion="21" />
6
-
7
- <queries>
8
- <package android:name="com.google.android.apps.nbu.paisa.user" />
9
- <package android:name="com.phonepe.app" />
10
- <package android:name="net.one97.paytm" />
11
- </queries>
12
-
13
- </manifest>
@@ -1,18 +0,0 @@
1
- {
2
- "version": 3,
3
- "artifactType": {
4
- "type": "AAPT_FRIENDLY_MERGED_MANIFESTS",
5
- "kind": "Directory"
6
- },
7
- "applicationId": "com.reactnativemodule",
8
- "variantName": "debug",
9
- "elements": [
10
- {
11
- "type": "SINGLE",
12
- "filters": [],
13
- "attributes": [],
14
- "outputFile": "AndroidManifest.xml"
15
- }
16
- ],
17
- "elementType": "File"
18
- }
@@ -1,6 +0,0 @@
1
- aarFormatVersion=1.0
2
- aarMetadataVersion=1.0
3
- minCompileSdk=1
4
- minCompileSdkExtension=0
5
- minAndroidGradlePluginVersion=1.0.0
6
- coreLibraryDesugaringEnabled=false
@@ -1,2 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <merger version="3"><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/ishikabansal/checkout-react-native-sdk/node_modules/cross_platform_sdk_react_native_plugin/android/src/main/res"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="main" generated-set="main$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/ishikabansal/checkout-react-native-sdk/node_modules/cross_platform_sdk_react_native_plugin/android/src/main/res"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="debug$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/ishikabansal/checkout-react-native-sdk/node_modules/cross_platform_sdk_react_native_plugin/android/src/debug/res"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="debug" generated-set="debug$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/ishikabansal/checkout-react-native-sdk/node_modules/cross_platform_sdk_react_native_plugin/android/src/debug/res"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="generated$Generated" generated="true" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/ishikabansal/checkout-react-native-sdk/node_modules/cross_platform_sdk_react_native_plugin/android/build/generated/res/resValues/debug"/></dataSet><dataSet aapt-namespace="http://schemas.android.com/apk/res-auto" config="generated" generated-set="generated$Generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/ishikabansal/checkout-react-native-sdk/node_modules/cross_platform_sdk_react_native_plugin/android/build/generated/res/resValues/debug"/></dataSet><mergedItems/></merger>
@@ -1,2 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/ishikabansal/checkout-react-native-sdk/node_modules/cross_platform_sdk_react_native_plugin/android/src/main/jniLibs"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/ishikabansal/checkout-react-native-sdk/node_modules/cross_platform_sdk_react_native_plugin/android/src/debug/jniLibs"/></dataSet></merger>
@@ -1,2 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/ishikabansal/checkout-react-native-sdk/node_modules/cross_platform_sdk_react_native_plugin/android/src/main/shaders"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/ishikabansal/checkout-react-native-sdk/node_modules/cross_platform_sdk_react_native_plugin/android/src/debug/shaders"/></dataSet></merger>
@@ -1,2 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <merger version="3"><dataSet config="main" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/ishikabansal/checkout-react-native-sdk/node_modules/cross_platform_sdk_react_native_plugin/android/src/main/assets"/></dataSet><dataSet config="debug" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/ishikabansal/checkout-react-native-sdk/node_modules/cross_platform_sdk_react_native_plugin/android/src/debug/assets"/></dataSet><dataSet config="generated" ignore_pattern="!.svn:!.git:!.ds_store:!*.scc:.*:&lt;dir>_*:!CVS:!thumbs.db:!picasa.ini:!*~"><source path="/Users/ishikabansal/checkout-react-native-sdk/node_modules/cross_platform_sdk_react_native_plugin/android/build/intermediates/shader_assets/debug/compileDebugShaders/out"/></dataSet></merger>
@@ -1,2 +0,0 @@
1
- R_DEF: Internal format may change without notice
2
- local
@@ -1,20 +0,0 @@
1
- 1<?xml version="1.0" encoding="utf-8"?>
2
- 2<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
- 3 package="com.reactnativemodule" >
4
- 4
5
- 5 <uses-sdk android:minSdkVersion="21" />
6
- 6
7
- 7 <queries>
8
- 7-->/Users/ishikabansal/checkout-react-native-sdk/node_modules/cross_platform_sdk_react_native_plugin/android/src/main/AndroidManifest.xml:3:1-7:15
9
- 8 <package android:name="com.google.android.apps.nbu.paisa.user" />
10
- 8-->/Users/ishikabansal/checkout-react-native-sdk/node_modules/cross_platform_sdk_react_native_plugin/android/src/main/AndroidManifest.xml:4:9-73
11
- 8-->/Users/ishikabansal/checkout-react-native-sdk/node_modules/cross_platform_sdk_react_native_plugin/android/src/main/AndroidManifest.xml:4:18-71
12
- 9 <package android:name="com.phonepe.app" />
13
- 9-->/Users/ishikabansal/checkout-react-native-sdk/node_modules/cross_platform_sdk_react_native_plugin/android/src/main/AndroidManifest.xml:5:9-50
14
- 9-->/Users/ishikabansal/checkout-react-native-sdk/node_modules/cross_platform_sdk_react_native_plugin/android/src/main/AndroidManifest.xml:5:18-48
15
- 10 <package android:name="net.one97.paytm" />
16
- 10-->/Users/ishikabansal/checkout-react-native-sdk/node_modules/cross_platform_sdk_react_native_plugin/android/src/main/AndroidManifest.xml:6:9-50
17
- 10-->/Users/ishikabansal/checkout-react-native-sdk/node_modules/cross_platform_sdk_react_native_plugin/android/src/main/AndroidManifest.xml:6:18-48
18
- 11 </queries>
19
- 12
20
- 13</manifest>
@@ -1,13 +0,0 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
- package="com.reactnativemodule" >
4
-
5
- <uses-sdk android:minSdkVersion="21" />
6
-
7
- <queries>
8
- <package android:name="com.google.android.apps.nbu.paisa.user" />
9
- <package android:name="com.phonepe.app" />
10
- <package android:name="net.one97.paytm" />
11
- </queries>
12
-
13
- </manifest>