@pelcro/react-pelcro-js 3.21.0-beta.1 → 3.21.0-beta.2

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
@@ -16397,7 +16397,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16397
16397
  }
16398
16398
  });
16399
16399
  } else {
16400
- window.Pelcro.payment.authorize({
16400
+ window.Pelcro.payment.verify({
16401
16401
  auth_token: window.Pelcro.user.read().auth_token,
16402
16402
  first_name: window.Pelcro.user.read().first_name || state.firstName,
16403
16403
  last_name: window.Pelcro.user.read().last_name || state.lastName,
@@ -16406,7 +16406,8 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16406
16406
  amount: totalAmount,
16407
16407
  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,
16408
16408
  tap_token: result.id,
16409
- redirect_url: `${window.Pelcro.environment.domain}/webhook/tap/callback/3dsecure?auth_token=${window.Pelcro.user.read().auth_token}`
16409
+ funding: result.card.funding,
16410
+ 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}`
16410
16411
  }, (err, res) => {
16411
16412
  if (err) {
16412
16413
  // Inform the user if there was an error
@@ -16483,6 +16484,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16483
16484
  type: LOADING,
16484
16485
  payload: false
16485
16486
  });
16487
+ toggleAuthenticationSuccessPendingView(false);
16486
16488
  if (err) {
16487
16489
  onFailure(err);
16488
16490
  return dispatch({
@@ -16501,8 +16503,10 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16501
16503
  }
16502
16504
  });
16503
16505
  onSuccess(res);
16504
- });
16506
+ } //
16507
+ );
16505
16508
  }
16509
+
16506
16510
  function handleTapSubscription() {
16507
16511
  const payment = new Payment(new TapGateway());
16508
16512
  const createSubscription = !isGift && !subscriptionIdToRenew;
@@ -16791,7 +16795,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16791
16795
  const tapInstanceRef = React__default['default'].useRef(null);
16792
16796
  const tapInstanceCard = React__default['default'].useRef(null);
16793
16797
  React.useEffect(() => {
16794
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16798
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) return;
16795
16799
  if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
16796
16800
  var _window$Pelcro$site$r2, _window$Pelcro$site$r3;
16797
16801
  const payPageId = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.vantiv_gateway_settings.pay_page_id;
@@ -16820,7 +16824,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16820
16824
  }, [selectedPaymentMethodId]);
16821
16825
  React.useEffect(() => {
16822
16826
  whenUserReady(() => {
16823
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16827
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) return;
16824
16828
  if (cardProcessor === "tap" && !window.Tapjsli) {
16825
16829
  window.Pelcro.helpers.loadSDK("https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js", "tap-bluebird");
16826
16830
  window.Pelcro.helpers.loadSDK("https://secure.gosell.io/js/sdk/tap.min.js", "tap-sdk");
@@ -16834,7 +16838,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16834
16838
  });
16835
16839
  }, [selectedPaymentMethodId]);
16836
16840
  const initPaymentRequest = (state, dispatch) => {
16837
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16841
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) return;
16838
16842
  try {
16839
16843
  const paymentRequest = stripe.paymentRequest({
16840
16844
  country: window.Pelcro.user.location.countryCode || "US",
@@ -16903,7 +16907,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16903
16907
  */
16904
16908
  const updateTotalAmountWithTax = () => {
16905
16909
  var _window$Pelcro$site$r4;
16906
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16910
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) return;
16907
16911
  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;
16908
16912
  if (taxesEnabled && type === "createPayment") {
16909
16913
  dispatch({
@@ -17498,6 +17502,29 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17498
17502
  });
17499
17503
  };
17500
17504
  const submitPayment = (state, dispatch) => {
17505
+ if (skipPayment && (order === null || order === void 0 ? void 0 : order.price) === 0) {
17506
+ const isQuickPurchase = !Array.isArray(order);
17507
+ const mappedOrderItems = isQuickPurchase ? [{
17508
+ sku_id: order.id,
17509
+ quantity: order.quantity
17510
+ }] : order.map(item => ({
17511
+ sku_id: item.id,
17512
+ quantity: item.quantity
17513
+ }));
17514
+ window.Pelcro.ecommerce.order.create({
17515
+ items: mappedOrderItems,
17516
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
17517
+ ...(selectedAddressId && {
17518
+ address_id: selectedAddressId
17519
+ })
17520
+ }, (err, res) => {
17521
+ if (err) {
17522
+ return handlePaymentError(err);
17523
+ }
17524
+ return onSuccess(res);
17525
+ });
17526
+ return;
17527
+ }
17501
17528
  stripe.createSource({
17502
17529
  type: "card"
17503
17530
  }).then(_ref8 => {
@@ -17859,10 +17886,14 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17859
17886
  state,
17860
17887
  dispatch
17861
17888
  }
17862
- }, children.length ? children.map((child, i) => /*#__PURE__*/React__default['default'].cloneElement(child, {
17863
- store: store$k,
17864
- key: i
17865
- })) : /*#__PURE__*/React__default['default'].cloneElement(children, {
17889
+ }, children.length ? children.map((child, i) => {
17890
+ if (child) {
17891
+ return /*#__PURE__*/React__default['default'].cloneElement(child, {
17892
+ store: store$k,
17893
+ key: i
17894
+ });
17895
+ }
17896
+ }) : /*#__PURE__*/React__default['default'].cloneElement(children, {
17866
17897
  store: store$k
17867
17898
  })));
17868
17899
  };
@@ -18684,6 +18715,42 @@ const SubscriptionCreateFreePlanButton = _ref => {
18684
18715
  }, otherProps), t("buttons.subscribe"));
18685
18716
  };
18686
18717
 
18718
+ const OrderCreateFreeButton = _ref => {
18719
+ let {
18720
+ name,
18721
+ onClick,
18722
+ ...otherProps
18723
+ } = _ref;
18724
+ const {
18725
+ state: {
18726
+ disableSubmit
18727
+ },
18728
+ dispatch
18729
+ } = React.useContext(store$k);
18730
+ const {
18731
+ t
18732
+ } = useTranslation("checkoutForm");
18733
+ const [isDisabled, setDisabled] = React.useState(true);
18734
+ React.useEffect(() => {
18735
+ setDisabled(disableSubmit);
18736
+ }, [disableSubmit]);
18737
+ return /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({
18738
+ className: "plc-w-full",
18739
+ onClick: () => {
18740
+ dispatch({
18741
+ type: DISABLE_SUBMIT,
18742
+ payload: true
18743
+ });
18744
+ dispatch({
18745
+ type: SUBMIT_PAYMENT
18746
+ });
18747
+ onClick === null || onClick === void 0 ? void 0 : onClick();
18748
+ },
18749
+ disabled: isDisabled,
18750
+ isLoading: disableSubmit
18751
+ }, otherProps), t("labels.submit"));
18752
+ };
18753
+
18687
18754
  /**
18688
18755
  *
18689
18756
  */
@@ -18696,7 +18763,8 @@ function PaymentMethodView(_ref) {
18696
18763
  type,
18697
18764
  showCoupon,
18698
18765
  showExternalPaymentMethods,
18699
- showSubscriptionButton
18766
+ showSubscriptionButton,
18767
+ showOrderButton
18700
18768
  } = _ref;
18701
18769
  const {
18702
18770
  t
@@ -18709,7 +18777,7 @@ function PaymentMethodView(_ref) {
18709
18777
  const isUserPhone = Boolean(window.Pelcro.user.read().phone);
18710
18778
  return /*#__PURE__*/React__default['default'].createElement("div", {
18711
18779
  className: "plc-flex plc-flex-col plc-items-center plc-mt-4 sm:plc-px-8 pelcro-payment-block"
18712
- }, cardProcessor === "stripe" && !showSubscriptionButton && /*#__PURE__*/React__default['default'].createElement("div", {
18780
+ }, cardProcessor === "stripe" && !showSubscriptionButton && !showOrderButton && /*#__PURE__*/React__default['default'].createElement("div", {
18713
18781
  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"
18714
18782
  }, /*#__PURE__*/React__default['default'].createElement(SvgLock, {
18715
18783
  className: "plc-w-5 plc-h-5 plc-mr-1"
@@ -18728,7 +18796,7 @@ function PaymentMethodView(_ref) {
18728
18796
  onFailure: onFailure
18729
18797
  }, /*#__PURE__*/React__default['default'].createElement(AlertWithContext, {
18730
18798
  className: "plc-mb-2"
18731
- }), 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", {
18799
+ }), 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", {
18732
18800
  className: "plc-flex plc-items-start"
18733
18801
  }, /*#__PURE__*/React__default['default'].createElement(IncludeFirstName, {
18734
18802
  id: "pelcro-input-first-name",
@@ -24138,9 +24206,15 @@ const OrderCreateContainer = props => /*#__PURE__*/React__default['default'].cre
24138
24206
  }, props));
24139
24207
 
24140
24208
  const OrderCreateView = props => {
24209
+ var _window$Pelcro, _window$Pelcro$uiSett;
24141
24210
  const {
24142
24211
  t
24143
24212
  } = useTranslation("payment");
24213
+ const {
24214
+ order
24215
+ } = usePelcro();
24216
+ 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;
24217
+ const showOrderButton = skipPayment && (order === null || order === void 0 ? void 0 : order.price) === 0;
24144
24218
  return /*#__PURE__*/React__default['default'].createElement("div", {
24145
24219
  id: "pelcro-order-create-view"
24146
24220
  }, /*#__PURE__*/React__default['default'].createElement("div", {
@@ -24151,7 +24225,8 @@ const OrderCreateView = props => {
24151
24225
  }, /*#__PURE__*/React__default['default'].createElement(PaymentMethodView, Object.assign({
24152
24226
  type: "orderCreate",
24153
24227
  showCoupon: true,
24154
- showExternalPaymentMethods: false
24228
+ showExternalPaymentMethods: false,
24229
+ showOrderButton: showOrderButton
24155
24230
  }, props))));
24156
24231
  };
24157
24232
 
@@ -25359,11 +25434,12 @@ const PaymentMethodSelectModal = _ref => {
25359
25434
  const {
25360
25435
  switchToCheckoutForm,
25361
25436
  set,
25362
- plan
25437
+ plan,
25438
+ order
25363
25439
  } = usePelcro();
25364
25440
  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;
25365
25441
  React.useEffect(() => {
25366
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) {
25442
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) {
25367
25443
  switchToCheckoutForm();
25368
25444
  }
25369
25445
  }, []);
@@ -32181,6 +32257,7 @@ exports.NewsletterUpdateView = NewsletterUpdateView;
32181
32257
  exports.Notification = Notification;
32182
32258
  exports.OrderConfirmModal = OrderConfirmModal;
32183
32259
  exports.OrderCreateContainer = OrderCreateContainer;
32260
+ exports.OrderCreateFreeButton = OrderCreateFreeButton;
32184
32261
  exports.OrderCreateModal = OrderCreateModal;
32185
32262
  exports.OrderCreateSubmitButton = OrderCreateSubmitButton;
32186
32263
  exports.OrderCreateView = OrderCreateView;
package/dist/index.esm.js CHANGED
@@ -16367,7 +16367,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16367
16367
  }
16368
16368
  });
16369
16369
  } else {
16370
- window.Pelcro.payment.authorize({
16370
+ window.Pelcro.payment.verify({
16371
16371
  auth_token: window.Pelcro.user.read().auth_token,
16372
16372
  first_name: window.Pelcro.user.read().first_name || state.firstName,
16373
16373
  last_name: window.Pelcro.user.read().last_name || state.lastName,
@@ -16376,7 +16376,8 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16376
16376
  amount: totalAmount,
16377
16377
  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,
16378
16378
  tap_token: result.id,
16379
- redirect_url: `${window.Pelcro.environment.domain}/webhook/tap/callback/3dsecure?auth_token=${window.Pelcro.user.read().auth_token}`
16379
+ funding: result.card.funding,
16380
+ 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}`
16380
16381
  }, (err, res) => {
16381
16382
  if (err) {
16382
16383
  // Inform the user if there was an error
@@ -16453,6 +16454,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16453
16454
  type: LOADING,
16454
16455
  payload: false
16455
16456
  });
16457
+ toggleAuthenticationSuccessPendingView(false);
16456
16458
  if (err) {
16457
16459
  onFailure(err);
16458
16460
  return dispatch({
@@ -16471,8 +16473,10 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16471
16473
  }
16472
16474
  });
16473
16475
  onSuccess(res);
16474
- });
16476
+ } //
16477
+ );
16475
16478
  }
16479
+
16476
16480
  function handleTapSubscription() {
16477
16481
  const payment = new Payment(new TapGateway());
16478
16482
  const createSubscription = !isGift && !subscriptionIdToRenew;
@@ -16761,7 +16765,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16761
16765
  const tapInstanceRef = React__default.useRef(null);
16762
16766
  const tapInstanceCard = React__default.useRef(null);
16763
16767
  useEffect(() => {
16764
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16768
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) return;
16765
16769
  if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
16766
16770
  var _window$Pelcro$site$r2, _window$Pelcro$site$r3;
16767
16771
  const payPageId = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.vantiv_gateway_settings.pay_page_id;
@@ -16790,7 +16794,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16790
16794
  }, [selectedPaymentMethodId]);
16791
16795
  useEffect(() => {
16792
16796
  whenUserReady(() => {
16793
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16797
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) return;
16794
16798
  if (cardProcessor === "tap" && !window.Tapjsli) {
16795
16799
  window.Pelcro.helpers.loadSDK("https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js", "tap-bluebird");
16796
16800
  window.Pelcro.helpers.loadSDK("https://secure.gosell.io/js/sdk/tap.min.js", "tap-sdk");
@@ -16804,7 +16808,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16804
16808
  });
16805
16809
  }, [selectedPaymentMethodId]);
16806
16810
  const initPaymentRequest = (state, dispatch) => {
16807
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16811
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) return;
16808
16812
  try {
16809
16813
  const paymentRequest = stripe.paymentRequest({
16810
16814
  country: window.Pelcro.user.location.countryCode || "US",
@@ -16873,7 +16877,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16873
16877
  */
16874
16878
  const updateTotalAmountWithTax = () => {
16875
16879
  var _window$Pelcro$site$r4;
16876
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16880
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) return;
16877
16881
  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;
16878
16882
  if (taxesEnabled && type === "createPayment") {
16879
16883
  dispatch({
@@ -17468,6 +17472,29 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17468
17472
  });
17469
17473
  };
17470
17474
  const submitPayment = (state, dispatch) => {
17475
+ if (skipPayment && (order === null || order === void 0 ? void 0 : order.price) === 0) {
17476
+ const isQuickPurchase = !Array.isArray(order);
17477
+ const mappedOrderItems = isQuickPurchase ? [{
17478
+ sku_id: order.id,
17479
+ quantity: order.quantity
17480
+ }] : order.map(item => ({
17481
+ sku_id: item.id,
17482
+ quantity: item.quantity
17483
+ }));
17484
+ window.Pelcro.ecommerce.order.create({
17485
+ items: mappedOrderItems,
17486
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
17487
+ ...(selectedAddressId && {
17488
+ address_id: selectedAddressId
17489
+ })
17490
+ }, (err, res) => {
17491
+ if (err) {
17492
+ return handlePaymentError(err);
17493
+ }
17494
+ return onSuccess(res);
17495
+ });
17496
+ return;
17497
+ }
17471
17498
  stripe.createSource({
17472
17499
  type: "card"
17473
17500
  }).then(_ref8 => {
@@ -17829,10 +17856,14 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17829
17856
  state,
17830
17857
  dispatch
17831
17858
  }
17832
- }, children.length ? children.map((child, i) => /*#__PURE__*/React__default.cloneElement(child, {
17833
- store: store$k,
17834
- key: i
17835
- })) : /*#__PURE__*/React__default.cloneElement(children, {
17859
+ }, children.length ? children.map((child, i) => {
17860
+ if (child) {
17861
+ return /*#__PURE__*/React__default.cloneElement(child, {
17862
+ store: store$k,
17863
+ key: i
17864
+ });
17865
+ }
17866
+ }) : /*#__PURE__*/React__default.cloneElement(children, {
17836
17867
  store: store$k
17837
17868
  })));
17838
17869
  };
@@ -18654,6 +18685,42 @@ const SubscriptionCreateFreePlanButton = _ref => {
18654
18685
  }, otherProps), t("buttons.subscribe"));
18655
18686
  };
18656
18687
 
18688
+ const OrderCreateFreeButton = _ref => {
18689
+ let {
18690
+ name,
18691
+ onClick,
18692
+ ...otherProps
18693
+ } = _ref;
18694
+ const {
18695
+ state: {
18696
+ disableSubmit
18697
+ },
18698
+ dispatch
18699
+ } = useContext(store$k);
18700
+ const {
18701
+ t
18702
+ } = useTranslation("checkoutForm");
18703
+ const [isDisabled, setDisabled] = useState(true);
18704
+ useEffect(() => {
18705
+ setDisabled(disableSubmit);
18706
+ }, [disableSubmit]);
18707
+ return /*#__PURE__*/React__default.createElement(Button, Object.assign({
18708
+ className: "plc-w-full",
18709
+ onClick: () => {
18710
+ dispatch({
18711
+ type: DISABLE_SUBMIT,
18712
+ payload: true
18713
+ });
18714
+ dispatch({
18715
+ type: SUBMIT_PAYMENT
18716
+ });
18717
+ onClick === null || onClick === void 0 ? void 0 : onClick();
18718
+ },
18719
+ disabled: isDisabled,
18720
+ isLoading: disableSubmit
18721
+ }, otherProps), t("labels.submit"));
18722
+ };
18723
+
18657
18724
  /**
18658
18725
  *
18659
18726
  */
@@ -18666,7 +18733,8 @@ function PaymentMethodView(_ref) {
18666
18733
  type,
18667
18734
  showCoupon,
18668
18735
  showExternalPaymentMethods,
18669
- showSubscriptionButton
18736
+ showSubscriptionButton,
18737
+ showOrderButton
18670
18738
  } = _ref;
18671
18739
  const {
18672
18740
  t
@@ -18679,7 +18747,7 @@ function PaymentMethodView(_ref) {
18679
18747
  const isUserPhone = Boolean(window.Pelcro.user.read().phone);
18680
18748
  return /*#__PURE__*/React__default.createElement("div", {
18681
18749
  className: "plc-flex plc-flex-col plc-items-center plc-mt-4 sm:plc-px-8 pelcro-payment-block"
18682
- }, cardProcessor === "stripe" && !showSubscriptionButton && /*#__PURE__*/React__default.createElement("div", {
18750
+ }, cardProcessor === "stripe" && !showSubscriptionButton && !showOrderButton && /*#__PURE__*/React__default.createElement("div", {
18683
18751
  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"
18684
18752
  }, /*#__PURE__*/React__default.createElement(SvgLock, {
18685
18753
  className: "plc-w-5 plc-h-5 plc-mr-1"
@@ -18698,7 +18766,7 @@ function PaymentMethodView(_ref) {
18698
18766
  onFailure: onFailure
18699
18767
  }, /*#__PURE__*/React__default.createElement(AlertWithContext, {
18700
18768
  className: "plc-mb-2"
18701
- }), showSubscriptionButton ? /*#__PURE__*/React__default.createElement(SubscriptionCreateFreePlanButton, null) : /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(BankRedirection, null), /*#__PURE__*/React__default.createElement(BankAuthenticationSuccess, null), /*#__PURE__*/React__default.createElement(SelectedPaymentMethod, null), supportsTap && (!isUserFirstName || !isUserLastName || !isUserPhone) && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
18769
+ }), showSubscriptionButton && /*#__PURE__*/React__default.createElement(SubscriptionCreateFreePlanButton, null), showOrderButton && /*#__PURE__*/React__default.createElement(OrderCreateFreeButton, null), !showSubscriptionButton && !showOrderButton && /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(BankRedirection, null), /*#__PURE__*/React__default.createElement(BankAuthenticationSuccess, null), /*#__PURE__*/React__default.createElement(SelectedPaymentMethod, null), supportsTap && (!isUserFirstName || !isUserLastName || !isUserPhone) && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
18702
18770
  className: "plc-flex plc-items-start"
18703
18771
  }, /*#__PURE__*/React__default.createElement(IncludeFirstName, {
18704
18772
  id: "pelcro-input-first-name",
@@ -24108,9 +24176,15 @@ const OrderCreateContainer = props => /*#__PURE__*/React__default.createElement(
24108
24176
  }, props));
24109
24177
 
24110
24178
  const OrderCreateView = props => {
24179
+ var _window$Pelcro, _window$Pelcro$uiSett;
24111
24180
  const {
24112
24181
  t
24113
24182
  } = useTranslation("payment");
24183
+ const {
24184
+ order
24185
+ } = usePelcro();
24186
+ 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;
24187
+ const showOrderButton = skipPayment && (order === null || order === void 0 ? void 0 : order.price) === 0;
24114
24188
  return /*#__PURE__*/React__default.createElement("div", {
24115
24189
  id: "pelcro-order-create-view"
24116
24190
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -24121,7 +24195,8 @@ const OrderCreateView = props => {
24121
24195
  }, /*#__PURE__*/React__default.createElement(PaymentMethodView, Object.assign({
24122
24196
  type: "orderCreate",
24123
24197
  showCoupon: true,
24124
- showExternalPaymentMethods: false
24198
+ showExternalPaymentMethods: false,
24199
+ showOrderButton: showOrderButton
24125
24200
  }, props))));
24126
24201
  };
24127
24202
 
@@ -25329,11 +25404,12 @@ const PaymentMethodSelectModal = _ref => {
25329
25404
  const {
25330
25405
  switchToCheckoutForm,
25331
25406
  set,
25332
- plan
25407
+ plan,
25408
+ order
25333
25409
  } = usePelcro();
25334
25410
  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;
25335
25411
  useEffect(() => {
25336
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) {
25412
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) {
25337
25413
  switchToCheckoutForm();
25338
25414
  }
25339
25415
  }, []);
@@ -32038,4 +32114,4 @@ const QrCodeModal = _ref => {
32038
32114
  };
32039
32115
  QrCodeModal.viewId = "qrcode";
32040
32116
 
32041
- export { AddressCreateCity, AddressCreateContainer, AddressCreateCountrySelect, AddressCreateFirstName, AddressCreateLastName, AddressCreateLine1, AddressCreateLine2, AddressCreateModal, AddressCreatePostalCode, AddressCreateSetDefault, AddressCreateStateSelect, AddressCreateSubmit, AddressCreateTextInput, AddressCreateView, AddressSelectContainer, AddressSelectList, AddressSelectModal, AddressSelectSubmit, AddressSelectView, AddressUpdateCity, AddressUpdateContainer, AddressUpdateCountrySelect, AddressUpdateFirstName, AddressUpdateLastName, AddressUpdateLine1, AddressUpdateLine2, AddressUpdateModal, AddressUpdatePostalCode, AddressUpdateSetDefault, AddressUpdateStateSelect, AddressUpdateSubmit, AddressUpdateTextInput, AddressUpdateView, AlertWithContext as Alert, Alert as AlertElement, ApplyCouponButton, Auth0LoginButton, Badge, BankAuthenticationSuccess, BankRedirection, Button, CartContainer, CartModal, CartRemoveItemButton, CartSubmit, CartTotalPrice, CartView, Checkbox, CheckoutForm, ConfirmPassword, CouponCode, CouponCodeField, DashboardWithHook as Dashboard, DashboardOpenButton, DatePicker, DiscountedPrice, Email, EmailVerifyContainer, EmailVerifyModal, EmailVerifyResendButton, EmailVerifyView, FacebookLoginButton, GiftCreateContainer, GiftCreateEmail, GiftCreateFirstName, GiftCreateLastName, GiftCreateMessage, GiftCreateModal, GiftCreateStartDate, GiftCreateSubmitButton, GiftCreateView, GiftRedeemCode, GiftRedeemContainer, GiftRedeemModal, GiftRedeemSubmitButton, GiftRedeemView, GoogleLoginButton, IncludeFirstName, IncludeLastName, IncludePhone, Input, InvoiceDetailsContainer, InvoiceDetailsDownloadButton, InvoiceDetailsModal, InvoiceDetailsPayButton, InvoiceDetailsView, InvoicePaymentContainer, InvoicePaymentModal, InvoicePaymentView, Link, LoginButton, LoginContainer, LoginEmail, LoginModal, LoginPassword, LoginRequestLoginToken, LoginUsername, LoginView, Logout, MeterModal, MeterView, Modal, ModalBody, ModalFooter, NewsletterWithHook as NewsLetter, NewsletterUpdateButton, NewsletterUpdateContainer, NewsletterUpdateList, NewsletterUpdateModal, NewsletterUpdateView, Notification, OrderConfirmModal, OrderCreateContainer, OrderCreateModal, OrderCreateSubmitButton, OrderCreateView, Password, PasswordChangeButton, PasswordChangeConfirmNewPassword, PasswordChangeContainer, PasswordChangeCurrentPassword, PasswordChangeModal, PasswordChangeNewPassword, PasswordChangeView, PasswordForgotButton, PasswordForgotContainer, PasswordForgotEmail, PasswordForgotModal, PasswordForgotView, PasswordResetButton, PasswordResetConfirmPassword, PasswordResetContainer, PasswordResetEmail, PasswordResetModal, PasswordResetPassword, PasswordResetView, PasswordlessRequestContainer, PasswordlessRequestEmail, PasswordlessRequestModal, PasswordlessRequestView, PasswordlessRequestViewButton, PaymentCreateContainer, PaymentCreateView, PaymentMethodContainer, PaymentMethodSelectContainer, PaymentMethodSelectList, PaymentMethodSelectModal, PaymentMethodSelectSubmit, PaymentMethodSelectView, PaymentMethodUpdateContainer, PaymentMethodUpdateModal, PaymentMethodUpdateView, PaymentMethodView, PaymentSuccessModal, PaymentSuccessView, PaypalSubscribeButton, PelcroCardCVC, PelcroCardExpiry, PelcroCardNumber, PelcroModalController, PelcroPaymentRequestButton, ProfilePicChangeButton, ProfilePicChangeContainer, ProfilePicChangeCropper, ProfilePicChangeModal, ProfilePicChangeRemoveButton, ProfilePicChangeSelectButton, ProfilePicChangeView, ProfilePicChangeZoom, QrCodeModal, QrCodeView, Radio, RegisterButton, RegisterCompany, RegisterContainer, RegisterEmail, RegisterFirstName, RegisterJobTitle, RegisterLastName, RegisterModal, RegisterPassword, RegisterView, Select, SelectModalWithHook as SelectModal, SelectedPaymentMethod, ShopPurchaseButton, ShopSelectProductButton, ShopView, SubmitPaymentMethod, SubscriptionCancelModal, SubscriptionCreateContainer, SubscriptionCreateFreePlanButton, SubscriptionCreateModal, SubscriptionCreateView, SubscriptionManageMembersButton, SubscriptionManageMembersContainer, SubscriptionManageMembersEmails, SubscriptionManageMembersList, SubscriptionManageMembersModal, SubscriptionManageMembersView, SubscriptionRenewContainer, SubscriptionRenewModal, SubscriptionRenewView, SubscriptionSuspendContainer, SubscriptionSuspendModal, SubscriptionSuspendView, TaxAmount, TextArea, Tooltip, UserNameInput, UserUpdateButton, UserUpdateContainer, UserUpdateDisplayName, UserUpdateEmail, UserUpdateFirstName, UserUpdateLastName, UserUpdateModal, UserUpdatePhone, UserUpdateProfilePic, UserUpdateTextInput, UserUpdateTin, UserUpdateUsername, UserUpdateView, VerifyLinkTokenContainer, VerifyLinkTokenLoader, VerifyLinkTokenModal, VerifyLinkTokenView, authenticatedButtons, i18next as i18n, init$1 as initButtons, init as initContentEntitlement, invoicePaymentSubmitButton, notify$1 as notify, unauthenticatedButtons, usePelcro };
32117
+ export { AddressCreateCity, AddressCreateContainer, AddressCreateCountrySelect, AddressCreateFirstName, AddressCreateLastName, AddressCreateLine1, AddressCreateLine2, AddressCreateModal, AddressCreatePostalCode, AddressCreateSetDefault, AddressCreateStateSelect, AddressCreateSubmit, AddressCreateTextInput, AddressCreateView, AddressSelectContainer, AddressSelectList, AddressSelectModal, AddressSelectSubmit, AddressSelectView, AddressUpdateCity, AddressUpdateContainer, AddressUpdateCountrySelect, AddressUpdateFirstName, AddressUpdateLastName, AddressUpdateLine1, AddressUpdateLine2, AddressUpdateModal, AddressUpdatePostalCode, AddressUpdateSetDefault, AddressUpdateStateSelect, AddressUpdateSubmit, AddressUpdateTextInput, AddressUpdateView, AlertWithContext as Alert, Alert as AlertElement, ApplyCouponButton, Auth0LoginButton, Badge, BankAuthenticationSuccess, BankRedirection, Button, CartContainer, CartModal, CartRemoveItemButton, CartSubmit, CartTotalPrice, CartView, Checkbox, CheckoutForm, ConfirmPassword, CouponCode, CouponCodeField, DashboardWithHook as Dashboard, DashboardOpenButton, DatePicker, DiscountedPrice, Email, EmailVerifyContainer, EmailVerifyModal, EmailVerifyResendButton, EmailVerifyView, FacebookLoginButton, GiftCreateContainer, GiftCreateEmail, GiftCreateFirstName, GiftCreateLastName, GiftCreateMessage, GiftCreateModal, GiftCreateStartDate, GiftCreateSubmitButton, GiftCreateView, GiftRedeemCode, GiftRedeemContainer, GiftRedeemModal, GiftRedeemSubmitButton, GiftRedeemView, GoogleLoginButton, IncludeFirstName, IncludeLastName, IncludePhone, Input, InvoiceDetailsContainer, InvoiceDetailsDownloadButton, InvoiceDetailsModal, InvoiceDetailsPayButton, InvoiceDetailsView, InvoicePaymentContainer, InvoicePaymentModal, InvoicePaymentView, Link, LoginButton, LoginContainer, LoginEmail, LoginModal, LoginPassword, LoginRequestLoginToken, LoginUsername, LoginView, Logout, MeterModal, MeterView, Modal, ModalBody, ModalFooter, NewsletterWithHook as NewsLetter, NewsletterUpdateButton, NewsletterUpdateContainer, NewsletterUpdateList, NewsletterUpdateModal, NewsletterUpdateView, Notification, OrderConfirmModal, OrderCreateContainer, OrderCreateFreeButton, OrderCreateModal, OrderCreateSubmitButton, OrderCreateView, Password, PasswordChangeButton, PasswordChangeConfirmNewPassword, PasswordChangeContainer, PasswordChangeCurrentPassword, PasswordChangeModal, PasswordChangeNewPassword, PasswordChangeView, PasswordForgotButton, PasswordForgotContainer, PasswordForgotEmail, PasswordForgotModal, PasswordForgotView, PasswordResetButton, PasswordResetConfirmPassword, PasswordResetContainer, PasswordResetEmail, PasswordResetModal, PasswordResetPassword, PasswordResetView, PasswordlessRequestContainer, PasswordlessRequestEmail, PasswordlessRequestModal, PasswordlessRequestView, PasswordlessRequestViewButton, PaymentCreateContainer, PaymentCreateView, PaymentMethodContainer, PaymentMethodSelectContainer, PaymentMethodSelectList, PaymentMethodSelectModal, PaymentMethodSelectSubmit, PaymentMethodSelectView, PaymentMethodUpdateContainer, PaymentMethodUpdateModal, PaymentMethodUpdateView, PaymentMethodView, PaymentSuccessModal, PaymentSuccessView, PaypalSubscribeButton, PelcroCardCVC, PelcroCardExpiry, PelcroCardNumber, PelcroModalController, PelcroPaymentRequestButton, ProfilePicChangeButton, ProfilePicChangeContainer, ProfilePicChangeCropper, ProfilePicChangeModal, ProfilePicChangeRemoveButton, ProfilePicChangeSelectButton, ProfilePicChangeView, ProfilePicChangeZoom, QrCodeModal, QrCodeView, Radio, RegisterButton, RegisterCompany, RegisterContainer, RegisterEmail, RegisterFirstName, RegisterJobTitle, RegisterLastName, RegisterModal, RegisterPassword, RegisterView, Select, SelectModalWithHook as SelectModal, SelectedPaymentMethod, ShopPurchaseButton, ShopSelectProductButton, ShopView, SubmitPaymentMethod, SubscriptionCancelModal, SubscriptionCreateContainer, SubscriptionCreateFreePlanButton, SubscriptionCreateModal, SubscriptionCreateView, SubscriptionManageMembersButton, SubscriptionManageMembersContainer, SubscriptionManageMembersEmails, SubscriptionManageMembersList, SubscriptionManageMembersModal, SubscriptionManageMembersView, SubscriptionRenewContainer, SubscriptionRenewModal, SubscriptionRenewView, SubscriptionSuspendContainer, SubscriptionSuspendModal, SubscriptionSuspendView, TaxAmount, TextArea, Tooltip, UserNameInput, UserUpdateButton, UserUpdateContainer, UserUpdateDisplayName, UserUpdateEmail, UserUpdateFirstName, UserUpdateLastName, UserUpdateModal, UserUpdatePhone, UserUpdateProfilePic, UserUpdateTextInput, UserUpdateTin, UserUpdateUsername, UserUpdateView, VerifyLinkTokenContainer, VerifyLinkTokenLoader, VerifyLinkTokenModal, VerifyLinkTokenView, authenticatedButtons, i18next as i18n, init$1 as initButtons, init as initContentEntitlement, invoicePaymentSubmitButton, notify$1 as notify, unauthenticatedButtons, usePelcro };
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.21.0-beta.1",
4
+ "version": "3.21.0-beta.2",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",