ordering-ui-react-native 0.15.26 → 0.15.29
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/StripeMethodForm/index.tsx +21 -15
- package/themes/original/src/components/Checkout/index.tsx +3 -1
- package/themes/original/src/components/PaymentOptions/index.tsx +3 -1
- package/themes/original/src/components/StripeElementsForm/index.tsx +3 -1
- package/themes/original/src/components/UpsellingProducts/index.tsx +6 -6
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react'
|
|
2
|
-
import { useLanguage } from 'ordering-components/native'
|
|
2
|
+
import { useLanguage, useConfig } from 'ordering-components/native'
|
|
3
3
|
import { useGooglePay, ApplePayButton, useApplePay } from '@stripe/stripe-react-native'
|
|
4
|
-
import { OButton } from '../shared';
|
|
4
|
+
import { OButton, OText } from '../shared';
|
|
5
5
|
import { Platform, View } from 'react-native';
|
|
6
6
|
import { StripeMethodFormParams } from '../../types';
|
|
7
7
|
import Spinner from 'react-native-loading-spinner-overlay';
|
|
@@ -20,6 +20,7 @@ export const StripeMethodForm = (props: StripeMethodFormParams) => {
|
|
|
20
20
|
const [initialized, setInitialized] = useState(false);
|
|
21
21
|
const [loadingGooglePayment, setLoadingGooglePayment] = useState(false)
|
|
22
22
|
const [, t] = useLanguage()
|
|
23
|
+
const [configs] = useConfig()
|
|
23
24
|
|
|
24
25
|
useEffect(() => {
|
|
25
26
|
if (paymethod !== 'google_pay' || !initGooglePay) return
|
|
@@ -66,7 +67,7 @@ export const StripeMethodForm = (props: StripeMethodFormParams) => {
|
|
|
66
67
|
setLoadingGooglePayment(true)
|
|
67
68
|
const { error, paymentMethod } = await createGooglePayPaymentMethod({
|
|
68
69
|
amount: cart?.balance ?? cart?.total,
|
|
69
|
-
currencyCode: 'USD',
|
|
70
|
+
currencyCode: configs?.stripe_currency?.value ?? 'USD',
|
|
70
71
|
});
|
|
71
72
|
if (error) {
|
|
72
73
|
setErrors(error.code + ' - ' + error.message);
|
|
@@ -97,7 +98,7 @@ export const StripeMethodForm = (props: StripeMethodFormParams) => {
|
|
|
97
98
|
const { error, paymentMethod } = await presentApplePay({
|
|
98
99
|
cartItems: cart?.products?.map((product: any) => ({ label: product?.name, amount: product?.price?.toString?.() })),
|
|
99
100
|
country: 'US',
|
|
100
|
-
currency: 'USD',
|
|
101
|
+
currency: configs?.stripe_currency?.value ?? 'USD',
|
|
101
102
|
shippingMethods: [
|
|
102
103
|
{
|
|
103
104
|
amount: cart?.balance?.toString() ?? cart?.total?.toString?.(),
|
|
@@ -146,17 +147,22 @@ export const StripeMethodForm = (props: StripeMethodFormParams) => {
|
|
|
146
147
|
</View>
|
|
147
148
|
) : (
|
|
148
149
|
<View>
|
|
149
|
-
{isApplePaySupported
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
150
|
+
{isApplePaySupported ? (
|
|
151
|
+
<>
|
|
152
|
+
<OText>{t('APPLE_PAY_PAYMENT', 'Apple pay payment')}</OText>
|
|
153
|
+
<ApplePayButton
|
|
154
|
+
onPress={pay}
|
|
155
|
+
type="plain"
|
|
156
|
+
buttonStyle="black"
|
|
157
|
+
borderRadius={4}
|
|
158
|
+
style={{
|
|
159
|
+
width: '100%',
|
|
160
|
+
height: 50,
|
|
161
|
+
}}
|
|
162
|
+
/>
|
|
163
|
+
</>
|
|
164
|
+
) : (
|
|
165
|
+
<OText>{t('APPLE_PAY_NOT_SUPPORTED', 'Apple pay not supported')}</OText>
|
|
160
166
|
)}
|
|
161
167
|
</View>
|
|
162
168
|
)}
|
|
@@ -85,7 +85,8 @@ const CheckoutUI = (props: any) => {
|
|
|
85
85
|
deliveryOptionSelected,
|
|
86
86
|
instructionsOptions,
|
|
87
87
|
handleChangeDeliveryOption,
|
|
88
|
-
currency
|
|
88
|
+
currency,
|
|
89
|
+
merchantId
|
|
89
90
|
} = props
|
|
90
91
|
|
|
91
92
|
const theme = useTheme();
|
|
@@ -547,6 +548,7 @@ const CheckoutUI = (props: any) => {
|
|
|
547
548
|
paySelected={paymethodSelected}
|
|
548
549
|
handlePaymentMethodClickCustom={handlePaymentMethodClick}
|
|
549
550
|
handlePlaceOrder={handlePlaceOrder}
|
|
551
|
+
merchantId={merchantId}
|
|
550
552
|
/>
|
|
551
553
|
</ChPaymethods>
|
|
552
554
|
</ChSection>
|
|
@@ -57,7 +57,8 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
57
57
|
handlePaymethodDataChange,
|
|
58
58
|
isOpenMethod,
|
|
59
59
|
handlePaymentMethodClickCustom,
|
|
60
|
-
handlePlaceOrder
|
|
60
|
+
handlePlaceOrder,
|
|
61
|
+
merchantId
|
|
61
62
|
} = props
|
|
62
63
|
|
|
63
64
|
const theme = useTheme();
|
|
@@ -316,6 +317,7 @@ const PaymentOptionsUI = (props: any) => {
|
|
|
316
317
|
publicKey={isOpenMethod?.paymethod?.credentials?.publishable || isOpenMethod?.paymethod?.credentials?.publishable_key}
|
|
317
318
|
handleSource={handlePaymethodDataChange}
|
|
318
319
|
onCancel={() => handlePaymethodClick(null)}
|
|
320
|
+
merchantId={merchantId}
|
|
319
321
|
/>
|
|
320
322
|
</KeyboardAvoidingView>
|
|
321
323
|
</OModal>
|
|
@@ -27,6 +27,7 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
27
27
|
paymethod,
|
|
28
28
|
onCancel,
|
|
29
29
|
cart,
|
|
30
|
+
merchantId
|
|
30
31
|
} = props;
|
|
31
32
|
|
|
32
33
|
const theme = useTheme();
|
|
@@ -160,7 +161,8 @@ const StripeElementsFormUI = (props: any) => {
|
|
|
160
161
|
<View style={{ flex: 1 }}>
|
|
161
162
|
<StripeProvider
|
|
162
163
|
publishableKey={publicKey}
|
|
163
|
-
merchantIdentifier={`merchant.${
|
|
164
|
+
merchantIdentifier={`merchant.${merchantId}`}
|
|
165
|
+
urlScheme={merchantId}
|
|
164
166
|
>
|
|
165
167
|
{methodsPay?.includes(paymethod) ? (
|
|
166
168
|
<StripeMethodForm
|
|
@@ -157,6 +157,12 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
157
157
|
</TopActions>
|
|
158
158
|
</TopBar>
|
|
159
159
|
<ScrollView style={{ marginBottom: props.isPage ? 40 : bottom + (Platform.OS == 'ios' ? 96 : 130) }} showsVerticalScrollIndicator={false}>
|
|
160
|
+
{productsList.length > 0 &&
|
|
161
|
+
<View style={{ paddingHorizontal: 40, overflow: 'visible' }}>
|
|
162
|
+
<OText size={16} lineHeight={24} weight={'500'}>{t('WANT_SOMETHING_ELSE', 'Do you want something else?')}</OText>
|
|
163
|
+
<UpsellingLayout />
|
|
164
|
+
</View>
|
|
165
|
+
}
|
|
160
166
|
<View style={{ paddingHorizontal: 40 }}>
|
|
161
167
|
<OText size={20} lineHeight={30} weight={600} style={{ marginTop: 10, marginBottom: 17 }}>{t('YOUR_CART', 'Your cart')}</OText>
|
|
162
168
|
<OrderSummary
|
|
@@ -165,12 +171,6 @@ const UpsellingProductsUI = (props: UpsellingProductsParams) => {
|
|
|
165
171
|
onNavigationRedirect={onNavigationRedirect}
|
|
166
172
|
/>
|
|
167
173
|
</View>
|
|
168
|
-
{productsList.length > 0 &&
|
|
169
|
-
<View style={{ paddingHorizontal: 40, overflow: 'visible' }}>
|
|
170
|
-
<OText size={16} lineHeight={24} weight={'500'}>{t('WANT_SOMETHING_ELSE', 'Do you want something else?')}</OText>
|
|
171
|
-
<UpsellingLayout />
|
|
172
|
-
</View>
|
|
173
|
-
}
|
|
174
174
|
</ScrollView>
|
|
175
175
|
<View
|
|
176
176
|
style={{
|