boxpay-checkout-reactnative-sdk 1.0.0-beta03 → 1.0.0-beta04

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.
@@ -1,638 +1,29 @@
1
1
  "use strict";
2
2
 
3
- import { useEffect, useRef, useState } from 'react';
4
- import { View, Text, BackHandler, AppState, Image, ScrollView, StatusBar, Alert } from 'react-native'; // Added ScrollView
5
- import Header from "./components/header.js";
6
- import upiPostRequest from "./postRequest/upiPostRequest.js";
7
- import { decode as atob } from 'base-64';
8
- import { Linking } from 'react-native';
9
- import LottieView from 'lottie-react-native';
10
- import PaymentSuccess from "./components/paymentSuccess.js";
11
- import SessionExpire from "./components/sessionExpire.js";
12
- import PaymentFailed from "./components/paymentFailed.js";
13
- import fetchStatus from "./postRequest/fetchStatus.js";
14
- import UpiScreen from "./screens/upiScreen.js";
15
- import { useNavigation } from "@react-navigation/native";
16
- import { paymentHandler, setPaymentHandler } from "./sharedContext/paymentStatusHandler.js";
17
- import { loadCustomFonts, loadInterCustomFonts } from "./components/fontFamily.js";
18
- import { setUserDataHandler, userDataHandler } from "./sharedContext/userdataHandler.js";
19
- import { APIStatus, AnalyticsEvents } from "./interface.js";
20
- import { checkoutDetailsHandler, setCheckoutDetailsHandler } from "./sharedContext/checkoutDetailsHandler.js";
21
- import WebViewScreen from "./screens/webViewScreen.js";
3
+ import { useEffect } from 'react';
4
+ import { setPaymentHandler } from "./sharedContext/paymentStatusHandler.js";
5
+ import { checkoutDetailsHandler } from "./sharedContext/checkoutDetailsHandler.js";
22
6
  import styles from "./styles/indexStyles.js";
23
- import getSymbolFromCurrency from 'currency-symbol-map';
24
- import OrderDetails from "./components/orderDetails.js";
25
7
  import { SafeAreaView } from 'react-native-safe-area-context';
26
- import PaymentSelectorView from "./components/paymentSelector.js";
27
- import SavedCardComponentView from "./components/savedCardComponent.js";
28
- import ShimmerView from "./components/shimmerView.js";
29
- import AddressComponent from "./components/addressCard.js";
30
- import fetchSessionDetails from "./postRequest/fetchSessionDetails.js";
31
- import MorePaymentMethods from "./components/morePaymentMethods.js";
32
- import { fetchSavedInstrumentsHandler, handleFetchStatusResponseHandler, handlePaymentResponse } from "./sharedContext/handlePaymentResponseHandler.js";
33
- import callUIAnalytics from "./postRequest/callUIAnalytics.js";
34
8
  import CheckoutContainer from "./navigation.js";
35
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
9
+ import { jsx as _jsx } from "react/jsx-runtime";
36
10
  const BoxpayCheckout = ({
37
11
  token,
38
12
  configurationOptions,
39
13
  onPaymentResult,
40
14
  shopperToken = null
41
15
  }) => {
42
- const [status, setStatus] = useState('NOACTION');
43
- const [transactionId, setTransactionId] = useState('');
44
- const env = configurationOptions?.ENABLE_SANDBOX_ENV ? 'test' : 'prod';
45
- const appStateListenerRef = useRef(null);
46
- const [loadingState, setLoadingState] = useState(false);
47
- const [isFirstLoading, setIsFirstLoading] = useState(true);
48
- const [amount, setAmount] = useState('');
49
- const totalItemsRef = useRef(0);
50
- const [address, setAddress] = useState('');
51
- const [failedModalOpen, setFailedModalState] = useState(false);
52
- const [successModalOpen, setSuccessModalState] = useState(false);
53
- const lastOpenendUrl = useRef('');
54
- const paymentFailedMessage = useRef('You may have cancelled the payment or there was a delay in response. Please retry.');
55
- const [sessionExpireModalOpen, setSessionExppireModalState] = useState(false);
56
- const [successfulTimeStamp, setSuccessfulTimeStamp] = useState('');
57
- const navigation = useNavigation(); // Use correct type
58
- const timerRef = useRef(null);
59
- const [showWebView, setShowWebView] = useState(false);
60
- const [paymentUrl, setPaymentUrl] = useState(null);
61
- const [paymentHtml, setPaymentHtml] = useState(null);
62
- const isUpiOpeningRef = useRef(false);
63
- const shippingAmountRef = useRef('');
64
- const taxAmountRef = useRef('');
65
- const subTotalAmountRef = useRef('');
66
- const orderItemsArrayRef = useRef([]);
67
- const [recommendedInstrumentsArray, setRecommendedInstruments] = useState([]);
68
- const [savedCardArray, setSavedCardArray] = useState([]);
69
- const [savedUpiArray, setSavedUpiArray] = useState([]);
70
- let isFirstTimeLoadRef = true;
71
- const handlePaymentIntent = async selectedIntent => {
72
- setLoadingState(true);
73
- const response = await upiPostRequest({
74
- type: 'upi/intent',
75
- ...(selectedIntent && {
76
- upiAppDetails: {
77
- upiApp: selectedIntent
78
- }
79
- }) // Conditionally add upiAppDetails only if upiIntent is present
80
- });
81
- handlePaymentResponse({
82
- response: response,
83
- checkoutDetailsErrorMessage: checkoutDetailsHandler.checkoutDetails.errorMessage,
84
- onSetStatus: setStatus,
85
- onSetTransactionId: setTransactionId,
86
- onSetPaymentHtml: setPaymentHtml,
87
- onSetPaymentUrl: setPaymentUrl,
88
- onSetFailedMessage: msg => paymentFailedMessage.current = msg,
89
- onShowFailedModal: () => setFailedModalState(true),
90
- onShowSuccessModal: ts => {
91
- setSuccessfulTimeStamp(ts);
92
- setSuccessModalState(true);
93
- },
94
- onShowSessionExpiredModal: () => setSessionExppireModalState(true),
95
- onNavigateToTimer: id => navigation.navigate("UpiTimerScreen", {
96
- upiId: id
97
- }),
98
- onOpenUpiIntent: url => {
99
- urlToBase64(url);
100
- },
101
- setLoading: setLoadingState
102
- });
103
- };
104
- const handleUpiCollectPayment = async (upiId, instrumentRef, type) => {
105
- const requestPayload = type === 'Card' ? {
106
- type: 'card/token',
107
- savedCard: {
108
- instrumentRef: instrumentRef
109
- }
110
- } : {
111
- type: 'upi/collect',
112
- upi: instrumentRef ? {
113
- instrumentRef: instrumentRef
114
- } : {
115
- shopperVpa: upiId
116
- }
117
- };
118
- setLoadingState(true);
119
- const response = await upiPostRequest(requestPayload);
120
- handlePaymentResponse({
121
- response: response,
122
- upiId: upiId,
123
- checkoutDetailsErrorMessage: checkoutDetailsHandler.checkoutDetails.errorMessage,
124
- onSetStatus: setStatus,
125
- onSetTransactionId: setTransactionId,
126
- onSetPaymentHtml: setPaymentHtml,
127
- onSetPaymentUrl: setPaymentUrl,
128
- onSetFailedMessage: msg => paymentFailedMessage.current = msg,
129
- onShowFailedModal: () => setFailedModalState(true),
130
- onShowSuccessModal: ts => {
131
- setSuccessfulTimeStamp(ts);
132
- setSuccessModalState(true);
133
- },
134
- onShowSessionExpiredModal: () => setSessionExppireModalState(true),
135
- onNavigateToTimer: id => navigation.navigate("UpiTimerScreen", {
136
- upiId: id
137
- }),
138
- onOpenUpiIntent: url => {
139
- urlToBase64(url);
140
- },
141
- setLoading: setLoadingState
142
- });
143
- };
144
- useEffect(() => {
145
- if (isFirstTimeLoadRef) {
146
- isFirstTimeLoadRef = false;
147
- return;
148
- }
149
- const refreshData = () => {
150
- const address1Ref = userDataHandler.userData.address1;
151
- const address2Ref = userDataHandler.userData.address2;
152
- const cityRef = userDataHandler.userData.city;
153
- const stateRef = userDataHandler.userData.state;
154
- const postalCodeRef = userDataHandler.userData.pincode;
155
- if (address2Ref == null || address2Ref == '') {
156
- setAddress(`${address1Ref}, ${cityRef}, ${stateRef}, ${postalCodeRef}`);
157
- } else {
158
- setAddress(`${address1Ref}, ${address2Ref}, ${cityRef}, ${stateRef}, ${postalCodeRef}`);
159
- }
160
- };
161
- refreshData();
162
- });
163
- const urlToBase64 = base64String => {
164
- try {
165
- const decodedString = atob(base64String);
166
- lastOpenendUrl.current = decodedString;
167
- openUPIIntent(decodedString);
168
- } catch (error) {
169
- setFailedModalState(true);
170
- callUIAnalytics(AnalyticsEvents.FAILED_TO_LAUNCH_UPI_INTENT, "Index Screen UrlToBase64 failed", `${error}`);
171
- setLoadingState(false);
172
- }
173
- };
174
- const getRecommendedInstruments = async () => {
175
- fetchSavedInstrumentsHandler({
176
- setRecommendedList: setRecommendedInstruments,
177
- setUpiInstrumentList: setSavedUpiArray,
178
- setCardInstrumentList: setSavedCardArray
179
- });
180
- setIsFirstLoading(false);
181
- };
182
- useEffect(() => {
183
- if (paymentUrl || paymentHtml) {
184
- setShowWebView(true);
185
- }
186
- }, [paymentUrl, paymentHtml]);
187
- const openUPIIntent = async url => {
188
- try {
189
- await Linking.openURL(url); // Open the UPI app
190
- appStateListenerRef.current = AppState.addEventListener('change', handleAppStateChange);
191
- isUpiOpeningRef.current = true;
192
- } catch (error) {
193
- isUpiOpeningRef.current = false;
194
- callUIAnalytics(AnalyticsEvents.FAILED_TO_LAUNCH_UPI_INTENT, "Index Screen open UPI Intent failed", `${error}`);
195
- setFailedModalState(true);
196
- setLoadingState(false);
197
- }
198
- };
199
- const handleAppStateChange = () => {
200
- if (AppState.currentState === 'active' && isUpiOpeningRef.current) {
201
- callFetchStatusApi();
202
- }
203
- };
204
- const stopExpireTimerCountDown = () => {
205
- if (timerRef.current) {
206
- clearInterval(timerRef.current);
207
- }
208
- };
209
- const callFetchStatusApi = async () => {
210
- const response = await fetchStatus();
211
- handleFetchStatusResponseHandler({
212
- response: response,
213
- checkoutDetailsErrorMessage: checkoutDetailsHandler.checkoutDetails.errorMessage,
214
- onSetStatus: setStatus,
215
- onSetTransactionId: setTransactionId,
216
- onSetFailedMessage: msg => paymentFailedMessage.current = msg,
217
- onShowFailedModal: () => setFailedModalState(true),
218
- onShowSuccessModal: ts => {
219
- setSuccessfulTimeStamp(ts);
220
- setSuccessModalState(true);
221
- },
222
- onShowSessionExpiredModal: () => setSessionExppireModalState(true),
223
- setLoading: setLoadingState
224
- });
225
- appStateListenerRef.current?.remove();
226
- isUpiOpeningRef.current = false;
227
- };
228
- const onExitCheckout = () => {
229
- if (!loadingState) {
230
- stopExpireTimerCountDown();
231
- const mockPaymentResult = {
232
- status: status,
233
- transactionId: transactionId
234
- };
235
- paymentHandler.onPaymentResult(mockPaymentResult);
236
- return true;
237
- }
238
- return false;
239
- };
240
16
  useEffect(() => {
241
- const backHandler = BackHandler.addEventListener('hardwareBackPress', () => {
242
- if (showWebView) {
243
- setShowWebView(false);
244
- paymentFailedMessage.current = checkoutDetailsHandler.checkoutDetails.errorMessage;
245
- setStatus('Failed');
246
- setFailedModalState(true);
247
- setLoadingState(false);
248
- return true;
249
- } else if (loadingState) {
250
- return true;
251
- }
252
- return onExitCheckout(); // Allow back navigation if not loading
17
+ checkoutDetailsHandler.checkoutDetails.token = token;
18
+ checkoutDetailsHandler.checkoutDetails.shopperToken = shopperToken;
19
+ checkoutDetailsHandler.checkoutDetails.isSuccessScreenVisible = configurationOptions?.SHOW_BOXPAY_SUCCESS_SCREEN ? true : false;
20
+ setPaymentHandler({
21
+ onPaymentResult: onPaymentResult
253
22
  });
254
- return () => backHandler.remove();
255
23
  });
256
- useEffect(() => {
257
- async function loadFonts() {
258
- await loadCustomFonts();
259
- await loadInterCustomFonts();
260
- }
261
- loadFonts();
262
- async function loadSession() {
263
- if (token != "") {
264
- checkoutDetailsHandler.checkoutDetails.env = env;
265
- checkoutDetailsHandler.checkoutDetails.token = token;
266
- const response = await fetchSessionDetails();
267
- try {
268
- switch (response.apiStatus) {
269
- case APIStatus.Success:
270
- {
271
- const paymentMethods = response.data.configs.paymentMethods;
272
- const enabledFields = response.data.configs.enabledFields;
273
- const paymentDetails = response.data.paymentDetails;
274
- const methodFlags = {
275
- isUPIIntentVisible: false,
276
- isUPICollectVisible: false,
277
- isCardsVisible: false,
278
- isWalletVisible: false,
279
- isNetbankingVisible: false,
280
- isEMIVisible: false,
281
- isBNPLVisible: false
282
- };
283
- paymentMethods.forEach(method => {
284
- if (method.type === 'Upi') {
285
- if (method.brand === 'UpiIntent') {
286
- methodFlags.isUPIIntentVisible = true;
287
- } else if (method.brand === 'UpiCollect') {
288
- methodFlags.isUPICollectVisible = true;
289
- }
290
- } else if (method.type === 'Card') {
291
- methodFlags.isCardsVisible = true;
292
- } else if (method.type === 'Wallet') {
293
- methodFlags.isWalletVisible = true;
294
- } else if (method.type === 'NetBanking') {
295
- methodFlags.isNetbankingVisible = true;
296
- } else if (method.type === 'Emi') {
297
- methodFlags.isEMIVisible = true;
298
- } else if (method.type === 'BuyNowPayLater') {
299
- methodFlags.isBNPLVisible = true;
300
- }
301
- });
302
- setAmount(paymentDetails.money.amountLocaleFull);
303
- const currencyCode = paymentDetails?.money?.currencyCode;
304
- const symbol = currencyCode ? getSymbolFromCurrency(currencyCode) ?? '₹' : '₹';
305
- if (paymentDetails.order != null && paymentDetails.order.items != null) {
306
- const total = paymentDetails.order.items.reduce((sum, item) => sum + (item.quantity || 1), 0);
307
- totalItemsRef.current = total;
308
- shippingAmountRef.current = paymentDetails.order.shippingAmountLocaleFull != null ? paymentDetails.order.shippingAmountLocaleFull : '';
309
- taxAmountRef.current = paymentDetails.order.taxAmountLocaleFull != null ? paymentDetails.order.taxAmountLocaleFull : '';
310
- subTotalAmountRef.current = paymentDetails.order.originalAmountLocaleFull != null ? paymentDetails.order.originalAmountLocaleFull : '';
311
- const formattedItemsArray = paymentDetails.order.items.map(item => ({
312
- imageUrl: item.imageUrl,
313
- imageTitle: item.itemName,
314
- imageOty: item.quantity,
315
- imageAmount: item.amountWithoutTaxLocaleFull
316
- }));
317
- orderItemsArrayRef.current = formattedItemsArray;
318
- }
319
- const emailRef = paymentDetails.shopper.email;
320
- const firstNameRef = paymentDetails.shopper.firstName;
321
- const lastNameRef = paymentDetails.shopper.lastName;
322
- const phoneRef = paymentDetails.shopper.phoneNumber;
323
- const uniqueIdRef = paymentDetails.shopper.uniqueReference;
324
- const dobRef = paymentDetails.shopper.dateOfBirth;
325
- const panRef = paymentDetails.shopper.panNumber;
326
- startCountdown(response.data.sessionExpiryTimestamp);
327
- let labelTypeRef = null;
328
- let address1Ref = null;
329
- let labelNameRef = null;
330
- let address2Ref = null;
331
- let cityRef = null;
332
- let stateRef = null;
333
- let postalCodeRef = null;
334
- let countryCodeRef = null;
335
- if (paymentDetails.shopper.deliveryAddress != null) {
336
- const deliveryObject = paymentDetails.shopper.deliveryAddress;
337
- labelTypeRef = deliveryObject.labelType;
338
- labelNameRef = deliveryObject.labelName;
339
- address1Ref = deliveryObject.address1;
340
- address2Ref = deliveryObject.address2;
341
- cityRef = deliveryObject.city;
342
- stateRef = deliveryObject.state;
343
- postalCodeRef = deliveryObject.postalCode;
344
- countryCodeRef = deliveryObject.countryCode;
345
- if (address2Ref == null || address2Ref == '') {
346
- setAddress(`${address1Ref}, ${cityRef}, ${stateRef}, ${postalCodeRef}`);
347
- } else {
348
- setAddress(`${address1Ref}, ${address2Ref}, ${cityRef}, ${stateRef}, ${postalCodeRef}`);
349
- }
350
- }
351
- if (['APPROVED', 'SUCCESS', 'PAID'].includes(response.data.status)) {
352
- setSuccessfulTimeStamp(response.data.lastPaidAtTimestamp);
353
- setTransactionId(response.data.lastTransactionId);
354
- setStatus(response.data.status);
355
- setSuccessModalState(true);
356
- } else if (['EXPIRED'].includes(response.data.status)) {
357
- setSessionExppireModalState(true);
358
- }
359
- setUserDataHandler({
360
- userData: {
361
- email: emailRef,
362
- firstName: firstNameRef,
363
- lastName: lastNameRef,
364
- phone: phoneRef,
365
- uniqueId: uniqueIdRef,
366
- dob: dobRef,
367
- pan: panRef,
368
- address1: address1Ref,
369
- address2: address2Ref,
370
- city: cityRef,
371
- state: stateRef,
372
- pincode: postalCodeRef,
373
- country: countryCodeRef,
374
- labelType: labelTypeRef,
375
- labelName: labelNameRef
376
- }
377
- });
378
- const isFieldEnabled = fieldName => {
379
- return enabledFields.some(field => field.field === fieldName);
380
- };
381
- const isFieldEditable = fieldName => {
382
- const field = enabledFields.find(field => field.field === fieldName);
383
- return field?.editable === true;
384
- };
385
- setCheckoutDetailsHandler({
386
- checkoutDetails: {
387
- currencySymbol: symbol,
388
- amount: paymentDetails.money.amountLocaleFull,
389
- token: token,
390
- brandColor: response.data.merchantDetails.checkoutTheme.primaryButtonColor,
391
- env: env,
392
- itemsLength: totalItemsRef.current,
393
- errorMessage: 'You may have cancelled the payment or there was a delay in response. Please retry.',
394
- shopperToken: shopperToken,
395
- isSuccessScreenVisible: configurationOptions?.SHOW_BOXPAY_SUCCESS_SCREEN ? true : false,
396
- isShippingAddressEnabled: isFieldEnabled('SHIPPING_ADDRESS'),
397
- isShippingAddressEditable: isFieldEditable('SHIPPING_ADDRESS'),
398
- isFullNameEnabled: isFieldEnabled('SHOPPER_NAME'),
399
- isFullNameEditable: isFieldEditable('SHOPPER_NAME'),
400
- isEmailEnabled: isFieldEnabled('SHOPPER_EMAIL'),
401
- isEmailEditable: isFieldEditable('SHOPPER_EMAIL'),
402
- isPhoneEnabled: isFieldEnabled('SHOPPER_PHONE'),
403
- isPhoneEditable: isFieldEditable('SHOPPER_PHONE'),
404
- isPanEnabled: isFieldEnabled('SHOPPER_PAN'),
405
- isPanEditable: isFieldEditable('SHOPPER_PAN'),
406
- isDOBEnabled: isFieldEnabled('SHOPPER_DOB'),
407
- isDOBEditable: isFieldEditable('SHOPPER_DOB'),
408
- isUpiIntentMethodEnabled: methodFlags.isUPIIntentVisible,
409
- isUpiCollectMethodEnabled: methodFlags.isUPICollectVisible,
410
- isCardMethodEnabled: methodFlags.isCardsVisible,
411
- isWalletMethodEnabled: methodFlags.isWalletVisible,
412
- isNetBankingMethodEnabled: methodFlags.isNetbankingVisible,
413
- isEmiMethodEnabled: methodFlags.isEMIVisible,
414
- isBnplMethodEnabled: methodFlags.isBNPLVisible
415
- }
416
- });
417
- setPaymentHandler({
418
- onPaymentResult: onPaymentResult
419
- });
420
- callUIAnalytics(AnalyticsEvents.CHECKOUT_LOADED, "Index Screen Session Loaded", "");
421
- break;
422
- }
423
- case APIStatus.Failed:
424
- {
425
- Alert.alert('Error', response.data.status.reason);
426
- break;
427
- }
428
- default:
429
- {
430
- break;
431
- }
432
- }
433
- } catch (error) {
434
- Alert.alert('Error', `${error}`);
435
- }
436
- } else {
437
- Alert.alert('Error', `Token is empty`);
438
- }
439
- }
440
- loadSession();
441
- if (shopperToken != null && shopperToken != "") {
442
- checkoutDetailsHandler.checkoutDetails.shopperToken = shopperToken;
443
- getRecommendedInstruments();
444
- }
445
- }, [token]);
446
- const handleRecommendedSectionClick = instrumentValue => {
447
- const updatedList = recommendedInstrumentsArray.map(item => ({
448
- ...item,
449
- isSelected: item.id === instrumentValue
450
- }));
451
- setRecommendedInstruments(updatedList);
452
- setDefaultSavedUpiList();
453
- setDefaultSavedCardsList();
454
- };
455
- const handleSavedUpiSectionClick = instrumentValue => {
456
- const updatedList = savedUpiArray.map(item => ({
457
- ...item,
458
- isSelected: item.id === instrumentValue
459
- }));
460
- setSavedUpiArray(updatedList);
461
- setDefaultRecommendedList();
462
- setDefaultSavedCardsList();
463
- };
464
- const handleSavedCardSectionClick = instrumentValue => {
465
- const updatedList = savedCardArray.map(item => ({
466
- ...item,
467
- isSelected: item.id === instrumentValue
468
- }));
469
- setSavedCardArray(updatedList);
470
- setDefaultRecommendedList();
471
- setDefaultSavedUpiList();
472
- };
473
- const setDefaultRecommendedList = () => {
474
- const updatedList = recommendedInstrumentsArray.map(item => ({
475
- ...item,
476
- isSelected: false
477
- }));
478
- setRecommendedInstruments(updatedList);
479
- };
480
- const setDefaultSavedCardsList = () => {
481
- const updatedList = savedCardArray.map(item => ({
482
- ...item,
483
- isSelected: false
484
- }));
485
- setSavedCardArray(updatedList);
486
- };
487
- const setDefaultSavedUpiList = () => {
488
- const updatedList = savedUpiArray.map(item => ({
489
- ...item,
490
- isSelected: false
491
- }));
492
- setSavedUpiArray(updatedList);
493
- };
494
- function startCountdown(sessionExpiryTimestamp) {
495
- if (sessionExpiryTimestamp === '') {
496
- return;
497
- }
498
- const expiryTime = new Date(sessionExpiryTimestamp);
499
- const expiryTimeIST = new Date(expiryTime.getTime() + 5.5 * 60 * 60 * 1000);
500
- timerRef.current = setInterval(() => {
501
- const currentTimeIST = new Date(new Date().getTime() + 5.5 * 60 * 60 * 1000);
502
- const timeDiff = expiryTimeIST.getTime() - currentTimeIST.getTime();
503
- if (timeDiff <= 0) {
504
- if (timerRef.current) {
505
- clearInterval(timerRef.current);
506
- }
507
- setStatus('EXPIRED');
508
- setSessionExppireModalState(true);
509
- }
510
- // const hours = Math.floor((timeDiff / (1000 * 60 * 60)) % 24);
511
- // const minutes = Math.floor((timeDiff / (1000 * 60)) % 60);
512
- // const seconds = Math.floor((timeDiff / 1000) % 60);
513
-
514
- // console.log(`${hours}hr ${minutes}min ${seconds}sec`)
515
- }, 1000);
516
- }
517
- return /*#__PURE__*/_jsxs(SafeAreaView, {
24
+ return /*#__PURE__*/_jsx(SafeAreaView, {
518
25
  style: styles.screenView,
519
- children: [/*#__PURE__*/_jsx(StatusBar, {
520
- barStyle: "dark-content"
521
- }), isFirstLoading ? /*#__PURE__*/_jsx(ShimmerView, {}) : loadingState ? /*#__PURE__*/_jsxs(View, {
522
- style: styles.loadingContainer,
523
- children: [/*#__PURE__*/_jsx(LottieView, {
524
- source: require('../assets/animations/boxpayLogo.json'),
525
- autoPlay: true,
526
- loop: true,
527
- style: styles.lottieStyle
528
- }), /*#__PURE__*/_jsx(Text, {
529
- children: "Loading..."
530
- })]
531
- }) : /*#__PURE__*/_jsx(View, {
532
- style: styles.screenView,
533
- children: /*#__PURE__*/_jsx(ScrollView, {
534
- contentContainerStyle: {
535
- flexGrow: 1
536
- },
537
- keyboardShouldPersistTaps: "handled",
538
- children: /*#__PURE__*/_jsxs(View, {
539
- style: {
540
- flex: 1
541
- },
542
- children: [/*#__PURE__*/_jsx(Header, {
543
- onBackPress: onExitCheckout,
544
- showDesc: true,
545
- showSecure: true,
546
- text: "Payment Details"
547
- }), /*#__PURE__*/_jsx(AddressComponent, {
548
- address: address,
549
- navigateToAddressScreen: () => navigation.navigate("AddressScreen", {})
550
- }), recommendedInstrumentsArray.length > 0 && /*#__PURE__*/_jsxs(_Fragment, {
551
- children: [/*#__PURE__*/_jsx(View, {
552
- style: styles.container,
553
- children: /*#__PURE__*/_jsx(Text, {
554
- style: styles.headingText,
555
- children: "Recommended"
556
- })
557
- }), /*#__PURE__*/_jsx(View, {
558
- style: styles.paymentContainer,
559
- children: /*#__PURE__*/_jsx(PaymentSelectorView, {
560
- providerList: recommendedInstrumentsArray,
561
- onProceedForward: (displayValue, instrumentValue, type) => handleUpiCollectPayment(displayValue, instrumentValue, type),
562
- errorImage: require('../assets/images/ic_upi.png'),
563
- isLastUsed: true,
564
- onClickRadio: selectedInstrumentRef => {
565
- handleRecommendedSectionClick(selectedInstrumentRef);
566
- }
567
- })
568
- })]
569
- }), /*#__PURE__*/_jsx(UpiScreen, {
570
- handleUpiPayment: selectedIntent => handlePaymentIntent(selectedIntent),
571
- handleCollectPayment: (displayValue, instrumentValue, type) => handleUpiCollectPayment(displayValue, instrumentValue, type),
572
- savedUpiArray: savedUpiArray,
573
- onClickRadio: handleSavedUpiSectionClick
574
- }), savedCardArray.length != 0 && /*#__PURE__*/_jsxs(View, {
575
- children: [/*#__PURE__*/_jsx(Text, {
576
- style: styles.headingText,
577
- children: "Credit & Debit Cards"
578
- }), /*#__PURE__*/_jsx(View, {
579
- style: styles.paymentContainer,
580
- children: /*#__PURE__*/_jsx(SavedCardComponentView, {
581
- savedCards: savedCardArray,
582
- onProceedForward: instrumentValue => {
583
- handleUpiCollectPayment('', instrumentValue, 'Card');
584
- },
585
- errorImage: require('../assets/images/ic_card.png'),
586
- onClickAddCard: () => navigation.navigate("CardScreen", {}),
587
- onClickRadio: selectedInstrumentRef => handleSavedCardSectionClick(selectedInstrumentRef)
588
- })
589
- })]
590
- }), /*#__PURE__*/_jsx(MorePaymentMethods, {
591
- savedCards: savedCardArray
592
- }), /*#__PURE__*/_jsxs(View, {
593
- children: [/*#__PURE__*/_jsx(Text, {
594
- style: styles.headingText,
595
- children: "Order Summary"
596
- }), /*#__PURE__*/_jsx(OrderDetails, {
597
- subTotalAmount: subTotalAmountRef.current,
598
- shippingAmount: shippingAmountRef.current,
599
- totalAmount: amount,
600
- itemsArray: orderItemsArrayRef.current,
601
- taxAmount: taxAmountRef.current
602
- })]
603
- }), /*#__PURE__*/_jsxs(View, {
604
- style: styles.footerContainer,
605
- children: [/*#__PURE__*/_jsx(Text, {
606
- style: styles.footerText,
607
- children: "Secured by"
608
- }), /*#__PURE__*/_jsx(Image, {
609
- source: require('../assets/images/splash-icon.png'),
610
- style: styles.footerImage
611
- })]
612
- })]
613
- })
614
- })
615
- }), failedModalOpen && /*#__PURE__*/_jsx(PaymentFailed, {
616
- onClick: () => setFailedModalState(false),
617
- errorMessage: paymentFailedMessage.current
618
- }), successModalOpen && /*#__PURE__*/_jsx(PaymentSuccess, {
619
- onClick: onExitCheckout,
620
- transactionId: transactionId,
621
- method: "UPI",
622
- localDateTime: successfulTimeStamp
623
- }), sessionExpireModalOpen && /*#__PURE__*/_jsx(SessionExpire, {
624
- onClick: onExitCheckout
625
- }), showWebView && /*#__PURE__*/_jsx(View, {
626
- style: styles.webViewScreenStyle,
627
- children: /*#__PURE__*/_jsx(WebViewScreen, {
628
- url: paymentUrl,
629
- html: paymentHtml,
630
- onBackPress: () => {
631
- callFetchStatusApi();
632
- setShowWebView(false);
633
- }
634
- })
635
- }), /*#__PURE__*/_jsx(CheckoutContainer, {})]
26
+ children: /*#__PURE__*/_jsx(CheckoutContainer, {})
636
27
  });
637
28
  };
638
29
  export default BoxpayCheckout;