ordering-ui-react-native 0.21.29 → 0.21.30

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.21.29",
3
+ "version": "0.21.30",
4
4
  "description": "Reusable components made in react native",
5
5
  "main": "src/index.tsx",
6
6
  "author": "ordering.inc",
@@ -162,6 +162,7 @@ const CheckoutUI = (props: any) => {
162
162
  const [allowedGuest, setAllowedGuest] = useState(false)
163
163
  const [placeByMethodPay, setPlaceByMethodPay] = useState(false)
164
164
  const [methodPaySupported, setMethodPaySupported] = useState({ enabled: false, message: null, loading: true })
165
+ const [paymethodClicked, setPaymethodClicked] = useState<any>(null)
165
166
  const [cardList, setCardList] = useState<any>({ cards: [], loading: false, error: null })
166
167
  const cardsMethods = ['credomatic']
167
168
  const stripePaymethods: any = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect']
@@ -742,6 +743,10 @@ const CheckoutUI = (props: any) => {
742
743
  setPlaceByMethodPay={setPlaceByMethodPay}
743
744
  cardList={cardList}
744
745
  setCardList={setCardList}
746
+ requiredFields={requiredFields}
747
+ openUserModal={setIsOpen}
748
+ paymethodClicked={paymethodClicked}
749
+ setPaymethodClicked={setPaymethodClicked}
745
750
  />
746
751
  </ChPaymethods>
747
752
  </ChSection>
@@ -926,7 +931,14 @@ const CheckoutUI = (props: any) => {
926
931
  handlePlaceOrderAsGuest={handlePlaceOrderAsGuest}
927
932
  onClose={() => {
928
933
  setIsOpen(false)
929
- handlePlaceOrder(null, true)
934
+ if (paymethodClicked) {
935
+ setPaymethodClicked({
936
+ ...paymethodClicked,
937
+ confirmed: true
938
+ })
939
+ } else {
940
+ handlePlaceOrder(null, true)
941
+ }
930
942
  }}
931
943
  setIsOpen={setIsOpen}
932
944
  />
@@ -69,7 +69,11 @@ const PaymentOptionsUI = (props: any) => {
69
69
  methodPaySupported,
70
70
  setPlaceByMethodPay,
71
71
  setCardList,
72
- onPaymentChange
72
+ onPaymentChange,
73
+ requiredFields,
74
+ openUserModal,
75
+ paymethodClicked,
76
+ setPaymethodClicked
73
77
  } = props
74
78
 
75
79
  const theme = useTheme();
@@ -115,6 +119,14 @@ const PaymentOptionsUI = (props: any) => {
115
119
 
116
120
  const handlePaymentMethodClick = (paymethod: any) => {
117
121
  if (cart?.balance > 0) {
122
+ if (paymethod?.gateway === 'paypal' && requiredFields.length > 0) {
123
+ openUserModal && openUserModal(true)
124
+ setPaymethodClicked({
125
+ confirmed: false,
126
+ paymethod
127
+ })
128
+ return
129
+ }
118
130
  const isPopupMethod = ['stripe', 'stripe_direct', 'stripe_connect', 'stripe_redirect', 'paypal'].includes(paymethod?.gateway)
119
131
  if (webViewPaymentGateway.includes(paymethod?.gateway)) {
120
132
  handlePaymentMethodClickCustom(paymethod)
@@ -159,7 +171,14 @@ const PaymentOptionsUI = (props: any) => {
159
171
  handlePlaceOrder(confirmApplePayPayment)
160
172
  }
161
173
  }, [paymethodData, paymethodSelected])
162
-
174
+
175
+ useEffect(() => {
176
+ if (paymethodClicked?.confirmed) {
177
+ handlePaymentMethodClickCustom(paymethodClicked?.paymethod)
178
+ }
179
+ }, [paymethodClicked?.confirmed])
180
+
181
+
163
182
  const renderPaymethods = ({ item }: any) => {
164
183
  return (
165
184
  <>