boxpay-checkout-reactnative-sdk 1.0.0-beta31 → 1.0.0-beta33

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 (70) hide show
  1. package/assets/images/ic_qr.png +0 -0
  2. package/lib/assets/assets/images/ic_qr.png +0 -0
  3. package/lib/assets/images/ic_qr.png +0 -0
  4. package/lib/module/components/sessionExpire.js +0 -3
  5. package/lib/module/components/sessionExpire.js.map +1 -1
  6. package/lib/module/interface.js.map +1 -1
  7. package/lib/module/postRequest/callUIAnalytics.js +3 -14
  8. package/lib/module/postRequest/callUIAnalytics.js.map +1 -1
  9. package/lib/module/postRequest/cardPostRequest.js +5 -42
  10. package/lib/module/postRequest/cardPostRequest.js.map +1 -1
  11. package/lib/module/postRequest/emiPostRequest.js +5 -42
  12. package/lib/module/postRequest/emiPostRequest.js.map +1 -1
  13. package/lib/module/postRequest/methodsPostRequest.js +5 -42
  14. package/lib/module/postRequest/methodsPostRequest.js.map +1 -1
  15. package/lib/module/postRequest/upiPostRequest.js +5 -42
  16. package/lib/module/postRequest/upiPostRequest.js.map +1 -1
  17. package/lib/module/screens/mainScreen.js +70 -1
  18. package/lib/module/screens/mainScreen.js.map +1 -1
  19. package/lib/module/screens/upiScreen.js +154 -43
  20. package/lib/module/screens/upiScreen.js.map +1 -1
  21. package/lib/module/scripts/checkPeerDeps.js +27 -0
  22. package/lib/module/scripts/checkPeerDeps.js.map +1 -0
  23. package/lib/module/sharedContext/checkoutDetailsHandler.js +1 -0
  24. package/lib/module/sharedContext/checkoutDetailsHandler.js.map +1 -1
  25. package/lib/module/sharedContext/handlePaymentResponseHandler.js +6 -1
  26. package/lib/module/sharedContext/handlePaymentResponseHandler.js.map +1 -1
  27. package/lib/module/styles/screens/savedAddressScreenStyles.js +2 -2
  28. package/lib/module/styles/screens/upiScreenStyles.js +64 -0
  29. package/lib/module/styles/screens/upiScreenStyles.js.map +1 -1
  30. package/lib/module/utils/listAndObjectUtils.js +56 -6
  31. package/lib/module/utils/listAndObjectUtils.js.map +1 -1
  32. package/lib/module/utils/stringUtils.js +5 -0
  33. package/lib/module/utils/stringUtils.js.map +1 -1
  34. package/lib/typescript/src/components/sessionExpire.d.ts.map +1 -1
  35. package/lib/typescript/src/interface.d.ts +7 -1
  36. package/lib/typescript/src/interface.d.ts.map +1 -1
  37. package/lib/typescript/src/postRequest/callUIAnalytics.d.ts.map +1 -1
  38. package/lib/typescript/src/postRequest/cardPostRequest.d.ts.map +1 -1
  39. package/lib/typescript/src/postRequest/emiPostRequest.d.ts.map +1 -1
  40. package/lib/typescript/src/postRequest/methodsPostRequest.d.ts.map +1 -1
  41. package/lib/typescript/src/postRequest/upiPostRequest.d.ts.map +1 -1
  42. package/lib/typescript/src/screens/mainScreen.d.ts.map +1 -1
  43. package/lib/typescript/src/screens/upiScreen.d.ts +5 -0
  44. package/lib/typescript/src/screens/upiScreen.d.ts.map +1 -1
  45. package/lib/typescript/src/sharedContext/checkoutDetailsHandler.d.ts.map +1 -1
  46. package/lib/typescript/src/sharedContext/handlePaymentResponseHandler.d.ts +1 -2
  47. package/lib/typescript/src/sharedContext/handlePaymentResponseHandler.d.ts.map +1 -1
  48. package/lib/typescript/src/styles/screens/upiScreenStyles.d.ts +64 -0
  49. package/lib/typescript/src/styles/screens/upiScreenStyles.d.ts.map +1 -1
  50. package/lib/typescript/src/utils/listAndObjectUtils.d.ts +34 -2
  51. package/lib/typescript/src/utils/listAndObjectUtils.d.ts.map +1 -1
  52. package/lib/typescript/src/utils/stringUtils.d.ts +1 -0
  53. package/lib/typescript/src/utils/stringUtils.d.ts.map +1 -1
  54. package/package.json +4 -3
  55. package/src/components/sessionExpire.tsx +0 -3
  56. package/src/interface.ts +10 -2
  57. package/src/postRequest/callUIAnalytics.ts +3 -20
  58. package/src/postRequest/cardPostRequest.ts +6 -51
  59. package/src/postRequest/emiPostRequest.ts +6 -52
  60. package/src/postRequest/methodsPostRequest.tsx +6 -52
  61. package/src/postRequest/upiPostRequest.tsx +6 -52
  62. package/src/screens/mainScreen.tsx +72 -0
  63. package/src/screens/upiScreen.tsx +168 -40
  64. package/src/scripts/checkPeerDeps.js +23 -0
  65. package/src/sharedContext/checkoutDetailsHandler.ts +1 -0
  66. package/src/sharedContext/handlePaymentResponseHandler.ts +8 -1
  67. package/src/styles/screens/savedAddressScreenStyles.ts +2 -2
  68. package/src/styles/screens/upiScreenStyles.ts +64 -0
  69. package/src/utils/listAndObjectUtils.ts +58 -7
  70. package/src/utils/stringUtils.ts +7 -1
@@ -3,8 +3,6 @@ import React from 'react';
3
3
  import Modal from 'react-native-modal';
4
4
  import LottieView from 'lottie-react-native';
5
5
  import { checkoutDetailsHandler } from '../sharedContext/checkoutDetailsHandler';
6
- import callUIAnalytics from '../postRequest/callUIAnalytics';
7
- import { AnalyticsEvents } from '../interface';
8
6
 
9
7
  interface SessionExpireProps {
10
8
  onClick: () => void;
@@ -46,7 +44,6 @@ const SessionExpire: React.FC<SessionExpireProps> = ({ onClick }) => {
46
44
  { backgroundColor: checkoutDetails.brandColor },
47
45
  ]}
48
46
  onPress={() => {
49
- callUIAnalytics(AnalyticsEvents.PAYMENT_RESULT_SCREEN_DISPLAYED, "Session Expired button clicked", "")
50
47
  onClick()
51
48
  }}
52
49
  >
package/src/interface.ts CHANGED
@@ -40,6 +40,7 @@ export interface CheckoutDetails {
40
40
  isDOBEditable: boolean;
41
41
  isUpiIntentMethodEnabled : boolean,
42
42
  isUpiCollectMethodEnabled : boolean,
43
+ isUpiQRMethodEnabled : boolean,
43
44
  isCardMethodEnabled : boolean,
44
45
  isWalletMethodEnabled : boolean,
45
46
  isNetBankingMethodEnabled : boolean,
@@ -139,6 +140,10 @@ interface CardTokenPayload {
139
140
  };
140
141
  }
141
142
 
143
+ interface UPIQRPayload {
144
+ type : 'upi/qr'
145
+ }
146
+
142
147
  interface UPICollectPayload {
143
148
  type: 'upi/collect';
144
149
  upi?: {
@@ -150,7 +155,8 @@ interface UPICollectPayload {
150
155
  export type InstrumentDetails =
151
156
  | UPIIntentPayload
152
157
  | CardTokenPayload
153
- | UPICollectPayload;
158
+ | UPICollectPayload
159
+ | UPIQRPayload
154
160
 
155
161
  export interface PaymentMethod {
156
162
  id: string;
@@ -235,7 +241,8 @@ interface PaymentActions {
235
241
  method : string,
236
242
  url : string,
237
243
  type : string,
238
- htmlPageString : string
244
+ htmlPageString : string,
245
+ content : string
239
246
  }
240
247
 
241
248
  export interface FetchCardDetails {
@@ -264,6 +271,7 @@ export interface HandlePaymentOptions {
264
271
  onShowSuccessModal: (timestamp: string) => void;
265
272
  onShowSessionExpiredModal: () => void;
266
273
  onNavigateToTimer?: (upiId: string) => void;
274
+ onOpenQr? : (qrImage : string) => void
267
275
  onOpenUpiIntent?: (url: string) => void;
268
276
  setLoading: (loading: boolean) => void;
269
277
  }
@@ -1,7 +1,6 @@
1
- import Constants from 'expo-constants';
2
1
  import { checkoutDetailsHandler } from '../sharedContext/checkoutDetailsHandler';
3
2
  import type { AnalyticsApiResponse } from '../interface';
4
- import { getDeviceDetails } from '../utils/listAndObjectUtils';
3
+ import { getBrowserData, getDeviceDetails } from '../utils/listAndObjectUtils';
5
4
  import { APIStatus } from '../interface';
6
5
  import axios from 'axios';
7
6
  import { getBaseURL } from '../utils/stringUtils';
@@ -13,26 +12,10 @@ const callUIAnalytics = async (
13
12
  ) : Promise<AnalyticsApiResponse> => {
14
13
  const { checkoutDetails } = checkoutDetailsHandler;
15
14
  const deviceDetails = getDeviceDetails()
15
+ const browserData = getBrowserData()
16
16
 
17
17
  const requestBody = {
18
- browserData: {
19
- screenHeight:
20
- Constants.platform?.ios?.screenHeight ||
21
- Constants.platform?.android?.screenHeight ||
22
- 0,
23
- screenWidth:
24
- Constants.platform?.ios?.screenWidth ||
25
- Constants.platform?.android?.screenWidth ||
26
- 0,
27
- acceptHeader: 'application/json',
28
- userAgentHeader: 'Expo App',
29
- browserLanguage: 'en_US',
30
- ipAddress: 'null',
31
- colorDepth: 24,
32
- javaEnabled: true,
33
- timeZoneOffSet: new Date().getTimezoneOffset(),
34
- packageId: Constants.manifest?.id || 'com.boxpay.checkout.sdk',
35
- },
18
+ browserData: browserData,
36
19
  callerToken : checkoutDetails.token,
37
20
  uiEvent : uiEvent,
38
21
  eventAttrs : {
@@ -1,9 +1,7 @@
1
- import Constants from 'expo-constants';
2
1
  import api from '../serviceRequest'
3
- import { userDataHandler } from '../sharedContext/userdataHandler';
4
2
  import { checkoutDetailsHandler } from '../sharedContext/checkoutDetailsHandler';
5
- import type { PaymentExecutedPostResponse, DeliveryAddress } from '../interface';
6
- import { getDeviceDetails } from '../utils/listAndObjectUtils';
3
+ import type { PaymentExecutedPostResponse } from '../interface';
4
+ import { getBrowserData, getDeviceDetails, getShopperDetails } from '../utils/listAndObjectUtils';
7
5
  import { AnalyticsEvents, APIStatus } from '../interface';
8
6
  import callUIAnalytics from './callUIAnalytics';
9
7
 
@@ -15,49 +13,18 @@ const cardPostRequest = async (
15
13
  cardNickName: string,
16
14
  isCheckboxClicked: boolean
17
15
  ) : Promise<PaymentExecutedPostResponse> => {
18
- const { userData } = userDataHandler;
19
16
  const { checkoutDetails } = checkoutDetailsHandler;
20
17
  const deviceDetails = getDeviceDetails()
18
+ const browserData = getBrowserData()
19
+ const shopperData = getShopperDetails()
21
20
 
22
21
  const formatExpiry = (input: string) => {
23
22
  const [month, year] = input.split('/');
24
23
  return `20${year}-${month}`;
25
24
  };
26
- const isDeliveryAddressEmpty = (address: DeliveryAddress): boolean => {
27
- return Object.values(address).every(
28
- (value) => value === null || value === undefined || value === ''
29
- );
30
- };
31
25
 
32
- const deliveryAddress = {
33
- address1: userData.address1,
34
- address2: userData.address2,
35
- city: userData.city,
36
- state: userData.state,
37
- countryCode: userData.country,
38
- postalCode: userData.pincode,
39
- labelType: userData.labelType,
40
- labelName: userData.labelName,
41
- };
42
26
  const requestBody = {
43
- browserData: {
44
- screenHeight:
45
- Constants.platform?.ios?.screenHeight ||
46
- Constants.platform?.android?.screenHeight ||
47
- 0,
48
- screenWidth:
49
- Constants.platform?.ios?.screenWidth ||
50
- Constants.platform?.android?.screenWidth ||
51
- 0,
52
- acceptHeader: 'application/json',
53
- userAgentHeader: 'Expo App',
54
- browserLanguage: 'en_US',
55
- ipAddress: 'null',
56
- colorDepth: 24,
57
- javaEnabled: true,
58
- timeZoneOffSet: new Date().getTimezoneOffset(),
59
- packageId: Constants.manifest?.id || 'com.boxpay.checkout.sdk',
60
- },
27
+ browserData: browserData,
61
28
  instrumentDetails: {
62
29
  type: 'card/plain',
63
30
  card: {
@@ -73,19 +40,7 @@ const cardPostRequest = async (
73
40
  ? { saveInstrument: true }
74
41
  : {}),
75
42
  },
76
- shopper: {
77
- email: userData.email,
78
- firstName: userData.firstName,
79
- gender: null,
80
- lastName: userData.lastName,
81
- phoneNumber: userData.phone,
82
- uniqueReference: userData.uniqueId,
83
- dateOfBirth: userData.dob,
84
- panNumber: userData.pan,
85
- deliveryAddress: isDeliveryAddressEmpty(deliveryAddress)
86
- ? null
87
- : deliveryAddress,
88
- },
43
+ shopper: shopperData,
89
44
  deviceDetails: deviceDetails,
90
45
  };
91
46
  callUIAnalytics(AnalyticsEvents.PAYMENT_CATEGORY_SELECTED,"Card Post Request",``)
@@ -1,8 +1,6 @@
1
- import Constants from 'expo-constants';
2
1
  import api from '../serviceRequest'
3
- import { userDataHandler } from '../sharedContext/userdataHandler';
4
- import type { PaymentExecutedPostResponse, DeliveryAddress } from '../interface';
5
- import { getDeviceDetails } from '../utils/listAndObjectUtils';
2
+ import type { PaymentExecutedPostResponse } from '../interface';
3
+ import { getBrowserData, getDeviceDetails, getShopperDetails } from '../utils/listAndObjectUtils';
6
4
  import { AnalyticsEvents, APIStatus } from '../interface';
7
5
  import callUIAnalytics from './callUIAnalytics';
8
6
 
@@ -27,8 +25,9 @@ const emiPostRequest = async (
27
25
  duration
28
26
  } : EmiPostPayload
29
27
  ) : Promise<PaymentExecutedPostResponse> => {
30
- const { userData } = userDataHandler;
31
28
  const deviceDetails = getDeviceDetails()
29
+ const browserData = getBrowserData()
30
+ const shopperData = getShopperDetails()
32
31
  const formatExpiry = (input: string) => {
33
32
  const [month, year] = input.split('/');
34
33
  return `20${year}-${month}`;
@@ -59,56 +58,11 @@ const emiPostRequest = async (
59
58
  },
60
59
  };
61
60
 
62
- const isDeliveryAddressEmpty = (address: DeliveryAddress): boolean => {
63
- return Object.values(address).every(
64
- (value) => value === null || value === undefined || value === ''
65
- );
66
- };
67
-
68
- const deliveryAddress = {
69
- address1: userData.address1,
70
- address2: userData.address2,
71
- city: userData.city,
72
- state: userData.state,
73
- countryCode: userData.country,
74
- postalCode: userData.pincode,
75
- labelType: userData.labelType,
76
- labelName: userData.labelName,
77
- };
78
61
  const requestBody = {
79
- browserData: {
80
- screenHeight:
81
- Constants.platform?.ios?.screenHeight ||
82
- Constants.platform?.android?.screenHeight ||
83
- 0,
84
- screenWidth:
85
- Constants.platform?.ios?.screenWidth ||
86
- Constants.platform?.android?.screenWidth ||
87
- 0,
88
- acceptHeader: 'application/json',
89
- userAgentHeader: 'Expo App',
90
- browserLanguage: 'en_US',
91
- ipAddress: 'null',
92
- colorDepth: 24,
93
- javaEnabled: true,
94
- timeZoneOffSet: new Date().getTimezoneOffset(),
95
- packageId: Constants.manifest?.id || 'com.boxpay.checkout.sdk',
96
- },
62
+ browserData: browserData,
97
63
  instrumentDetails: instrumentDetails,
98
64
  ...(offerCode?.trim() !== '' && { offers: [offerCode] }),
99
- shopper: {
100
- email: userData.email,
101
- firstName: userData.firstName,
102
- gender: null,
103
- lastName: userData.lastName,
104
- phoneNumber: userData.phone,
105
- uniqueReference: userData.uniqueId,
106
- dateOfBirth: userData.dob,
107
- panNumber: userData.pan,
108
- deliveryAddress: isDeliveryAddressEmpty(deliveryAddress)
109
- ? null
110
- : deliveryAddress,
111
- },
65
+ shopper: shopperData,
112
66
  deviceDetails: deviceDetails,
113
67
  };
114
68
 
@@ -1,9 +1,7 @@
1
- import Constants from 'expo-constants';
2
1
  import { checkoutDetailsHandler } from '../sharedContext/checkoutDetailsHandler';
3
2
  import api from '../serviceRequest'
4
- import { userDataHandler } from '../sharedContext/userdataHandler';
5
- import type { PaymentExecutedPostResponse, DeliveryAddress } from '../interface';
6
- import { getDeviceDetails } from '../utils/listAndObjectUtils';
3
+ import type { PaymentExecutedPostResponse } from '../interface';
4
+ import { getBrowserData, getDeviceDetails, getShopperDetails } from '../utils/listAndObjectUtils';
7
5
  import { AnalyticsEvents, APIStatus } from '../interface';
8
6
  import callUIAnalytics from './callUIAnalytics';
9
7
 
@@ -11,64 +9,20 @@ const methodsPostRequest = async (
11
9
  instrumentDetails: string,
12
10
  paymentMethod: string
13
11
  ) : Promise<PaymentExecutedPostResponse> => {
14
- const { userData } = userDataHandler;
15
12
  const { checkoutDetails } = checkoutDetailsHandler;
16
13
  const deviceDetails = getDeviceDetails()
17
- const isDeliveryAddressEmpty = (address: DeliveryAddress): boolean => {
18
- return Object.values(address).every(
19
- (value) => value === null || value === undefined || value === ''
20
- );
21
- };
22
-
23
- const deliveryAddress = {
24
- address1: userData.address1,
25
- address2: userData.address2,
26
- city: userData.city,
27
- state: userData.state,
28
- countryCode: userData.country,
29
- postalCode: userData.pincode,
30
- labelType: userData.labelType,
31
- labelName: userData.labelName,
32
- };
14
+ const browserData = getBrowserData()
15
+ const shopperData = getShopperDetails()
33
16
 
34
17
  const requestBody = {
35
- browserData: {
36
- screenHeight:
37
- Constants.platform?.ios?.screenHeight ||
38
- Constants.platform?.android?.screenHeight ||
39
- 0,
40
- screenWidth:
41
- Constants.platform?.ios?.screenWidth ||
42
- Constants.platform?.android?.screenWidth ||
43
- 0,
44
- acceptHeader: 'application/json',
45
- userAgentHeader: 'Expo App',
46
- browserLanguage: 'en_US',
47
- ipAddress: 'null',
48
- colorDepth: 24,
49
- javaEnabled: true,
50
- timeZoneOffSet: new Date().getTimezoneOffset(),
51
- packageId: Constants.manifest?.id || 'com.boxpay.checkout.sdk',
52
- },
18
+ browserData: browserData,
53
19
  instrumentDetails: {
54
20
  type: instrumentDetails,
55
21
  [paymentMethod]: {
56
22
  token: checkoutDetails.token,
57
23
  },
58
24
  },
59
- shopper: {
60
- email: userData.email,
61
- firstName: userData.firstName,
62
- gender: null,
63
- lastName: userData.lastName,
64
- phoneNumber: userData.phone,
65
- uniqueReference: userData.uniqueId,
66
- dateOfBirth: userData.dob,
67
- panNumber: userData.pan,
68
- deliveryAddress: isDeliveryAddressEmpty(deliveryAddress)
69
- ? null
70
- : deliveryAddress,
71
- },
25
+ shopper: shopperData,
72
26
  deviceDetails: deviceDetails
73
27
  };
74
28
 
@@ -1,64 +1,18 @@
1
- import Constants from 'expo-constants';
2
1
  import api from '../serviceRequest';
3
- import { userDataHandler } from '../sharedContext/userdataHandler';
4
- import type { DeliveryAddress, InstrumentDetails, PaymentExecutedPostResponse } from '../interface';
5
- import { getDeviceDetails } from '../utils/listAndObjectUtils';
2
+ import type { InstrumentDetails, PaymentExecutedPostResponse } from '../interface';
3
+ import { getBrowserData, getDeviceDetails, getShopperDetails } from '../utils/listAndObjectUtils';
6
4
  import { AnalyticsEvents, APIStatus } from '../interface';
7
5
  import callUIAnalytics from './callUIAnalytics';
8
6
 
9
7
  const upiPostRequest = async (instrumentDetails: InstrumentDetails) : Promise<PaymentExecutedPostResponse> => {
10
- const { userData } = userDataHandler;
11
8
  const deviceDetails = getDeviceDetails()
9
+ const browserData = getBrowserData()
10
+ const shopperData = getShopperDetails()
12
11
 
13
- const isDeliveryAddressEmpty = (address: DeliveryAddress): boolean => {
14
- return Object.values(address).every(
15
- (value) => value === null || value === undefined || value === ''
16
- );
17
- };
18
-
19
- const deliveryAddress = {
20
- address1: userData.address1,
21
- address2: userData.address2,
22
- city: userData.city,
23
- state: userData.state,
24
- countryCode: userData.country,
25
- postalCode: userData.pincode,
26
- labelType: userData.labelType,
27
- labelName: userData.labelName,
28
- };
29
12
  const requestBody = {
30
- browserData: {
31
- screenHeight:
32
- Constants.platform?.ios?.screenHeight ||
33
- Constants.platform?.android?.screenHeight ||
34
- 0,
35
- screenWidth:
36
- Constants.platform?.ios?.screenWidth ||
37
- Constants.platform?.android?.screenWidth ||
38
- 0,
39
- acceptHeader: 'application/json',
40
- userAgentHeader: 'Expo App',
41
- browserLanguage: 'en_US',
42
- ipAddress: 'null',
43
- colorDepth: 24,
44
- javaEnabled: true,
45
- timeZoneOffSet: new Date().getTimezoneOffset(),
46
- packageId: Constants.manifest?.id || 'com.boxpay.checkout.sdk',
47
- },
13
+ browserData: browserData,
48
14
  instrumentDetails,
49
- shopper: {
50
- email: userData.email,
51
- firstName: userData.firstName,
52
- gender: null,
53
- lastName: userData.lastName,
54
- phoneNumber: userData.phone,
55
- uniqueReference: userData.uniqueId,
56
- dateOfBirth: userData.dob,
57
- panNumber: userData.pan,
58
- deliveryAddress: isDeliveryAddressEmpty(deliveryAddress)
59
- ? null
60
- : deliveryAddress,
61
- },
15
+ shopper: shopperData,
62
16
  deviceDetails: deviceDetails
63
17
  };
64
18
 
@@ -80,8 +80,12 @@ const MainScreen = ({route, navigation} : MainScreenProps) => {
80
80
  const [recommendedInstrumentsArray, setRecommendedInstruments] = useState<PaymentClass[]>([]);
81
81
  const [savedCardArray, setSavedCardArray] = useState<PaymentClass[]>([]);
82
82
  const [savedUpiArray, setSavedUpiArray] = useState<PaymentClass[]>([]);
83
+ const [qrImageUrl, setQrImageUrl] = useState<string | null> (null)
84
+ const qrTimerRef = useRef<NodeJS.Timeout | null>(null);
85
+ const [timerValue, setTimerValue] = useState(5 * 60);
83
86
 
84
87
  let isFirstTimeLoadRef = useRef(true);
88
+ let qrIsExpired = useRef(false)
85
89
 
86
90
  const handlePaymentIntent = async (selectedIntent: string) => {
87
91
  setLoadingState(true);
@@ -153,6 +157,38 @@ const MainScreen = ({route, navigation} : MainScreenProps) => {
153
157
  });
154
158
  };
155
159
 
160
+ const handleUpiQRPayment = async() => {
161
+ const requestPayload: InstrumentDetails ={
162
+ type: 'upi/qr',
163
+ }
164
+ setLoadingState(true);
165
+ const response = await upiPostRequest(requestPayload);
166
+ handlePaymentResponse({
167
+ response: response,
168
+ checkoutDetailsErrorMessage: checkoutDetailsHandler.checkoutDetails.errorMessage,
169
+ onSetStatus: setStatus,
170
+ onSetTransactionId: setTransactionId,
171
+ onSetPaymentHtml: setPaymentHtml,
172
+ onSetPaymentUrl: setPaymentUrl,
173
+ onSetFailedMessage: (msg) => (paymentFailedMessage.current = msg),
174
+ onShowFailedModal: () => setFailedModalState(true),
175
+ onShowSuccessModal: (ts) => {
176
+ setSuccessfulTimeStamp(ts);
177
+ setSuccessModalState(true);
178
+ },
179
+ onShowSessionExpiredModal: () => setSessionExppireModalState(true),
180
+ onOpenQr: (id:string)=> {
181
+ setQrImageUrl(id)
182
+ startQRTimer()
183
+ qrIsExpired.current = false
184
+ },
185
+ onOpenUpiIntent : (url) => {
186
+ urlToBase64(url);
187
+ },
188
+ setLoading: setLoadingState
189
+ });
190
+ }
191
+
156
192
  useEffect(() => {
157
193
  if (isFirstTimeLoadRef.current) {
158
194
  isFirstTimeLoadRef.current = false;
@@ -202,6 +238,33 @@ const MainScreen = ({route, navigation} : MainScreenProps) => {
202
238
  }
203
239
  }, [paymentUrl, paymentHtml]);
204
240
 
241
+ const startQRTimer = () => {
242
+ qrTimerRef.current = setInterval(() => {
243
+ setTimerValue((prevTime) => {
244
+ if (prevTime <= 1) {
245
+ clearInterval(qrTimerRef.current!);
246
+ qrIsExpired.current = true
247
+ return 0;
248
+ }
249
+
250
+ // ⏱️ Decrement timer
251
+ const newTime = prevTime - 1;
252
+
253
+ // 🌐 Call API every 4 seconds (or any interval you want)
254
+ if (newTime % 4 === 0) {
255
+ callFetchStatusApi();
256
+ }
257
+
258
+ return newTime;
259
+ });
260
+ }, 1000);
261
+ }
262
+
263
+ const stopQRTimer= () => {
264
+ if(qrTimerRef.current) {
265
+ clearInterval(qrTimerRef.current!);
266
+ }
267
+ }
205
268
  const openUPIIntent = async (url: string) => {
206
269
  try {
207
270
  await Linking.openURL(url); // Open the UPI app
@@ -304,6 +367,7 @@ const MainScreen = ({route, navigation} : MainScreenProps) => {
304
367
  const methodFlags = {
305
368
  isUPIIntentVisible: false,
306
369
  isUPICollectVisible: false,
370
+ isUPIQRVisible : false,
307
371
  isCardsVisible: false,
308
372
  isWalletVisible: false,
309
373
  isNetbankingVisible: false,
@@ -317,6 +381,8 @@ const MainScreen = ({route, navigation} : MainScreenProps) => {
317
381
  methodFlags.isUPIIntentVisible = true;
318
382
  } else if (method.brand === 'UpiCollect') {
319
383
  methodFlags.isUPICollectVisible = true;
384
+ } else if(method.brand === 'UpiQr') {
385
+ methodFlags.isUPIQRVisible = true
320
386
  }
321
387
  } else if (method.type === 'Card') {
322
388
  methodFlags.isCardsVisible = true;
@@ -471,6 +537,7 @@ const MainScreen = ({route, navigation} : MainScreenProps) => {
471
537
  isDOBEditable: isFieldEditable('SHOPPER_DOB'),
472
538
  isUpiIntentMethodEnabled : methodFlags.isUPIIntentVisible,
473
539
  isUpiCollectMethodEnabled : methodFlags.isUPICollectVisible,
540
+ isUpiQRMethodEnabled : methodFlags.isUPIQRVisible,
474
541
  isCardMethodEnabled : methodFlags.isCardsVisible,
475
542
  isWalletMethodEnabled : methodFlags.isWalletVisible,
476
543
  isNetBankingMethodEnabled : methodFlags.isNetbankingVisible,
@@ -666,6 +733,11 @@ const MainScreen = ({route, navigation} : MainScreenProps) => {
666
733
  }
667
734
  savedUpiArray={savedUpiArray}
668
735
  onClickRadio={handleSavedUpiSectionClick}
736
+ qrImage={qrImageUrl}
737
+ handleQRPayment={handleUpiQRPayment}
738
+ qrIsExpired = {qrIsExpired.current}
739
+ timeRemaining={timerValue}
740
+ stopTimer = {stopQRTimer}
669
741
  />
670
742
 
671
743
  {savedCardArray.length != 0 && (