boxpay-checkout-reactnative-sdk 1.0.12 → 1.0.13-beta2

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 (37) hide show
  1. package/lib/module/components/checkboxContainer.js +12 -2
  2. package/lib/module/components/checkboxContainer.js.map +1 -1
  3. package/lib/module/components/savedCardComponent.js +1 -1
  4. package/lib/module/components/savedCardComponent.js.map +1 -1
  5. package/lib/module/interface.js +7 -1
  6. package/lib/module/interface.js.map +1 -1
  7. package/lib/module/postRequest/cardPostRequest.js +1 -1
  8. package/lib/module/postRequest/cardPostRequest.js.map +1 -1
  9. package/lib/module/postRequest/upiPostRequest.js +1 -1
  10. package/lib/module/postRequest/upiPostRequest.js.map +1 -1
  11. package/lib/module/screens/cardScreen.js +3 -3
  12. package/lib/module/screens/cardScreen.js.map +1 -1
  13. package/lib/module/screens/mainScreen.js +8 -3
  14. package/lib/module/screens/mainScreen.js.map +1 -1
  15. package/lib/module/sdk-version.json +1 -1
  16. package/lib/module/sharedContext/checkoutDetailsHandler.js +4 -2
  17. package/lib/module/sharedContext/checkoutDetailsHandler.js.map +1 -1
  18. package/lib/module/utility.js +5 -0
  19. package/lib/module/utility.js.map +1 -1
  20. package/lib/typescript/src/components/checkboxContainer.d.ts.map +1 -1
  21. package/lib/typescript/src/interface.d.ts +16 -3
  22. package/lib/typescript/src/interface.d.ts.map +1 -1
  23. package/lib/typescript/src/screens/mainScreen.d.ts.map +1 -1
  24. package/lib/typescript/src/sharedContext/checkoutDetailsHandler.d.ts.map +1 -1
  25. package/lib/typescript/src/utility.d.ts +5 -0
  26. package/lib/typescript/src/utility.d.ts.map +1 -1
  27. package/package.json +3 -3
  28. package/src/components/checkboxContainer.tsx +10 -1
  29. package/src/components/savedCardComponent.tsx +1 -1
  30. package/src/interface.ts +18 -3
  31. package/src/postRequest/cardPostRequest.ts +1 -1
  32. package/src/postRequest/upiPostRequest.tsx +1 -1
  33. package/src/screens/cardScreen.tsx +3 -3
  34. package/src/screens/mainScreen.tsx +6 -3
  35. package/src/sdk-version.json +1 -1
  36. package/src/sharedContext/checkoutDetailsHandler.ts +4 -2
  37. package/src/utility.ts +12 -1
@@ -38,7 +38,7 @@ const cardPostRequest = async (
38
38
  },
39
39
  shopper: shopperData,
40
40
  ...(checkoutDetails.isSubscriptionCheckout
41
- ? { oneTimePayment: checkoutDetails.isSICheckboxVisible && !isSICheckBoxClicked }
41
+ ? { oneTimePayment: !isSICheckBoxClicked }
42
42
  : {}),
43
43
  deviceDetails: deviceDetails,
44
44
  };
@@ -15,7 +15,7 @@ const upiPostRequest = async (instrumentDetails: InstrumentDetails, isSICheckBox
15
15
  browserData: browserData,
16
16
  instrumentDetails,
17
17
  ...((checkoutDetails.isSubscriptionCheckout && instrumentDetails.type === 'card/token')
18
- ? { oneTimePayment: checkoutDetails.isSICheckboxVisible && !isSICheckBoxClicked }
18
+ ? { oneTimePayment: !isSICheckBoxClicked }
19
19
  : {}),
20
20
  shopper: shopperData,
21
21
  deviceDetails: deviceDetails
@@ -117,7 +117,7 @@ const CardScreen = ({ route, navigation }: Props) => {
117
117
  const [isSavedCardCheckBoxClicked, setIsSavedCardCheckBoxClicked] =
118
118
  useState(false);
119
119
 
120
- const [isSICheckBoxClicked, setIsSICheckBoxClicked] = useState(false)
120
+ const [isSICheckBoxClicked, setIsSICheckBoxClicked] = useState(checkoutDetails.isSICheckboxChecked)
121
121
  const [paymentUrl, setPaymentUrl] = useState<string | null>(null);
122
122
  const [paymentHtml, setPaymentHtml] = useState<string | null>(null);
123
123
  const [showWebView, setShowWebView] = useState(false);
@@ -237,7 +237,7 @@ const CardScreen = ({ route, navigation }: Props) => {
237
237
 
238
238
  const isSubscriptionDetailsVisible =
239
239
  checkoutDetails.isSubscriptionCheckout &&
240
- (isSICheckBoxClicked || !checkoutDetails.isSICheckboxVisible);
240
+ (isSICheckBoxClicked);
241
241
 
242
242
  const isValidCardNumberByLuhn = (stringInputCardNumber: string): boolean => {
243
243
  const minCardLength = 13;
@@ -995,7 +995,7 @@ const CardScreen = ({ route, navigation }: Props) => {
995
995
  </>
996
996
  )}
997
997
 
998
- {(checkoutDetails.isSICheckboxVisible && checkoutDetails.isSubscriptionCheckout) && (
998
+ {((checkoutDetails.isSICheckboxChecked || checkoutDetails.isSICheckboxEnabled) && checkoutDetails.isSubscriptionCheckout) && (
999
999
  <CheckBoxContainer
1000
1000
  text = {"Set up Standing Instructions (SI) for this payment."}
1001
1001
  isCheckBoxSelected = {isSICheckBoxClicked}
@@ -15,7 +15,7 @@ import type { CheckoutStackParamList } from '../navigation';
15
15
  import { paymentHandler, setPaymentHandler } from "../sharedContext/paymentStatusHandler";
16
16
  import { loadBoxpayFonts } from '../components/fontFamily';
17
17
  import { setUserDataHandler, setUserDataHandlerToDefault, userDataHandler } from '../sharedContext/userdataHandler';
18
- import { type PaymentResultObject, type PaymentClass, type InstrumentDetails, type PaymentMethod, type OrderItem, APIStatus, AnalyticsEvents, type DeliveryAddress, type BoxpayCheckoutProps, type GetInstantOffersResponse, UIConfigurationOptions, TransactionStatus, type SubscriptionDetails } from '../interface';
18
+ import { type PaymentResultObject, type PaymentClass, type InstrumentDetails, type PaymentMethod, type OrderItem, APIStatus, AnalyticsEvents, type DeliveryAddress, type BoxpayCheckoutProps, type GetInstantOffersResponse, UIConfigurationOptions, TransactionStatus, type SubscriptionDetails, ConfigurationOptions } from '../interface';
19
19
  import { checkoutDetailsHandler, setCheckoutDetailsHandler, setCheckOutDetailsHandlerToDefault } from '../sharedContext/checkoutDetailsHandler';
20
20
  import WebViewScreen from '../screens/webViewScreen';
21
21
  import styles from '../styles/indexStyles';
@@ -30,7 +30,7 @@ import fetchSessionDetails from '../postRequest/fetchSessionDetails';
30
30
  import MorePaymentMethods from '../components/morePaymentMethods';
31
31
  import { fetchSavedInstrumentsHandler, handleFetchStatusResponseHandler, handlePaymentResponse } from '../sharedContext/handlePaymentResponseHandler';
32
32
  import callUIAnalytics from '../postRequest/callUIAnalytics';
33
- import { formatAddress, formatDate, getPhoneNumberCodeAndCountryName, isEmpty, useCountdown } from '../utility';
33
+ import { formatAddress, formatDate, getCheckboxProps, getPhoneNumberCodeAndCountryName, isEmpty, useCountdown } from '../utility';
34
34
  import fetchSurCharge from '../postRequest/fetchSurcharge';
35
35
  import fetchInstantOffer from '../postRequest/fetchInstantOffer';
36
36
  import ApplyCouponCard from '../components/applyCouponCard';
@@ -532,6 +532,8 @@ const MainScreen = ({route, navigation} : MainScreenProps) => {
532
532
  );
533
533
  return field?.editable === true;
534
534
  };
535
+
536
+ const {checked, enabled} = getCheckboxProps(configurationOptions?.[ConfigurationOptions.SICheckBoxState])
535
537
 
536
538
  setCheckoutDetailsHandler({
537
539
  checkoutDetails: {
@@ -592,7 +594,8 @@ const MainScreen = ({route, navigation} : MainScreenProps) => {
592
594
  isUPIOtmIntentMethodEnabled : methodFlags.isUPIOtmIntentVisible,
593
595
  isUPIOtmQRMethodEnabled : methodFlags.isUPIOtmQRVisible,
594
596
  isOrderItemDetailsVisible : isFieldEnabled('ORDER_ITEM_DETAILS'),
595
- isSICheckboxVisible : configurationOptions?.SHOW_SI_CHECKBOX ? true : false,
597
+ isSICheckboxChecked : checked,
598
+ isSICheckboxEnabled : enabled,
596
599
  isSubscriptionCheckout : paymentDetails.subscriptionDetails != null ? true : false,
597
600
  subscriptionDetails : getSubscriptionDetails(paymentDetails.subscriptionDetails, paymentDetails.money.amountLocaleFull, symbol)
598
601
  },
@@ -1 +1 @@
1
- { "version": "1.0.12" }
1
+ { "version": "1.0.13-beta2" }
@@ -48,7 +48,8 @@ export let checkoutDetailsHandler: CheckoutDetailsHandler = {
48
48
  isUPIOtmCollectMethodEnabled : false,
49
49
  isUPIOtmQRMethodEnabled : false,
50
50
  isOrderItemDetailsVisible : true,
51
- isSICheckboxVisible : false,
51
+ isSICheckboxChecked : false,
52
+ isSICheckboxEnabled : false,
52
53
  isSubscriptionCheckout : false,
53
54
  subscriptionDetails : null
54
55
  },
@@ -103,7 +104,8 @@ export const setCheckOutDetailsHandlerToDefault = () => {
103
104
  isUPIOtmCollectMethodEnabled: false,
104
105
  isUPIOtmQRMethodEnabled: false,
105
106
  isOrderItemDetailsVisible : true,
106
- isSICheckboxVisible : false,
107
+ isSICheckboxChecked : false,
108
+ isSICheckboxEnabled : false,
107
109
  isSubscriptionCheckout : false,
108
110
  subscriptionDetails : null
109
111
  },
package/src/utility.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { PaymentMethod, PaymentClass, DeliveryAddress, CountryDetails } from './interface';
2
+ import { SICheckboxState } from './interface';
2
3
  import { Dimensions, Platform } from 'react-native';
3
4
  import { userDataHandler } from './sharedContext/userdataHandler';
4
5
  import { useState, useRef, useCallback, useEffect } from 'react';
@@ -220,4 +221,14 @@ export const isEmpty = (value: unknown): boolean => {
220
221
  if (Array.isArray(value)) return value.length === 0;
221
222
  if (typeof value === 'object') return Object.keys(value).length === 0;
222
223
  return false;
223
- };
224
+ };
225
+
226
+ export const getCheckboxProps = (state?: SICheckboxState | null) => ({
227
+ checked:
228
+ state === SICheckboxState.CHECKED_AND_DISABLED ||
229
+ state === SICheckboxState.CHECKED_AND_ENABLED,
230
+
231
+ enabled:
232
+ state === SICheckboxState.CHECKED_AND_ENABLED ||
233
+ state === SICheckboxState.UNCHECKED_AND_ENABLED,
234
+ });