ordering-ui-react-native 0.22.52 → 0.22.53-release

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 (164) hide show
  1. package/package.json +5 -7
  2. package/src/DeliveryApp.tsx +1 -1
  3. package/src/components/BusinessesListing/index.tsx +1 -1
  4. package/src/components/Checkout/index.tsx +40 -39
  5. package/src/components/VerifyPhone/styles.tsx +1 -2
  6. package/src/context/OfflineActions/index.tsx +236 -0
  7. package/src/providers/AlertProvider.tsx +3 -1
  8. package/themes/business/src/components/AcceptOrRejectOrder/index.tsx +9 -6
  9. package/themes/business/src/components/AcceptOrRejectOrder/styles.tsx +1 -0
  10. package/themes/business/src/components/BusinessController/index.tsx +8 -3
  11. package/themes/business/src/components/BusinessProductList/index.tsx +3 -2
  12. package/themes/business/src/components/Chat/index.tsx +15 -3
  13. package/themes/business/src/components/DriverMap/index.tsx +44 -33
  14. package/themes/business/src/components/FloatingButton/index.tsx +3 -2
  15. package/themes/business/src/components/LanguageSelector/index.tsx +1 -1
  16. package/themes/business/src/components/LoginForm/index.tsx +123 -98
  17. package/themes/business/src/components/LogoutButton/index.tsx +13 -4
  18. package/themes/business/src/components/MapView/index.tsx +22 -17
  19. package/themes/business/src/components/NewOrderNotification/index.tsx +25 -14
  20. package/themes/business/src/components/OrderDetails/Business.tsx +56 -20
  21. package/themes/business/src/components/OrderDetails/Delivery.tsx +134 -53
  22. package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +155 -45
  23. package/themes/business/src/components/OrderDetails/OrderHeaderComponent.tsx +51 -28
  24. package/themes/business/src/components/OrderDetails/styles.tsx +39 -3
  25. package/themes/business/src/components/OrderDetails/usePrinterCommands.tsx +17 -16
  26. package/themes/business/src/components/OrderDetailsLogistic/index.tsx +3 -2
  27. package/themes/business/src/components/OrderSummary/index.tsx +271 -176
  28. package/themes/business/src/components/OrdersListManager/index.tsx +13 -1
  29. package/themes/business/src/components/OrdersOption/index.tsx +345 -231
  30. package/themes/business/src/components/OrdersOption/styles.tsx +14 -0
  31. package/themes/business/src/components/PreviousMessages/index.tsx +26 -3
  32. package/themes/business/src/components/PreviousOrders/OrderItem.tsx +30 -18
  33. package/themes/business/src/components/PreviousOrders/index.tsx +74 -66
  34. package/themes/business/src/components/PreviousOrders/styles.tsx +2 -1
  35. package/themes/business/src/components/PrinterEdition/MessageAlert.tsx +33 -0
  36. package/themes/business/src/components/PrinterEdition/index.tsx +143 -75
  37. package/themes/business/src/components/PrinterEdition/printerList.tsx +23 -0
  38. package/themes/business/src/components/PrinterSettings/index.tsx +1 -1
  39. package/themes/business/src/components/ProductItemAccordion/index.tsx +3 -2
  40. package/themes/business/src/components/ReviewCustomer/index.tsx +2 -0
  41. package/themes/business/src/components/StoresList/index.tsx +2 -2
  42. package/themes/business/src/components/UserProfileForm/index.tsx +48 -10
  43. package/themes/business/src/components/UserProfileForm/styles.tsx +7 -0
  44. package/themes/business/src/components/WebsocketStatus/index.tsx +2 -2
  45. package/themes/business/src/config/currency.tsx +1010 -0
  46. package/themes/business/src/hooks/useLocation.tsx +16 -12
  47. package/themes/business/src/layouts/SafeAreaContainer.tsx +35 -19
  48. package/themes/business/src/types/index.tsx +22 -7
  49. package/themes/business/src/utils/index.tsx +28 -3
  50. package/themes/doordash/src/components/BusinessesListing/index.tsx +1 -1
  51. package/themes/doordash/src/components/LoginForm/index.tsx +1 -2
  52. package/themes/instacart/src/components/BusinessesListing/index.tsx +1 -1
  53. package/themes/kiosk/src/components/Checkout/index.tsx +9 -5
  54. package/themes/kiosk/src/components/CustomerName/index.tsx +1 -1
  55. package/themes/kiosk/src/components/NavBar/index.tsx +14 -14
  56. package/themes/kiosk/src/components/OptionCard/index.tsx +1 -1
  57. package/themes/kiosk/src/components/OrderTypeCardSelector/index.tsx +8 -10
  58. package/themes/kiosk/src/components/PaymentOptions/index.tsx +121 -57
  59. package/themes/kiosk/src/components/shared/OButton.tsx +5 -18
  60. package/themes/original/index.tsx +9 -1
  61. package/themes/original/src/components/AddressForm/index.tsx +19 -19
  62. package/themes/original/src/components/AddressList/index.tsx +0 -13
  63. package/themes/original/src/components/AppleLogin/index.tsx +4 -4
  64. package/themes/original/src/components/BusinessBasicInformation/index.tsx +1 -1
  65. package/themes/original/src/components/BusinessController/index.tsx +4 -2
  66. package/themes/original/src/components/BusinessItemAccordion/index.tsx +14 -6
  67. package/themes/original/src/components/BusinessListingSearch/BusinessSearchFooter.tsx +103 -92
  68. package/themes/original/src/components/BusinessListingSearch/BusinessSearchHeader.tsx +8 -6
  69. package/themes/original/src/components/BusinessListingSearch/index.tsx +1 -2
  70. package/themes/original/src/components/BusinessPreorder/index.tsx +46 -30
  71. package/themes/original/src/components/BusinessProductsList/SubcategoriesComponent/index.tsx +73 -70
  72. package/themes/original/src/components/BusinessProductsList/index.tsx +6 -7
  73. package/themes/original/src/components/BusinessProductsList/styles.tsx +0 -3
  74. package/themes/original/src/components/BusinessProductsListing/index.tsx +10 -6
  75. package/themes/original/src/components/BusinessTypeFilter/index.tsx +9 -8
  76. package/themes/original/src/components/BusinessesListing/Layout/Appointment/index.tsx +2 -1
  77. package/themes/original/src/components/BusinessesListing/Layout/Original/styles.tsx +1 -1
  78. package/themes/original/src/components/BusinessesListing/index.tsx +0 -1
  79. package/themes/original/src/components/Cart/index.tsx +49 -15
  80. package/themes/original/src/components/CartContent/index.tsx +2 -4
  81. package/themes/original/src/components/Checkout/index.tsx +109 -88
  82. package/themes/original/src/components/CitiesControl/index.tsx +0 -3
  83. package/themes/original/src/components/CouponControl/index.tsx +1 -3
  84. package/themes/original/src/components/DriverTips/index.tsx +1 -3
  85. package/themes/original/src/components/Favorite/index.tsx +1 -10
  86. package/themes/original/src/components/FavoriteList/index.tsx +0 -1
  87. package/themes/original/src/components/ForgotPasswordForm/index.tsx +5 -12
  88. package/themes/original/src/components/GiftCard/GiftCardUI/index.tsx +15 -17
  89. package/themes/original/src/components/GiftCard/PurchaseGiftCard/index.tsx +3 -7
  90. package/themes/original/src/components/GiftCard/RedeemGiftCard/index.tsx +24 -32
  91. package/themes/original/src/components/GiftCard/SendGiftCard/index.tsx +7 -9
  92. package/themes/original/src/components/GiftCard/VerticalGiftCardOrdersLayout/index.tsx +11 -12
  93. package/themes/original/src/components/GoogleMap/index.tsx +39 -18
  94. package/themes/original/src/components/Help/index.tsx +0 -5
  95. package/themes/original/src/components/HelpAccountAndPayment/index.tsx +0 -5
  96. package/themes/original/src/components/HelpGuide/index.tsx +0 -5
  97. package/themes/original/src/components/HelpOrder/index.tsx +0 -5
  98. package/themes/original/src/components/HighestRatedBusinesses/index.tsx +1 -1
  99. package/themes/original/src/components/Home/index.tsx +35 -19
  100. package/themes/original/src/components/LoginForm/Otp/index.tsx +0 -3
  101. package/themes/original/src/components/LoginForm/index.tsx +12 -14
  102. package/themes/original/src/components/MessageListing/index.tsx +1 -6
  103. package/themes/original/src/components/Messages/index.tsx +20 -13
  104. package/themes/original/src/components/MomentOption/TimeListItem.tsx +56 -0
  105. package/themes/original/src/components/MomentOption/index.tsx +73 -59
  106. package/themes/original/src/components/MomentSelector/index.tsx +5 -2
  107. package/themes/original/src/components/MultiCartsPaymethodsAndWallets/index.tsx +1 -0
  108. package/themes/original/src/components/MultiCheckout/index.tsx +55 -27
  109. package/themes/original/src/components/MultiOrdersDetails/index.tsx +1 -0
  110. package/themes/original/src/components/MyOrders/index.tsx +2 -7
  111. package/themes/original/src/components/NavBar/index.tsx +7 -6
  112. package/themes/original/src/components/NetworkError/index.tsx +0 -5
  113. package/themes/original/src/components/NotFoundSource/index.tsx +0 -3
  114. package/themes/original/src/components/Notifications/index.tsx +0 -5
  115. package/themes/original/src/components/OrderDetails/OrderEta.tsx +4 -3
  116. package/themes/original/src/components/OrderDetails/OrderHistory.tsx +16 -11
  117. package/themes/original/src/components/OrderDetails/index.tsx +44 -21
  118. package/themes/original/src/components/OrderDetails/styles.tsx +0 -1
  119. package/themes/original/src/components/OrderProgress/index.tsx +4 -3
  120. package/themes/original/src/components/OrderSummary/index.tsx +32 -11
  121. package/themes/original/src/components/OrderTypeSelector/index.tsx +7 -11
  122. package/themes/original/src/components/OrdersOption/index.tsx +3 -6
  123. package/themes/original/src/components/PaymentOptionStripe/index.tsx +0 -5
  124. package/themes/original/src/components/PaymentOptionWallet/index.tsx +56 -56
  125. package/themes/original/src/components/PaymentOptions/index.tsx +462 -461
  126. package/themes/original/src/components/PhoneInputNumber/index.tsx +92 -7
  127. package/themes/original/src/components/PlaceSpot/index.tsx +1 -3
  128. package/themes/original/src/components/PreviousOrders/index.tsx +1 -4
  129. package/themes/original/src/components/ProductForm/ActionButton.tsx +7 -12
  130. package/themes/original/src/components/ProductItemAccordion/index.tsx +28 -37
  131. package/themes/original/src/components/ProductOptionSubOption/index.tsx +16 -8
  132. package/themes/original/src/components/ProfessionalProfile/index.tsx +4 -5
  133. package/themes/original/src/components/Promotions/index.tsx +2 -7
  134. package/themes/original/src/components/ReviewDriver/index.tsx +1 -6
  135. package/themes/original/src/components/ReviewOrder/index.tsx +2 -7
  136. package/themes/original/src/components/ReviewProducts/index.tsx +1 -6
  137. package/themes/original/src/components/ReviewTrigger/index.tsx +2 -2
  138. package/themes/original/src/components/ServiceForm/index.tsx +53 -55
  139. package/themes/original/src/components/Sessions/index.tsx +3 -8
  140. package/themes/original/src/components/SignupForm/index.tsx +44 -37
  141. package/themes/original/src/components/SingleOrderCard/index.tsx +7 -5
  142. package/themes/original/src/components/SingleProductCard/index.tsx +3 -4
  143. package/themes/original/src/components/SingleProductCard/styles.tsx +0 -3
  144. package/themes/original/src/components/StripeCardForm/index.tsx +0 -3
  145. package/themes/original/src/components/StripeCardsList/index.tsx +16 -3
  146. package/themes/original/src/components/StripeElementsForm/index.tsx +6 -4
  147. package/themes/original/src/components/StripeElementsForm/naked.tsx +1 -1
  148. package/themes/original/src/components/StripeRedirectForm/index.tsx +0 -3
  149. package/themes/original/src/components/TaxInformation/index.tsx +3 -2
  150. package/themes/original/src/components/UpsellingProducts/UpsellingContent.tsx +8 -5
  151. package/themes/original/src/components/UserDetails/index.tsx +17 -16
  152. package/themes/original/src/components/UserFormDetails/index.tsx +113 -73
  153. package/themes/original/src/components/UserProfile/index.tsx +9 -1
  154. package/themes/original/src/components/UserProfileForm/index.tsx +0 -5
  155. package/themes/original/src/components/UserVerification/index.tsx +18 -5
  156. package/themes/original/src/components/Wallets/index.tsx +1 -3
  157. package/themes/original/src/components/WebsocketStatus/index.tsx +1 -4
  158. package/themes/original/src/components/shared/OAlert.tsx +2 -1
  159. package/themes/original/src/components/shared/OButton.tsx +5 -4
  160. package/themes/original/src/components/shared/OInput.tsx +4 -8
  161. package/themes/original/src/components/shared/OModal.tsx +7 -2
  162. package/themes/original/src/types/index.tsx +12 -4
  163. package/themes/original/src/utils/index.tsx +29 -0
  164. package/themes/uber-eats/src/components/BusinessesListing/index.tsx +1 -1
@@ -1,17 +1,17 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import { FlatList, TouchableOpacity, View, StyleSheet, KeyboardAvoidingView, Platform } from 'react-native';
3
3
  import {
4
- Placeholder,
5
- PlaceholderLine,
6
- Fade
4
+ Placeholder,
5
+ PlaceholderLine,
6
+ Fade
7
7
  } from "rn-placeholder";
8
8
 
9
9
  import {
10
- PaymentOptions as PaymentOptionsController,
11
- useLanguage,
12
- ToastType,
13
- useToast,
14
- useSession
10
+ PaymentOptions as PaymentOptionsController,
11
+ useLanguage,
12
+ ToastType,
13
+ useToast,
14
+ useSession
15
15
  } from 'ordering-components/native';
16
16
  import { useTheme } from 'styled-components/native';
17
17
  import { PaymentOptionCash } from '../PaymentOptionCash';
@@ -27,10 +27,10 @@ import { PaymentOptionCard } from '../PaymentOptionCard'
27
27
  import { OText, OIcon, OModal, OButton } from '../shared';
28
28
 
29
29
  import {
30
- PMContainer,
31
- PMItem,
32
- PMCardSelected,
33
- PMCardItemContent
30
+ PMContainer,
31
+ PMItem,
32
+ PMCardSelected,
33
+ PMCardItemContent
34
34
  } from './styles'
35
35
  import { getIconCard, flatArray } from '../../utils';
36
36
  import { useApplePay } from '@stripe/stripe-react-native';
@@ -50,246 +50,247 @@ const multiCheckoutMethods = ['global_google_pay', 'global_apple_pay']
50
50
  const cardsPaymethods = ['credomatic']
51
51
 
52
52
  const PaymentOptionsUI = (props: any) => {
53
- const {
54
- cart,
55
- errorCash,
56
- isLoading,
57
- isDisabled,
58
- paymethodData,
59
- paymethodsList,
60
- setPaymethodData,
61
- onNavigationRedirect,
62
- handlePaymethodClick,
63
- handlePaymethodDataChange,
64
- isOpenMethod,
65
- handlePaymentMethodClickCustom,
66
- handlePlaceOrder,
67
- merchantId,
68
- urlscheme,
69
- setMethodPaySupported,
70
- placeByMethodPay,
71
- methodPaySupported,
72
- setPlaceByMethodPay,
73
- setCardList,
74
- onPaymentChange,
75
- requiredFields,
76
- openUserModal,
77
- paymethodClicked,
78
- setPaymethodClicked,
79
- androidAppId
80
- } = props
81
-
82
- const theme = useTheme();
83
- const [, { showToast }] = useToast();
84
- const [{ user }] = useSession()
85
- const { confirmApplePayPayment } = useApplePay()
86
-
87
- const getPayIcon = (method: string) => {
88
- switch (method) {
89
- case 'cash':
90
- return theme.images.general.cash
91
- case 'card_delivery':
92
- return theme.images.general.carddelivery
93
- case 'paypal':
94
- return theme.images.general.paypal
95
- case 'stripe':
96
- return theme.images.general.creditCard
97
- case 'stripe_direct':
98
- return theme.images.general.stripecc
99
- case 'stripe_connect':
100
- return theme.images.general.stripes
101
- case 'stripe_redirect':
102
- return theme.images.general.stripesb
103
- case 'apple_pay':
104
- return theme.images.general.applePayMark
105
- case 'google_pay':
106
- return theme.images.general.googlePayMark
107
- default:
108
- return theme.images.general.creditCard
109
- }
110
- }
111
-
112
- const [, t] = useLanguage();
113
-
114
- const [addCardOpen, setAddCardOpen] = useState({ stripe: false, stripeConnect: false, card: false });
115
- const paymethodSelected = props.paySelected || props.paymethodSelected || isOpenMethod?.paymethod
116
- // const [{ token }] = useSession()
117
-
118
- // const [card, setCard] = useState(null);
119
-
120
- // const stripeRedirectValues = [
121
- // { name: t('SELECT_A_PAYMENT_METHOD', 'Select a payment method'), value: '-1' },
122
- // ]
123
-
124
- const paymethodsFieldRequired = ['paypal', 'apple_pay', 'global_apple_pay']
125
-
126
- const handlePaymentMethodClick = (paymethod: any) => {
127
- if (cart?.balance > 0 || !!user?.guest_id) {
128
- if (paymethodsFieldRequired.includes(paymethod?.gateway) && requiredFields.length > 0) {
129
- openUserModal && openUserModal(true)
130
- setPaymethodClicked({
131
- confirmed: false,
132
- paymethod
133
- })
134
- return
135
- }
136
- const isPopupMethod = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect', 'paypal'].includes(paymethod?.gateway)
137
- if (webViewPaymentGateway.includes(paymethod?.gateway)) {
138
- handlePaymentMethodClickCustom(paymethod)
139
- }
140
- handlePaymethodClick(paymethod, isPopupMethod)
141
- return
142
- }
143
- showToast(
144
- ToastType.Error,
145
- t('CART_BALANCE_ZERO', 'Sorry, the amount to pay is equal to zero and it is not necessary to select a payment method'))
146
- ;
147
- }
148
-
149
- useEffect(() => {
150
- if (cart?.balance === 0) {
151
- handlePaymethodClick(null)
152
- }
153
- }, [cart?.balance])
154
-
155
- useEffect(() => {
156
- if (paymethodsList.paymethods.length === 1) {
157
- handlePaymethodClick && handlePaymethodClick(paymethodsList.paymethods[0])
158
- }
159
- }, [paymethodsList.paymethods])
160
-
161
- useEffect(() => {
162
- if (paymethodSelected?.gateway !== 'cash' && errorCash) {
163
- props.setErrorCash(false)
164
- }
165
- }, [paymethodSelected])
166
-
167
- useEffect(() => {
168
- if (props.paySelected && props.paySelected?.data) {
169
- requestAnimationFrame(() => {
170
- setPaymethodData && setPaymethodData(props.paySelected?.data)
171
- })
172
- }
173
- }, [props.paySelected])
174
-
175
- useEffect(() => {
176
- if (methodsPay.includes(paymethodSelected?.gateway) && paymethodData?.id && paymethodSelected?.data?.card) {
177
- handlePlaceOrder(confirmApplePayPayment)
178
- }
179
- }, [paymethodData, paymethodSelected])
180
-
181
- useEffect(() => {
182
- if (paymethodClicked?.confirmed) {
183
- handlePaymentMethodClickCustom(paymethodClicked?.paymethod)
184
- }
185
- }, [paymethodClicked?.confirmed])
186
-
187
-
188
- const renderPaymethods = ({ item }: any) => {
189
- return (
190
- <>
191
- {methodsPay.includes(item?.gateway) ? (
192
- <TouchableOpacity
193
- onPress={() => handlePaymentMethodClick(item)}
194
- >
195
- <OIcon
196
- src={getPayIcon(item.gateway)}
197
- width={70}
198
- height={70}
199
- style={{ marginRight: 10 }}
200
- />
201
- </TouchableOpacity>
202
- ) : (
203
- <TouchableOpacity
204
- onPress={() => handlePaymentMethodClick(item)}
205
- >
206
- <PMItem
207
- key={item.id}
208
- isDisabled={isDisabled}
209
- isActive={paymethodSelected?.id === item.id}
210
- >
211
- <OIcon
212
- src={getPayIcon(item.gateway)}
213
- width={20}
214
- height={20}
215
- color={item?.gateway === 'apple_pay' ? '' : paymethodSelected?.id === item.id ? theme.colors.white : theme.colors.backgroundDark}
216
- />
217
- <OText
218
- size={10}
219
- style={{ margin: 0, marginTop: 4 }}
220
- color={paymethodSelected?.id === item.id ? theme.colors.white : '#000'}
221
- >
222
- {t(item?.gateway?.toUpperCase(), item.name)}
223
- </OText>
224
- </PMItem>
225
- </TouchableOpacity>
226
- )}
227
- </>
228
-
229
- )
230
- }
231
-
232
- const excludeIds: any = [32]; //exclude paypal & connect & redirect
233
- const filterMethodsPay = (gateway: string) => Platform.OS === 'ios' ? gateway !== 'google_pay' : gateway !== 'apple_pay'
234
-
235
- return (
236
- <PMContainer>
237
- {paymethodsList.paymethods.length > 0 && (
238
- <FlatList
239
- horizontal
240
- showsHorizontalScrollIndicator={false}
241
- // data={paymethodsList.paymethods.sort((a: any, b: any) => a.id - b.id)}
242
- data={paymethodsList.paymethods.sort((a: any, b: any) => a.id - b.id)
243
- .filter((p: any) =>
244
- !multiCheckoutMethods.includes(p.gateway) &&
245
- filterMethodsPay(p.gateway) &&
246
- !excludeIds.includes(p.id))}
247
- renderItem={renderPaymethods}
248
- keyExtractor={(paymethod: any) => paymethod?.id?.toString?.()}
249
- />
250
- )}
251
-
252
- {(paymethodsList.loading || isLoading) && (
253
- <Placeholder style={{ marginTop: 10 }} Animation={Fade}>
254
- <View style={{ display: 'flex', flexDirection: 'row' }}>
255
- {[...Array(3)].map((_, i) => (
256
- <PlaceholderLine
257
- key={i}
258
- width={37}
259
- height={80}
260
- noMargin
261
- style={{ borderRadius: 10, marginRight: 10 }}
262
- />
263
- ))}
264
- </View>
265
- </Placeholder>
266
- )}
267
-
268
- {paymethodsList.error && paymethodsList.error.length > 0 && (
269
- <OText size={12} style={{ margin: 0 }}>
270
- {paymethodsList?.error[0]?.message || paymethodsList?.error[0]}
271
- </OText>
272
- )}
273
-
274
- {!(paymethodsList.loading || isLoading) &&
275
- !paymethodsList.error &&
276
- (!paymethodsList?.paymethods || paymethodsList.paymethods.length === 0) &&
277
- (
278
- <OText size={12} style={{ margin: 0 }}>
279
- {t('NO_PAYMENT_METHODS', 'No payment methods!')}
280
- </OText>
281
- )}
282
-
283
- {paymethodSelected?.gateway === 'cash' && (
284
- <PaymentOptionCash
285
- orderTotal={cart.balance ?? cart.total}
286
- defaultValue={paymethodSelected?.data?.cash}
287
- onChangeData={handlePaymethodDataChange}
288
- setErrorCash={props.setErrorCash}
289
- />
290
- )}
291
-
292
- {/* {stripeOptions.includes(paymethodSelected?.gateway) &&
53
+ const {
54
+ cart,
55
+ errorCash,
56
+ isLoading,
57
+ isDisabled,
58
+ paymethodData,
59
+ paymethodsList,
60
+ setPaymethodData,
61
+ onNavigationRedirect,
62
+ handlePaymethodClick,
63
+ handlePaymethodDataChange,
64
+ isOpenMethod,
65
+ handlePaymentMethodClickCustom,
66
+ handlePlaceOrder,
67
+ merchantId,
68
+ urlscheme,
69
+ setMethodPaySupported,
70
+ placeByMethodPay,
71
+ methodPaySupported,
72
+ setPlaceByMethodPay,
73
+ setCardList,
74
+ onPaymentChange,
75
+ requiredFields,
76
+ openUserModal,
77
+ paymethodClicked,
78
+ setPaymethodClicked,
79
+ androidAppId,
80
+ setUserHasCards
81
+ } = props
82
+
83
+ const theme = useTheme();
84
+ const [, { showToast }] = useToast();
85
+ const [{ user }] = useSession()
86
+ const { confirmApplePayPayment } = useApplePay()
87
+
88
+ const getPayIcon = (method: string) => {
89
+ switch (method) {
90
+ case 'cash':
91
+ return theme.images.general.cash
92
+ case 'card_delivery':
93
+ return theme.images.general.carddelivery
94
+ case 'paypal':
95
+ return theme.images.general.paypal
96
+ case 'stripe':
97
+ return theme.images.general.creditCard
98
+ case 'stripe_direct':
99
+ return theme.images.general.stripecc
100
+ case 'stripe_connect':
101
+ return theme.images.general.stripes
102
+ case 'stripe_redirect':
103
+ return theme.images.general.stripesb
104
+ case 'apple_pay':
105
+ return theme.images.general.applePayMark
106
+ case 'google_pay':
107
+ return theme.images.general.googlePayMark
108
+ default:
109
+ return theme.images.general.creditCard
110
+ }
111
+ }
112
+
113
+ const [, t] = useLanguage();
114
+
115
+ const [addCardOpen, setAddCardOpen] = useState({ stripe: false, stripeConnect: false, card: false });
116
+ const paymethodSelected = props.paySelected || props.paymethodSelected || isOpenMethod?.paymethod
117
+ // const [{ token }] = useSession()
118
+
119
+ // const [card, setCard] = useState(null);
120
+
121
+ // const stripeRedirectValues = [
122
+ // { name: t('SELECT_A_PAYMENT_METHOD', 'Select a payment method'), value: '-1' },
123
+ // ]
124
+
125
+ const paymethodsFieldRequired = ['paypal', 'apple_pay', 'global_apple_pay']
126
+
127
+ const handlePaymentMethodClick = (paymethod: any) => {
128
+ if (cart?.balance > 0 || !!user?.guest_id) {
129
+ if (paymethodsFieldRequired.includes(paymethod?.gateway) && requiredFields.length > 0) {
130
+ openUserModal && openUserModal(true)
131
+ setPaymethodClicked({
132
+ confirmed: false,
133
+ paymethod
134
+ })
135
+ return
136
+ }
137
+ const isPopupMethod = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect', 'paypal'].includes(paymethod?.gateway)
138
+ if (webViewPaymentGateway.includes(paymethod?.gateway)) {
139
+ handlePaymentMethodClickCustom(paymethod)
140
+ }
141
+ handlePaymethodClick(paymethod, isPopupMethod)
142
+ return
143
+ }
144
+ showToast(
145
+ ToastType.Error,
146
+ t('CART_BALANCE_ZERO', 'Sorry, the amount to pay is equal to zero and it is not necessary to select a payment method'))
147
+ ;
148
+ }
149
+
150
+ useEffect(() => {
151
+ if (cart?.balance === 0) {
152
+ handlePaymethodClick(null)
153
+ }
154
+ }, [cart?.balance])
155
+
156
+ useEffect(() => {
157
+ if (paymethodsList.paymethods.length === 1) {
158
+ handlePaymethodClick && handlePaymethodClick(paymethodsList.paymethods[0])
159
+ }
160
+ }, [paymethodsList.paymethods])
161
+
162
+ useEffect(() => {
163
+ if (paymethodSelected?.gateway !== 'cash' && errorCash) {
164
+ props.setErrorCash(false)
165
+ }
166
+ }, [paymethodSelected])
167
+
168
+ useEffect(() => {
169
+ if (props.paySelected && props.paySelected?.data) {
170
+ requestAnimationFrame(() => {
171
+ setPaymethodData && setPaymethodData(props.paySelected?.data)
172
+ })
173
+ }
174
+ }, [props.paySelected])
175
+
176
+ useEffect(() => {
177
+ if (methodsPay.includes(paymethodSelected?.gateway) && paymethodData?.id && paymethodSelected?.data?.card) {
178
+ handlePlaceOrder(confirmApplePayPayment)
179
+ }
180
+ }, [paymethodData, paymethodSelected])
181
+
182
+ useEffect(() => {
183
+ if (paymethodClicked?.confirmed) {
184
+ handlePaymentMethodClickCustom(paymethodClicked?.paymethod)
185
+ }
186
+ }, [paymethodClicked?.confirmed])
187
+
188
+
189
+ const renderPaymethods = ({ item }: any) => {
190
+ return (
191
+ <>
192
+ {methodsPay.includes(item?.gateway) ? (
193
+ <TouchableOpacity
194
+ onPress={() => handlePaymentMethodClick(item)}
195
+ >
196
+ <OIcon
197
+ src={getPayIcon(item.gateway)}
198
+ width={70}
199
+ height={70}
200
+ style={{ marginRight: 10 }}
201
+ />
202
+ </TouchableOpacity>
203
+ ) : (
204
+ <TouchableOpacity
205
+ onPress={() => handlePaymentMethodClick(item)}
206
+ >
207
+ <PMItem
208
+ key={item.id}
209
+ isDisabled={isDisabled}
210
+ isActive={paymethodSelected?.id === item.id}
211
+ >
212
+ <OIcon
213
+ src={getPayIcon(item.gateway)}
214
+ width={20}
215
+ height={20}
216
+ color={item?.gateway === 'apple_pay' ? '' : paymethodSelected?.id === item.id ? theme.colors.white : theme.colors.backgroundDark}
217
+ />
218
+ <OText
219
+ size={10}
220
+ style={{ margin: 0, marginTop: 4 }}
221
+ color={paymethodSelected?.id === item.id ? theme.colors.white : '#000'}
222
+ >
223
+ {t(item?.gateway?.toUpperCase(), item.name)}
224
+ </OText>
225
+ </PMItem>
226
+ </TouchableOpacity>
227
+ )}
228
+ </>
229
+
230
+ )
231
+ }
232
+
233
+ const excludeIds: any = [32]; //exclude paypal & connect & redirect
234
+ const filterMethodsPay = (gateway: string) => Platform.OS === 'ios' ? gateway !== 'google_pay' : gateway !== 'apple_pay'
235
+
236
+ return (
237
+ <PMContainer>
238
+ {paymethodsList.paymethods.length > 0 && (
239
+ <FlatList
240
+ horizontal
241
+ showsHorizontalScrollIndicator={false}
242
+ // data={paymethodsList.paymethods.sort((a: any, b: any) => a.id - b.id)}
243
+ data={paymethodsList.paymethods.sort((a: any, b: any) => a.id - b.id)
244
+ .filter((p: any) =>
245
+ !multiCheckoutMethods.includes(p.gateway) &&
246
+ filterMethodsPay(p.gateway) &&
247
+ !excludeIds.includes(p.id))}
248
+ renderItem={renderPaymethods}
249
+ keyExtractor={(paymethod: any) => paymethod?.id?.toString?.()}
250
+ />
251
+ )}
252
+
253
+ {(paymethodsList.loading || isLoading) && (
254
+ <Placeholder style={{ marginTop: 10 }} Animation={Fade}>
255
+ <View style={{ display: 'flex', flexDirection: 'row' }}>
256
+ {[...Array(3)].map((_, i) => (
257
+ <PlaceholderLine
258
+ key={i}
259
+ width={37}
260
+ height={80}
261
+ noMargin
262
+ style={{ borderRadius: 10, marginRight: 10 }}
263
+ />
264
+ ))}
265
+ </View>
266
+ </Placeholder>
267
+ )}
268
+
269
+ {paymethodsList.error && paymethodsList.error.length > 0 && (
270
+ <OText size={12} style={{ margin: 0 }}>
271
+ {paymethodsList?.error[0]?.message || paymethodsList?.error[0]}
272
+ </OText>
273
+ )}
274
+
275
+ {!(paymethodsList.loading || isLoading) &&
276
+ !paymethodsList.error &&
277
+ (!paymethodsList?.paymethods || paymethodsList.paymethods.length === 0) &&
278
+ (
279
+ <OText size={12} style={{ margin: 0 }}>
280
+ {t('NO_PAYMENT_METHODS', 'No payment methods!')}
281
+ </OText>
282
+ )}
283
+
284
+ {paymethodSelected?.gateway === 'cash' && (
285
+ <PaymentOptionCash
286
+ orderTotal={cart.balance ?? cart.total}
287
+ defaultValue={paymethodSelected?.data?.cash}
288
+ onChangeData={handlePaymethodDataChange}
289
+ setErrorCash={props.setErrorCash}
290
+ />
291
+ )}
292
+
293
+ {/* {stripeOptions.includes(paymethodSelected?.gateway) &&
293
294
  (paymethodData?.brand || paymethodData?.card?.brand) &&
294
295
  (paymethodData?.last4 || paymethodData?.card?.last4) &&
295
296
  (
@@ -320,188 +321,188 @@ const PaymentOptionsUI = (props: any) => {
320
321
  </PMCardSelected>
321
322
  )} */}
322
323
 
323
- {/* Stripe */}
324
- {isOpenMethod?.paymethod?.gateway === 'stripe' && (
325
- <View>
326
- <OButton
327
- text={t('ADD_PAYMENT_CARD', 'Add New Payment Card')}
328
- bgColor={theme.colors.white}
329
- borderColor={theme.colors.primary}
330
- style={styles.btnAddStyle}
331
- textStyle={{ color: theme.colors.primary, fontSize: 12 }}
332
- imgRightSrc={null}
333
- onClick={() => setAddCardOpen({ ...addCardOpen, stripe: true })}
334
- />
335
- <StripeCardsList
336
- paymethod={isOpenMethod?.paymethod}
337
- businessId={props.businessId}
338
- publicKey={isOpenMethod?.paymethod?.credentials?.publishable}
339
- payType={paymethodsList?.name}
340
- onSelectCard={handlePaymethodDataChange}
341
- onNavigationRedirect={onNavigationRedirect}
342
- paymethodCardId={paymethodData?.id}
343
- onCancel={() => handlePaymethodClick(null)}
344
- setAddCardOpen={setAddCardOpen}
345
- addCardOpen={addCardOpen}
346
- isOpenMethod={isOpenMethod}
347
- handleSource={handlePaymethodDataChange}
348
- clientSecret={props.clientSecret}
349
- businessId={props.businessId}
350
- onPaymentChange={onPaymentChange}
351
- paySelected={props.paySelected}
352
- />
353
- </View>
354
- )}
355
- {/* Google pay, Apple pay */}
356
- {methodsPay.includes(isOpenMethod?.paymethod?.gateway) && (
357
- <StripeElementsForm
358
- cart={cart}
359
- paymethod={isOpenMethod?.paymethod?.gateway}
360
- methodsPay={methodsPay}
361
- businessId={props.businessId}
362
- publicKey={isOpenMethod?.paymethod?.credentials?.publishable || isOpenMethod?.paymethod?.credentials?.publishable_key}
363
- handleSource={handlePaymethodDataChange}
364
- onCancel={() => handlePaymethodClick(null)}
365
- merchantId={merchantId}
366
- urlscheme={urlscheme}
367
- androidAppId={androidAppId}
368
- setMethodPaySupported={setMethodPaySupported}
369
- methodPaySupported={methodPaySupported}
370
- placeByMethodPay={placeByMethodPay}
371
- setPlaceByMethodPay={setPlaceByMethodPay}
372
- publicKeyAddCard={isOpenMethod?.paymethod?.credentials?.stripe?.publishable || isOpenMethod?.paymethod?.credentials?.publishable}
373
- />
374
- )}
375
-
376
- {(cardsPaymethods.includes(isOpenMethod?.paymethod?.gateway) || cardsPaymethods.includes(paymethodSelected?.gateway)) && (
377
- <PaymentOptionCard
378
- setCardList={setCardList}
379
- paymethod={isOpenMethod?.paymethod}
380
- businessId={props.businessId}
381
- publicKey={isOpenMethod?.paymethod?.credentials?.publishable}
382
- gateway={isOpenMethod?.paymethod?.gateway || paymethodSelected?.gateway}
383
- onPaymentChange={onPaymentChange}
384
- payType={isOpenMethod?.paymethod?.name}
385
- onSelectCard={handlePaymethodDataChange}
386
- addCardOpen={addCardOpen}
387
- setAddCardOpen={setAddCardOpen}
388
- onCancel={() => handlePaymethodClick(null)}
389
- paymethodSelected={paymethodSelected?.data?.id}
390
- handlePaymentMethodClick={handlePaymentMethodClick}
391
- />
392
- )}
393
-
394
- {/* Stripe direct */}
395
- <OModal
396
- entireModal
397
- title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
398
- open={stripeDirectMethods?.includes(isOpenMethod?.paymethod?.gateway) && !paymethodData.id}
399
- onClose={() => handlePaymethodClick(null)}
400
- >
401
- <KeyboardAvoidingView
402
- behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
403
- keyboardVerticalOffset={Platform.OS == 'ios' ? 0 : 0}
404
- enabled={Platform.OS === 'ios' ? true : false}
405
- >
406
- <StripeElementsForm
407
- cart={cart}
408
- paymethod={isOpenMethod?.paymethod?.gateway}
409
- methodsPay={methodsPay}
410
- businessId={props.businessId}
411
- publicKey={isOpenMethod?.paymethod?.credentials?.publishable || isOpenMethod?.paymethod?.credentials?.publishable_key}
412
- handleSource={handlePaymethodDataChange}
413
- onCancel={() => handlePaymethodClick(null)}
414
- merchantId={merchantId}
415
- urlscheme={urlscheme}
416
- androidAppId={androidAppId}
417
- publicKeyAddCard={isOpenMethod?.paymethod?.credentials?.stripe?.publishable || isOpenMethod?.paymethod?.credentials?.publishable}
418
- paySelected={props.paySelected}
419
- />
420
- </KeyboardAvoidingView>
421
- </OModal>
422
-
423
- {/* Stripe Connect */}
424
- {isOpenMethod?.paymethod?.gateway === 'stripe_connect' && !paymethodData?.id && (
425
- <View>
426
- <OButton
427
- text={t('ADD_PAYMENT_CARD', 'Add New Payment Card')}
428
- bgColor={theme.colors.white}
429
- borderColor={theme.colors.primary}
430
- style={styles.btnAddStyle}
431
- textStyle={{ color: theme.colors.primary, fontSize: 12 }}
432
- imgRightSrc={null}
433
- onClick={() => setAddCardOpen({ ...addCardOpen, stripeConnect: true })}
434
- />
435
- <StripeCardsList
436
- paymethod={isOpenMethod?.paymethod}
437
- businessId={props.businessId}
438
- payType={paymethodsList?.name}
439
- onSelectCard={handlePaymethodDataChange}
440
- onNavigationRedirect={onNavigationRedirect}
441
- onCancel={() => handlePaymethodClick(null)}
442
- publicKey={isOpenMethod?.paymethod?.credentials.publishable}
443
- publicKeyAddCard={isOpenMethod?.paymethod?.credentials?.stripe?.publishable || isOpenMethod?.paymethod?.credentials?.publishable}
444
- paySelected={props.paySelected}
445
- />
446
- </View>
447
- )}
448
- {/** Stripe connect add cards */}
449
- <OModal
450
- entireModal
451
- title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
452
- open={addCardOpen.stripeConnect}
453
- onClose={() => setAddCardOpen({ ...addCardOpen, stripeConnect: false })}
454
- >
455
- <KeyboardAvoidingView
456
- behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
457
- keyboardVerticalOffset={Platform.OS == 'ios' ? 0 : 0}
458
- enabled={Platform.OS === 'ios' ? true : false}
459
- >
460
- <StripeElementsForm
461
- openCarts={props.openCarts}
462
- toSave
463
- businessId={props.businessId}
464
- publicKey={isOpenMethod?.paymethod?.credentials?.stripe?.publishable}
465
- requirements={isOpenMethod?.paymethod?.credentials?.publishable}
466
- accountId={isOpenMethod?.paymethod?.credentials?.user}
467
- onSelectCard={handlePaymethodDataChange}
468
- onCancel={() => setAddCardOpen({ ...addCardOpen, stripeConnect: false })}
469
- publicKeyAddCard={isOpenMethod?.paymethod?.credentials?.stripe?.publishable || isOpenMethod?.paymethod?.credentials?.publishable}
470
- />
471
- </KeyboardAvoidingView>
472
- </OModal>
473
-
474
- {/* Stripe Add card */}
475
- <OModal
476
- entireModal
477
- title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
478
- open={addCardOpen?.stripe}
479
- onClose={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
480
- style={{ backgroundColor: 'red' }}
481
- >
482
- <KeyboardAvoidingView
483
- behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
484
- keyboardVerticalOffset={Platform.OS == 'ios' ? 0 : 0}
485
- enabled={Platform.OS === 'ios' ? true : false}
486
- >
487
- <StripeElementsForm
488
- openCarts={props.openCarts}
489
- toSave
490
- businessId={props.businessId}
491
- businessIds={props.businessIds}
492
- publicKey={props.publicKey || isOpenMethod?.paymethod?.credentials?.publishable}
493
- setCardsList={setCardList}
494
- requirements={props.clientSecret}
495
- handleSource={handlePaymethodDataChange}
496
- onSelectCard={handlePaymethodDataChange}
497
- onCancel={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
498
- publicKeyAddCard={isOpenMethod?.paymethod?.credentials?.stripe?.publishable || isOpenMethod?.paymethod?.credentials?.publishable}
499
- />
500
- </KeyboardAvoidingView>
501
- </OModal>
502
-
503
- {/* Stripe Redirect */}
504
- {/* <OModal
324
+ {/* Stripe */}
325
+ {isOpenMethod?.paymethod?.gateway === 'stripe' && (
326
+ <View>
327
+ <OButton
328
+ text={t('ADD_PAYMENT_CARD', 'Add New Payment Card')}
329
+ bgColor={theme.colors.white}
330
+ style={styles.btnAddStyle}
331
+ textStyle={{ color: theme.colors.primary, fontSize: 12 }}
332
+ imgRightSrc={null}
333
+ onClick={() => setAddCardOpen({ ...addCardOpen, stripe: true })}
334
+ />
335
+ <StripeCardsList
336
+ paymethod={isOpenMethod?.paymethod}
337
+ businessId={props.businessId}
338
+ publicKey={isOpenMethod?.paymethod?.credentials?.publishable}
339
+ payType={paymethodsList?.name}
340
+ onSelectCard={handlePaymethodDataChange}
341
+ onNavigationRedirect={onNavigationRedirect}
342
+ paymethodCardId={paymethodData?.id}
343
+ onCancel={() => handlePaymethodClick(null)}
344
+ setAddCardOpen={setAddCardOpen}
345
+ addCardOpen={addCardOpen}
346
+ isOpenMethod={isOpenMethod}
347
+ handleSource={handlePaymethodDataChange}
348
+ clientSecret={props.clientSecret}
349
+ businessId={props.businessId}
350
+ onPaymentChange={onPaymentChange}
351
+ paySelected={props.paySelected}
352
+ setUserHasCards={setUserHasCards}
353
+ />
354
+ </View>
355
+ )}
356
+ {/* Google pay, Apple pay */}
357
+ {methodsPay.includes(isOpenMethod?.paymethod?.gateway) && (
358
+ <StripeElementsForm
359
+ cart={cart}
360
+ paymethod={isOpenMethod?.paymethod?.gateway}
361
+ methodsPay={methodsPay}
362
+ businessId={props.businessId}
363
+ publicKey={isOpenMethod?.paymethod?.credentials?.publishable || isOpenMethod?.paymethod?.credentials?.publishable_key}
364
+ handleSource={handlePaymethodDataChange}
365
+ onCancel={() => handlePaymethodClick(null)}
366
+ merchantId={merchantId}
367
+ urlscheme={urlscheme}
368
+ androidAppId={androidAppId}
369
+ setMethodPaySupported={setMethodPaySupported}
370
+ methodPaySupported={methodPaySupported}
371
+ placeByMethodPay={placeByMethodPay}
372
+ setPlaceByMethodPay={setPlaceByMethodPay}
373
+ publicKeyAddCard={isOpenMethod?.paymethod?.credentials?.stripe?.publishable || isOpenMethod?.paymethod?.credentials?.publishable}
374
+ />
375
+ )}
376
+
377
+ {(cardsPaymethods.includes(isOpenMethod?.paymethod?.gateway) || cardsPaymethods.includes(paymethodSelected?.gateway)) && (
378
+ <PaymentOptionCard
379
+ setCardList={setCardList}
380
+ paymethod={isOpenMethod?.paymethod}
381
+ businessId={props.businessId}
382
+ publicKey={isOpenMethod?.paymethod?.credentials?.publishable}
383
+ gateway={isOpenMethod?.paymethod?.gateway || paymethodSelected?.gateway}
384
+ onPaymentChange={onPaymentChange}
385
+ payType={isOpenMethod?.paymethod?.name}
386
+ onSelectCard={handlePaymethodDataChange}
387
+ addCardOpen={addCardOpen}
388
+ setAddCardOpen={setAddCardOpen}
389
+ onCancel={() => handlePaymethodClick(null)}
390
+ paymethodSelected={paymethodSelected?.data?.id}
391
+ handlePaymentMethodClick={handlePaymentMethodClick}
392
+ />
393
+ )}
394
+
395
+ {/* Stripe direct */}
396
+ <OModal
397
+ entireModal
398
+ title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
399
+ open={stripeDirectMethods?.includes(isOpenMethod?.paymethod?.gateway) && !paymethodData.id}
400
+ onClose={() => handlePaymethodClick(null)}
401
+ >
402
+ <KeyboardAvoidingView
403
+ behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
404
+ keyboardVerticalOffset={Platform.OS == 'ios' ? 0 : 0}
405
+ enabled={Platform.OS === 'ios' ? true : false}
406
+ >
407
+ <StripeElementsForm
408
+ cart={cart}
409
+ paymethod={isOpenMethod?.paymethod?.gateway}
410
+ methodsPay={methodsPay}
411
+ businessId={props.businessId}
412
+ publicKey={isOpenMethod?.paymethod?.credentials?.publishable || isOpenMethod?.paymethod?.credentials?.publishable_key}
413
+ handleSource={handlePaymethodDataChange}
414
+ onCancel={() => handlePaymethodClick(null)}
415
+ merchantId={merchantId}
416
+ urlscheme={urlscheme}
417
+ androidAppId={androidAppId}
418
+ publicKeyAddCard={isOpenMethod?.paymethod?.credentials?.stripe?.publishable || isOpenMethod?.paymethod?.credentials?.publishable}
419
+ paySelected={props.paySelected}
420
+ />
421
+ </KeyboardAvoidingView>
422
+ </OModal>
423
+
424
+ {/* Stripe Connect */}
425
+ {isOpenMethod?.paymethod?.gateway === 'stripe_connect' && (
426
+ <View>
427
+ <OButton
428
+ text={t('ADD_PAYMENT_CARD', 'Add New Payment Card')}
429
+ bgColor={theme.colors.white}
430
+ style={styles.btnAddStyle}
431
+ textStyle={{ color: theme.colors.primary, fontSize: 12 }}
432
+ imgRightSrc={null}
433
+ onClick={() => setAddCardOpen({ ...addCardOpen, stripeConnect: true })}
434
+ />
435
+ <StripeCardsList
436
+ paymethod={isOpenMethod?.paymethod}
437
+ businessId={props.businessId}
438
+ payType={paymethodsList?.name}
439
+ onSelectCard={handlePaymethodDataChange}
440
+ onNavigationRedirect={onNavigationRedirect}
441
+ onCancel={() => handlePaymethodClick(null)}
442
+ publicKey={isOpenMethod?.paymethod?.credentials.publishable}
443
+ publicKeyAddCard={isOpenMethod?.paymethod?.credentials?.stripe?.publishable || isOpenMethod?.paymethod?.credentials?.publishable}
444
+ paySelected={props.paySelected}
445
+ setUserHasCards={setUserHasCards}
446
+ />
447
+ </View>
448
+ )}
449
+ {/** Stripe connect add cards */}
450
+ <OModal
451
+ entireModal
452
+ title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
453
+ open={addCardOpen.stripeConnect}
454
+ onClose={() => setAddCardOpen({ ...addCardOpen, stripeConnect: false })}
455
+ >
456
+ <KeyboardAvoidingView
457
+ behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
458
+ keyboardVerticalOffset={Platform.OS == 'ios' ? 0 : 0}
459
+ enabled={Platform.OS === 'ios' ? true : false}
460
+ >
461
+ <StripeElementsForm
462
+ openCarts={props.openCarts}
463
+ toSave
464
+ businessId={props.businessId}
465
+ publicKey={isOpenMethod?.paymethod?.credentials?.stripe?.publishable}
466
+ requirements={isOpenMethod?.paymethod?.credentials?.publishable}
467
+ accountId={isOpenMethod?.paymethod?.credentials?.user}
468
+ onSelectCard={handlePaymethodDataChange}
469
+ onCancel={() => setAddCardOpen({ ...addCardOpen, stripeConnect: false })}
470
+ publicKeyAddCard={isOpenMethod?.paymethod?.credentials?.stripe?.publishable || isOpenMethod?.paymethod?.credentials?.publishable}
471
+ />
472
+ </KeyboardAvoidingView>
473
+ </OModal>
474
+
475
+ {/* Stripe Add card */}
476
+ <OModal
477
+ entireModal
478
+ title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
479
+ open={addCardOpen?.stripe}
480
+ onClose={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
481
+ style={{ backgroundColor: 'red' }}
482
+ >
483
+ <KeyboardAvoidingView
484
+ behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
485
+ keyboardVerticalOffset={Platform.OS == 'ios' ? 0 : 0}
486
+ enabled={Platform.OS === 'ios' ? true : false}
487
+ >
488
+ <StripeElementsForm
489
+ openCarts={props.openCarts}
490
+ toSave
491
+ businessId={props.businessId}
492
+ businessIds={props.businessIds}
493
+ publicKey={props.publicKey || isOpenMethod?.paymethod?.credentials?.publishable}
494
+ setCardsList={setCardList}
495
+ requirements={props.clientSecret}
496
+ handleSource={handlePaymethodDataChange}
497
+ onSelectCard={handlePaymethodDataChange}
498
+ onCancel={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
499
+ publicKeyAddCard={isOpenMethod?.paymethod?.credentials?.stripe?.publishable || isOpenMethod?.paymethod?.credentials?.publishable}
500
+ />
501
+ </KeyboardAvoidingView>
502
+ </OModal>
503
+
504
+ {/* Stripe Redirect */}
505
+ {/* <OModal
505
506
  isNotDecoration
506
507
  open={['stripe_redirect'].includes(paymethodSelected?.gateway) && !paymethodData.type}
507
508
  title={t('STRIPE_REDIRECT', 'Stripe Redirect')}
@@ -517,8 +518,8 @@ const PaymentOptionsUI = (props: any) => {
517
518
  />
518
519
  </OModal> */}
519
520
 
520
- {/* Paypal */}
521
- {/* <Modal
521
+ {/* Paypal */}
522
+ {/* <Modal
522
523
  className='modal-info'
523
524
  open={paymethodSelected?.gateway === 'paypal' && !paymethodData?.id}
524
525
  onClose={() => handlePaymethodClick(null)}
@@ -543,35 +544,35 @@ const PaymentOptionsUI = (props: any) => {
543
544
  />
544
545
  )}
545
546
  </Modal> */}
546
- </PMContainer>
547
- )
547
+ </PMContainer>
548
+ )
548
549
  }
549
550
 
550
551
  const styles = StyleSheet.create({
551
- viewStyle: {
552
- marginRight: 10
553
- },
554
- cardsList: {
555
- borderWidth: 1,
556
- borderColor: 'red',
557
- flex: 1,
558
- height: 120
559
- },
560
- btnAddStyle: {
561
- marginVertical: 20,
562
- borderRadius: 7.6,
563
- shadowOpacity: 0,
564
- height: 44,
565
- borderWidth: 1
566
- },
552
+ viewStyle: {
553
+ marginRight: 10
554
+ },
555
+ cardsList: {
556
+ borderWidth: 1,
557
+ borderColor: 'red',
558
+ flex: 1,
559
+ height: 120
560
+ },
561
+ btnAddStyle: {
562
+ marginVertical: 20,
563
+ borderRadius: 7.6,
564
+ shadowOpacity: 0,
565
+ height: 44,
566
+ borderWidth: 1
567
+ },
567
568
  })
568
569
 
569
570
  export const PaymentOptions = (props: any) => {
570
- const paymentOptions = {
571
- ...props,
572
- UIComponent: PaymentOptionsUI
573
- }
574
- return (
575
- <PaymentOptionsController {...paymentOptions} />
576
- )
571
+ const paymentOptions = {
572
+ ...props,
573
+ UIComponent: PaymentOptionsUI
574
+ }
575
+ return (
576
+ <PaymentOptionsController {...paymentOptions} />
577
+ )
577
578
  }