@pelcro/react-pelcro-js 3.51.0 → 3.54.0

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
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
- var ReactDOM = require('react-dom');
7
6
  var PropTypes = require('prop-types');
7
+ var ReactDOM = require('react-dom');
8
8
 
9
9
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
10
10
 
@@ -30,8 +30,8 @@ function _interopNamespace(e) {
30
30
 
31
31
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
32
32
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
33
- var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
34
33
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
34
+ var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
35
35
 
36
36
  function _typeof$3(obj) {
37
37
  "@babel/helpers - typeof";
@@ -2574,7 +2574,7 @@ var voidElements = {
2574
2574
  "wbr": true
2575
2575
  };
2576
2576
 
2577
- var t$1=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function n$1(n){var r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},i=n.match(/<\/?([^\s]+?)[/\s>]/);if(i&&(r.name=i[1],(voidElements[i[1]]||"/"===n.charAt(n.length-2))&&(r.voidElement=!0),r.name.startsWith("!--"))){var s=n.indexOf("--\x3e");return {type:"comment",comment:-1!==s?n.slice(4,s):""}}for(var a=new RegExp(t$1),c=null;null!==(c=a.exec(n));)if(c[0].trim())if(c[1]){var o=c[1].trim(),l=[o,""];o.indexOf("=")>-1&&(l=o.split("=")),r.attrs[l[0]]=l[1],a.lastIndex--;}else c[2]&&(r.attrs[c[2]]=c[3].trim().substring(1,c[3].length-1));return r}var r=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,i$2=/^\s*$/,s$1=Object.create(null);function a$1(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(a$1,"")+"</"+t.name+">";case"comment":return e+"\x3c!--"+t.comment+"--\x3e"}}var c$2={parse:function(e,t){t||(t={}),t.components||(t.components=s$1);var a,c=[],o=[],l=-1,m=!1;if(0!==e.indexOf("<")){var u=e.indexOf("<");c.push({type:"text",content:-1===u?e:e.substring(0,u)});}return e.replace(r,function(r,s){if(m){if(r!=="</"+a.name+">")return;m=!1;}var u,f="/"!==r.charAt(1),h=r.startsWith("\x3c!--"),p=s+r.length,d=e.charAt(p);if(h){var v=n$1(r);return l<0?(c.push(v),c):((u=o[l]).children.push(v),c)}if(f&&(l++,"tag"===(a=n$1(r)).type&&t.components[a.name]&&(a.type="component",m=!0),a.voidElement||m||!d||"<"===d||a.children.push({type:"text",content:e.slice(p,e.indexOf("<",p))}),0===l&&c.push(a),(u=o[l-1])&&u.children.push(a),o[l]=a),(!f||a.voidElement)&&(l>-1&&(a.voidElement||a.name===r.slice(2,-1))&&(l--,a=-1===l?c:o[l]),!m&&"<"!==d&&d)){u=-1===l?c:o[l].children;var x=e.indexOf("<",p),g=e.slice(p,-1===x?void 0:x);i$2.test(g)&&(g=" "),(x>-1&&l+u.length>=0||" "!==g)&&u.push({type:"text",content:g});}}),c},stringify:function(e){return e.reduce(function(e,t){return e+a$1("",t)},"")}};
2577
+ var t$1=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function n$1(n){var r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},i=n.match(/<\/?([^\s]+?)[/\s>]/);if(i&&(r.name=i[1],(voidElements[i[1]]||"/"===n.charAt(n.length-2))&&(r.voidElement=!0),r.name.startsWith("!--"))){var s=n.indexOf("--\x3e");return {type:"comment",comment:-1!==s?n.slice(4,s):""}}for(var a=new RegExp(t$1),c=null;null!==(c=a.exec(n));)if(c[0].trim())if(c[1]){var o=c[1].trim(),l=[o,""];o.indexOf("=")>-1&&(l=o.split("=")),r.attrs[l[0]]=l[1],a.lastIndex--;}else c[2]&&(r.attrs[c[2]]=c[3].trim().substring(1,c[3].length-1));return r}var r=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,i$2=/^\s*$/,s$1=Object.create(null);function a$1(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(a$1,"")+"</"+t.name+">";case"comment":return e+"\x3c!--"+t.comment+"--\x3e"}}var c$1={parse:function(e,t){t||(t={}),t.components||(t.components=s$1);var a,c=[],o=[],l=-1,m=!1;if(0!==e.indexOf("<")){var u=e.indexOf("<");c.push({type:"text",content:-1===u?e:e.substring(0,u)});}return e.replace(r,function(r,s){if(m){if(r!=="</"+a.name+">")return;m=!1;}var u,f="/"!==r.charAt(1),h=r.startsWith("\x3c!--"),p=s+r.length,d=e.charAt(p);if(h){var v=n$1(r);return l<0?(c.push(v),c):((u=o[l]).children.push(v),c)}if(f&&(l++,"tag"===(a=n$1(r)).type&&t.components[a.name]&&(a.type="component",m=!0),a.voidElement||m||!d||"<"===d||a.children.push({type:"text",content:e.slice(p,e.indexOf("<",p))}),0===l&&c.push(a),(u=o[l-1])&&u.children.push(a),o[l]=a),(!f||a.voidElement)&&(l>-1&&(a.voidElement||a.name===r.slice(2,-1))&&(l--,a=-1===l?c:o[l]),!m&&"<"!==d&&d)){u=-1===l?c:o[l].children;var x=e.indexOf("<",p),g=e.slice(p,-1===x?void 0:x);i$2.test(g)&&(g=" "),(x>-1&&l+u.length>=0||" "!==g)&&u.push({type:"text",content:g});}}),c},stringify:function(e){return e.reduce(function(e,t){return e+a$1("",t)},"")}};
2578
2578
 
2579
2579
  var classCallCheck = createCommonjsModule(function (module) {
2580
2580
  function _classCallCheck(instance, Constructor) {
@@ -2836,7 +2836,7 @@ function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts) {
2836
2836
 
2837
2837
  getData(children);
2838
2838
  var interpolatedString = i18n.services.interpolator.interpolate(targetString, _objectSpread$5(_objectSpread$5({}, data), combinedTOpts), i18n.language);
2839
- var ast = c$2.parse("<0>".concat(interpolatedString, "</0>"));
2839
+ var ast = c$1.parse("<0>".concat(interpolatedString, "</0>"));
2840
2840
 
2841
2841
  function renderInner(child, node, rootReactNode) {
2842
2842
  var childs = getChildren(child);
@@ -7098,8 +7098,6 @@ exports.default = create;
7098
7098
 
7099
7099
  var createStore = unwrapExports(vanilla);
7100
7100
 
7101
- function c$1(c,r,d){const u={count:0},s=t=>{const o=React.useRef(u.count);return React.useEffect(()=>{o.current+=1,o.current===u.count+1&&(o.current-=1,r.setState(t));}),null};if(s.displayName=`((${c})) devtool`,!d){let t=document.getElementById("simple-zustand-devtools");t||(t=document.createElement("div"),t.id="simple-zustand-devtools"),document.body.appendChild(t),d=t;}const m=e=>{e&&(ReactDOM.render(React__default['default'].createElement(s,Object.assign({},e)),d),u.count+=1);};m(r.getState()),r.subscribe(m);}
7102
-
7103
7101
  var _extends_1 = createCommonjsModule(function (module) {
7104
7102
  function _extends() {
7105
7103
  module.exports = _extends = Object.assign || function (target) {
@@ -9301,7 +9299,8 @@ const usePelcro = createPelcroHook(pelcroStore);
9301
9299
 
9302
9300
  /* istanbul ignore next */
9303
9301
  if (process.env.NODE_ENV === "development") {
9304
- c$1("Pelcro Store", usePelcro);
9302
+ // mountStoreDevtool("Pelcro Store", usePelcro);
9303
+ console.log("Pelcro Store devtools disabled - simple-zustand-devtools incompatible with React 16");
9305
9304
  }
9306
9305
 
9307
9306
  /**
@@ -17892,6 +17891,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17892
17891
  onSuccess = () => {},
17893
17892
  onGiftRenewalSuccess = () => {},
17894
17893
  onFailure = () => {},
17894
+ onPriceUpdate = () => {},
17895
17895
  ...props
17896
17896
  } = _ref;
17897
17897
  const [vantivPaymentRequest, setVantivPaymentRequest] = React.useState(null);
@@ -18672,7 +18672,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18672
18672
  payload: true
18673
18673
  });
18674
18674
  try {
18675
- var _window$Pelcro$site$r7, _window$Pelcro$site$r8;
18675
+ var _window$Pelcro$site$r7, _window$Pelcro$site$r8, _window$Pelcro$site$r9;
18676
18676
  // Ensure the DOM element exists before creating Drop-in UI
18677
18677
  const dropinContainer = document.querySelector("#dropin-container");
18678
18678
  if (!dropinContainer) {
@@ -18727,22 +18727,25 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18727
18727
  // Enable Google Pay for both orders and subscriptions
18728
18728
  googlePay: {
18729
18729
  googlePayVersion: 2,
18730
- merchantId: (_window$Pelcro$site$r8 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r8 === void 0 ? void 0 : _window$Pelcro$site$r8.google_merchant_id,
18730
+ merchantId: (_window$Pelcro$site$r8 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r8 === void 0 ? void 0 : (_window$Pelcro$site$r9 = _window$Pelcro$site$r8.braintree_gateway_settings) === null || _window$Pelcro$site$r9 === void 0 ? void 0 : _window$Pelcro$site$r9.google_pay_merchant_id,
18731
18731
  transactionInfo: {
18732
18732
  totalPriceStatus: "FINAL",
18733
18733
  totalPrice: googlePayAmount,
18734
18734
  currencyCode: (() => {
18735
18735
  const currency = getCurrencyFromPaymentType(plan, order, invoice);
18736
18736
  return (currency === null || currency === void 0 ? void 0 : currency.toUpperCase()) || "USD";
18737
- })()
18737
+ })(),
18738
+ countryCode: "US" // Required for production Google Pay
18738
18739
  },
18740
+
18739
18741
  // Add button configuration
18740
18742
  button: {
18741
18743
  color: "black",
18742
- type: type === "createPayment" ? "subscribe" : "buy"
18744
+ type: "buy" // Always use "buy" - "subscribe" type causes OR_BIBED_11 error
18743
18745
  }
18744
18746
  }
18745
18747
  });
18748
+
18746
18749
  console.log("Setting skeleton loader to false after successful Braintree initialization");
18747
18750
  dispatch({
18748
18751
  type: SKELETON_LOADER,
@@ -18758,11 +18761,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18758
18761
  }
18759
18762
  });
18760
18763
  } catch (error) {
18761
- var _error$message, _error$message2, _error$message3, _error$message4;
18764
+ var _error$message, _error$message2, _error$message3, _error$message4, _error$message5, _error$message6;
18762
18765
  console.error("Failed to initialize Braintree Drop-in UI:", error);
18763
18766
 
18764
18767
  // Check if it's a Google Pay specific error
18765
- if (error !== null && error !== void 0 && (_error$message = error.message) !== null && _error$message !== void 0 && _error$message.includes("OR_BIBED_06") || error !== null && error !== void 0 && (_error$message2 = error.message) !== null && _error$message2 !== void 0 && _error$message2.includes("Google Pay")) {
18768
+ if (error !== null && error !== void 0 && (_error$message = error.message) !== null && _error$message !== void 0 && _error$message.includes("OR_BIBED_06") || error !== null && error !== void 0 && (_error$message2 = error.message) !== null && _error$message2 !== void 0 && _error$message2.includes("OR_BIBED_11") || error !== null && error !== void 0 && (_error$message3 = error.message) !== null && _error$message3 !== void 0 && _error$message3.includes("Google Pay")) {
18766
18769
  console.warn("Google Pay configuration issue detected. " + `Transaction type: ${type}. ` + "This might be due to merchant settings or unsupported payment flow.");
18767
18770
  }
18768
18771
  dispatch({
@@ -18772,7 +18775,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18772
18775
 
18773
18776
  // Don't show error to user for Google Pay configuration issues
18774
18777
  // as it's expected for subscriptions
18775
- if (!(error !== null && error !== void 0 && (_error$message3 = error.message) !== null && _error$message3 !== void 0 && _error$message3.includes("OR_BIBED_06")) && !(error !== null && error !== void 0 && (_error$message4 = error.message) !== null && _error$message4 !== void 0 && _error$message4.includes("Google Pay"))) {
18778
+ if (!(error !== null && error !== void 0 && (_error$message4 = error.message) !== null && _error$message4 !== void 0 && _error$message4.includes("OR_BIBED_06")) && !(error !== null && error !== void 0 && (_error$message5 = error.message) !== null && _error$message5 !== void 0 && _error$message5.includes("OR_BIBED_11")) && !(error !== null && error !== void 0 && (_error$message6 = error.message) !== null && _error$message6 !== void 0 && _error$message6.includes("Google Pay"))) {
18776
18779
  dispatch({
18777
18780
  type: SHOW_ALERT,
18778
18781
  payload: {
@@ -19471,9 +19474,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19471
19474
  React.useEffect(() => {
19472
19475
  if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
19473
19476
  if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
19474
- var _window$Pelcro$site$r9, _window$Pelcro$site$r10;
19475
- const payPageId = (_window$Pelcro$site$r9 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r9 === void 0 ? void 0 : _window$Pelcro$site$r9.vantiv_gateway_settings.pay_page_id;
19476
- const reportGroup = (_window$Pelcro$site$r10 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r10 === void 0 ? void 0 : _window$Pelcro$site$r10.vantiv_gateway_settings.report_group;
19477
+ var _window$Pelcro$site$r10, _window$Pelcro$site$r11;
19478
+ const payPageId = (_window$Pelcro$site$r10 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r10 === void 0 ? void 0 : _window$Pelcro$site$r10.vantiv_gateway_settings.pay_page_id;
19479
+ const reportGroup = (_window$Pelcro$site$r11 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r11 === void 0 ? void 0 : _window$Pelcro$site$r11.vantiv_gateway_settings.report_group;
19477
19480
  vantivInstanceRef.current = new window.EprotectIframeClient({
19478
19481
  paypageId: payPageId,
19479
19482
  reportGroup: reportGroup,
@@ -19593,9 +19596,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19593
19596
  * Updates the total amount after adding taxes only if site taxes are enabled
19594
19597
  */
19595
19598
  const updateTotalAmountWithTax = () => {
19596
- var _window$Pelcro$site$r11;
19599
+ var _window$Pelcro$site$r12;
19597
19600
  if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
19598
- const taxesEnabled = (_window$Pelcro$site$r11 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r11 === void 0 ? void 0 : _window$Pelcro$site$r11.taxes_enabled;
19601
+ const taxesEnabled = (_window$Pelcro$site$r12 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r12 === void 0 ? void 0 : _window$Pelcro$site$r12.taxes_enabled;
19599
19602
  if (taxesEnabled && type === "createPayment") {
19600
19603
  dispatch({
19601
19604
  type: DISABLE_SUBMIT,
@@ -20542,11 +20545,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20542
20545
  * @return {Promise}
20543
20546
  */
20544
20547
  const resolveTaxCalculation = () => {
20545
- var _window$Pelcro$site$r12;
20548
+ var _window$Pelcro$site$r13;
20546
20549
  if (type === "invoicePayment") {
20547
20550
  return new Promise(resolve => resolve());
20548
20551
  }
20549
- const taxesEnabled = (_window$Pelcro$site$r12 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r12 === void 0 ? void 0 : _window$Pelcro$site$r12.taxes_enabled;
20552
+ const taxesEnabled = (_window$Pelcro$site$r13 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r13 === void 0 ? void 0 : _window$Pelcro$site$r13.taxes_enabled;
20550
20553
  return new Promise((resolve, reject) => {
20551
20554
  // resolve early if taxes isn't enabled
20552
20555
  if (!taxesEnabled) {
@@ -20788,10 +20791,10 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20788
20791
  setVantivPaymentRequest(action.payload);
20789
20792
  });
20790
20793
  case SET_UPDATED_PRICE:
20791
- return lib_7({
20794
+ return lib_5({
20792
20795
  ...state,
20793
20796
  updatedPrice: action.payload
20794
- });
20797
+ }, () => onPriceUpdate(action.payload));
20795
20798
  case SET_TAX_AMOUNT:
20796
20799
  return lib_7({
20797
20800
  ...state,
@@ -22368,7 +22371,8 @@ function PaymentMethodView(_ref) {
22368
22371
  showSubscriptionButton,
22369
22372
  showOrderButton,
22370
22373
  showApplePayButton,
22371
- order
22374
+ order,
22375
+ onPriceUpdate
22372
22376
  } = _ref;
22373
22377
  const {
22374
22378
  t
@@ -22411,7 +22415,8 @@ function PaymentMethodView(_ref) {
22411
22415
  onSuccess: onSuccess,
22412
22416
  onGiftRenewalSuccess: onGiftRenewalSuccess,
22413
22417
  onFailure: onFailure,
22414
- freeOrders: showOrderButton
22418
+ freeOrders: showOrderButton,
22419
+ onPriceUpdate: onPriceUpdate
22415
22420
  }, /*#__PURE__*/React__default['default'].createElement(AlertWithContext, {
22416
22421
  className: "plc-mb-2"
22417
22422
  }), 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", {
@@ -22458,8 +22463,11 @@ const SubscriptionRenewView = _ref => {
22458
22463
  product,
22459
22464
  plan
22460
22465
  } = usePelcro();
22466
+ const [updatedPrice, setUpdatedPrice] = React.useState(null);
22461
22467
  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;
22462
- const showSubscriptionButton = skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0;
22468
+
22469
+ // Check both original plan amount and final amount after coupon
22470
+ const showSubscriptionButton = skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || updatedPrice === 0);
22463
22471
  const getPricingText = plan => {
22464
22472
  const autoRenewed = plan.auto_renew;
22465
22473
  const {
@@ -22496,7 +22504,8 @@ const SubscriptionRenewView = _ref => {
22496
22504
  onSuccess: onSuccess,
22497
22505
  onGiftRenewalSuccess: onGiftRenewalSuccess,
22498
22506
  onFailure: onFailure,
22499
- showSubscriptionButton: showSubscriptionButton
22507
+ showSubscriptionButton: showSubscriptionButton,
22508
+ onPriceUpdate: setUpdatedPrice
22500
22509
  }));
22501
22510
  };
22502
22511
 
@@ -23829,8 +23838,11 @@ const SubscriptionCreateView = _ref => {
23829
23838
  product,
23830
23839
  plan
23831
23840
  } = usePelcro();
23841
+ const [updatedPrice, setUpdatedPrice] = React.useState(null);
23832
23842
  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;
23833
- const showSubscriptionButton = skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0;
23843
+
23844
+ // Check both original plan amount and final amount after coupon
23845
+ const showSubscriptionButton = skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || updatedPrice === 0);
23834
23846
  const getPricingText = plan => {
23835
23847
  var _plan$quantity;
23836
23848
  const autoRenewed = plan.auto_renew;
@@ -23868,7 +23880,8 @@ const SubscriptionCreateView = _ref => {
23868
23880
  showApplePayButton: true,
23869
23881
  onSuccess: onSuccess,
23870
23882
  onFailure: onFailure,
23871
- showSubscriptionButton: showSubscriptionButton
23883
+ showSubscriptionButton: showSubscriptionButton,
23884
+ onPriceUpdate: setUpdatedPrice
23872
23885
  }));
23873
23886
  };
23874
23887
 
package/dist/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import React__default, { useContext, useState, useRef, useEffect, useReducer, useLayoutEffect, Component, memo, createElement, Fragment, useMemo, forwardRef, createContext, useCallback, isValidElement, cloneElement } from 'react';
3
- import ReactDOM, { render as render$1 } from 'react-dom';
4
3
  import PropTypes from 'prop-types';
4
+ import ReactDOM from 'react-dom';
5
5
 
6
6
  function _typeof$3(obj) {
7
7
  "@babel/helpers - typeof";
@@ -2544,7 +2544,7 @@ var voidElements = {
2544
2544
  "wbr": true
2545
2545
  };
2546
2546
 
2547
- var t$1=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function n$1(n){var r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},i=n.match(/<\/?([^\s]+?)[/\s>]/);if(i&&(r.name=i[1],(voidElements[i[1]]||"/"===n.charAt(n.length-2))&&(r.voidElement=!0),r.name.startsWith("!--"))){var s=n.indexOf("--\x3e");return {type:"comment",comment:-1!==s?n.slice(4,s):""}}for(var a=new RegExp(t$1),c=null;null!==(c=a.exec(n));)if(c[0].trim())if(c[1]){var o=c[1].trim(),l=[o,""];o.indexOf("=")>-1&&(l=o.split("=")),r.attrs[l[0]]=l[1],a.lastIndex--;}else c[2]&&(r.attrs[c[2]]=c[3].trim().substring(1,c[3].length-1));return r}var r=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,i$2=/^\s*$/,s$1=Object.create(null);function a$1(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(a$1,"")+"</"+t.name+">";case"comment":return e+"\x3c!--"+t.comment+"--\x3e"}}var c$2={parse:function(e,t){t||(t={}),t.components||(t.components=s$1);var a,c=[],o=[],l=-1,m=!1;if(0!==e.indexOf("<")){var u=e.indexOf("<");c.push({type:"text",content:-1===u?e:e.substring(0,u)});}return e.replace(r,function(r,s){if(m){if(r!=="</"+a.name+">")return;m=!1;}var u,f="/"!==r.charAt(1),h=r.startsWith("\x3c!--"),p=s+r.length,d=e.charAt(p);if(h){var v=n$1(r);return l<0?(c.push(v),c):((u=o[l]).children.push(v),c)}if(f&&(l++,"tag"===(a=n$1(r)).type&&t.components[a.name]&&(a.type="component",m=!0),a.voidElement||m||!d||"<"===d||a.children.push({type:"text",content:e.slice(p,e.indexOf("<",p))}),0===l&&c.push(a),(u=o[l-1])&&u.children.push(a),o[l]=a),(!f||a.voidElement)&&(l>-1&&(a.voidElement||a.name===r.slice(2,-1))&&(l--,a=-1===l?c:o[l]),!m&&"<"!==d&&d)){u=-1===l?c:o[l].children;var x=e.indexOf("<",p),g=e.slice(p,-1===x?void 0:x);i$2.test(g)&&(g=" "),(x>-1&&l+u.length>=0||" "!==g)&&u.push({type:"text",content:g});}}),c},stringify:function(e){return e.reduce(function(e,t){return e+a$1("",t)},"")}};
2547
+ var t$1=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function n$1(n){var r={type:"tag",name:"",voidElement:!1,attrs:{},children:[]},i=n.match(/<\/?([^\s]+?)[/\s>]/);if(i&&(r.name=i[1],(voidElements[i[1]]||"/"===n.charAt(n.length-2))&&(r.voidElement=!0),r.name.startsWith("!--"))){var s=n.indexOf("--\x3e");return {type:"comment",comment:-1!==s?n.slice(4,s):""}}for(var a=new RegExp(t$1),c=null;null!==(c=a.exec(n));)if(c[0].trim())if(c[1]){var o=c[1].trim(),l=[o,""];o.indexOf("=")>-1&&(l=o.split("=")),r.attrs[l[0]]=l[1],a.lastIndex--;}else c[2]&&(r.attrs[c[2]]=c[3].trim().substring(1,c[3].length-1));return r}var r=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,i$2=/^\s*$/,s$1=Object.create(null);function a$1(e,t){switch(t.type){case"text":return e+t.content;case"tag":return e+="<"+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+'="'+e[n]+'"');return t.length?" "+t.join(" "):""}(t.attrs):"")+(t.voidElement?"/>":">"),t.voidElement?e:e+t.children.reduce(a$1,"")+"</"+t.name+">";case"comment":return e+"\x3c!--"+t.comment+"--\x3e"}}var c$1={parse:function(e,t){t||(t={}),t.components||(t.components=s$1);var a,c=[],o=[],l=-1,m=!1;if(0!==e.indexOf("<")){var u=e.indexOf("<");c.push({type:"text",content:-1===u?e:e.substring(0,u)});}return e.replace(r,function(r,s){if(m){if(r!=="</"+a.name+">")return;m=!1;}var u,f="/"!==r.charAt(1),h=r.startsWith("\x3c!--"),p=s+r.length,d=e.charAt(p);if(h){var v=n$1(r);return l<0?(c.push(v),c):((u=o[l]).children.push(v),c)}if(f&&(l++,"tag"===(a=n$1(r)).type&&t.components[a.name]&&(a.type="component",m=!0),a.voidElement||m||!d||"<"===d||a.children.push({type:"text",content:e.slice(p,e.indexOf("<",p))}),0===l&&c.push(a),(u=o[l-1])&&u.children.push(a),o[l]=a),(!f||a.voidElement)&&(l>-1&&(a.voidElement||a.name===r.slice(2,-1))&&(l--,a=-1===l?c:o[l]),!m&&"<"!==d&&d)){u=-1===l?c:o[l].children;var x=e.indexOf("<",p),g=e.slice(p,-1===x?void 0:x);i$2.test(g)&&(g=" "),(x>-1&&l+u.length>=0||" "!==g)&&u.push({type:"text",content:g});}}),c},stringify:function(e){return e.reduce(function(e,t){return e+a$1("",t)},"")}};
2548
2548
 
2549
2549
  var classCallCheck = createCommonjsModule(function (module) {
2550
2550
  function _classCallCheck(instance, Constructor) {
@@ -2806,7 +2806,7 @@ function renderNodes(children, targetString, i18n, i18nOptions, combinedTOpts) {
2806
2806
 
2807
2807
  getData(children);
2808
2808
  var interpolatedString = i18n.services.interpolator.interpolate(targetString, _objectSpread$5(_objectSpread$5({}, data), combinedTOpts), i18n.language);
2809
- var ast = c$2.parse("<0>".concat(interpolatedString, "</0>"));
2809
+ var ast = c$1.parse("<0>".concat(interpolatedString, "</0>"));
2810
2810
 
2811
2811
  function renderInner(child, node, rootReactNode) {
2812
2812
  var childs = getChildren(child);
@@ -7068,8 +7068,6 @@ exports.default = create;
7068
7068
 
7069
7069
  var createStore = unwrapExports(vanilla);
7070
7070
 
7071
- function c$1(c,r,d){const u={count:0},s=t=>{const o=useRef(u.count);return useEffect(()=>{o.current+=1,o.current===u.count+1&&(o.current-=1,r.setState(t));}),null};if(s.displayName=`((${c})) devtool`,!d){let t=document.getElementById("simple-zustand-devtools");t||(t=document.createElement("div"),t.id="simple-zustand-devtools"),document.body.appendChild(t),d=t;}const m=e=>{e&&(render$1(React__default.createElement(s,Object.assign({},e)),d),u.count+=1);};m(r.getState()),r.subscribe(m);}
7072
-
7073
7071
  var _extends_1 = createCommonjsModule(function (module) {
7074
7072
  function _extends() {
7075
7073
  module.exports = _extends = Object.assign || function (target) {
@@ -9271,7 +9269,8 @@ const usePelcro = createPelcroHook(pelcroStore);
9271
9269
 
9272
9270
  /* istanbul ignore next */
9273
9271
  if (process.env.NODE_ENV === "development") {
9274
- c$1("Pelcro Store", usePelcro);
9272
+ // mountStoreDevtool("Pelcro Store", usePelcro);
9273
+ console.log("Pelcro Store devtools disabled - simple-zustand-devtools incompatible with React 16");
9275
9274
  }
9276
9275
 
9277
9276
  /**
@@ -17862,6 +17861,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17862
17861
  onSuccess = () => {},
17863
17862
  onGiftRenewalSuccess = () => {},
17864
17863
  onFailure = () => {},
17864
+ onPriceUpdate = () => {},
17865
17865
  ...props
17866
17866
  } = _ref;
17867
17867
  const [vantivPaymentRequest, setVantivPaymentRequest] = useState(null);
@@ -18642,7 +18642,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18642
18642
  payload: true
18643
18643
  });
18644
18644
  try {
18645
- var _window$Pelcro$site$r7, _window$Pelcro$site$r8;
18645
+ var _window$Pelcro$site$r7, _window$Pelcro$site$r8, _window$Pelcro$site$r9;
18646
18646
  // Ensure the DOM element exists before creating Drop-in UI
18647
18647
  const dropinContainer = document.querySelector("#dropin-container");
18648
18648
  if (!dropinContainer) {
@@ -18697,22 +18697,25 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18697
18697
  // Enable Google Pay for both orders and subscriptions
18698
18698
  googlePay: {
18699
18699
  googlePayVersion: 2,
18700
- merchantId: (_window$Pelcro$site$r8 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r8 === void 0 ? void 0 : _window$Pelcro$site$r8.google_merchant_id,
18700
+ merchantId: (_window$Pelcro$site$r8 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r8 === void 0 ? void 0 : (_window$Pelcro$site$r9 = _window$Pelcro$site$r8.braintree_gateway_settings) === null || _window$Pelcro$site$r9 === void 0 ? void 0 : _window$Pelcro$site$r9.google_pay_merchant_id,
18701
18701
  transactionInfo: {
18702
18702
  totalPriceStatus: "FINAL",
18703
18703
  totalPrice: googlePayAmount,
18704
18704
  currencyCode: (() => {
18705
18705
  const currency = getCurrencyFromPaymentType(plan, order, invoice);
18706
18706
  return (currency === null || currency === void 0 ? void 0 : currency.toUpperCase()) || "USD";
18707
- })()
18707
+ })(),
18708
+ countryCode: "US" // Required for production Google Pay
18708
18709
  },
18710
+
18709
18711
  // Add button configuration
18710
18712
  button: {
18711
18713
  color: "black",
18712
- type: type === "createPayment" ? "subscribe" : "buy"
18714
+ type: "buy" // Always use "buy" - "subscribe" type causes OR_BIBED_11 error
18713
18715
  }
18714
18716
  }
18715
18717
  });
18718
+
18716
18719
  console.log("Setting skeleton loader to false after successful Braintree initialization");
18717
18720
  dispatch({
18718
18721
  type: SKELETON_LOADER,
@@ -18728,11 +18731,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18728
18731
  }
18729
18732
  });
18730
18733
  } catch (error) {
18731
- var _error$message, _error$message2, _error$message3, _error$message4;
18734
+ var _error$message, _error$message2, _error$message3, _error$message4, _error$message5, _error$message6;
18732
18735
  console.error("Failed to initialize Braintree Drop-in UI:", error);
18733
18736
 
18734
18737
  // Check if it's a Google Pay specific error
18735
- if (error !== null && error !== void 0 && (_error$message = error.message) !== null && _error$message !== void 0 && _error$message.includes("OR_BIBED_06") || error !== null && error !== void 0 && (_error$message2 = error.message) !== null && _error$message2 !== void 0 && _error$message2.includes("Google Pay")) {
18738
+ if (error !== null && error !== void 0 && (_error$message = error.message) !== null && _error$message !== void 0 && _error$message.includes("OR_BIBED_06") || error !== null && error !== void 0 && (_error$message2 = error.message) !== null && _error$message2 !== void 0 && _error$message2.includes("OR_BIBED_11") || error !== null && error !== void 0 && (_error$message3 = error.message) !== null && _error$message3 !== void 0 && _error$message3.includes("Google Pay")) {
18736
18739
  console.warn("Google Pay configuration issue detected. " + `Transaction type: ${type}. ` + "This might be due to merchant settings or unsupported payment flow.");
18737
18740
  }
18738
18741
  dispatch({
@@ -18742,7 +18745,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
18742
18745
 
18743
18746
  // Don't show error to user for Google Pay configuration issues
18744
18747
  // as it's expected for subscriptions
18745
- if (!(error !== null && error !== void 0 && (_error$message3 = error.message) !== null && _error$message3 !== void 0 && _error$message3.includes("OR_BIBED_06")) && !(error !== null && error !== void 0 && (_error$message4 = error.message) !== null && _error$message4 !== void 0 && _error$message4.includes("Google Pay"))) {
18748
+ if (!(error !== null && error !== void 0 && (_error$message4 = error.message) !== null && _error$message4 !== void 0 && _error$message4.includes("OR_BIBED_06")) && !(error !== null && error !== void 0 && (_error$message5 = error.message) !== null && _error$message5 !== void 0 && _error$message5.includes("OR_BIBED_11")) && !(error !== null && error !== void 0 && (_error$message6 = error.message) !== null && _error$message6 !== void 0 && _error$message6.includes("Google Pay"))) {
18746
18749
  dispatch({
18747
18750
  type: SHOW_ALERT,
18748
18751
  payload: {
@@ -19441,9 +19444,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19441
19444
  useEffect(() => {
19442
19445
  if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
19443
19446
  if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
19444
- var _window$Pelcro$site$r9, _window$Pelcro$site$r10;
19445
- const payPageId = (_window$Pelcro$site$r9 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r9 === void 0 ? void 0 : _window$Pelcro$site$r9.vantiv_gateway_settings.pay_page_id;
19446
- const reportGroup = (_window$Pelcro$site$r10 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r10 === void 0 ? void 0 : _window$Pelcro$site$r10.vantiv_gateway_settings.report_group;
19447
+ var _window$Pelcro$site$r10, _window$Pelcro$site$r11;
19448
+ const payPageId = (_window$Pelcro$site$r10 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r10 === void 0 ? void 0 : _window$Pelcro$site$r10.vantiv_gateway_settings.pay_page_id;
19449
+ const reportGroup = (_window$Pelcro$site$r11 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r11 === void 0 ? void 0 : _window$Pelcro$site$r11.vantiv_gateway_settings.report_group;
19447
19450
  vantivInstanceRef.current = new window.EprotectIframeClient({
19448
19451
  paypageId: payPageId,
19449
19452
  reportGroup: reportGroup,
@@ -19563,9 +19566,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
19563
19566
  * Updates the total amount after adding taxes only if site taxes are enabled
19564
19567
  */
19565
19568
  const updateTotalAmountWithTax = () => {
19566
- var _window$Pelcro$site$r11;
19569
+ var _window$Pelcro$site$r12;
19567
19570
  if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
19568
- const taxesEnabled = (_window$Pelcro$site$r11 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r11 === void 0 ? void 0 : _window$Pelcro$site$r11.taxes_enabled;
19571
+ const taxesEnabled = (_window$Pelcro$site$r12 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r12 === void 0 ? void 0 : _window$Pelcro$site$r12.taxes_enabled;
19569
19572
  if (taxesEnabled && type === "createPayment") {
19570
19573
  dispatch({
19571
19574
  type: DISABLE_SUBMIT,
@@ -20512,11 +20515,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20512
20515
  * @return {Promise}
20513
20516
  */
20514
20517
  const resolveTaxCalculation = () => {
20515
- var _window$Pelcro$site$r12;
20518
+ var _window$Pelcro$site$r13;
20516
20519
  if (type === "invoicePayment") {
20517
20520
  return new Promise(resolve => resolve());
20518
20521
  }
20519
- const taxesEnabled = (_window$Pelcro$site$r12 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r12 === void 0 ? void 0 : _window$Pelcro$site$r12.taxes_enabled;
20522
+ const taxesEnabled = (_window$Pelcro$site$r13 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r13 === void 0 ? void 0 : _window$Pelcro$site$r13.taxes_enabled;
20520
20523
  return new Promise((resolve, reject) => {
20521
20524
  // resolve early if taxes isn't enabled
20522
20525
  if (!taxesEnabled) {
@@ -20758,10 +20761,10 @@ const PaymentMethodContainerWithoutStripe = _ref => {
20758
20761
  setVantivPaymentRequest(action.payload);
20759
20762
  });
20760
20763
  case SET_UPDATED_PRICE:
20761
- return lib_7({
20764
+ return lib_5({
20762
20765
  ...state,
20763
20766
  updatedPrice: action.payload
20764
- });
20767
+ }, () => onPriceUpdate(action.payload));
20765
20768
  case SET_TAX_AMOUNT:
20766
20769
  return lib_7({
20767
20770
  ...state,
@@ -22338,7 +22341,8 @@ function PaymentMethodView(_ref) {
22338
22341
  showSubscriptionButton,
22339
22342
  showOrderButton,
22340
22343
  showApplePayButton,
22341
- order
22344
+ order,
22345
+ onPriceUpdate
22342
22346
  } = _ref;
22343
22347
  const {
22344
22348
  t
@@ -22381,7 +22385,8 @@ function PaymentMethodView(_ref) {
22381
22385
  onSuccess: onSuccess,
22382
22386
  onGiftRenewalSuccess: onGiftRenewalSuccess,
22383
22387
  onFailure: onFailure,
22384
- freeOrders: showOrderButton
22388
+ freeOrders: showOrderButton,
22389
+ onPriceUpdate: onPriceUpdate
22385
22390
  }, /*#__PURE__*/React__default.createElement(AlertWithContext, {
22386
22391
  className: "plc-mb-2"
22387
22392
  }), 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", {
@@ -22428,8 +22433,11 @@ const SubscriptionRenewView = _ref => {
22428
22433
  product,
22429
22434
  plan
22430
22435
  } = usePelcro();
22436
+ const [updatedPrice, setUpdatedPrice] = useState(null);
22431
22437
  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;
22432
- const showSubscriptionButton = skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0;
22438
+
22439
+ // Check both original plan amount and final amount after coupon
22440
+ const showSubscriptionButton = skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || updatedPrice === 0);
22433
22441
  const getPricingText = plan => {
22434
22442
  const autoRenewed = plan.auto_renew;
22435
22443
  const {
@@ -22466,7 +22474,8 @@ const SubscriptionRenewView = _ref => {
22466
22474
  onSuccess: onSuccess,
22467
22475
  onGiftRenewalSuccess: onGiftRenewalSuccess,
22468
22476
  onFailure: onFailure,
22469
- showSubscriptionButton: showSubscriptionButton
22477
+ showSubscriptionButton: showSubscriptionButton,
22478
+ onPriceUpdate: setUpdatedPrice
22470
22479
  }));
22471
22480
  };
22472
22481
 
@@ -23799,8 +23808,11 @@ const SubscriptionCreateView = _ref => {
23799
23808
  product,
23800
23809
  plan
23801
23810
  } = usePelcro();
23811
+ const [updatedPrice, setUpdatedPrice] = useState(null);
23802
23812
  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;
23803
- const showSubscriptionButton = skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0;
23813
+
23814
+ // Check both original plan amount and final amount after coupon
23815
+ const showSubscriptionButton = skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || updatedPrice === 0);
23804
23816
  const getPricingText = plan => {
23805
23817
  var _plan$quantity;
23806
23818
  const autoRenewed = plan.auto_renew;
@@ -23838,7 +23850,8 @@ const SubscriptionCreateView = _ref => {
23838
23850
  showApplePayButton: true,
23839
23851
  onSuccess: onSuccess,
23840
23852
  onFailure: onFailure,
23841
- showSubscriptionButton: showSubscriptionButton
23853
+ showSubscriptionButton: showSubscriptionButton,
23854
+ onPriceUpdate: setUpdatedPrice
23842
23855
  }));
23843
23856
  };
23844
23857
 
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.51.0",
4
+ "version": "3.54.0",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",