@pelcro/react-pelcro-js 3.22.0 → 3.22.1

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/dist/index.cjs.js CHANGED
@@ -16628,19 +16628,25 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16628
16628
 
16629
16629
  /*====== Start Cybersource integration ========*/
16630
16630
  const cybersourceErrorHandle = err => {
16631
- var _err$details, _err$details$response;
16632
- const errorMessages = [];
16631
+ var _err$details, _err$details$response, _err$details$response2;
16632
+ if ((err === null || err === void 0 ? void 0 : (_err$details = err.details) === null || _err$details === void 0 ? void 0 : (_err$details$response = _err$details.responseStatus) === null || _err$details$response === void 0 ? void 0 : (_err$details$response2 = _err$details$response.details) === null || _err$details$response2 === void 0 ? void 0 : _err$details$response2.length) > 0) {
16633
+ var _err$details2, _err$details2$respons;
16634
+ const errorMessages = [];
16633
16635
 
16634
- // enumerable error (ex: validation errors)
16635
- Object.values(err === null || err === void 0 ? void 0 : (_err$details = err.details) === null || _err$details === void 0 ? void 0 : (_err$details$response = _err$details.responseStatus) === null || _err$details$response === void 0 ? void 0 : _err$details$response.details).forEach(_ref2 => {
16636
- let {
16637
- message
16638
- } = _ref2;
16639
- errorMessages.push(message);
16640
- });
16636
+ // enumerable error (ex: validation errors)
16637
+ Object.values(err === null || err === void 0 ? void 0 : (_err$details2 = err.details) === null || _err$details2 === void 0 ? void 0 : (_err$details2$respons = _err$details2.responseStatus) === null || _err$details2$respons === void 0 ? void 0 : _err$details2$respons.details).forEach(_ref2 => {
16638
+ let {
16639
+ message
16640
+ } = _ref2;
16641
+ errorMessages.push(message);
16642
+ });
16641
16643
 
16642
- // convert to multiline string
16643
- return errorMessages.join("\n");
16644
+ // convert to multiline string
16645
+ return errorMessages.join("\n");
16646
+ } else {
16647
+ var _err$details3;
16648
+ return getErrorMessages(err === null || err === void 0 ? void 0 : (_err$details3 = err.details) === null || _err$details3 === void 0 ? void 0 : _err$details3.responseStatus);
16649
+ }
16644
16650
  };
16645
16651
  const submitUsingCybersource = (state, dispatch) => {
16646
16652
  var _cybersourceInstanceR;
@@ -18720,12 +18726,12 @@ const CheckoutForm = () => {
18720
18726
  className: "plc-w-6/12 plc-pr-4"
18721
18727
  }, /*#__PURE__*/React__default['default'].createElement(MonthSelect, {
18722
18728
  store: store$k,
18723
- placeholder: "Exp Month"
18729
+ placeholder: "Exp Month *"
18724
18730
  })), /*#__PURE__*/React__default['default'].createElement("div", {
18725
18731
  className: "plc-w-6/12"
18726
18732
  }, /*#__PURE__*/React__default['default'].createElement(YearSelect, {
18727
18733
  store: store$k,
18728
- placeholder: "Exp Year"
18734
+ placeholder: "Exp Year *"
18729
18735
  }))));
18730
18736
  }
18731
18737
  if (cardProcessor === "stripe") {
@@ -18788,13 +18794,14 @@ const DiscountedPrice = props => {
18788
18794
  };
18789
18795
 
18790
18796
  const SubmitPaymentMethod = _ref => {
18791
- var _plan$quantity, _window$Pelcro$site$r;
18797
+ var _plan$quantity, _window$Pelcro$site$r, _window$Pelcro$site$r2;
18792
18798
  let {
18793
18799
  onClick,
18794
18800
  ...otherProps
18795
18801
  } = _ref;
18796
18802
  const {
18797
- plan
18803
+ plan,
18804
+ selectedPaymentMethodId
18798
18805
  } = usePelcro();
18799
18806
  const {
18800
18807
  t
@@ -18810,13 +18817,16 @@ const SubmitPaymentMethod = _ref => {
18810
18817
  phone,
18811
18818
  disableSubmit,
18812
18819
  isLoading,
18813
- updatedPrice
18820
+ updatedPrice,
18821
+ month,
18822
+ year
18814
18823
  }
18815
18824
  } = React.useContext(store$k);
18816
18825
  const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
18817
18826
  const price = updatedPrice !== null && updatedPrice !== void 0 ? updatedPrice : plan === null || plan === void 0 ? void 0 : plan.amount;
18818
18827
  const priceFormatted = getFormattedPriceByLocal(price * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
18819
18828
  const supportsTap = Boolean((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.tap_gateway_settings);
18829
+ const supportsCybersource = Boolean((_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.cybersource_gateway_settings);
18820
18830
  const isUserFirstName = Boolean(window.Pelcro.user.read().first_name);
18821
18831
  const isUserLastName = Boolean(window.Pelcro.user.read().last_name);
18822
18832
  const isUserPhone = Boolean(window.Pelcro.user.read().phone);
@@ -18825,9 +18835,9 @@ const SubmitPaymentMethod = _ref => {
18825
18835
  if (supportsTap && isUserFirstName && isUserLastName && isUserPhone) {
18826
18836
  setDisabled(disableSubmit);
18827
18837
  } else {
18828
- setDisabled(disableSubmit || supportsTap && firstNameError || supportsTap && lastNameError || supportsTap && phoneError || supportsTap && !(firstName !== null && firstName !== void 0 && firstName.length) || supportsTap && !(lastName !== null && lastName !== void 0 && lastName.length) || supportsTap && !(phone !== null && phone !== void 0 && phone.length));
18838
+ setDisabled(disableSubmit || supportsTap && firstNameError || supportsTap && lastNameError || supportsTap && phoneError || supportsTap && !(firstName !== null && firstName !== void 0 && firstName.length) || supportsTap && !(lastName !== null && lastName !== void 0 && lastName.length) || supportsTap && !(phone !== null && phone !== void 0 && phone.length) || supportsCybersource && !selectedPaymentMethodId && !(month !== null && month !== void 0 && month.length) || supportsCybersource && !selectedPaymentMethodId && !(year !== null && year !== void 0 && year.length));
18829
18839
  }
18830
- }, [disableSubmit, firstNameError, lastNameError, phoneError, firstName, lastName, phone]);
18840
+ }, [disableSubmit, firstNameError, lastNameError, phoneError, firstName, lastName, phone, month, year]);
18831
18841
  return /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({
18832
18842
  role: "submit",
18833
18843
  className: "plc-w-full plc-py-3",
package/dist/index.esm.js CHANGED
@@ -16598,19 +16598,25 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16598
16598
 
16599
16599
  /*====== Start Cybersource integration ========*/
16600
16600
  const cybersourceErrorHandle = err => {
16601
- var _err$details, _err$details$response;
16602
- const errorMessages = [];
16601
+ var _err$details, _err$details$response, _err$details$response2;
16602
+ if ((err === null || err === void 0 ? void 0 : (_err$details = err.details) === null || _err$details === void 0 ? void 0 : (_err$details$response = _err$details.responseStatus) === null || _err$details$response === void 0 ? void 0 : (_err$details$response2 = _err$details$response.details) === null || _err$details$response2 === void 0 ? void 0 : _err$details$response2.length) > 0) {
16603
+ var _err$details2, _err$details2$respons;
16604
+ const errorMessages = [];
16603
16605
 
16604
- // enumerable error (ex: validation errors)
16605
- Object.values(err === null || err === void 0 ? void 0 : (_err$details = err.details) === null || _err$details === void 0 ? void 0 : (_err$details$response = _err$details.responseStatus) === null || _err$details$response === void 0 ? void 0 : _err$details$response.details).forEach(_ref2 => {
16606
- let {
16607
- message
16608
- } = _ref2;
16609
- errorMessages.push(message);
16610
- });
16606
+ // enumerable error (ex: validation errors)
16607
+ Object.values(err === null || err === void 0 ? void 0 : (_err$details2 = err.details) === null || _err$details2 === void 0 ? void 0 : (_err$details2$respons = _err$details2.responseStatus) === null || _err$details2$respons === void 0 ? void 0 : _err$details2$respons.details).forEach(_ref2 => {
16608
+ let {
16609
+ message
16610
+ } = _ref2;
16611
+ errorMessages.push(message);
16612
+ });
16611
16613
 
16612
- // convert to multiline string
16613
- return errorMessages.join("\n");
16614
+ // convert to multiline string
16615
+ return errorMessages.join("\n");
16616
+ } else {
16617
+ var _err$details3;
16618
+ return getErrorMessages(err === null || err === void 0 ? void 0 : (_err$details3 = err.details) === null || _err$details3 === void 0 ? void 0 : _err$details3.responseStatus);
16619
+ }
16614
16620
  };
16615
16621
  const submitUsingCybersource = (state, dispatch) => {
16616
16622
  var _cybersourceInstanceR;
@@ -18690,12 +18696,12 @@ const CheckoutForm = () => {
18690
18696
  className: "plc-w-6/12 plc-pr-4"
18691
18697
  }, /*#__PURE__*/React__default.createElement(MonthSelect, {
18692
18698
  store: store$k,
18693
- placeholder: "Exp Month"
18699
+ placeholder: "Exp Month *"
18694
18700
  })), /*#__PURE__*/React__default.createElement("div", {
18695
18701
  className: "plc-w-6/12"
18696
18702
  }, /*#__PURE__*/React__default.createElement(YearSelect, {
18697
18703
  store: store$k,
18698
- placeholder: "Exp Year"
18704
+ placeholder: "Exp Year *"
18699
18705
  }))));
18700
18706
  }
18701
18707
  if (cardProcessor === "stripe") {
@@ -18758,13 +18764,14 @@ const DiscountedPrice = props => {
18758
18764
  };
18759
18765
 
18760
18766
  const SubmitPaymentMethod = _ref => {
18761
- var _plan$quantity, _window$Pelcro$site$r;
18767
+ var _plan$quantity, _window$Pelcro$site$r, _window$Pelcro$site$r2;
18762
18768
  let {
18763
18769
  onClick,
18764
18770
  ...otherProps
18765
18771
  } = _ref;
18766
18772
  const {
18767
- plan
18773
+ plan,
18774
+ selectedPaymentMethodId
18768
18775
  } = usePelcro();
18769
18776
  const {
18770
18777
  t
@@ -18780,13 +18787,16 @@ const SubmitPaymentMethod = _ref => {
18780
18787
  phone,
18781
18788
  disableSubmit,
18782
18789
  isLoading,
18783
- updatedPrice
18790
+ updatedPrice,
18791
+ month,
18792
+ year
18784
18793
  }
18785
18794
  } = useContext(store$k);
18786
18795
  const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
18787
18796
  const price = updatedPrice !== null && updatedPrice !== void 0 ? updatedPrice : plan === null || plan === void 0 ? void 0 : plan.amount;
18788
18797
  const priceFormatted = getFormattedPriceByLocal(price * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
18789
18798
  const supportsTap = Boolean((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.tap_gateway_settings);
18799
+ const supportsCybersource = Boolean((_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.cybersource_gateway_settings);
18790
18800
  const isUserFirstName = Boolean(window.Pelcro.user.read().first_name);
18791
18801
  const isUserLastName = Boolean(window.Pelcro.user.read().last_name);
18792
18802
  const isUserPhone = Boolean(window.Pelcro.user.read().phone);
@@ -18795,9 +18805,9 @@ const SubmitPaymentMethod = _ref => {
18795
18805
  if (supportsTap && isUserFirstName && isUserLastName && isUserPhone) {
18796
18806
  setDisabled(disableSubmit);
18797
18807
  } else {
18798
- setDisabled(disableSubmit || supportsTap && firstNameError || supportsTap && lastNameError || supportsTap && phoneError || supportsTap && !(firstName !== null && firstName !== void 0 && firstName.length) || supportsTap && !(lastName !== null && lastName !== void 0 && lastName.length) || supportsTap && !(phone !== null && phone !== void 0 && phone.length));
18808
+ setDisabled(disableSubmit || supportsTap && firstNameError || supportsTap && lastNameError || supportsTap && phoneError || supportsTap && !(firstName !== null && firstName !== void 0 && firstName.length) || supportsTap && !(lastName !== null && lastName !== void 0 && lastName.length) || supportsTap && !(phone !== null && phone !== void 0 && phone.length) || supportsCybersource && !selectedPaymentMethodId && !(month !== null && month !== void 0 && month.length) || supportsCybersource && !selectedPaymentMethodId && !(year !== null && year !== void 0 && year.length));
18799
18809
  }
18800
- }, [disableSubmit, firstNameError, lastNameError, phoneError, firstName, lastName, phone]);
18810
+ }, [disableSubmit, firstNameError, lastNameError, phoneError, firstName, lastName, phone, month, year]);
18801
18811
  return /*#__PURE__*/React__default.createElement(Button, Object.assign({
18802
18812
  role: "submit",
18803
18813
  className: "plc-w-full plc-py-3",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pelcro/react-pelcro-js",
3
3
  "description": "Pelcro's React UI Elements",
4
- "version": "3.22.0",
4
+ "version": "3.22.1",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",