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

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
@@ -11141,6 +11141,9 @@ const initViewFromURL = () => {
11141
11141
  if (view === "manage-members") {
11142
11142
  return showSubscriptionManageMembersFromUrl();
11143
11143
  }
11144
+ if (view === "payment-method-update") {
11145
+ return showPaymentMethodUpdateFromUrl();
11146
+ }
11144
11147
  switchView(view);
11145
11148
  });
11146
11149
  }
@@ -11349,6 +11352,43 @@ const showPasswordlessRequestFromUrl = () => {
11349
11352
  } = usePelcro.getStore();
11350
11353
  return switchView("passwordless-request");
11351
11354
  };
11355
+ const showPaymentMethodUpdateFromUrl = () => {
11356
+ const {
11357
+ isAuthenticated,
11358
+ whenSiteReady,
11359
+ whenUserReady,
11360
+ switchView
11361
+ } = usePelcro.getStore();
11362
+ whenSiteReady(() => {
11363
+ if (!isAuthenticated()) {
11364
+ return switchView("login");
11365
+ }
11366
+ whenUserReady(() => {
11367
+ const supportsVantiv = Boolean(window.Pelcro.site.read().vantiv_gateway_settings);
11368
+ const supportsTap = Boolean(window.Pelcro.site.read().tap_gateway_settings);
11369
+ if (!window.Stripe && !supportsVantiv && !supportsTap) {
11370
+ document.querySelector('script[src="https://js.stripe.com/v3"]').addEventListener("load", () => {
11371
+ return switchView("payment-method-update");
11372
+ });
11373
+ return;
11374
+ }
11375
+
11376
+ //vantiv
11377
+ if (supportsVantiv) {
11378
+ document.querySelector("#vantiv-eprotect-sdk").addEventListener("load", () => {
11379
+ return switchView("payment-method-update");
11380
+ });
11381
+ return;
11382
+ }
11383
+
11384
+ //Tap
11385
+ if (supportsTap && document.querySelector("#tap-sdk")) {
11386
+ return switchView("payment-method-update");
11387
+ }
11388
+ return switchView("payment-method-update");
11389
+ });
11390
+ });
11391
+ };
11352
11392
  const showInvoiceDetailsFromUrl = () => {
11353
11393
  const {
11354
11394
  isAuthenticated,
@@ -16397,7 +16437,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16397
16437
  }
16398
16438
  });
16399
16439
  } else {
16400
- window.Pelcro.payment.authorize({
16440
+ window.Pelcro.payment.verify({
16401
16441
  auth_token: window.Pelcro.user.read().auth_token,
16402
16442
  first_name: window.Pelcro.user.read().first_name || state.firstName,
16403
16443
  last_name: window.Pelcro.user.read().last_name || state.lastName,
@@ -16406,7 +16446,8 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16406
16446
  amount: totalAmount,
16407
16447
  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
16448
  tap_token: result.id,
16409
- redirect_url: `${window.Pelcro.environment.domain}/webhook/tap/callback/3dsecure?auth_token=${window.Pelcro.user.read().auth_token}`
16449
+ funding: result.card.funding,
16450
+ 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
16451
  }, (err, res) => {
16411
16452
  if (err) {
16412
16453
  // Inform the user if there was an error
@@ -16483,6 +16524,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16483
16524
  type: LOADING,
16484
16525
  payload: false
16485
16526
  });
16527
+ toggleAuthenticationSuccessPendingView(false);
16486
16528
  if (err) {
16487
16529
  onFailure(err);
16488
16530
  return dispatch({
@@ -16501,8 +16543,10 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16501
16543
  }
16502
16544
  });
16503
16545
  onSuccess(res);
16504
- });
16546
+ } //
16547
+ );
16505
16548
  }
16549
+
16506
16550
  function handleTapSubscription() {
16507
16551
  const payment = new Payment(new TapGateway());
16508
16552
  const createSubscription = !isGift && !subscriptionIdToRenew;
@@ -16791,7 +16835,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16791
16835
  const tapInstanceRef = React__default['default'].useRef(null);
16792
16836
  const tapInstanceCard = React__default['default'].useRef(null);
16793
16837
  React.useEffect(() => {
16794
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16838
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) return;
16795
16839
  if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
16796
16840
  var _window$Pelcro$site$r2, _window$Pelcro$site$r3;
16797
16841
  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 +16864,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16820
16864
  }, [selectedPaymentMethodId]);
16821
16865
  React.useEffect(() => {
16822
16866
  whenUserReady(() => {
16823
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16867
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) return;
16824
16868
  if (cardProcessor === "tap" && !window.Tapjsli) {
16825
16869
  window.Pelcro.helpers.loadSDK("https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js", "tap-bluebird");
16826
16870
  window.Pelcro.helpers.loadSDK("https://secure.gosell.io/js/sdk/tap.min.js", "tap-sdk");
@@ -16834,7 +16878,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16834
16878
  });
16835
16879
  }, [selectedPaymentMethodId]);
16836
16880
  const initPaymentRequest = (state, dispatch) => {
16837
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16881
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) return;
16838
16882
  try {
16839
16883
  const paymentRequest = stripe.paymentRequest({
16840
16884
  country: window.Pelcro.user.location.countryCode || "US",
@@ -16903,7 +16947,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16903
16947
  */
16904
16948
  const updateTotalAmountWithTax = () => {
16905
16949
  var _window$Pelcro$site$r4;
16906
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16950
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) return;
16907
16951
  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
16952
  if (taxesEnabled && type === "createPayment") {
16909
16953
  dispatch({
@@ -17498,6 +17542,29 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17498
17542
  });
17499
17543
  };
17500
17544
  const submitPayment = (state, dispatch) => {
17545
+ if (skipPayment && (order === null || order === void 0 ? void 0 : order.price) === 0) {
17546
+ const isQuickPurchase = !Array.isArray(order);
17547
+ const mappedOrderItems = isQuickPurchase ? [{
17548
+ sku_id: order.id,
17549
+ quantity: order.quantity
17550
+ }] : order.map(item => ({
17551
+ sku_id: item.id,
17552
+ quantity: item.quantity
17553
+ }));
17554
+ window.Pelcro.ecommerce.order.create({
17555
+ items: mappedOrderItems,
17556
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
17557
+ ...(selectedAddressId && {
17558
+ address_id: selectedAddressId
17559
+ })
17560
+ }, (err, res) => {
17561
+ if (err) {
17562
+ return handlePaymentError(err);
17563
+ }
17564
+ return onSuccess(res);
17565
+ });
17566
+ return;
17567
+ }
17501
17568
  stripe.createSource({
17502
17569
  type: "card"
17503
17570
  }).then(_ref8 => {
@@ -17859,10 +17926,14 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17859
17926
  state,
17860
17927
  dispatch
17861
17928
  }
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, {
17929
+ }, children.length ? children.map((child, i) => {
17930
+ if (child) {
17931
+ return /*#__PURE__*/React__default['default'].cloneElement(child, {
17932
+ store: store$k,
17933
+ key: i
17934
+ });
17935
+ }
17936
+ }) : /*#__PURE__*/React__default['default'].cloneElement(children, {
17866
17937
  store: store$k
17867
17938
  })));
17868
17939
  };
@@ -18684,6 +18755,42 @@ const SubscriptionCreateFreePlanButton = _ref => {
18684
18755
  }, otherProps), t("buttons.subscribe"));
18685
18756
  };
18686
18757
 
18758
+ const OrderCreateFreeButton = _ref => {
18759
+ let {
18760
+ name,
18761
+ onClick,
18762
+ ...otherProps
18763
+ } = _ref;
18764
+ const {
18765
+ state: {
18766
+ disableSubmit
18767
+ },
18768
+ dispatch
18769
+ } = React.useContext(store$k);
18770
+ const {
18771
+ t
18772
+ } = useTranslation("checkoutForm");
18773
+ const [isDisabled, setDisabled] = React.useState(true);
18774
+ React.useEffect(() => {
18775
+ setDisabled(disableSubmit);
18776
+ }, [disableSubmit]);
18777
+ return /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({
18778
+ className: "plc-w-full",
18779
+ onClick: () => {
18780
+ dispatch({
18781
+ type: DISABLE_SUBMIT,
18782
+ payload: true
18783
+ });
18784
+ dispatch({
18785
+ type: SUBMIT_PAYMENT
18786
+ });
18787
+ onClick === null || onClick === void 0 ? void 0 : onClick();
18788
+ },
18789
+ disabled: isDisabled,
18790
+ isLoading: disableSubmit
18791
+ }, otherProps), t("labels.submit"));
18792
+ };
18793
+
18687
18794
  /**
18688
18795
  *
18689
18796
  */
@@ -18696,7 +18803,8 @@ function PaymentMethodView(_ref) {
18696
18803
  type,
18697
18804
  showCoupon,
18698
18805
  showExternalPaymentMethods,
18699
- showSubscriptionButton
18806
+ showSubscriptionButton,
18807
+ showOrderButton
18700
18808
  } = _ref;
18701
18809
  const {
18702
18810
  t
@@ -18709,7 +18817,7 @@ function PaymentMethodView(_ref) {
18709
18817
  const isUserPhone = Boolean(window.Pelcro.user.read().phone);
18710
18818
  return /*#__PURE__*/React__default['default'].createElement("div", {
18711
18819
  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", {
18820
+ }, cardProcessor === "stripe" && !showSubscriptionButton && !showOrderButton && /*#__PURE__*/React__default['default'].createElement("div", {
18713
18821
  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
18822
  }, /*#__PURE__*/React__default['default'].createElement(SvgLock, {
18715
18823
  className: "plc-w-5 plc-h-5 plc-mr-1"
@@ -18728,7 +18836,7 @@ function PaymentMethodView(_ref) {
18728
18836
  onFailure: onFailure
18729
18837
  }, /*#__PURE__*/React__default['default'].createElement(AlertWithContext, {
18730
18838
  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", {
18839
+ }), 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
18840
  className: "plc-flex plc-items-start"
18733
18841
  }, /*#__PURE__*/React__default['default'].createElement(IncludeFirstName, {
18734
18842
  id: "pelcro-input-first-name",
@@ -24138,9 +24246,15 @@ const OrderCreateContainer = props => /*#__PURE__*/React__default['default'].cre
24138
24246
  }, props));
24139
24247
 
24140
24248
  const OrderCreateView = props => {
24249
+ var _window$Pelcro, _window$Pelcro$uiSett;
24141
24250
  const {
24142
24251
  t
24143
24252
  } = useTranslation("payment");
24253
+ const {
24254
+ order
24255
+ } = usePelcro();
24256
+ 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;
24257
+ const showOrderButton = skipPayment && (order === null || order === void 0 ? void 0 : order.price) === 0;
24144
24258
  return /*#__PURE__*/React__default['default'].createElement("div", {
24145
24259
  id: "pelcro-order-create-view"
24146
24260
  }, /*#__PURE__*/React__default['default'].createElement("div", {
@@ -24151,7 +24265,8 @@ const OrderCreateView = props => {
24151
24265
  }, /*#__PURE__*/React__default['default'].createElement(PaymentMethodView, Object.assign({
24152
24266
  type: "orderCreate",
24153
24267
  showCoupon: true,
24154
- showExternalPaymentMethods: false
24268
+ showExternalPaymentMethods: false,
24269
+ showOrderButton: showOrderButton
24155
24270
  }, props))));
24156
24271
  };
24157
24272
 
@@ -25359,11 +25474,12 @@ const PaymentMethodSelectModal = _ref => {
25359
25474
  const {
25360
25475
  switchToCheckoutForm,
25361
25476
  set,
25362
- plan
25477
+ plan,
25478
+ order
25363
25479
  } = usePelcro();
25364
25480
  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
25481
  React.useEffect(() => {
25366
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) {
25482
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) {
25367
25483
  switchToCheckoutForm();
25368
25484
  }
25369
25485
  }, []);
@@ -32181,6 +32297,7 @@ exports.NewsletterUpdateView = NewsletterUpdateView;
32181
32297
  exports.Notification = Notification;
32182
32298
  exports.OrderConfirmModal = OrderConfirmModal;
32183
32299
  exports.OrderCreateContainer = OrderCreateContainer;
32300
+ exports.OrderCreateFreeButton = OrderCreateFreeButton;
32184
32301
  exports.OrderCreateModal = OrderCreateModal;
32185
32302
  exports.OrderCreateSubmitButton = OrderCreateSubmitButton;
32186
32303
  exports.OrderCreateView = OrderCreateView;
package/dist/index.esm.js CHANGED
@@ -11111,6 +11111,9 @@ const initViewFromURL = () => {
11111
11111
  if (view === "manage-members") {
11112
11112
  return showSubscriptionManageMembersFromUrl();
11113
11113
  }
11114
+ if (view === "payment-method-update") {
11115
+ return showPaymentMethodUpdateFromUrl();
11116
+ }
11114
11117
  switchView(view);
11115
11118
  });
11116
11119
  }
@@ -11319,6 +11322,43 @@ const showPasswordlessRequestFromUrl = () => {
11319
11322
  } = usePelcro.getStore();
11320
11323
  return switchView("passwordless-request");
11321
11324
  };
11325
+ const showPaymentMethodUpdateFromUrl = () => {
11326
+ const {
11327
+ isAuthenticated,
11328
+ whenSiteReady,
11329
+ whenUserReady,
11330
+ switchView
11331
+ } = usePelcro.getStore();
11332
+ whenSiteReady(() => {
11333
+ if (!isAuthenticated()) {
11334
+ return switchView("login");
11335
+ }
11336
+ whenUserReady(() => {
11337
+ const supportsVantiv = Boolean(window.Pelcro.site.read().vantiv_gateway_settings);
11338
+ const supportsTap = Boolean(window.Pelcro.site.read().tap_gateway_settings);
11339
+ if (!window.Stripe && !supportsVantiv && !supportsTap) {
11340
+ document.querySelector('script[src="https://js.stripe.com/v3"]').addEventListener("load", () => {
11341
+ return switchView("payment-method-update");
11342
+ });
11343
+ return;
11344
+ }
11345
+
11346
+ //vantiv
11347
+ if (supportsVantiv) {
11348
+ document.querySelector("#vantiv-eprotect-sdk").addEventListener("load", () => {
11349
+ return switchView("payment-method-update");
11350
+ });
11351
+ return;
11352
+ }
11353
+
11354
+ //Tap
11355
+ if (supportsTap && document.querySelector("#tap-sdk")) {
11356
+ return switchView("payment-method-update");
11357
+ }
11358
+ return switchView("payment-method-update");
11359
+ });
11360
+ });
11361
+ };
11322
11362
  const showInvoiceDetailsFromUrl = () => {
11323
11363
  const {
11324
11364
  isAuthenticated,
@@ -16367,7 +16407,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16367
16407
  }
16368
16408
  });
16369
16409
  } else {
16370
- window.Pelcro.payment.authorize({
16410
+ window.Pelcro.payment.verify({
16371
16411
  auth_token: window.Pelcro.user.read().auth_token,
16372
16412
  first_name: window.Pelcro.user.read().first_name || state.firstName,
16373
16413
  last_name: window.Pelcro.user.read().last_name || state.lastName,
@@ -16376,7 +16416,8 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16376
16416
  amount: totalAmount,
16377
16417
  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
16418
  tap_token: result.id,
16379
- redirect_url: `${window.Pelcro.environment.domain}/webhook/tap/callback/3dsecure?auth_token=${window.Pelcro.user.read().auth_token}`
16419
+ funding: result.card.funding,
16420
+ 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
16421
  }, (err, res) => {
16381
16422
  if (err) {
16382
16423
  // Inform the user if there was an error
@@ -16453,6 +16494,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16453
16494
  type: LOADING,
16454
16495
  payload: false
16455
16496
  });
16497
+ toggleAuthenticationSuccessPendingView(false);
16456
16498
  if (err) {
16457
16499
  onFailure(err);
16458
16500
  return dispatch({
@@ -16471,8 +16513,10 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16471
16513
  }
16472
16514
  });
16473
16515
  onSuccess(res);
16474
- });
16516
+ } //
16517
+ );
16475
16518
  }
16519
+
16476
16520
  function handleTapSubscription() {
16477
16521
  const payment = new Payment(new TapGateway());
16478
16522
  const createSubscription = !isGift && !subscriptionIdToRenew;
@@ -16761,7 +16805,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16761
16805
  const tapInstanceRef = React__default.useRef(null);
16762
16806
  const tapInstanceCard = React__default.useRef(null);
16763
16807
  useEffect(() => {
16764
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16808
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) return;
16765
16809
  if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
16766
16810
  var _window$Pelcro$site$r2, _window$Pelcro$site$r3;
16767
16811
  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 +16834,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16790
16834
  }, [selectedPaymentMethodId]);
16791
16835
  useEffect(() => {
16792
16836
  whenUserReady(() => {
16793
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16837
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) return;
16794
16838
  if (cardProcessor === "tap" && !window.Tapjsli) {
16795
16839
  window.Pelcro.helpers.loadSDK("https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js", "tap-bluebird");
16796
16840
  window.Pelcro.helpers.loadSDK("https://secure.gosell.io/js/sdk/tap.min.js", "tap-sdk");
@@ -16804,7 +16848,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16804
16848
  });
16805
16849
  }, [selectedPaymentMethodId]);
16806
16850
  const initPaymentRequest = (state, dispatch) => {
16807
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16851
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) return;
16808
16852
  try {
16809
16853
  const paymentRequest = stripe.paymentRequest({
16810
16854
  country: window.Pelcro.user.location.countryCode || "US",
@@ -16873,7 +16917,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16873
16917
  */
16874
16918
  const updateTotalAmountWithTax = () => {
16875
16919
  var _window$Pelcro$site$r4;
16876
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
16920
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) return;
16877
16921
  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
16922
  if (taxesEnabled && type === "createPayment") {
16879
16923
  dispatch({
@@ -17468,6 +17512,29 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17468
17512
  });
17469
17513
  };
17470
17514
  const submitPayment = (state, dispatch) => {
17515
+ if (skipPayment && (order === null || order === void 0 ? void 0 : order.price) === 0) {
17516
+ const isQuickPurchase = !Array.isArray(order);
17517
+ const mappedOrderItems = isQuickPurchase ? [{
17518
+ sku_id: order.id,
17519
+ quantity: order.quantity
17520
+ }] : order.map(item => ({
17521
+ sku_id: item.id,
17522
+ quantity: item.quantity
17523
+ }));
17524
+ window.Pelcro.ecommerce.order.create({
17525
+ items: mappedOrderItems,
17526
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
17527
+ ...(selectedAddressId && {
17528
+ address_id: selectedAddressId
17529
+ })
17530
+ }, (err, res) => {
17531
+ if (err) {
17532
+ return handlePaymentError(err);
17533
+ }
17534
+ return onSuccess(res);
17535
+ });
17536
+ return;
17537
+ }
17471
17538
  stripe.createSource({
17472
17539
  type: "card"
17473
17540
  }).then(_ref8 => {
@@ -17829,10 +17896,14 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17829
17896
  state,
17830
17897
  dispatch
17831
17898
  }
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, {
17899
+ }, children.length ? children.map((child, i) => {
17900
+ if (child) {
17901
+ return /*#__PURE__*/React__default.cloneElement(child, {
17902
+ store: store$k,
17903
+ key: i
17904
+ });
17905
+ }
17906
+ }) : /*#__PURE__*/React__default.cloneElement(children, {
17836
17907
  store: store$k
17837
17908
  })));
17838
17909
  };
@@ -18654,6 +18725,42 @@ const SubscriptionCreateFreePlanButton = _ref => {
18654
18725
  }, otherProps), t("buttons.subscribe"));
18655
18726
  };
18656
18727
 
18728
+ const OrderCreateFreeButton = _ref => {
18729
+ let {
18730
+ name,
18731
+ onClick,
18732
+ ...otherProps
18733
+ } = _ref;
18734
+ const {
18735
+ state: {
18736
+ disableSubmit
18737
+ },
18738
+ dispatch
18739
+ } = useContext(store$k);
18740
+ const {
18741
+ t
18742
+ } = useTranslation("checkoutForm");
18743
+ const [isDisabled, setDisabled] = useState(true);
18744
+ useEffect(() => {
18745
+ setDisabled(disableSubmit);
18746
+ }, [disableSubmit]);
18747
+ return /*#__PURE__*/React__default.createElement(Button, Object.assign({
18748
+ className: "plc-w-full",
18749
+ onClick: () => {
18750
+ dispatch({
18751
+ type: DISABLE_SUBMIT,
18752
+ payload: true
18753
+ });
18754
+ dispatch({
18755
+ type: SUBMIT_PAYMENT
18756
+ });
18757
+ onClick === null || onClick === void 0 ? void 0 : onClick();
18758
+ },
18759
+ disabled: isDisabled,
18760
+ isLoading: disableSubmit
18761
+ }, otherProps), t("labels.submit"));
18762
+ };
18763
+
18657
18764
  /**
18658
18765
  *
18659
18766
  */
@@ -18666,7 +18773,8 @@ function PaymentMethodView(_ref) {
18666
18773
  type,
18667
18774
  showCoupon,
18668
18775
  showExternalPaymentMethods,
18669
- showSubscriptionButton
18776
+ showSubscriptionButton,
18777
+ showOrderButton
18670
18778
  } = _ref;
18671
18779
  const {
18672
18780
  t
@@ -18679,7 +18787,7 @@ function PaymentMethodView(_ref) {
18679
18787
  const isUserPhone = Boolean(window.Pelcro.user.read().phone);
18680
18788
  return /*#__PURE__*/React__default.createElement("div", {
18681
18789
  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", {
18790
+ }, cardProcessor === "stripe" && !showSubscriptionButton && !showOrderButton && /*#__PURE__*/React__default.createElement("div", {
18683
18791
  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
18792
  }, /*#__PURE__*/React__default.createElement(SvgLock, {
18685
18793
  className: "plc-w-5 plc-h-5 plc-mr-1"
@@ -18698,7 +18806,7 @@ function PaymentMethodView(_ref) {
18698
18806
  onFailure: onFailure
18699
18807
  }, /*#__PURE__*/React__default.createElement(AlertWithContext, {
18700
18808
  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", {
18809
+ }), 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
18810
  className: "plc-flex plc-items-start"
18703
18811
  }, /*#__PURE__*/React__default.createElement(IncludeFirstName, {
18704
18812
  id: "pelcro-input-first-name",
@@ -24108,9 +24216,15 @@ const OrderCreateContainer = props => /*#__PURE__*/React__default.createElement(
24108
24216
  }, props));
24109
24217
 
24110
24218
  const OrderCreateView = props => {
24219
+ var _window$Pelcro, _window$Pelcro$uiSett;
24111
24220
  const {
24112
24221
  t
24113
24222
  } = useTranslation("payment");
24223
+ const {
24224
+ order
24225
+ } = usePelcro();
24226
+ 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;
24227
+ const showOrderButton = skipPayment && (order === null || order === void 0 ? void 0 : order.price) === 0;
24114
24228
  return /*#__PURE__*/React__default.createElement("div", {
24115
24229
  id: "pelcro-order-create-view"
24116
24230
  }, /*#__PURE__*/React__default.createElement("div", {
@@ -24121,7 +24235,8 @@ const OrderCreateView = props => {
24121
24235
  }, /*#__PURE__*/React__default.createElement(PaymentMethodView, Object.assign({
24122
24236
  type: "orderCreate",
24123
24237
  showCoupon: true,
24124
- showExternalPaymentMethods: false
24238
+ showExternalPaymentMethods: false,
24239
+ showOrderButton: showOrderButton
24125
24240
  }, props))));
24126
24241
  };
24127
24242
 
@@ -25329,11 +25444,12 @@ const PaymentMethodSelectModal = _ref => {
25329
25444
  const {
25330
25445
  switchToCheckoutForm,
25331
25446
  set,
25332
- plan
25447
+ plan,
25448
+ order
25333
25449
  } = usePelcro();
25334
25450
  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
25451
  useEffect(() => {
25336
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) {
25452
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) {
25337
25453
  switchToCheckoutForm();
25338
25454
  }
25339
25455
  }, []);
@@ -32038,4 +32154,4 @@ const QrCodeModal = _ref => {
32038
32154
  };
32039
32155
  QrCodeModal.viewId = "qrcode";
32040
32156
 
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 };
32157
+ 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.3",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",