ordering-ui-react-native 0.16.74 → 0.16.75

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.16.74",
3
+ "version": "0.16.75",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -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>
@@ -62,7 +62,8 @@ const PaymentOptionsUI = (props: any) => {
62
62
  handlePaymentMethodClickCustom,
63
63
  isOpenMethod,
64
64
  setCardData,
65
- handlePlaceOrder
65
+ handlePlaceOrder,
66
+ merchantId
66
67
  } = props
67
68
 
68
69
  const theme = useTheme();
@@ -220,7 +221,7 @@ const PaymentOptionsUI = (props: any) => {
220
221
 
221
222
  {paymethodSelected?.gateway === 'cash' && (
222
223
  <PaymentOptionCash
223
- orderTotal={cart.total}
224
+ orderTotal={cart.balance ?? cart.total}
224
225
  defaultValue={paymethodSelected?.data?.cash}
225
226
  onChangeData={handlePaymethodDataChange}
226
227
  setErrorCash={props.setErrorCash}
@@ -322,6 +323,7 @@ const PaymentOptionsUI = (props: any) => {
322
323
  publicKey={isOpenMethod?.paymethod?.credentials?.publishable || isOpenMethod?.paymethod?.credentials?.publishable_key}
323
324
  handleSource={handlePaymethodDataChange}
324
325
  onCancel={() => handlePaymethodClick(null)}
326
+ merchantId={merchantId}
325
327
  />
326
328
  </KeyboardAvoidingView>
327
329
  </OModal>
@@ -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
- billingDetails.addressLine1 = user?.address
58
- }
57
+ billingDetails.address = {
58
+ line1: user?.address
59
+ }
60
+ }
59
61
 
60
62
  const createPayMethod = async () => {
61
- const params: any = { type: 'Card' }
62
- if (Object.keys(billingDetails).length > 0) {
63
- params.billingDetails = billingDetails
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 = { type: 'Card' }
91
- if (Object.keys(billingDetails).length > 0) {
92
- params.billingDetails = billingDetails
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.${configs.apple_app_id}`}
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
  ))}
@@ -160,7 +160,6 @@ const PaymentOptionsUI = (props: any) => {
160
160
  <TouchableOpacity
161
161
  onPress={() => handlePaymentMethodClick(item)}
162
162
  >
163
- {console.log(item?.gateway)}
164
163
  <PMItem
165
164
  key={item.id}
166
165
  isDisabled={isDisabled}
@@ -61,7 +61,9 @@ const StripeElementsFormUI = (props: any) => {
61
61
  }
62
62
 
63
63
  if (user?.address) {
64
- billingDetails.address.line1 = user?.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({