ordering-ui-react-native 0.23.69 → 0.23.71

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ordering-ui-react-native",
3
- "version": "0.23.69",
3
+ "version": "0.23.71",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -49,7 +49,7 @@ export const BusinessItemAccordion = (props: any) => {
49
49
  if (cartsLength === 1) {
50
50
  changeActiveState && changeActiveState(!isClosed, cart?.uuid)
51
51
  }
52
- }, [orderState?.carts, isClosed])
52
+ }, [orderState?.carts?.length, isClosed])
53
53
 
54
54
  const subtotalWithTaxes = cart?.taxes?.reduce((acc: any, item: any) => {
55
55
  if (item?.type === 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,247 +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
- 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) &&
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) &&
294
294
  (paymethodData?.brand || paymethodData?.card?.brand) &&
295
295
  (paymethodData?.last4 || paymethodData?.card?.last4) &&
296
296
  (
@@ -321,188 +321,188 @@ const PaymentOptionsUI = (props: any) => {
321
321
  </PMCardSelected>
322
322
  )} */}
323
323
 
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' && !paymethodData?.id && (
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
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
506
506
  isNotDecoration
507
507
  open={['stripe_redirect'].includes(paymethodSelected?.gateway) && !paymethodData.type}
508
508
  title={t('STRIPE_REDIRECT', 'Stripe Redirect')}
@@ -518,8 +518,8 @@ const PaymentOptionsUI = (props: any) => {
518
518
  />
519
519
  </OModal> */}
520
520
 
521
- {/* Paypal */}
522
- {/* <Modal
521
+ {/* Paypal */}
522
+ {/* <Modal
523
523
  className='modal-info'
524
524
  open={paymethodSelected?.gateway === 'paypal' && !paymethodData?.id}
525
525
  onClose={() => handlePaymethodClick(null)}
@@ -544,35 +544,35 @@ const PaymentOptionsUI = (props: any) => {
544
544
  />
545
545
  )}
546
546
  </Modal> */}
547
- </PMContainer>
548
- )
547
+ </PMContainer>
548
+ )
549
549
  }
550
550
 
551
551
  const styles = StyleSheet.create({
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
- },
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
+ },
568
568
  })
569
569
 
570
570
  export const PaymentOptions = (props: any) => {
571
- const paymentOptions = {
572
- ...props,
573
- UIComponent: PaymentOptionsUI
574
- }
575
- return (
576
- <PaymentOptionsController {...paymentOptions} />
577
- )
571
+ const paymentOptions = {
572
+ ...props,
573
+ UIComponent: PaymentOptionsUI
574
+ }
575
+ return (
576
+ <PaymentOptionsController {...paymentOptions} />
577
+ )
578
578
  }