@pelcro/react-pelcro-js 4.0.0-alpha.35 → 4.0.0-alpha.36

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
@@ -3453,7 +3453,8 @@ var labels$10 = {
3453
3453
  removeCoupon: "REMOVE",
3454
3454
  firstName: "First name",
3455
3455
  lastName: "Last name",
3456
- phone: "Phone"
3456
+ phone: "Phone",
3457
+ freeItems: "Free Items"
3457
3458
  };
3458
3459
  var checkoutForm_en = {
3459
3460
  messages: messages$14,
@@ -4397,7 +4398,8 @@ var labels$H = {
4397
4398
  removeCoupon: "RETIRER",
4398
4399
  firstName: "Prénom",
4399
4400
  lastName: "Nom de famille",
4400
- phone: "Téléphoner"
4401
+ phone: "Téléphoner",
4402
+ freeItems: "Articles gratuits"
4401
4403
  };
4402
4404
  var checkoutForm_fr = {
4403
4405
  messages: messages$M,
@@ -5288,7 +5290,8 @@ var labels$s = {
5288
5290
  removeCoupon: "제거",
5289
5291
  firstName: "이름",
5290
5292
  lastName: "성",
5291
- phone: "핸드폰"
5293
+ phone: "핸드폰",
5294
+ freeItems: "무료 아이템"
5292
5295
  };
5293
5296
  var checkoutForm_ko = {
5294
5297
  messages: messages$v,
@@ -6228,7 +6231,8 @@ var labels$d = {
6228
6231
  removeCoupon: "ELIMINAR",
6229
6232
  firstName: "Nombre",
6230
6233
  lastName: "Apellido",
6231
- phone: "Teléfono"
6234
+ phone: "Teléfono",
6235
+ freeItems: "Artículos gratis"
6232
6236
  };
6233
6237
  var checkoutForm_es = {
6234
6238
  messages: messages$e,
@@ -8865,7 +8869,7 @@ const calcAndFormatItemsTotal = (items, currency) => {
8865
8869
  let totalWithoutDividingBy100 = 0;
8866
8870
 
8867
8871
  for (const item of items) {
8868
- totalWithoutDividingBy100 += parseFloat(item.price ? isCurrencyZeroDecimal(currency) ? item.price * item.quantity : (item.price * item.quantity).toFixed(2) : isCurrencyZeroDecimal(currency) ? item.amount : item.amount.toFixed(2));
8872
+ totalWithoutDividingBy100 += parseFloat(item !== null && item !== void 0 && item.price || (item === null || item === void 0 ? void 0 : item.price) === 0 ? isCurrencyZeroDecimal(currency) ? item.price * item.quantity : (item.price * item.quantity).toFixed(2) : isCurrencyZeroDecimal(currency) ? item.amount : item.amount.toFixed(2));
8869
8873
  }
8870
8874
 
8871
8875
  return getFormattedPriceByLocal(totalWithoutDividingBy100, currency, getPageOrDefaultLanguage());
@@ -11478,6 +11482,10 @@ const initViewFromURL = () => {
11478
11482
  return showSubscriptionManageMembersFromUrl();
11479
11483
  }
11480
11484
 
11485
+ if (view === "payment-method-update") {
11486
+ return showPaymentMethodUpdateFromUrl();
11487
+ }
11488
+
11481
11489
  switchView(view);
11482
11490
  });
11483
11491
  }
@@ -11713,6 +11721,47 @@ const showPasswordlessRequestFromUrl = () => {
11713
11721
  return switchView("passwordless-request");
11714
11722
  };
11715
11723
 
11724
+ const showPaymentMethodUpdateFromUrl = () => {
11725
+ const {
11726
+ isAuthenticated,
11727
+ whenSiteReady,
11728
+ whenUserReady,
11729
+ switchView
11730
+ } = usePelcro.getStore();
11731
+ whenSiteReady(() => {
11732
+ if (!isAuthenticated()) {
11733
+ return switchView("login");
11734
+ }
11735
+
11736
+ whenUserReady(() => {
11737
+ const supportsVantiv = Boolean(window.Pelcro.site.read().vantiv_gateway_settings);
11738
+ const supportsTap = Boolean(window.Pelcro.site.read().tap_gateway_settings);
11739
+
11740
+ if (!window.Stripe && !supportsVantiv && !supportsTap) {
11741
+ document.querySelector('script[src="https://js.stripe.com/v3"]').addEventListener("load", () => {
11742
+ return switchView("payment-method-update");
11743
+ });
11744
+ return;
11745
+ } //vantiv
11746
+
11747
+
11748
+ if (supportsVantiv) {
11749
+ document.querySelector("#vantiv-eprotect-sdk").addEventListener("load", () => {
11750
+ return switchView("payment-method-update");
11751
+ });
11752
+ return;
11753
+ } //Tap
11754
+
11755
+
11756
+ if (supportsTap && document.querySelector("#tap-sdk")) {
11757
+ return switchView("payment-method-update");
11758
+ }
11759
+
11760
+ return switchView("payment-method-update");
11761
+ });
11762
+ });
11763
+ };
11764
+
11716
11765
  const showInvoiceDetailsFromUrl = () => {
11717
11766
  const {
11718
11767
  isAuthenticated,
@@ -13670,7 +13719,7 @@ function LoginModal({
13670
13719
 
13671
13720
  resetView();
13672
13721
  const viewFromURL = getStableViewID(window.Pelcro.helpers.getURLParameter("view"));
13673
- const viewsURLs = ["invoice-details", "gift-redeem", "plan-select"];
13722
+ const viewsURLs = ["invoice-details", "gift-redeem", "plan-select", "payment-method-update"];
13674
13723
 
13675
13724
  if (viewsURLs.includes(viewFromURL)) {
13676
13725
  initViewFromURL();
@@ -18985,6 +19034,29 @@ function SelectModalWithHook(props) {
18985
19034
  matchingEntitlements: view === "_plan-select-entitlements" ? entitlements : null
18986
19035
  });
18987
19036
  }
19037
+
19038
+ function productsWithMatchedTaggedFirst() {
19039
+ var _window$Pelcro$produc;
19040
+
19041
+ const allProducts = (_window$Pelcro$produc = window.Pelcro.product.list()) !== null && _window$Pelcro$produc !== void 0 ? _window$Pelcro$produc : [];
19042
+ const productsThatMatchArticleTag = window.Pelcro.product.getByMatchingPageTags();
19043
+ const allProductsMinusMatched = allProducts.filter(product => !productsThatMatchArticleTag.some(matchedProduct => matchedProduct.id === product.id));
19044
+ return [productsThatMatchArticleTag, allProductsMinusMatched];
19045
+ }
19046
+
19047
+ function productMatchPageLanguage(product) {
19048
+ if (!product) {
19049
+ return false;
19050
+ }
19051
+
19052
+ if (product.language === null) {
19053
+ return true;
19054
+ }
19055
+
19056
+ const siteLanguage = window.Pelcro.helpers.getHtmlLanguageAttribute();
19057
+ return product.language === siteLanguage;
19058
+ }
19059
+
18988
19060
  SelectModalWithHook.viewId = "plan-select";
18989
19061
 
18990
19062
  class SelectModal extends React.Component {
@@ -19029,19 +19101,50 @@ class SelectModal extends React.Component {
19029
19101
  document.addEventListener("keydown", this.handleSubmit);
19030
19102
 
19031
19103
  if (!document.querySelector("#pelcro-selection-view") || !document.querySelector(".pelcro-select-product-wrapper")) {
19104
+ var _window$Pelcro, _window$Pelcro$user, _window$Pelcro2, _window$Pelcro2$user, _window$Pelcro3, _window$Pelcro3$user, _window$Pelcro4, _window$Pelcro4$site;
19105
+
19106
+ const userCurrency = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$user = _window$Pelcro.user) === null || _window$Pelcro$user === void 0 ? void 0 : _window$Pelcro$user.read().currency;
19107
+ const userCountry = (_window$Pelcro2 = window.Pelcro) === null || _window$Pelcro2 === void 0 ? void 0 : (_window$Pelcro2$user = _window$Pelcro2.user) === null || _window$Pelcro2$user === void 0 ? void 0 : _window$Pelcro2$user.location.countryCode;
19108
+ const userLanguage = (_window$Pelcro3 = window.Pelcro) === null || _window$Pelcro3 === void 0 ? void 0 : (_window$Pelcro3$user = _window$Pelcro3.user) === null || _window$Pelcro3$user === void 0 ? void 0 : _window$Pelcro3$user.read().language;
19109
+ const productsMatchingUserCurrency = (_window$Pelcro4 = window.Pelcro) === null || _window$Pelcro4 === void 0 ? void 0 : (_window$Pelcro4$site = _window$Pelcro4.site) === null || _window$Pelcro4$site === void 0 ? void 0 : _window$Pelcro4$site.read().products.filter(product => {
19110
+ const filteredPlans = product.plans.filter(plan => plan.currency === userCurrency || !userCurrency);
19111
+ if (filteredPlans.length) return filteredPlans;
19112
+ });
19113
+ const productsMatchingUserCountry = productsMatchingUserCurrency.filter(product => {
19114
+ const filteredPlans = product.plans.filter(plan => {
19115
+ var _plan$countries;
19116
+
19117
+ return plan.countries && ((_plan$countries = plan.countries) === null || _plan$countries === void 0 ? void 0 : _plan$countries.includes(userCountry)) || !plan.countries || !plan.countries.length;
19118
+ });
19119
+ if (filteredPlans.length) return filteredPlans;
19120
+ });
19032
19121
  notifyBugsnag(() => {
19033
19122
  Bugsnag.notify("SelectModal - No data viewed", event => {
19034
- var _window$Pelcro, _window$Pelcro$site, _window$Pelcro2, _window$Pelcro2$user, _window$Pelcro3, _window$Pelcro3$uiSet, _window$Pelcro4;
19123
+ var _window$Pelcro5, _window$Pelcro5$site, _window$Pelcro6, _window$Pelcro6$user, _window$Pelcro7, _window$Pelcro7$uiSet, _window$Pelcro8, _this$props, _window$Pelcro9, _window$Pelcro9$helpe, _window$Pelcro10, _window$Pelcro10$site;
19035
19124
 
19036
19125
  event.addMetadata("MetaData", {
19037
- site: (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$site = _window$Pelcro.site) === null || _window$Pelcro$site === void 0 ? void 0 : _window$Pelcro$site.read(),
19038
- user: (_window$Pelcro2 = window.Pelcro) === null || _window$Pelcro2 === void 0 ? void 0 : (_window$Pelcro2$user = _window$Pelcro2.user) === null || _window$Pelcro2$user === void 0 ? void 0 : _window$Pelcro2$user.read(),
19039
- uiVersion: (_window$Pelcro3 = window.Pelcro) === null || _window$Pelcro3 === void 0 ? void 0 : (_window$Pelcro3$uiSet = _window$Pelcro3.uiSettings) === null || _window$Pelcro3$uiSet === void 0 ? void 0 : _window$Pelcro3$uiSet.uiVersion,
19040
- environment: (_window$Pelcro4 = window.Pelcro) === null || _window$Pelcro4 === void 0 ? void 0 : _window$Pelcro4.environment
19126
+ site: (_window$Pelcro5 = window.Pelcro) === null || _window$Pelcro5 === void 0 ? void 0 : (_window$Pelcro5$site = _window$Pelcro5.site) === null || _window$Pelcro5$site === void 0 ? void 0 : _window$Pelcro5$site.read(),
19127
+ user: (_window$Pelcro6 = window.Pelcro) === null || _window$Pelcro6 === void 0 ? void 0 : (_window$Pelcro6$user = _window$Pelcro6.user) === null || _window$Pelcro6$user === void 0 ? void 0 : _window$Pelcro6$user.read(),
19128
+ uiVersion: (_window$Pelcro7 = window.Pelcro) === null || _window$Pelcro7 === void 0 ? void 0 : (_window$Pelcro7$uiSet = _window$Pelcro7.uiSettings) === null || _window$Pelcro7$uiSet === void 0 ? void 0 : _window$Pelcro7$uiSet.uiVersion,
19129
+ environment: (_window$Pelcro8 = window.Pelcro) === null || _window$Pelcro8 === void 0 ? void 0 : _window$Pelcro8.environment,
19130
+ matchingEntitlementsProps: (_this$props = this.props) === null || _this$props === void 0 ? void 0 : _this$props.matchingEntitlements,
19131
+ productListState: this.state.productList,
19132
+ methods: {
19133
+ productsWithMatchedTaggedFirst: productsWithMatchedTaggedFirst(),
19134
+ pelcroSDKProductsListMethod: window.Pelcro.product.list(),
19135
+ pelcroSDKGetByEntitlements: this.props.matchingEntitlements ? window.Pelcro.product.getByEntitlements(this.props.matchingEntitlements) : null
19136
+ },
19137
+ userCurrency: userCurrency,
19138
+ userCountry: userCountry,
19139
+ userLanguage: userLanguage,
19140
+ siteLanguage: (_window$Pelcro9 = window.Pelcro) === null || _window$Pelcro9 === void 0 ? void 0 : (_window$Pelcro9$helpe = _window$Pelcro9.helpers) === null || _window$Pelcro9$helpe === void 0 ? void 0 : _window$Pelcro9$helpe.getHtmlLanguageAttribute(),
19141
+ products: (_window$Pelcro10 = window.Pelcro) === null || _window$Pelcro10 === void 0 ? void 0 : (_window$Pelcro10$site = _window$Pelcro10.site) === null || _window$Pelcro10$site === void 0 ? void 0 : _window$Pelcro10$site.read().products.length,
19142
+ currency_matching_filter: `${productsMatchingUserCurrency.length} Products Passed`,
19143
+ country_matching_filter: `${productsMatchingUserCountry.length} Products Passed`,
19144
+ language_matching_filter: `${productsMatchingUserCountry.filter(productMatchPageLanguage).length} Products Passed`
19041
19145
  });
19042
19146
  });
19043
19147
  });
19044
- console.log("bugsnag Triggered");
19045
19148
  }
19046
19149
  });
19047
19150
 
@@ -19199,15 +19302,6 @@ class SelectModal extends React.Component {
19199
19302
  }), /*#__PURE__*/React__default['default'].createElement("h3", {
19200
19303
  className: "plc-text-sm plc-font-semibold"
19201
19304
  }, this.locale("labels.restrictiveArticles.or")), allProductsMinusMatched.map((product, index) => this.renderOneProduct(product, index))));
19202
-
19203
- function productsWithMatchedTaggedFirst() {
19204
- var _window$Pelcro$produc;
19205
-
19206
- const allProducts = (_window$Pelcro$produc = window.Pelcro.product.list()) !== null && _window$Pelcro$produc !== void 0 ? _window$Pelcro$produc : [];
19207
- const productsThatMatchArticleTag = window.Pelcro.product.getByMatchingPageTags();
19208
- const allProductsMinusMatched = allProducts.filter(product => !productsThatMatchArticleTag.some(matchedProduct => matchedProduct.id === product.id));
19209
- return [productsThatMatchArticleTag, allProductsMinusMatched];
19210
- }
19211
19305
  });
19212
19306
 
19213
19307
  _defineProperty$3(this, "renderPlans", () => {
@@ -21541,6 +21635,8 @@ const PaymentMethodContainerWithoutStripe = ({
21541
21635
  }) => {
21542
21636
  var _props$product, _props$plan, _props$subscriptionId, _props$selectedAddres, _props$giftRecipient, _props$isGift, _props$isRenewingGift, _props$invoice, _window$Pelcro, _window$Pelcro$uiSett;
21543
21637
 
21638
+ const [vantivPaymentRequest, setVantivPaymentRequest] = React.useState(null);
21639
+ const [updatedCouponCode, setUpdatedCouponCode] = React.useState("");
21544
21640
  const {
21545
21641
  t
21546
21642
  } = useTranslation("payment");
@@ -21584,7 +21680,7 @@ const PaymentMethodContainerWithoutStripe = ({
21584
21680
  }, []);
21585
21681
  /*====== Start Tap integration ========*/
21586
21682
 
21587
- const submitUsingTap = () => {
21683
+ const submitUsingTap = state => {
21588
21684
  var _ref, _ref2, _ref3, _state$updatedPrice;
21589
21685
 
21590
21686
  const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
@@ -21639,7 +21735,7 @@ const PaymentMethodContainerWithoutStripe = ({
21639
21735
  }
21640
21736
  });
21641
21737
  } else {
21642
- window.Pelcro.payment.authorize({
21738
+ window.Pelcro.payment.verify({
21643
21739
  auth_token: window.Pelcro.user.read().auth_token,
21644
21740
  first_name: window.Pelcro.user.read().first_name || state.firstName,
21645
21741
  last_name: window.Pelcro.user.read().last_name || state.lastName,
@@ -21648,7 +21744,8 @@ const PaymentMethodContainerWithoutStripe = ({
21648
21744
  amount: totalAmount,
21649
21745
  currency: (plan === null || plan === void 0 ? void 0 : plan.currency) || (invoice === null || invoice === void 0 ? void 0 : invoice.currency) || window.Pelcro.site.read().default_currency,
21650
21746
  tap_token: result.id,
21651
- redirect_url: `${window.Pelcro.environment.domain}/webhook/tap/callback/3dsecure?auth_token=${window.Pelcro.user.read().auth_token}`
21747
+ funding: result.card.funding,
21748
+ redirect_url: `${window.Pelcro.environment.domain}/webhook/tap/callback/3dsecure?auth_token=${window.Pelcro.user.read().auth_token}&type=verify_card&site_id=${window.Pelcro.siteid}`
21652
21749
  }, (err, res) => {
21653
21750
  if (err) {
21654
21751
  // Inform the user if there was an error
@@ -21689,7 +21786,7 @@ const PaymentMethodContainerWithoutStripe = ({
21689
21786
  content: null
21690
21787
  }
21691
21788
  });
21692
- handleTapPayment(tapID);
21789
+ handleTapPayment(tapID, state);
21693
21790
  }
21694
21791
  }; // listen to injected iframe for authentication complete message
21695
21792
 
@@ -21704,7 +21801,7 @@ const PaymentMethodContainerWithoutStripe = ({
21704
21801
  });
21705
21802
  };
21706
21803
 
21707
- function handleTapPayment(paymentRequest) {
21804
+ function handleTapPayment(paymentRequest, state) {
21708
21805
  const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
21709
21806
 
21710
21807
  if (type === "createPayment") {
@@ -21731,6 +21828,7 @@ const PaymentMethodContainerWithoutStripe = ({
21731
21828
  type: LOADING,
21732
21829
  payload: false
21733
21830
  });
21831
+ toggleAuthenticationSuccessPendingView(false);
21734
21832
 
21735
21833
  if (err) {
21736
21834
  onFailure(err);
@@ -21751,7 +21849,8 @@ const PaymentMethodContainerWithoutStripe = ({
21751
21849
  }
21752
21850
  });
21753
21851
  onSuccess(res);
21754
- });
21852
+ } //
21853
+ );
21755
21854
  }
21756
21855
 
21757
21856
  function handleTapSubscription() {
@@ -21886,7 +21985,7 @@ const PaymentMethodContainerWithoutStripe = ({
21886
21985
  /*====== End Tap integration ========*/
21887
21986
 
21888
21987
 
21889
- const submitUsingVantiv = () => {
21988
+ const submitUsingVantiv = state => {
21890
21989
  const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
21891
21990
 
21892
21991
  if (isUsingExistingPaymentMethod) {
@@ -21909,7 +22008,7 @@ const PaymentMethodContainerWithoutStripe = ({
21909
22008
  });
21910
22009
  };
21911
22010
 
21912
- function handleVantivPayment(paymentRequest) {
22011
+ function handleVantivPayment(paymentRequest, couponCode) {
21913
22012
  if (paymentRequest) {
21914
22013
  const SUCCESS_STATUS = "870";
21915
22014
 
@@ -21983,9 +22082,6 @@ const PaymentMethodContainerWithoutStripe = ({
21983
22082
  const renewSubscription = !isGift && subscriptionIdToRenew;
21984
22083
  const giftSubscriprition = isGift && !subscriptionIdToRenew;
21985
22084
  const renewGift = isRenewingGift;
21986
- const {
21987
- couponCode
21988
- } = state;
21989
22085
 
21990
22086
  if (renewGift) {
21991
22087
  return payment.execute({
@@ -22065,6 +22161,8 @@ const PaymentMethodContainerWithoutStripe = ({
22065
22161
  const tapInstanceRef = React__default['default'].useRef(null);
22066
22162
  const tapInstanceCard = React__default['default'].useRef(null);
22067
22163
  React.useEffect(() => {
22164
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
22165
+
22068
22166
  if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
22069
22167
  var _window$Pelcro$site$r2, _window$Pelcro$site$r3;
22070
22168
 
@@ -22077,7 +22175,7 @@ const PaymentMethodContainerWithoutStripe = ({
22077
22175
  height: "245",
22078
22176
  timeout: 50000,
22079
22177
  div: "eProtectiframe",
22080
- callback: handleVantivPayment,
22178
+ callback: paymentRequest => setVantivPaymentRequest(paymentRequest),
22081
22179
  showCvv: true,
22082
22180
  numYears: 8,
22083
22181
  placeholderText: {
@@ -22091,9 +22189,17 @@ const PaymentMethodContainerWithoutStripe = ({
22091
22189
  }
22092
22190
  });
22093
22191
  }
22094
- }, [selectedPaymentMethodId]);
22192
+ }, [selectedPaymentMethodId]); //Trigger the handleVantivPayment method when a vantivePaymentRequest is present
22193
+
22194
+ React.useEffect(() => {
22195
+ if (vantivPaymentRequest) {
22196
+ handleVantivPayment(vantivPaymentRequest, updatedCouponCode);
22197
+ }
22198
+ }, [vantivPaymentRequest]);
22095
22199
  React.useEffect(() => {
22096
22200
  whenUserReady(() => {
22201
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
22202
+
22097
22203
  if (cardProcessor === "tap" && !window.Tapjsli) {
22098
22204
  window.Pelcro.helpers.loadSDK("https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js", "tap-bluebird");
22099
22205
  window.Pelcro.helpers.loadSDK("https://secure.gosell.io/js/sdk/tap.min.js", "tap-sdk");
@@ -22109,7 +22215,7 @@ const PaymentMethodContainerWithoutStripe = ({
22109
22215
  }, [selectedPaymentMethodId]);
22110
22216
 
22111
22217
  const initPaymentRequest = (state, dispatch) => {
22112
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
22218
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
22113
22219
 
22114
22220
  try {
22115
22221
  const paymentRequest = stripe.paymentRequest({
@@ -22182,7 +22288,7 @@ const PaymentMethodContainerWithoutStripe = ({
22182
22288
  const updateTotalAmountWithTax = () => {
22183
22289
  var _window$Pelcro$site$r4;
22184
22290
 
22185
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
22291
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
22186
22292
  const taxesEnabled = (_window$Pelcro$site$r4 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r4 === void 0 ? void 0 : _window$Pelcro$site$r4.taxes_enabled;
22187
22293
 
22188
22294
  if (taxesEnabled && type === "createPayment") {
@@ -22229,7 +22335,9 @@ const PaymentMethodContainerWithoutStripe = ({
22229
22335
  });
22230
22336
 
22231
22337
  if (err) {
22232
- onFailure(err);
22338
+ onFailure(err); //reset the coupon code in local state
22339
+
22340
+ setUpdatedCouponCode("");
22233
22341
  dispatch({
22234
22342
  type: SET_COUPON_ERROR,
22235
22343
  payload: getErrorMessages(err)
@@ -22289,7 +22397,9 @@ const PaymentMethodContainerWithoutStripe = ({
22289
22397
  dispatch({
22290
22398
  type: SET_COUPON,
22291
22399
  payload: res.data.coupon
22292
- });
22400
+ }); //set the coupon code in local state to be able to use with Vantiv
22401
+
22402
+ setUpdatedCouponCode(res.data.coupon.code);
22293
22403
  dispatch({
22294
22404
  type: SET_PERCENT_OFF,
22295
22405
  payload: `${(_res$data$coupon = res.data.coupon) === null || _res$data$coupon === void 0 ? void 0 : _res$data$coupon.percent_off}%`
@@ -22364,7 +22474,9 @@ const PaymentMethodContainerWithoutStripe = ({
22364
22474
  const debouncedApplyCouponCode = React.useRef(debounce$1(onApplyCouponCode, 1000)).current;
22365
22475
 
22366
22476
  const removeAppliedCoupon = state => {
22367
- state.couponCode = "";
22477
+ state.couponCode = ""; //reset the coupon code in local state
22478
+
22479
+ setUpdatedCouponCode("");
22368
22480
  dispatch({
22369
22481
  type: SET_COUPON_ERROR,
22370
22482
  payload: ""
@@ -22821,6 +22933,31 @@ const PaymentMethodContainerWithoutStripe = ({
22821
22933
  };
22822
22934
 
22823
22935
  const submitPayment = (state, dispatch) => {
22936
+ if (skipPayment && props !== null && props !== void 0 && props.freeOrders) {
22937
+ const isQuickPurchase = !Array.isArray(order);
22938
+ const mappedOrderItems = isQuickPurchase ? [{
22939
+ sku_id: order.id,
22940
+ quantity: order.quantity
22941
+ }] : order.map(item => ({
22942
+ sku_id: item.id,
22943
+ quantity: item.quantity
22944
+ }));
22945
+ window.Pelcro.ecommerce.order.create({
22946
+ items: mappedOrderItems,
22947
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
22948
+ ...(selectedAddressId && {
22949
+ address_id: selectedAddressId
22950
+ })
22951
+ }, (err, res) => {
22952
+ if (err) {
22953
+ return handlePaymentError(err);
22954
+ }
22955
+
22956
+ return onSuccess(res);
22957
+ });
22958
+ return;
22959
+ }
22960
+
22824
22961
  stripe.createSource({
22825
22962
  type: "card"
22826
22963
  }).then(({
@@ -23085,12 +23222,16 @@ const PaymentMethodContainerWithoutStripe = ({
23085
23222
  disableSubmit: true,
23086
23223
  isLoading: true
23087
23224
  }, (state, dispatch) => {
23225
+ if (skipPayment && props !== null && props !== void 0 && props.freeOrders) {
23226
+ return submitPayment(state);
23227
+ }
23228
+
23088
23229
  if (getSiteCardProcessor() === "vantiv") {
23089
23230
  return submitUsingVantiv();
23090
23231
  }
23091
23232
 
23092
23233
  if (getSiteCardProcessor() === "tap") {
23093
- return submitUsingTap();
23234
+ return submitUsingTap(state);
23094
23235
  }
23095
23236
 
23096
23237
  if (selectedPaymentMethodId) {
@@ -23219,10 +23360,14 @@ const PaymentMethodContainerWithoutStripe = ({
23219
23360
  state,
23220
23361
  dispatch
23221
23362
  }
23222
- }, children.length ? children.map((child, i) => /*#__PURE__*/React__default['default'].cloneElement(child, {
23223
- store: store$l,
23224
- key: i
23225
- })) : /*#__PURE__*/React__default['default'].cloneElement(children, {
23363
+ }, children.length ? children.map((child, i) => {
23364
+ if (child) {
23365
+ return /*#__PURE__*/React__default['default'].cloneElement(child, {
23366
+ store: store$l,
23367
+ key: i
23368
+ });
23369
+ }
23370
+ }) : /*#__PURE__*/React__default['default'].cloneElement(children, {
23226
23371
  store: store$l
23227
23372
  })));
23228
23373
  };
@@ -23253,11 +23398,13 @@ const PaymentMethodContainer = props => {
23253
23398
  }, /*#__PURE__*/React__default['default'].createElement(es_11, null, /*#__PURE__*/React__default['default'].createElement(UnwrappedForm, Object.assign({
23254
23399
  store: store$l
23255
23400
  }, props))));
23256
- } else {
23401
+ } else if (cardProcessor !== "stripe") {
23257
23402
  return /*#__PURE__*/React__default['default'].createElement(PaymentMethodContainerWithoutStripe, Object.assign({
23258
23403
  store: store$l
23259
23404
  }, props));
23260
23405
  }
23406
+
23407
+ return null;
23261
23408
  };
23262
23409
 
23263
23410
  const StripeInputStyle = {
@@ -24093,6 +24240,41 @@ const BankAuthenticationSuccess = () => {
24093
24240
  }));
24094
24241
  };
24095
24242
 
24243
+ const OrderCreateFreeButton = ({
24244
+ name,
24245
+ onClick,
24246
+ ...otherProps
24247
+ }) => {
24248
+ const {
24249
+ state: {
24250
+ disableSubmit
24251
+ },
24252
+ dispatch
24253
+ } = React.useContext(store$l);
24254
+ const {
24255
+ t
24256
+ } = useTranslation("checkoutForm");
24257
+ const [isDisabled, setDisabled] = React.useState(true);
24258
+ React.useEffect(() => {
24259
+ setDisabled(disableSubmit);
24260
+ }, [disableSubmit]);
24261
+ return /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({
24262
+ className: "plc-w-full",
24263
+ onClick: () => {
24264
+ dispatch({
24265
+ type: DISABLE_SUBMIT,
24266
+ payload: true
24267
+ });
24268
+ dispatch({
24269
+ type: SUBMIT_PAYMENT
24270
+ });
24271
+ onClick === null || onClick === void 0 ? void 0 : onClick();
24272
+ },
24273
+ disabled: isDisabled,
24274
+ isLoading: disableSubmit
24275
+ }, otherProps), t("labels.submit"));
24276
+ };
24277
+
24096
24278
  /**
24097
24279
  *
24098
24280
  */
@@ -24104,9 +24286,11 @@ function PaymentMethodView({
24104
24286
  type,
24105
24287
  showCoupon,
24106
24288
  showExternalPaymentMethods,
24107
- showSubscriptionButton
24289
+ showSubscriptionButton,
24290
+ showOrderButton,
24291
+ order
24108
24292
  }) {
24109
- var _window$Pelcro$site$r, _window$Pelcro$site$r2;
24293
+ var _window$Pelcro$site$r, _window$Pelcro$site$r2, _calcAndFormatItemsTo, _order$;
24110
24294
 
24111
24295
  const {
24112
24296
  t
@@ -24119,7 +24303,17 @@ function PaymentMethodView({
24119
24303
  const isUserPhone = Boolean(window.Pelcro.user.read().phone);
24120
24304
  return /*#__PURE__*/React__default['default'].createElement("div", {
24121
24305
  className: "plc-flex plc-flex-col plc-items-center plc-mt-4 sm:plc-px-8 pelcro-payment-block"
24122
- }, cardProcessor === "stripe" && !showSubscriptionButton && /*#__PURE__*/React__default['default'].createElement("div", {
24306
+ }, order && /*#__PURE__*/React__default['default'].createElement("div", {
24307
+ className: "plc-w-full plc-p-2 plc-mb-4 plc-font-semibold plc-text-center plc-text-gray-900 plc-bg-gray-100 plc-border plc-border-gray-200"
24308
+ }, /*#__PURE__*/React__default['default'].createElement("p", {
24309
+ className: "plc-text-gray-600"
24310
+ }, !Array.isArray(order) ? /*#__PURE__*/React__default['default'].createElement("span", {
24311
+ className: "plc-tracking-wider plc-uppercase"
24312
+ }, order === null || order === void 0 ? void 0 : order.name) : /*#__PURE__*/React__default['default'].createElement("span", {
24313
+ className: "plc-tracking-wider plc-uppercase"
24314
+ }, t("labels.freeItems")), /*#__PURE__*/React__default['default'].createElement("br", null), /*#__PURE__*/React__default['default'].createElement("span", {
24315
+ className: "plc-text-xl plc-font-semibold plc-text-primary-600"
24316
+ }, (_calcAndFormatItemsTo = calcAndFormatItemsTotal(order, (_order$ = order[0]) === null || _order$ === void 0 ? void 0 : _order$.currency)) !== null && _calcAndFormatItemsTo !== void 0 ? _calcAndFormatItemsTo : getFormattedPriceByLocal(order === null || order === void 0 ? void 0 : order.price, order === null || order === void 0 ? void 0 : order.currency, getPageOrDefaultLanguage())))), cardProcessor === "stripe" && !showSubscriptionButton && !showOrderButton && /*#__PURE__*/React__default['default'].createElement("div", {
24123
24317
  className: "plc-flex plc-items-center plc-w-full plc-px-4 plc-py-2 plc-text-center plc-text-green-600 plc-border plc-border-green-400 plc-rounded plc-bg-green-50"
24124
24318
  }, /*#__PURE__*/React__default['default'].createElement(SvgLock, {
24125
24319
  className: "plc-w-5 plc-h-5 plc-mr-1"
@@ -24135,10 +24329,11 @@ function PaymentMethodView({
24135
24329
  type: type,
24136
24330
  onSuccess: onSuccess,
24137
24331
  onGiftRenewalSuccess: onGiftRenewalSuccess,
24138
- onFailure: onFailure
24332
+ onFailure: onFailure,
24333
+ freeOrders: showOrderButton
24139
24334
  }, /*#__PURE__*/React__default['default'].createElement(AlertWithContext, {
24140
24335
  className: "plc-mb-2"
24141
- }), showSubscriptionButton ? /*#__PURE__*/React__default['default'].createElement(SubscriptionCreateFreePlanButton, null) : /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(BankRedirection, null), /*#__PURE__*/React__default['default'].createElement(BankAuthenticationSuccess, null), /*#__PURE__*/React__default['default'].createElement(SelectedPaymentMethod, null), supportsTap && (!isUserFirstName || !isUserLastName || !isUserPhone) && /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement("div", {
24336
+ }), showSubscriptionButton && /*#__PURE__*/React__default['default'].createElement(SubscriptionCreateFreePlanButton, null), showOrderButton && /*#__PURE__*/React__default['default'].createElement(OrderCreateFreeButton, null), !showSubscriptionButton && !showOrderButton && /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(BankRedirection, null), /*#__PURE__*/React__default['default'].createElement(BankAuthenticationSuccess, null), /*#__PURE__*/React__default['default'].createElement(SelectedPaymentMethod, null), supportsTap && (!isUserFirstName || !isUserLastName || !isUserPhone) && /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement("div", {
24142
24337
  className: "plc-flex plc-items-start"
24143
24338
  }, /*#__PURE__*/React__default['default'].createElement(IncludeFirstName, {
24144
24339
  id: "pelcro-input-first-name",
@@ -26014,6 +26209,19 @@ function SubscriptionManageMembersList(props) {
26014
26209
  icon: /*#__PURE__*/React__default['default'].createElement(SvgCheckMark, null)
26015
26210
  };
26016
26211
  }, []);
26212
+ const showMemberData = React.useCallback(member => {
26213
+ var _member$customer, _member$customer2, _member$customer3, _member$customer4;
26214
+
26215
+ let data;
26216
+
26217
+ if ((member === null || member === void 0 ? void 0 : member.status) !== "active") {
26218
+ data = member === null || member === void 0 ? void 0 : member.invitation_email;
26219
+ return data;
26220
+ }
26221
+
26222
+ data = (member === null || member === void 0 ? void 0 : (_member$customer = member.customer) === null || _member$customer === void 0 ? void 0 : _member$customer.email) || (member === null || member === void 0 ? void 0 : (_member$customer2 = member.customer) === null || _member$customer2 === void 0 ? void 0 : _member$customer2.first_name) + " " + (member === null || member === void 0 ? void 0 : (_member$customer3 = member.customer) === null || _member$customer3 === void 0 ? void 0 : _member$customer3.last_name) || (member === null || member === void 0 ? void 0 : (_member$customer4 = member.customer) === null || _member$customer4 === void 0 ? void 0 : _member$customer4.username) || "-----";
26223
+ return data;
26224
+ }, []);
26017
26225
 
26018
26226
  if (loading) {
26019
26227
  return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement("tr", null, /*#__PURE__*/React__default['default'].createElement("td", null, /*#__PURE__*/React__default['default'].createElement("div", {
@@ -26058,10 +26266,10 @@ function SubscriptionManageMembersList(props) {
26058
26266
  className: `plc-w-full plc-align-middle plc-cursor-pointer accordion-header hover:plc-bg-gray-50 plc-text-center`
26059
26267
  }, /*#__PURE__*/React__default['default'].createElement("td", {
26060
26268
  className: "plc-truncate plc-text-left",
26061
- title: member === null || member === void 0 ? void 0 : member.invitation_email
26269
+ title: showMemberData(member)
26062
26270
  }, /*#__PURE__*/React__default['default'].createElement("span", {
26063
26271
  className: "plc-font-semibold plc-text-gray-500"
26064
- }, member === null || member === void 0 ? void 0 : member.invitation_email)), /*#__PURE__*/React__default['default'].createElement("td", {
26272
+ }, showMemberData(member))), /*#__PURE__*/React__default['default'].createElement("td", {
26065
26273
  className: "plc-py-2"
26066
26274
  }, /*#__PURE__*/React__default['default'].createElement("span", {
26067
26275
  className: `plc-inline-flex plc-p-1 plc-text-xs plc-font-semibold ${getMemberStatus(member).bgColor} plc-uppercase ${getMemberStatus(member).textColor} plc-rounded-lg`
@@ -29738,6 +29946,14 @@ const OrderCreateContainer = props => /*#__PURE__*/React__default['default'].cre
29738
29946
  }, props));
29739
29947
 
29740
29948
  const OrderCreateView = props => {
29949
+ var _window$Pelcro, _window$Pelcro$uiSett;
29950
+
29951
+ useTranslation("payment");
29952
+ const {
29953
+ order
29954
+ } = usePelcro();
29955
+ const skipPayment = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.skipPaymentForFreePlans;
29956
+ const showOrderButton = skipPayment && ((order === null || order === void 0 ? void 0 : order.price) === 0 || (order === null || order === void 0 ? void 0 : order.length) > 0 && order.every(item => (item === null || item === void 0 ? void 0 : item.price) === 0));
29741
29957
  return /*#__PURE__*/React__default['default'].createElement("div", {
29742
29958
  id: "pelcro-order-create-view"
29743
29959
  }, /*#__PURE__*/React__default['default'].createElement("form", {
@@ -29746,7 +29962,9 @@ const OrderCreateView = props => {
29746
29962
  }, /*#__PURE__*/React__default['default'].createElement(PaymentMethodView, Object.assign({
29747
29963
  type: "orderCreate",
29748
29964
  showCoupon: true,
29749
- showExternalPaymentMethods: false
29965
+ showExternalPaymentMethods: false,
29966
+ showOrderButton: showOrderButton,
29967
+ order: order
29750
29968
  }, props))));
29751
29969
  };
29752
29970
 
@@ -31029,17 +31247,18 @@ const PaymentMethodSelectModal = ({
31029
31247
  }) => {
31030
31248
  var _window$Pelcro, _window$Pelcro$uiSett;
31031
31249
 
31250
+ const {
31251
+ t
31252
+ } = useTranslation("paymentMethod");
31032
31253
  const {
31033
31254
  switchToCheckoutForm,
31034
31255
  set,
31035
- plan
31256
+ plan,
31257
+ order
31036
31258
  } = usePelcro();
31037
- const {
31038
- t
31039
- } = useTranslation("paymentMethod");
31040
31259
  const skipPayment = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.skipPaymentForFreePlans;
31041
31260
  React.useEffect(() => {
31042
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) {
31261
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) {
31043
31262
  switchToCheckoutForm();
31044
31263
  }
31045
31264
  }, []);
@@ -38964,6 +39183,7 @@ exports.NewsletterUpdateView = NewsletterUpdateView;
38964
39183
  exports.Notification = Notification;
38965
39184
  exports.OrderConfirmModal = OrderConfirmModal;
38966
39185
  exports.OrderCreateContainer = OrderCreateContainer;
39186
+ exports.OrderCreateFreeButton = OrderCreateFreeButton;
38967
39187
  exports.OrderCreateModal = OrderCreateModal;
38968
39188
  exports.OrderCreateSubmitButton = OrderCreateSubmitButton;
38969
39189
  exports.OrderCreateView = OrderCreateView;