ordering-ui-react-native 0.16.74 → 0.16.76
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 +1 -1
- package/src/components/Checkout/index.tsx +2 -1
- package/src/components/PaymentOptions/index.tsx +298 -345
- package/src/components/StripeElementsForm/index.tsx +25 -16
- package/themes/business/src/components/OrderDetails/OrderContentComponent.tsx +16 -16
- package/themes/original/src/components/PaymentOptions/index.tsx +0 -1
- package/themes/original/src/components/StripeElementsForm/index.tsx +10 -2
package/package.json
CHANGED
|
@@ -93,7 +93,7 @@ const CheckoutUI = (props: any) => {
|
|
|
93
93
|
deliveryOptionSelected,
|
|
94
94
|
instructionsOptions,
|
|
95
95
|
handleChangeDeliveryOption,
|
|
96
|
-
|
|
96
|
+
merchantId
|
|
97
97
|
} = props
|
|
98
98
|
|
|
99
99
|
const theme = useTheme();
|
|
@@ -530,6 +530,7 @@ const CheckoutUI = (props: any) => {
|
|
|
530
530
|
handlePaymentMethodClickCustom={handlePaymentMethodClick}
|
|
531
531
|
setCardData={setCardData}
|
|
532
532
|
handlePlaceOrder={handlePlaceOrder}
|
|
533
|
+
merchantId={merchantId}
|
|
533
534
|
/>
|
|
534
535
|
</ChPaymethods>
|
|
535
536
|
</ChSection>
|
|
@@ -1,136 +1,129 @@
|
|
|
1
|
-
import React, { useEffect, useState
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { useTheme } from 'styled-components/native';
|
|
3
|
+
import { useApplePay } from '@stripe/stripe-react-native';
|
|
4
|
+
import { FlatList, TouchableOpacity, View, StyleSheet, KeyboardAvoidingView, Platform } from 'react-native';
|
|
4
5
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
Placeholder,
|
|
7
|
+
PlaceholderLine,
|
|
8
|
+
Fade
|
|
8
9
|
} from "rn-placeholder";
|
|
9
10
|
|
|
10
11
|
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
useOrder,
|
|
16
|
-
ToastType,
|
|
17
|
-
useToast
|
|
12
|
+
PaymentOptions as PaymentOptionsController,
|
|
13
|
+
useLanguage,
|
|
14
|
+
ToastType,
|
|
15
|
+
useToast,
|
|
18
16
|
} from 'ordering-components/native';
|
|
19
17
|
|
|
18
|
+
import { getIconCard } from '../../utils';
|
|
20
19
|
import { PaymentOptionCash } from '../PaymentOptionCash';
|
|
21
20
|
import { StripeElementsForm } from '../StripeElementsForm';
|
|
22
21
|
import { StripeCardsList } from '../StripeCardsList';
|
|
23
|
-
// import { PaymentOptionStripe } from '../PaymentOptionStripe';
|
|
24
|
-
// import { StripeRedirectForm } from '../StripeRedirectForm';
|
|
25
|
-
// import { PaymentOptionPaypal } from '../PaymentOptionPaypal'
|
|
26
|
-
// import { NotFoundSource } from '../NotFoundSource'
|
|
27
|
-
|
|
28
22
|
import { OText, OIcon, OModal, OButton } from '../shared';
|
|
29
23
|
|
|
30
24
|
import {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
25
|
+
PMContainer,
|
|
26
|
+
PMItem,
|
|
27
|
+
PMCardSelected,
|
|
28
|
+
PMCardItemContent
|
|
35
29
|
} from './styles'
|
|
36
|
-
import { getIconCard } from '../../utils';
|
|
37
|
-
import { WebView } from 'react-native-webview';
|
|
38
|
-
import { useTheme } from 'styled-components/native';
|
|
39
30
|
|
|
40
31
|
const stripeOptions: any = ['stripe_direct', 'stripe', 'stripe_connect']
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
// { name: 'Alipay', value: 'alipay' },
|
|
44
|
-
// { name: 'Giropay', value: 'giropay' },
|
|
45
|
-
// { name: 'iDEAL', value: 'ideal' }
|
|
46
|
-
// ]
|
|
47
|
-
|
|
32
|
+
const methodsPay = ['google_pay', 'apple_pay']
|
|
33
|
+
const stripeDirectMethods = ['stripe_direct', ...methodsPay]
|
|
48
34
|
const webViewPaymentGateway: any = ['paypal', 'square']
|
|
49
35
|
|
|
50
36
|
const PaymentOptionsUI = (props: any) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
37
|
+
const {
|
|
38
|
+
cart,
|
|
39
|
+
errorCash,
|
|
40
|
+
isLoading,
|
|
41
|
+
isDisabled,
|
|
42
|
+
paymethodData,
|
|
43
|
+
paymethodsList,
|
|
44
|
+
setPaymethodData,
|
|
45
|
+
onNavigationRedirect,
|
|
46
|
+
handlePaymethodClick,
|
|
47
|
+
handlePaymethodDataChange,
|
|
48
|
+
isOpenMethod,
|
|
49
|
+
handlePaymentMethodClickCustom,
|
|
50
|
+
handlePlaceOrder,
|
|
51
|
+
merchantId
|
|
52
|
+
} = props
|
|
67
53
|
|
|
68
|
-
|
|
54
|
+
const theme = useTheme();
|
|
69
55
|
const [, t] = useLanguage();
|
|
70
|
-
|
|
71
|
-
|
|
56
|
+
const [, { showToast }] = useToast();
|
|
57
|
+
const { confirmApplePayPayment } = useApplePay()
|
|
72
58
|
|
|
73
59
|
const [addCardOpen, setAddCardOpen] = useState({ stripe: false, stripeConnect: false });
|
|
74
|
-
|
|
60
|
+
const paymethodSelected = props.paySelected || props.paymethodSelected || isOpenMethod?.paymethod
|
|
75
61
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
62
|
+
const getPayIcon = (method: string) => {
|
|
63
|
+
switch (method) {
|
|
64
|
+
case 'cash':
|
|
65
|
+
return theme.images.general.cash
|
|
66
|
+
case 'card_delivery':
|
|
67
|
+
return theme.images.general.carddelivery
|
|
68
|
+
case 'paypal':
|
|
69
|
+
return theme.images.general.paypal
|
|
70
|
+
case 'stripe':
|
|
71
|
+
return theme.images.general.stripe
|
|
72
|
+
case 'stripe_direct':
|
|
73
|
+
return theme.images.general.stripecc
|
|
74
|
+
case 'stripe_connect':
|
|
75
|
+
return theme.images.general.stripes
|
|
76
|
+
case 'stripe_redirect':
|
|
77
|
+
return theme.images.general.stripesb
|
|
78
|
+
case 'apple_pay':
|
|
79
|
+
return theme.images.general.applePayMark
|
|
80
|
+
default:
|
|
81
|
+
return theme.images.general.creditCard
|
|
82
|
+
}
|
|
83
|
+
}
|
|
98
84
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
85
|
+
const handlePaymentMethodClick = (paymethod: any) => {
|
|
86
|
+
if (cart?.balance > 0) {
|
|
87
|
+
const isPopupMethod = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect', 'paypal'].includes(paymethod?.gateway)
|
|
88
|
+
if (webViewPaymentGateway.includes(paymethod?.gateway)) {
|
|
89
|
+
handlePaymentMethodClickCustom(paymethod)
|
|
90
|
+
}
|
|
91
|
+
handlePaymethodClick(paymethod, isPopupMethod)
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
showToast(
|
|
95
|
+
ToastType.Error,
|
|
96
|
+
t('CART_BALANCE_ZERO', 'Sorry, the amount to pay is equal to zero and it is not necessary to select a payment method'))
|
|
97
|
+
;
|
|
98
|
+
}
|
|
107
99
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
if (paymethodsList.paymethods.length === 1) {
|
|
102
|
+
handlePaymethodClick && handlePaymethodClick(paymethodsList.paymethods[0])
|
|
103
|
+
}
|
|
104
|
+
}, [paymethodsList.paymethods])
|
|
113
105
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
if (paymethodSelected?.gateway !== 'cash' && errorCash) {
|
|
108
|
+
props.setErrorCash(false)
|
|
109
|
+
}
|
|
110
|
+
}, [paymethodSelected])
|
|
119
111
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
112
|
+
useEffect(() => {
|
|
113
|
+
if (props.paySelected && props.paySelected?.data) {
|
|
114
|
+
requestAnimationFrame(() => {
|
|
115
|
+
setPaymethodData && setPaymethodData(props.paySelected?.data)
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
|
+
}, [props.paySelected])
|
|
125
119
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}, [paymethodData, paymethodSelected])
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
if (methodsPay.includes(paymethodSelected?.gateway) && paymethodData?.id && paymethodSelected?.data?.card) {
|
|
122
|
+
handlePlaceOrder(confirmApplePayPayment)
|
|
123
|
+
}
|
|
124
|
+
}, [paymethodData, paymethodSelected])
|
|
132
125
|
|
|
133
|
-
|
|
126
|
+
const renderPaymethods = ({ item }: any) => {
|
|
134
127
|
return (
|
|
135
128
|
<>
|
|
136
129
|
{item?.gateway === 'apple_pay' ? (
|
|
@@ -173,251 +166,211 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
173
166
|
)
|
|
174
167
|
}
|
|
175
168
|
|
|
176
|
-
|
|
169
|
+
const excludeIds: any = [32];
|
|
177
170
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
)}
|
|
190
|
-
{(paymethodsList.loading || isLoading) && (
|
|
191
|
-
<Placeholder style={{ marginTop: 10 }} Animation={Fade}>
|
|
192
|
-
<View style={{ display: 'flex', flexDirection: 'row' }}>
|
|
193
|
-
{[...Array(3)].map((_, i) => (
|
|
194
|
-
<PlaceholderLine
|
|
195
|
-
key={i}
|
|
196
|
-
width={37}
|
|
197
|
-
height={80}
|
|
198
|
-
noMargin
|
|
199
|
-
style={{ borderRadius: 10, marginRight: 10 }}
|
|
200
|
-
/>
|
|
201
|
-
))}
|
|
202
|
-
</View>
|
|
203
|
-
</Placeholder>
|
|
204
|
-
)}
|
|
171
|
+
return (
|
|
172
|
+
<PMContainer>
|
|
173
|
+
{paymethodsList.paymethods.length > 0 && (
|
|
174
|
+
<FlatList
|
|
175
|
+
horizontal
|
|
176
|
+
showsHorizontalScrollIndicator={false}
|
|
177
|
+
data={paymethodsList.paymethods.sort((a: any, b: any) => a.id - b.id).filter((p: any) => !excludeIds.includes(p.id))}
|
|
178
|
+
renderItem={renderPaymethods}
|
|
179
|
+
keyExtractor={(paymethod: any) => paymethod?.id?.toString?.()}
|
|
180
|
+
/>
|
|
181
|
+
)}
|
|
205
182
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
183
|
+
{(paymethodsList.loading || isLoading) && (
|
|
184
|
+
<Placeholder style={{ marginTop: 10 }} Animation={Fade}>
|
|
185
|
+
<View style={{ display: 'flex', flexDirection: 'row' }}>
|
|
186
|
+
{[...Array(3)].map((_, i) => (
|
|
187
|
+
<PlaceholderLine
|
|
188
|
+
key={i}
|
|
189
|
+
width={37}
|
|
190
|
+
height={80}
|
|
191
|
+
noMargin
|
|
192
|
+
style={{ borderRadius: 10, marginRight: 10 }}
|
|
193
|
+
/>
|
|
194
|
+
))}
|
|
195
|
+
</View>
|
|
196
|
+
</Placeholder>
|
|
197
|
+
)}
|
|
211
198
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
{t('NO_PAYMENT_METHODS', 'No payment methods!')}
|
|
218
|
-
</OText>
|
|
219
|
-
)}
|
|
199
|
+
{paymethodsList.error && paymethodsList.error.length > 0 && (
|
|
200
|
+
<OText size={12} style={{ margin: 0 }}>
|
|
201
|
+
{paymethodsList?.error[0]?.message || paymethodsList?.error[0]}
|
|
202
|
+
</OText>
|
|
203
|
+
)}
|
|
220
204
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
205
|
+
{!(paymethodsList.loading || isLoading) &&
|
|
206
|
+
!paymethodsList.error &&
|
|
207
|
+
(!paymethodsList?.paymethods || paymethodsList.paymethods.length === 0) &&
|
|
208
|
+
(
|
|
209
|
+
<OText size={12} style={{ margin: 0 }}>
|
|
210
|
+
{t('NO_PAYMENT_METHODS', 'No payment methods!')}
|
|
211
|
+
</OText>
|
|
212
|
+
)}
|
|
229
213
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
name='radiobox-marked'
|
|
239
|
-
size={24}
|
|
240
|
-
color={theme.colors.primary}
|
|
241
|
-
/>
|
|
242
|
-
</View>
|
|
243
|
-
<View style={styles.viewStyle}>
|
|
244
|
-
<OText>
|
|
245
|
-
{getIconCard((paymethodData?.brand || paymethodData?.card?.brand), 26)}
|
|
246
|
-
</OText>
|
|
247
|
-
</View>
|
|
248
|
-
<View style={styles.viewStyle}>
|
|
249
|
-
<OText
|
|
250
|
-
size={20}
|
|
251
|
-
>
|
|
252
|
-
XXXX-XXXX-XXXX-{(paymethodData?.last4 || paymethodData?.card?.last4)}
|
|
253
|
-
</OText>
|
|
254
|
-
</View>
|
|
255
|
-
</PMCardItemContent>
|
|
256
|
-
</PMCardSelected>
|
|
257
|
-
)}
|
|
214
|
+
{paymethodSelected?.gateway === 'cash' && (
|
|
215
|
+
<PaymentOptionCash
|
|
216
|
+
orderTotal={cart.balance ?? cart.total}
|
|
217
|
+
defaultValue={paymethodSelected?.data?.cash}
|
|
218
|
+
onChangeData={handlePaymethodDataChange}
|
|
219
|
+
setErrorCash={props.setErrorCash}
|
|
220
|
+
/>
|
|
221
|
+
)}
|
|
258
222
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
223
|
+
{stripeOptions.includes(paymethodSelected?.gateway) &&
|
|
224
|
+
(paymethodData?.brand || paymethodData?.card?.brand) &&
|
|
225
|
+
(paymethodData?.last4 || paymethodData?.card?.last4) &&
|
|
226
|
+
(
|
|
227
|
+
<PMCardSelected>
|
|
228
|
+
<PMCardItemContent>
|
|
229
|
+
<View style={styles.viewStyle}>
|
|
230
|
+
<OIcon
|
|
231
|
+
src={theme.images.general.radio_act}
|
|
232
|
+
width={16}
|
|
233
|
+
color={theme.colors.primary}
|
|
234
|
+
/>
|
|
235
|
+
</View>
|
|
236
|
+
<View style={styles.viewStyle}>
|
|
237
|
+
<OText>
|
|
238
|
+
{getIconCard((paymethodData?.brand || paymethodData?.card?.brand), 20)}
|
|
239
|
+
</OText>
|
|
240
|
+
</View>
|
|
241
|
+
<View style={styles.viewStyle}>
|
|
242
|
+
<OText
|
|
243
|
+
size={12}
|
|
244
|
+
lineHeight={18}
|
|
245
|
+
color={theme.colors.textNormal}
|
|
246
|
+
>
|
|
247
|
+
XXXX-XXXX-XXXX-{(paymethodData?.last4 || paymethodData?.card?.last4)}
|
|
248
|
+
</OText>
|
|
249
|
+
</View>
|
|
250
|
+
</PMCardItemContent>
|
|
251
|
+
</PMCardSelected>
|
|
252
|
+
)}
|
|
282
253
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
254
|
+
{/* Stripe */}
|
|
255
|
+
{isOpenMethod?.paymethod?.gateway === 'stripe' && !paymethodData?.id && (
|
|
256
|
+
<View>
|
|
257
|
+
<OButton
|
|
258
|
+
text={t('ADD_PAYMENT_CARD', 'Add New Payment Card')}
|
|
259
|
+
bgColor={theme.colors.white}
|
|
260
|
+
borderColor={theme.colors.primary}
|
|
261
|
+
style={styles.btnAddStyle}
|
|
262
|
+
textStyle={{ color: theme.colors.primary, fontSize: 12 }}
|
|
263
|
+
imgRightSrc={null}
|
|
264
|
+
onClick={() => setAddCardOpen({ ...addCardOpen, stripe: true })}
|
|
265
|
+
/>
|
|
266
|
+
<StripeCardsList
|
|
267
|
+
paymethod={isOpenMethod?.paymethod}
|
|
268
|
+
businessId={props.businessId}
|
|
269
|
+
publicKey={isOpenMethod?.paymethod?.credentials.publishable}
|
|
270
|
+
payType={paymethodsList?.name}
|
|
271
|
+
onSelectCard={handlePaymethodDataChange}
|
|
272
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
273
|
+
onCancel={() => handlePaymethodClick(null)}
|
|
274
|
+
/>
|
|
275
|
+
</View>
|
|
276
|
+
)}
|
|
304
277
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
</OModal>
|
|
278
|
+
<OModal
|
|
279
|
+
entireModal
|
|
280
|
+
title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
|
|
281
|
+
open={addCardOpen.stripe}
|
|
282
|
+
onClose={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
|
|
283
|
+
style={{ backgroundColor: 'red' }}
|
|
284
|
+
>
|
|
285
|
+
<KeyboardAvoidingView
|
|
286
|
+
behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
|
|
287
|
+
keyboardVerticalOffset={Platform.OS == 'ios' ? 0 : 0}
|
|
288
|
+
enabled={Platform.OS === 'ios' ? true : false}
|
|
289
|
+
>
|
|
290
|
+
<StripeElementsForm
|
|
291
|
+
toSave
|
|
292
|
+
businessId={props.businessId}
|
|
293
|
+
publicKey={isOpenMethod?.paymethod?.credentials?.publishable}
|
|
294
|
+
requirements={props.clientSecret}
|
|
295
|
+
onSelectCard={handlePaymethodDataChange}
|
|
296
|
+
onCancel={() => setAddCardOpen({ ...addCardOpen, stripe: false })}
|
|
297
|
+
/>
|
|
298
|
+
</KeyboardAvoidingView>
|
|
299
|
+
</OModal>
|
|
328
300
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
301
|
+
{/* Stripe direct, Google pay, Apple pay */}
|
|
302
|
+
<OModal
|
|
303
|
+
entireModal
|
|
304
|
+
title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
|
|
305
|
+
open={stripeDirectMethods?.includes(isOpenMethod?.paymethod?.gateway) && !paymethodData.id}
|
|
306
|
+
onClose={() => handlePaymethodClick(null)}
|
|
307
|
+
>
|
|
308
|
+
<KeyboardAvoidingView
|
|
309
|
+
behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
|
|
310
|
+
keyboardVerticalOffset={Platform.OS == 'ios' ? 0 : 0}
|
|
311
|
+
enabled={Platform.OS === 'ios' ? true : false}
|
|
312
|
+
>
|
|
313
|
+
<StripeElementsForm
|
|
314
|
+
cart={cart}
|
|
315
|
+
paymethod={isOpenMethod?.paymethod?.gateway}
|
|
316
|
+
methodsPay={methodsPay}
|
|
317
|
+
businessId={props.businessId}
|
|
318
|
+
publicKey={isOpenMethod?.paymethod?.credentials?.publishable || isOpenMethod?.paymethod?.credentials?.publishable_key}
|
|
319
|
+
handleSource={handlePaymethodDataChange}
|
|
320
|
+
onCancel={() => handlePaymethodClick(null)}
|
|
321
|
+
merchantId={merchantId}
|
|
322
|
+
/>
|
|
323
|
+
</KeyboardAvoidingView>
|
|
324
|
+
</OModal>
|
|
352
325
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
326
|
+
{/* Stripe Connect */}
|
|
327
|
+
{isOpenMethod?.paymethod?.gateway === 'stripe_connect' && !paymethodData?.id && (
|
|
328
|
+
<View>
|
|
329
|
+
<OButton
|
|
330
|
+
text={t('ADD_PAYMENT_CARD', 'Add New Payment Card')}
|
|
331
|
+
bgColor={theme.colors.white}
|
|
332
|
+
borderColor={theme.colors.primary}
|
|
333
|
+
style={styles.btnAddStyle}
|
|
334
|
+
textStyle={{ color: theme.colors.primary, fontSize: 12 }}
|
|
335
|
+
imgRightSrc={null}
|
|
336
|
+
onClick={() => setAddCardOpen({ ...addCardOpen, stripeConnect: true })}
|
|
337
|
+
/>
|
|
338
|
+
<StripeCardsList
|
|
339
|
+
paymethod={isOpenMethod?.paymethod}
|
|
340
|
+
businessId={props.businessId}
|
|
341
|
+
publicKey={isOpenMethod?.paymethod?.credentials.publishable}
|
|
342
|
+
payType={paymethodsList?.name}
|
|
343
|
+
onSelectCard={handlePaymethodDataChange}
|
|
344
|
+
onNavigationRedirect={onNavigationRedirect}
|
|
345
|
+
onCancel={() => handlePaymethodClick(null)}
|
|
346
|
+
/>
|
|
347
|
+
</View>
|
|
348
|
+
)}
|
|
375
349
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
{paymethodSelected?.gateway === 'paypal' && (
|
|
401
|
-
<PaymentOptionPaypal
|
|
402
|
-
clientId={paymethodSelected?.credentials?.client_id}
|
|
403
|
-
body={{
|
|
404
|
-
paymethod_id: paymethodSelected.id,
|
|
405
|
-
amount: cart.total,
|
|
406
|
-
delivery_zone_id: cart.delivery_zone_id,
|
|
407
|
-
cartUuid: cart.uuid
|
|
408
|
-
}}
|
|
409
|
-
btnStyle={paypalBtnStyle}
|
|
410
|
-
noAuthMessage={
|
|
411
|
-
!token
|
|
412
|
-
? t('NEED_LOGIN_TO_USE', 'Sorry, you need to login to use this method')
|
|
413
|
-
: null
|
|
414
|
-
}
|
|
415
|
-
handlerChangePaypal={(uuid) => onNavigationRedirect && onNavigationRedirect('OrderDetails', { orderId: uuid })}
|
|
416
|
-
/>
|
|
417
|
-
)}
|
|
418
|
-
</Modal> */}
|
|
419
|
-
</PMContainer>
|
|
420
|
-
)
|
|
350
|
+
<OModal
|
|
351
|
+
entireModal
|
|
352
|
+
title={t('ADD_CREDIT_OR_DEBIT_CARD', 'Add credit or debit card')}
|
|
353
|
+
open={addCardOpen.stripeConnect}
|
|
354
|
+
onClose={() => setAddCardOpen({ ...addCardOpen, stripeConnect: false })}
|
|
355
|
+
>
|
|
356
|
+
<KeyboardAvoidingView
|
|
357
|
+
behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
|
|
358
|
+
keyboardVerticalOffset={Platform.OS == 'ios' ? 0 : 0}
|
|
359
|
+
enabled={Platform.OS === 'ios' ? true : false}
|
|
360
|
+
>
|
|
361
|
+
<StripeElementsForm
|
|
362
|
+
toSave
|
|
363
|
+
businessId={props.businessId}
|
|
364
|
+
publicKey={isOpenMethod?.paymethod?.credentials?.stripe?.publishable}
|
|
365
|
+
requirements={isOpenMethod?.paymethod?.credentials?.publishable}
|
|
366
|
+
accountId={isOpenMethod?.paymethod?.credentials?.user}
|
|
367
|
+
onSelectCard={handlePaymethodDataChange}
|
|
368
|
+
onCancel={() => setAddCardOpen({ ...addCardOpen, stripeConnect: false })}
|
|
369
|
+
/>
|
|
370
|
+
</KeyboardAvoidingView>
|
|
371
|
+
</OModal>
|
|
372
|
+
</PMContainer>
|
|
373
|
+
)
|
|
421
374
|
}
|
|
422
375
|
|
|
423
376
|
const styles = StyleSheet.create({
|
|
@@ -452,11 +405,11 @@ const styles = StyleSheet.create({
|
|
|
452
405
|
})
|
|
453
406
|
|
|
454
407
|
export const PaymentOptions = (props: any) => {
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
408
|
+
const paymentOptions = {
|
|
409
|
+
...props,
|
|
410
|
+
UIComponent: PaymentOptionsUI
|
|
411
|
+
}
|
|
412
|
+
return (
|
|
413
|
+
<PaymentOptionsController {...paymentOptions} />
|
|
414
|
+
)
|
|
462
415
|
}
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
useConfirmSetupIntent,
|
|
8
8
|
createPaymentMethod
|
|
9
9
|
} from '@stripe/stripe-react-native';
|
|
10
|
-
import configs from '../../config.json'
|
|
11
10
|
import { ErrorMessage } from './styles';
|
|
12
11
|
|
|
13
12
|
import { StripeElementsForm as StripeFormController } from './naked';
|
|
@@ -26,7 +25,8 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
26
25
|
methodsPay,
|
|
27
26
|
paymethod,
|
|
28
27
|
onCancel,
|
|
29
|
-
cart
|
|
28
|
+
cart,
|
|
29
|
+
merchantId
|
|
30
30
|
} = props;
|
|
31
31
|
|
|
32
32
|
const theme = useTheme();
|
|
@@ -54,17 +54,25 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
if (user?.address) {
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
billingDetails.address = {
|
|
58
|
+
line1: user?.address
|
|
59
|
+
}
|
|
60
|
+
}
|
|
59
61
|
|
|
60
62
|
const createPayMethod = async () => {
|
|
61
|
-
const params: any = {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
const params: any = { paymentMethodType: 'Card', paymentMethodData: {} }
|
|
64
|
+
if (Object.keys(billingDetails).length > 0) {
|
|
65
|
+
params.paymentMethodData.billingDetails = {...billingDetails, token: card?.last4}
|
|
66
|
+
}
|
|
65
67
|
try {
|
|
66
68
|
setCreatePmLoading(true)
|
|
67
|
-
const { paymentMethod } = await createPaymentMethod(params);
|
|
69
|
+
const { paymentMethod, error } = await createPaymentMethod(params);
|
|
70
|
+
|
|
71
|
+
if (error) {
|
|
72
|
+
setErrors(error?.message);
|
|
73
|
+
setCreatePmLoading(false)
|
|
74
|
+
return
|
|
75
|
+
}
|
|
68
76
|
|
|
69
77
|
setCreatePmLoading(false)
|
|
70
78
|
handleSource && handleSource({
|
|
@@ -87,10 +95,10 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
87
95
|
createPayMethod();
|
|
88
96
|
return
|
|
89
97
|
}
|
|
90
|
-
const params: any = {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
98
|
+
const params: any = { paymentMethodType: 'Card', paymentMethodData: {} }
|
|
99
|
+
if (Object.keys(billingDetails).length > 0) {
|
|
100
|
+
params.paymentMethodData.billingDetails = {...billingDetails, token: card?.last4}
|
|
101
|
+
}
|
|
94
102
|
try {
|
|
95
103
|
const { setupIntent, error } = await confirmSetupIntent(requirements, params);
|
|
96
104
|
|
|
@@ -126,12 +134,13 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
126
134
|
<View style={styles.container}>
|
|
127
135
|
{publicKey ? (
|
|
128
136
|
<View style={{ flex: 1 }}>
|
|
129
|
-
<StripeProvider
|
|
137
|
+
<StripeProvider
|
|
130
138
|
publishableKey={publicKey}
|
|
131
|
-
merchantIdentifier={`merchant.${
|
|
139
|
+
merchantIdentifier={`merchant.${merchantId}`}
|
|
140
|
+
urlScheme={merchantId}
|
|
132
141
|
>
|
|
133
142
|
{methodsPay?.includes(paymethod) ? (
|
|
134
|
-
<StripeMethodForm
|
|
143
|
+
<StripeMethodForm
|
|
135
144
|
handleSource={handleSource}
|
|
136
145
|
onCancel={onCancel}
|
|
137
146
|
cart={cart}
|
|
@@ -372,7 +372,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
372
372
|
<Table>
|
|
373
373
|
<OText mBottom={4}>{t('SUBTOTAL', 'Subtotal')}</OText>
|
|
374
374
|
<OText mBottom={4}>
|
|
375
|
-
{parsePrice(((order?.summary?.subtotal ?? order?.subtotal) + getIncludedTaxes()))}
|
|
375
|
+
{parsePrice(((order?.summary?.subtotal ?? order?.subtotal) + getIncludedTaxes()), { currency: order?.currency})}
|
|
376
376
|
</OText>
|
|
377
377
|
</Table>
|
|
378
378
|
{(order?.summary?.discount > 0 ?? order?.discount > 0) && order?.offers?.length === 0 && (
|
|
@@ -385,7 +385,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
385
385
|
) : (
|
|
386
386
|
<OText mBottom={4}>{t('DISCOUNT', theme?.defaultLanguages?.DISCOUNT || 'Discount')}</OText>
|
|
387
387
|
)}
|
|
388
|
-
<OText>- {parsePrice(order?.summary?.discount ?? order?.discount)}</OText>
|
|
388
|
+
<OText>- {parsePrice(order?.summary?.discount ?? order?.discount, { currency: order?.currency})}</OText>
|
|
389
389
|
</Table>
|
|
390
390
|
)}
|
|
391
391
|
{
|
|
@@ -399,7 +399,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
399
399
|
)}
|
|
400
400
|
</OText>
|
|
401
401
|
</OSRow>
|
|
402
|
-
<OText mBottom={4}>- {parsePrice(offer?.summary?.discount)}</OText>
|
|
402
|
+
<OText mBottom={4}>- {parsePrice(offer?.summary?.discount, { currency: order?.currency})}</OText>
|
|
403
403
|
</Table>
|
|
404
404
|
))
|
|
405
405
|
}
|
|
@@ -407,9 +407,9 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
407
407
|
<Table>
|
|
408
408
|
<OText mBottom={4}>{t('SUBTOTAL_WITH_DISCOUNT', 'Subtotal with discount')}</OText>
|
|
409
409
|
{order?.tax_type === 1 ? (
|
|
410
|
-
<OText mBottom={4}>{parsePrice((order?.summary?.subtotal_with_discount + getIncludedTaxesDiscounts() ?? 0))}</OText>
|
|
410
|
+
<OText mBottom={4}>{parsePrice((order?.summary?.subtotal_with_discount + getIncludedTaxesDiscounts() ?? 0), { currency: order?.currency})}</OText>
|
|
411
411
|
) : (
|
|
412
|
-
<OText mBottom={4}>{parsePrice(order?.summary?.subtotal_with_discount ?? 0)}</OText>
|
|
412
|
+
<OText mBottom={4}>{parsePrice(order?.summary?.subtotal_with_discount ?? 0, { currency: order?.currency})}</OText>
|
|
413
413
|
)}
|
|
414
414
|
</Table>
|
|
415
415
|
)}
|
|
@@ -419,7 +419,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
419
419
|
{t('TAX', 'Tax')} {`(${verifyDecimals(order?.tax, parseNumber)}%)`}
|
|
420
420
|
</OText>
|
|
421
421
|
<OText mBottom={4}>
|
|
422
|
-
{parsePrice(order?.summary?.tax ?? 0)}
|
|
422
|
+
{parsePrice(order?.summary?.tax ?? 0, { currency: order?.currency})}
|
|
423
423
|
</OText>
|
|
424
424
|
</Table>
|
|
425
425
|
)}
|
|
@@ -430,7 +430,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
430
430
|
{t('SERVICE_FEE', 'Service fee')}
|
|
431
431
|
{`(${verifyDecimals(order?.service_fee, parseNumber)}%)`}
|
|
432
432
|
</OText>
|
|
433
|
-
<OText mBottom={4}>{parsePrice(order?.summary?.service_fee ?? 0)}</OText>
|
|
433
|
+
<OText mBottom={4}>{parsePrice(order?.summary?.service_fee ?? 0, { currency: order?.currency})}</OText>
|
|
434
434
|
</Table>
|
|
435
435
|
)
|
|
436
436
|
}
|
|
@@ -443,7 +443,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
443
443
|
{`(${verifyDecimals(tax?.rate, parseNumber)}%)`}{' '}
|
|
444
444
|
</OText>
|
|
445
445
|
</OSRow>
|
|
446
|
-
<OText mBottom={4}>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0)}</OText>
|
|
446
|
+
<OText mBottom={4}>{parsePrice(tax?.summary?.tax_after_discount ?? tax?.summary?.tax ?? 0, { currency: order?.currency})}</OText>
|
|
447
447
|
</Table>
|
|
448
448
|
))
|
|
449
449
|
}
|
|
@@ -453,10 +453,10 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
453
453
|
<OSRow>
|
|
454
454
|
<OText mBottom={4}>
|
|
455
455
|
{fee.name || t('INHERIT_FROM_BUSINESS', 'Inherit from business')}
|
|
456
|
-
({fee?.fixed > 0 && `${parsePrice(fee?.fixed)} + `}{fee.percentage}%){' '}
|
|
456
|
+
({fee?.fixed > 0 && `${parsePrice(fee?.fixed, { currency: order?.currency})} + `}{fee.percentage}%){' '}
|
|
457
457
|
</OText>
|
|
458
458
|
</OSRow>
|
|
459
|
-
<OText mBottom={4}>{parsePrice(fee?.summary?.fixed + (fee?.summary?.percentage_after_discount ?? fee?.summary?.percentage) ?? 0)}</OText>
|
|
459
|
+
<OText mBottom={4}>{parsePrice(fee?.summary?.fixed + (fee?.summary?.percentage_after_discount ?? fee?.summary?.percentage) ?? 0, { currency: order?.currency})}</OText>
|
|
460
460
|
</Table>
|
|
461
461
|
))
|
|
462
462
|
}
|
|
@@ -471,7 +471,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
471
471
|
)}
|
|
472
472
|
</OText>
|
|
473
473
|
</OSRow>
|
|
474
|
-
<OText mBottom={4}>- {parsePrice(offer?.summary?.discount)}</OText>
|
|
474
|
+
<OText mBottom={4}>- {parsePrice(offer?.summary?.discount, { currency: order?.currency})}</OText>
|
|
475
475
|
</Table>
|
|
476
476
|
))
|
|
477
477
|
}
|
|
@@ -483,7 +483,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
483
483
|
</OText>
|
|
484
484
|
|
|
485
485
|
<OText mBottom={4}>
|
|
486
|
-
{parsePrice(order?.summary?.delivery_price)}
|
|
486
|
+
{parsePrice(order?.summary?.delivery_price, { currency: order?.currency})}
|
|
487
487
|
</OText>
|
|
488
488
|
</Table>
|
|
489
489
|
)
|
|
@@ -499,7 +499,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
499
499
|
)}
|
|
500
500
|
</OText>
|
|
501
501
|
</OSRow>
|
|
502
|
-
<OText mBottom={4}>- {parsePrice(offer?.summary?.discount)}</OText>
|
|
502
|
+
<OText mBottom={4}>- {parsePrice(offer?.summary?.discount, { currency: order?.currency})}</OText>
|
|
503
503
|
</Table>
|
|
504
504
|
))
|
|
505
505
|
}
|
|
@@ -514,7 +514,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
514
514
|
`(${verifyDecimals(order?.summary?.driver_tip, parseNumber)}%)`
|
|
515
515
|
)}
|
|
516
516
|
</OText>
|
|
517
|
-
<OText mBottom={4}>{parsePrice(order?.summary?.driver_tip ?? order?.totalDriverTip)}</OText>
|
|
517
|
+
<OText mBottom={4}>{parsePrice(order?.summary?.driver_tip ?? order?.totalDriverTip, { currency: order?.currency})}</OText>
|
|
518
518
|
</Table>
|
|
519
519
|
)}
|
|
520
520
|
|
|
@@ -528,7 +528,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
528
528
|
mBottom={4}
|
|
529
529
|
style={styles.textBold}
|
|
530
530
|
color={theme.colors.primary}>
|
|
531
|
-
{parsePrice(order?.summary?.total ?? order?.total)}
|
|
531
|
+
{parsePrice(order?.summary?.total ?? order?.total, { currency: order?.currency})}
|
|
532
532
|
</OText>
|
|
533
533
|
</Table>
|
|
534
534
|
</Total>
|
|
@@ -571,7 +571,7 @@ export const OrderContentComponent = (props: OrderContent) => {
|
|
|
571
571
|
)}
|
|
572
572
|
</View>
|
|
573
573
|
<OText>
|
|
574
|
-
-{parsePrice(event.amount)}
|
|
574
|
+
-{parsePrice(event.amount, { currency: order?.currency})}
|
|
575
575
|
</OText>
|
|
576
576
|
</View>
|
|
577
577
|
))}
|
|
@@ -61,7 +61,9 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
if (user?.address) {
|
|
64
|
-
billingDetails.address
|
|
64
|
+
billingDetails.address = {
|
|
65
|
+
line1: user?.address
|
|
66
|
+
}
|
|
65
67
|
}
|
|
66
68
|
|
|
67
69
|
const createPayMethod = async () => {
|
|
@@ -71,7 +73,13 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
71
73
|
}
|
|
72
74
|
try {
|
|
73
75
|
setCreatePmLoading(true)
|
|
74
|
-
const { paymentMethod } = await createPaymentMethod(params);
|
|
76
|
+
const { paymentMethod, error } = await createPaymentMethod(params);
|
|
77
|
+
|
|
78
|
+
if (error) {
|
|
79
|
+
setErrors(error?.message);
|
|
80
|
+
setCreatePmLoading(false)
|
|
81
|
+
return
|
|
82
|
+
}
|
|
75
83
|
|
|
76
84
|
setCreatePmLoading(false)
|
|
77
85
|
handleSource && handleSource({
|