@pelcro/react-pelcro-js 3.2.0-beta.1 → 3.2.0-beta.12

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
@@ -4684,17 +4684,17 @@ var invoiceDetails_en = {
4684
4684
  buttons: buttons$1
4685
4685
  };
4686
4686
 
4687
- var title = "Invoice details";
4687
+ var title = "Détails de la facture";
4688
4688
  var labels = {
4689
- summary: "Summary",
4689
+ summary: "Résumé",
4690
4690
  total: "Total",
4691
- amountPaid: "Amount paid",
4692
- amountDue: "Amount due",
4693
- creationDate: "Created on:"
4691
+ amountPaid: "Montant payé",
4692
+ amountDue: "Montant ",
4693
+ creationDate: "Créé le:"
4694
4694
  };
4695
4695
  var buttons = {
4696
- download: "Download",
4697
- pay: "Pay now"
4696
+ download: "Télécharger",
4697
+ pay: "Payer"
4698
4698
  };
4699
4699
  var invoiceDetails_fr = {
4700
4700
  title: title,
@@ -7094,8 +7094,8 @@ const saveToMetadataButton = new SaveToMetadataButtonClass();
7094
7094
 
7095
7095
  let e={data:""},t=t=>"undefined"!=typeof window?((t?t.querySelector("#_goober"):window._goober)||Object.assign((t||document.head).appendChild(document.createElement("style")),{innerHTML:" ",id:"_goober"})).firstChild:t||e,l=/(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(})/g,a=/\/\*[^]*?\*\/|\s\s+|\n/g,n=(e,t)=>{let r,l="",a="",o="";for(let c in e){let s=e[c];"object"==typeof s?(r=t?t.replace(/([^,])+/g,e=>c.replace(/([^,])+/g,t=>/&/.test(t)?t.replace(/&/g,e):e?e+" "+t:t)):c,a+="@"==c[0]?"f"==c[1]?n(s,c):c+"{"+n(s,"k"==c[1]?"":t)+"}":n(s,r)):"@"==c[0]&&"i"==c[1]?l=c+" "+s+";":(c=c.replace(/[A-Z]/g,"-$&").toLowerCase(),o+=n.p?n.p(c,s):c+":"+s+";");}return o[0]?(r=t?t+"{"+o+"}":o,l+r+a):l+a},o={},c=e=>{let t="";for(let r in e)t+=r+("object"==typeof e[r]?c(e[r]):e[r]);return t},s=(e,t,r,s,i)=>{let p="object"==typeof e?c(e):e,u=o[p]||(o[p]=(e=>{let t=0,r=11;for(;t<e.length;)r=101*r+e.charCodeAt(t++)>>>0;return "go"+r})(p));if(!o[u]){let t="object"==typeof e?e:(e=>{let t,r=[{}];for(;t=l.exec(e.replace(a,""));)t[4]&&r.shift(),t[3]?r.unshift(r[0][t[3]]=r[0][t[3]]||{}):t[4]||(r[0][t[1]]=t[2]);return r[0]})(e);o[u]=n(i?{["@keyframes "+u]:t}:t,r?"":"."+u);}return ((e,t,r)=>{-1==t.data.indexOf(e)&&(t.data=r?e+t.data:t.data+e);})(o[u],t,s),u},i=(e,t,r)=>e.reduce((e,l,a)=>{let o=t[a];if(o&&o.call){let e=o(r),t=e&&e.props&&e.props.className||/^go/.test(e)&&e;o=t?"."+t:e&&"object"==typeof e?e.props?"":n(e,""):e;}return e+l+(null==o?"":o)},"");function p(e){let r=this||{},l=e.call?e(r.p):e;return s(l.unshift?l.raw?i(l,[].slice.call(arguments,1),r.p):l.reduce((e,t)=>t?Object.assign(e,t.call?t(r.p):t):e,{}):l,t(r.target),r.g,r.o,r.k)}let u,f,d;p.bind({g:1});let b=p.bind({k:1});function h(e,t,r,l){n.p=t,u=e,f=r,d=l;}function y(e,t){let r=this||{};return function(){let l=arguments;function a(n,o){let c=Object.assign({},n),s=c.className||a.className;r.p=Object.assign({theme:f&&f()},c),r.o=/ *go\d+/.test(s),c.className=p.apply(r,l)+(s?" "+s:""),t&&(c.ref=o);let i=c.as||e;return d&&i[0]&&d(c),u(i,c)}return t?t(a):a}}
7096
7096
 
7097
- function _extends$y() {
7098
- _extends$y = Object.assign || function (target) {
7097
+ function _extends$z() {
7098
+ _extends$z = Object.assign || function (target) {
7099
7099
  for (var i = 1; i < arguments.length; i++) {
7100
7100
  var source = arguments[i];
7101
7101
 
@@ -7109,7 +7109,7 @@ function _extends$y() {
7109
7109
  return target;
7110
7110
  };
7111
7111
 
7112
- return _extends$y.apply(this, arguments);
7112
+ return _extends$z.apply(this, arguments);
7113
7113
  }
7114
7114
 
7115
7115
  function _taggedTemplateLiteralLoose(strings, raw) {
@@ -7199,7 +7199,7 @@ var clearFromRemoveQueue = function clearFromRemoveQueue(toastId) {
7199
7199
  var reducer = function reducer(state, action) {
7200
7200
  switch (action.type) {
7201
7201
  case ActionType.ADD_TOAST:
7202
- return _extends$y({}, state, {
7202
+ return _extends$z({}, state, {
7203
7203
  toasts: [action.toast].concat(state.toasts).slice(0, TOAST_LIMIT)
7204
7204
  });
7205
7205
 
@@ -7209,9 +7209,9 @@ var reducer = function reducer(state, action) {
7209
7209
  clearFromRemoveQueue(action.toast.id);
7210
7210
  }
7211
7211
 
7212
- return _extends$y({}, state, {
7212
+ return _extends$z({}, state, {
7213
7213
  toasts: state.toasts.map(function (t) {
7214
- return t.id === action.toast.id ? _extends$y({}, t, action.toast) : t;
7214
+ return t.id === action.toast.id ? _extends$z({}, t, action.toast) : t;
7215
7215
  })
7216
7216
  });
7217
7217
 
@@ -7238,9 +7238,9 @@ var reducer = function reducer(state, action) {
7238
7238
  });
7239
7239
  }
7240
7240
 
7241
- return _extends$y({}, state, {
7241
+ return _extends$z({}, state, {
7242
7242
  toasts: state.toasts.map(function (t) {
7243
- return t.id === toastId || toastId === undefined ? _extends$y({}, t, {
7243
+ return t.id === toastId || toastId === undefined ? _extends$z({}, t, {
7244
7244
  visible: false
7245
7245
  }) : t;
7246
7246
  })
@@ -7248,28 +7248,28 @@ var reducer = function reducer(state, action) {
7248
7248
 
7249
7249
  case ActionType.REMOVE_TOAST:
7250
7250
  if (action.toastId === undefined) {
7251
- return _extends$y({}, state, {
7251
+ return _extends$z({}, state, {
7252
7252
  toasts: []
7253
7253
  });
7254
7254
  }
7255
7255
 
7256
- return _extends$y({}, state, {
7256
+ return _extends$z({}, state, {
7257
7257
  toasts: state.toasts.filter(function (t) {
7258
7258
  return t.id !== action.toastId;
7259
7259
  })
7260
7260
  });
7261
7261
 
7262
7262
  case ActionType.START_PAUSE:
7263
- return _extends$y({}, state, {
7263
+ return _extends$z({}, state, {
7264
7264
  pausedAt: action.time
7265
7265
  });
7266
7266
 
7267
7267
  case ActionType.END_PAUSE:
7268
7268
  var diff = action.time - (state.pausedAt || 0);
7269
- return _extends$y({}, state, {
7269
+ return _extends$z({}, state, {
7270
7270
  pausedAt: undefined,
7271
7271
  toasts: state.toasts.map(function (t) {
7272
- return _extends$y({}, t, {
7272
+ return _extends$z({}, t, {
7273
7273
  pauseDuration: t.pauseDuration + diff
7274
7274
  });
7275
7275
  })
@@ -7316,12 +7316,12 @@ var useStore = function useStore(toastOptions) {
7316
7316
  var mergedToasts = state.toasts.map(function (t) {
7317
7317
  var _toastOptions$t$type, _toastOptions, _toastOptions$t$type2;
7318
7318
 
7319
- return _extends$y({}, toastOptions, toastOptions[t.type], t, {
7319
+ return _extends$z({}, toastOptions, toastOptions[t.type], t, {
7320
7320
  duration: t.duration || ((_toastOptions$t$type = toastOptions[t.type]) == null ? void 0 : _toastOptions$t$type.duration) || ((_toastOptions = toastOptions) == null ? void 0 : _toastOptions.duration) || defaultTimeouts[t.type],
7321
- style: _extends$y({}, toastOptions.style, (_toastOptions$t$type2 = toastOptions[t.type]) == null ? void 0 : _toastOptions$t$type2.style, t.style)
7321
+ style: _extends$z({}, toastOptions.style, (_toastOptions$t$type2 = toastOptions[t.type]) == null ? void 0 : _toastOptions$t$type2.style, t.style)
7322
7322
  });
7323
7323
  });
7324
- return _extends$y({}, state, {
7324
+ return _extends$z({}, state, {
7325
7325
  toasts: mergedToasts
7326
7326
  });
7327
7327
  };
@@ -7331,7 +7331,7 @@ var createToast = function createToast(message, type, opts) {
7331
7331
  type = 'blank';
7332
7332
  }
7333
7333
 
7334
- return _extends$y({
7334
+ return _extends$z({
7335
7335
  createdAt: Date.now(),
7336
7336
  visible: true,
7337
7337
  type: type,
@@ -7381,14 +7381,14 @@ toast.remove = function (toastId) {
7381
7381
  };
7382
7382
 
7383
7383
  toast.promise = function (promise, msgs, opts) {
7384
- var id = toast.loading(msgs.loading, _extends$y({}, opts, opts == null ? void 0 : opts.loading));
7384
+ var id = toast.loading(msgs.loading, _extends$z({}, opts, opts == null ? void 0 : opts.loading));
7385
7385
  promise.then(function (p) {
7386
- toast.success(resolveValue(msgs.success, p), _extends$y({
7386
+ toast.success(resolveValue(msgs.success, p), _extends$z({
7387
7387
  id: id
7388
7388
  }, opts, opts == null ? void 0 : opts.success));
7389
7389
  return p;
7390
7390
  })["catch"](function (e) {
7391
- toast.error(resolveValue(msgs.error, e), _extends$y({
7391
+ toast.error(resolveValue(msgs.error, e), _extends$z({
7392
7392
  id: id
7393
7393
  }, opts, opts == null ? void 0 : opts.error));
7394
7394
  });
@@ -7727,7 +7727,7 @@ var ToastBar = /*#__PURE__*/React.memo(function (_ref2) {
7727
7727
  var message = React.createElement(Message, Object.assign({}, toast.ariaProps), resolveValue(toast.message, toast));
7728
7728
  return React.createElement(ToastBarBase, {
7729
7729
  className: toast.className,
7730
- style: _extends$y({}, animationStyle, style, toast.style)
7730
+ style: _extends$z({}, animationStyle, style, toast.style)
7731
7731
  }, typeof children === 'function' ? children({
7732
7732
  icon: icon,
7733
7733
  message: message
@@ -7757,7 +7757,7 @@ var getPositionStyle = function getPositionStyle(position, offset) {
7757
7757
  } : position.includes('right') ? {
7758
7758
  justifyContent: 'flex-end'
7759
7759
  } : {};
7760
- return _extends$y({
7760
+ return _extends$z({
7761
7761
  left: 0,
7762
7762
  right: 0,
7763
7763
  display: 'flex',
@@ -7784,7 +7784,7 @@ var Toaster = function Toaster(_ref) {
7784
7784
  handlers = _useToaster.handlers;
7785
7785
 
7786
7786
  return React.createElement("div", {
7787
- style: _extends$y({
7787
+ style: _extends$z({
7788
7788
  position: 'fixed',
7789
7789
  zIndex: 9999,
7790
7790
  top: DEFAULT_OFFSET,
@@ -7819,82 +7819,82 @@ var Toaster = function Toaster(_ref) {
7819
7819
  }));
7820
7820
  };
7821
7821
 
7822
- var _path$v;
7822
+ var _path$w;
7823
7823
 
7824
- function _extends$x() { _extends$x = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$x.apply(this, arguments); }
7824
+ function _extends$y() { _extends$y = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$y.apply(this, arguments); }
7825
7825
 
7826
7826
  function SvgCheckSolid(props) {
7827
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$x({
7827
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$y({
7828
7828
  xmlns: "http://www.w3.org/2000/svg",
7829
7829
  className: "h-5 w-5",
7830
7830
  viewBox: "0 0 20 20",
7831
7831
  fill: "currentColor"
7832
- }, props), _path$v || (_path$v = /*#__PURE__*/React__namespace.createElement("path", {
7832
+ }, props), _path$w || (_path$w = /*#__PURE__*/React__namespace.createElement("path", {
7833
7833
  fillRule: "evenodd",
7834
7834
  d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",
7835
7835
  clipRule: "evenodd"
7836
7836
  })));
7837
7837
  }
7838
7838
 
7839
- var _path$u;
7839
+ var _path$v;
7840
7840
 
7841
- function _extends$w() { _extends$w = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$w.apply(this, arguments); }
7841
+ function _extends$x() { _extends$x = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$x.apply(this, arguments); }
7842
7842
 
7843
7843
  function SvgXIcon(props) {
7844
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$w({
7844
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$x({
7845
7845
  xmlns: "http://www.w3.org/2000/svg",
7846
7846
  viewBox: "0 0 20 20",
7847
7847
  fill: "currentColor"
7848
- }, props), _path$u || (_path$u = /*#__PURE__*/React__namespace.createElement("path", {
7848
+ }, props), _path$v || (_path$v = /*#__PURE__*/React__namespace.createElement("path", {
7849
7849
  fill: "evenodd",
7850
7850
  d: "M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",
7851
7851
  clipRule: "evenodd"
7852
7852
  })));
7853
7853
  }
7854
7854
 
7855
- var _path$t;
7855
+ var _path$u;
7856
7856
 
7857
- function _extends$v() { _extends$v = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$v.apply(this, arguments); }
7857
+ function _extends$w() { _extends$w = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$w.apply(this, arguments); }
7858
7858
 
7859
7859
  function SvgXIconSolid(props) {
7860
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$v({
7860
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$w({
7861
7861
  className: "plc-w-4 plc-h-4",
7862
7862
  fill: "currentColor",
7863
7863
  xmlns: "http://www.w3.org/2000/svg",
7864
7864
  viewBox: "0 0 100 100"
7865
- }, props), _path$t || (_path$t = /*#__PURE__*/React__namespace.createElement("path", {
7865
+ }, props), _path$u || (_path$u = /*#__PURE__*/React__namespace.createElement("path", {
7866
7866
  d: "M94.842 48.408c0 24.852-20.148 44.999-45.002 44.999-24.851 0-44.997-20.146-44.997-44.999 0-24.854 20.146-45 44.997-45 24.853 0 45.002 20.146 45.002 45zM71.073 64.841L54.73 48.497l16.344-16.344-4.979-4.979-16.343 16.345-16.343-16.344-4.799 4.799 16.344 16.344L28.61 64.661l4.979 4.978 16.344-16.344 16.343 16.344 4.797-4.798z"
7867
7867
  })));
7868
7868
  }
7869
7869
 
7870
- var _path$s;
7870
+ var _path$t;
7871
7871
 
7872
- function _extends$u() { _extends$u = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$u.apply(this, arguments); }
7872
+ function _extends$v() { _extends$v = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$v.apply(this, arguments); }
7873
7873
 
7874
7874
  function SvgExclamation(props) {
7875
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$u({
7875
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$v({
7876
7876
  className: "plc-w-4 plc-h-4 plc-mr-1",
7877
7877
  xmlns: "http://www.w3.org/2000/svg",
7878
7878
  viewBox: "0 0 20 20",
7879
7879
  fill: "currentColor"
7880
- }, props), _path$s || (_path$s = /*#__PURE__*/React__namespace.createElement("path", {
7880
+ }, props), _path$t || (_path$t = /*#__PURE__*/React__namespace.createElement("path", {
7881
7881
  fillRule: "evenodd",
7882
7882
  d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z",
7883
7883
  clipRule: "evenodd"
7884
7884
  })));
7885
7885
  }
7886
7886
 
7887
- var _path$r, _path2$4;
7887
+ var _path$s, _path2$4;
7888
7888
 
7889
- function _extends$t() { _extends$t = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$t.apply(this, arguments); }
7889
+ function _extends$u() { _extends$u = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$u.apply(this, arguments); }
7890
7890
 
7891
7891
  function SvgSpinner(props) {
7892
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$t({
7892
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$u({
7893
7893
  className: "plc-animate-spin",
7894
7894
  viewBox: "0 0 24 24",
7895
7895
  fill: "currentColor",
7896
7896
  xmlns: "http://www.w3.org/2000/svg"
7897
- }, props), _path$r || (_path$r = /*#__PURE__*/React__namespace.createElement("path", {
7897
+ }, props), _path$s || (_path$s = /*#__PURE__*/React__namespace.createElement("path", {
7898
7898
  opacity: 0.2,
7899
7899
  fill: "evenodd",
7900
7900
  clipRule: "evenodd",
@@ -8649,6 +8649,10 @@ const getErrorMessages = error => {
8649
8649
  return error === null || error === void 0 ? void 0 : (_error$response4 = error.response) === null || _error$response4 === void 0 ? void 0 : (_error$response4$data = _error$response4.data) === null || _error$response4$data === void 0 ? void 0 : (_error$response4$data2 = _error$response4$data.error) === null || _error$response4$data2 === void 0 ? void 0 : _error$response4$data2.message;
8650
8650
  }
8651
8651
 
8652
+ if (error !== null && error !== void 0 && error.message) {
8653
+ return error.message;
8654
+ }
8655
+
8652
8656
  const errorMessages = []; // enumerable error (ex: validation errors)
8653
8657
 
8654
8658
  Object.values(error === null || error === void 0 ? void 0 : (_error$response5 = error.response) === null || _error$response5 === void 0 ? void 0 : (_error$response5$data = _error$response5.data) === null || _error$response5$data === void 0 ? void 0 : _error$response5$data.errors).forEach(([errorMessage]) => {
@@ -8687,7 +8691,7 @@ const debounce = (func, waitTime) => {
8687
8691
  function getSiteCardProcessor() {
8688
8692
  var _window$Pelcro$site$r;
8689
8693
 
8690
- if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_pay_page_id) {
8694
+ if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_gateway_settings) {
8691
8695
  return "vantiv";
8692
8696
  }
8693
8697
 
@@ -8783,7 +8787,7 @@ const loadPaymentSDKs = () => {
8783
8787
  } // Load Vantiv SDKs
8784
8788
 
8785
8789
 
8786
- const supportsVantiv = Boolean(window.Pelcro.site.read().vantiv_pay_page_id);
8790
+ const supportsVantiv = Boolean(window.Pelcro.site.read().vantiv_gateway_settings);
8787
8791
 
8788
8792
  if (supportsVantiv) {
8789
8793
  if (!window.jQuery) {
@@ -8791,7 +8795,10 @@ const loadPaymentSDKs = () => {
8791
8795
  }
8792
8796
 
8793
8797
  if (!window.EprotectIframeClient) {
8794
- window.Pelcro.helpers.loadSDK("https://request.eprotect.vantivprelive.com/eProtect/js/eProtect-iframe-client.min.js", "vantiv-eprotect-sdk");
8798
+ const PRELIVE_URL = "https://request.eprotect.vantivprelive.com/eProtect/js/eProtect-iframe-client.min.js";
8799
+ const PRODUCTION_URL = "https://request.eprotect.vantivcnp.com/eProtect/js/eProtect-iframe-client4.min.js";
8800
+ const scriptUrlToUse = window.Pelcro.site.read().vantiv_gateway_settings.environment === "production" ? PRODUCTION_URL : PRELIVE_URL;
8801
+ window.Pelcro.helpers.loadSDK(scriptUrlToUse, "vantiv-eprotect-sdk");
8795
8802
  }
8796
8803
  }
8797
8804
  };
@@ -8952,8 +8959,7 @@ const initViewFromURL = () => {
8952
8959
  }
8953
8960
 
8954
8961
  if (view === "invoice-details") {
8955
- // FIXME: commented out to remove from the release
8956
- return false; // return showInvoiceDetailsFromUrl();
8962
+ return showInvoiceDetailsFromUrl();
8957
8963
  }
8958
8964
 
8959
8965
  switchView(view);
@@ -9132,6 +9138,43 @@ const verifyEmailTokenFromUrl = () => {
9132
9138
  });
9133
9139
  };
9134
9140
 
9141
+ const showInvoiceDetailsFromUrl = () => {
9142
+ const {
9143
+ isAuthenticated,
9144
+ setInvoice,
9145
+ whenSiteReady,
9146
+ switchView
9147
+ } = usePelcro.getStore();
9148
+ whenSiteReady(() => {
9149
+ if (!isAuthenticated()) {
9150
+ return switchView("login");
9151
+ }
9152
+
9153
+ const invoiceId = window.Pelcro.helpers.getURLParameter("id");
9154
+ const wasSetSuccessfully = setInvoice(invoiceId);
9155
+
9156
+ if (!wasSetSuccessfully) {
9157
+ const errorMessage = i18next.t("messages:invalidInvoice", {
9158
+ returnObjects: true
9159
+ });
9160
+ return notify.error(errorMessage);
9161
+ }
9162
+
9163
+ const {
9164
+ invoice
9165
+ } = usePelcro.getStore();
9166
+
9167
+ if (invoice.total === 0) {
9168
+ const errorMessage = i18next.t("messages:zeroTotalInvoice", {
9169
+ returnObjects: true
9170
+ });
9171
+ return notify.error(errorMessage);
9172
+ }
9173
+
9174
+ return switchView("invoice-details");
9175
+ });
9176
+ };
9177
+
9135
9178
  const defaultOptions = {
9136
9179
  loadPaymentSDKs: true,
9137
9180
  loadAuth0SDK: true,
@@ -9901,16 +9944,16 @@ const LoginPassword = props => /*#__PURE__*/React__default['default'].createElem
9901
9944
  store: store$h
9902
9945
  }, props));
9903
9946
 
9904
- var _path$q;
9947
+ var _path$r;
9905
9948
 
9906
- function _extends$s() { _extends$s = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$s.apply(this, arguments); }
9949
+ function _extends$t() { _extends$t = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$t.apply(this, arguments); }
9907
9950
 
9908
9951
  function SvgCheck(props) {
9909
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$s({
9952
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$t({
9910
9953
  xmlns: "http://www.w3.org/2000/svg",
9911
9954
  fill: "currentColor",
9912
9955
  viewBox: "0 0 20 20"
9913
- }, props), _path$q || (_path$q = /*#__PURE__*/React__namespace.createElement("path", {
9956
+ }, props), _path$r || (_path$r = /*#__PURE__*/React__namespace.createElement("path", {
9914
9957
  fillRule: "evenodd",
9915
9958
  d: "M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",
9916
9959
  clipRule: "evenodd"
@@ -10229,15 +10272,15 @@ function hasSecurityTokenEnabled$1() {
10229
10272
  return hasSecuritySdkLoaded;
10230
10273
  }
10231
10274
 
10232
- var _path$p;
10275
+ var _path$q;
10233
10276
 
10234
- function _extends$r() { _extends$r = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$r.apply(this, arguments); }
10277
+ function _extends$s() { _extends$s = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$s.apply(this, arguments); }
10235
10278
 
10236
10279
  function SvgFacebookLogo(props) {
10237
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$r({
10280
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$s({
10238
10281
  xmlns: "http://www.w3.org/2000/svg",
10239
10282
  viewBox: "88.428 12.828 107.543 207.085"
10240
- }, props), _path$p || (_path$p = /*#__PURE__*/React__namespace.createElement("path", {
10283
+ }, props), _path$q || (_path$q = /*#__PURE__*/React__namespace.createElement("path", {
10241
10284
  d: "M158.232 219.912v-94.461h31.707l4.747-36.813h-36.454V65.134c0-10.658 2.96-17.922 18.245-17.922l19.494-.009V14.278c-3.373-.447-14.944-1.449-28.406-1.449-28.106 0-47.348 17.155-47.348 48.661v27.149H88.428v36.813h31.788v94.461l38.016-.001z",
10242
10285
  fill: "#3c5a9a"
10243
10286
  })));
@@ -10310,15 +10353,15 @@ var googleLogin = createCommonjsModule(function (module, exports) {
10310
10353
  unwrapExports(googleLogin);
10311
10354
  var googleLogin_1 = googleLogin.GoogleLogin;
10312
10355
 
10313
- var _path$o, _path2$3, _path3$1, _path4;
10356
+ var _path$p, _path2$3, _path3$1, _path4;
10314
10357
 
10315
- function _extends$q() { _extends$q = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$q.apply(this, arguments); }
10358
+ function _extends$r() { _extends$r = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$r.apply(this, arguments); }
10316
10359
 
10317
10360
  function SvgGoogleLogo(props) {
10318
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$q({
10361
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$r({
10319
10362
  viewBox: "0 0 24 24",
10320
10363
  xmlns: "http://www.w3.org/2000/svg"
10321
- }, props), _path$o || (_path$o = /*#__PURE__*/React__namespace.createElement("path", {
10364
+ }, props), _path$p || (_path$p = /*#__PURE__*/React__namespace.createElement("path", {
10322
10365
  fill: "#4285F4",
10323
10366
  d: "M23.745 12.27c0-.79-.07-1.54-.19-2.27h-11.3v4.51h6.47c-.29 1.48-1.14 2.73-2.4 3.58v3h3.86c2.26-2.09 3.56-5.17 3.56-8.82z"
10324
10367
  })), _path2$3 || (_path2$3 = /*#__PURE__*/React__namespace.createElement("path", {
@@ -10395,15 +10438,15 @@ const GoogleLoginButton = ({
10395
10438
  }) : null;
10396
10439
  };
10397
10440
 
10398
- var _path$n;
10441
+ var _path$o;
10399
10442
 
10400
- function _extends$p() { _extends$p = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$p.apply(this, arguments); }
10443
+ function _extends$q() { _extends$q = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$q.apply(this, arguments); }
10401
10444
 
10402
10445
  function SvgAuth0Logo(props) {
10403
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$p({
10446
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$q({
10404
10447
  viewBox: "0 0 256 285",
10405
10448
  xmlns: "http://www.w3.org/2000/svg"
10406
- }, props), _path$n || (_path$n = /*#__PURE__*/React__namespace.createElement("path", {
10449
+ }, props), _path$o || (_path$o = /*#__PURE__*/React__namespace.createElement("path", {
10407
10450
  d: "M220.412 0h-92.415l28.562 89.006h92.416l-74.77 53.077 28.57 89.511c48.128-35.06 63.854-88.12 46.208-142.588L220.413 0zM7.018 89.006h92.416L127.997 0H35.589L7.019 89.006c-17.655 54.468-1.92 107.529 46.207 142.588l28.563-89.51-74.77-53.078zm46.208 142.588l74.77 52.97 74.77-52.97-74.77-53.847-74.77 53.847z"
10408
10451
  })));
10409
10452
  }
@@ -10579,15 +10622,15 @@ function LoginView(props) {
10579
10622
  }, /*#__PURE__*/React__default['default'].createElement(GoogleLoginButton, null), /*#__PURE__*/React__default['default'].createElement(FacebookLoginButton, null), /*#__PURE__*/React__default['default'].createElement(Auth0LoginButton, null))))));
10580
10623
  }
10581
10624
 
10582
- var _path$m, _path2$2, _path3;
10625
+ var _path$n, _path2$2, _path3;
10583
10626
 
10584
- function _extends$o() { _extends$o = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$o.apply(this, arguments); }
10627
+ function _extends$p() { _extends$p = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$p.apply(this, arguments); }
10585
10628
 
10586
10629
  function SvgPelcroAuthorship(props) {
10587
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$o({
10630
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$p({
10588
10631
  xmlns: "http://www.w3.org/2000/svg",
10589
10632
  viewBox: "0 -80.652 497.072 179.991"
10590
- }, props), _path$m || (_path$m = /*#__PURE__*/React__namespace.createElement("path", {
10633
+ }, props), _path$n || (_path$n = /*#__PURE__*/React__namespace.createElement("path", {
10591
10634
  fill: "none",
10592
10635
  stroke: "#4a4a4a",
10593
10636
  d: "M487.89 42.299c0 13.158-10.671 23.829-23.829 23.829H37.074c-13.162 0-23.832-10.671-23.832-23.829v-63.552c0-13.158 10.67-23.831 23.832-23.831H464.06c13.158 0 23.829 10.672 23.829 23.831l.001 63.552z"
@@ -12707,20 +12750,21 @@ var es_12 = es.injectStripe;
12707
12750
  var es_13 = es.StripeProvider;
12708
12751
 
12709
12752
  /**
12710
- * @TODO: All subscription related business logic should end up moving
12753
+ * @TODO: All payment related business logic should end up moving
12711
12754
  * to this service, and out of react components.
12712
12755
  */
12713
12756
 
12714
12757
  /**
12715
- * Enum for subscription types
12758
+ * Enum for payment types
12716
12759
  * @readonly
12717
12760
  * @enum {string}
12718
12761
  */
12719
- const SUBSCRIPTION_TYPES = {
12762
+ const PAYMENT_TYPES = {
12720
12763
  CREATE_SUBSCRIPTION: "CREATE_SUBSCRIPTION",
12721
12764
  CREATE_GIFTED_SUBSCRIPTION: "CREATE_GIFTED_SUBSCRIPTION",
12722
12765
  RENEW_SUBSCRIPTION: "RENEW_SUBSCRIPTION",
12723
12766
  RENEW_GIFTED_SUBSCRIPTION: "RENEW_GIFTED_SUBSCRIPTION",
12767
+ PURCHASE_ECOMMERCE_ORDER: "PURCHASE_ECOMMERCE_ORDER",
12724
12768
  PAY_INVOICE: "PAY_INVOICE"
12725
12769
  };
12726
12770
 
@@ -12728,9 +12772,8 @@ var _isPaymentGatewayInvalid = /*#__PURE__*/new WeakMap();
12728
12772
 
12729
12773
  var _generateUserError = /*#__PURE__*/new WeakMap();
12730
12774
 
12731
- class Subscription {
12775
+ class Payment {
12732
12776
  /**
12733
- * Subscription service constructor
12734
12777
  * @param {(StripeGateway|PaypalGateway|VantivGateway)} paymentGateway
12735
12778
  */
12736
12779
  constructor(paymentGateway) {
@@ -12742,7 +12785,7 @@ class Subscription {
12742
12785
 
12743
12786
  if (!options.type) {
12744
12787
  callback(_classPrivateFieldGet(this, _generateUserError).call(this), null);
12745
- return console.error("No subscription type provided");
12788
+ return console.error("No payment type provided");
12746
12789
  } // delegate execution to paymentgateway
12747
12790
 
12748
12791
 
@@ -12760,21 +12803,21 @@ class Subscription {
12760
12803
  writable: true,
12761
12804
  value: () => {
12762
12805
  return {
12763
- error: new Error("An error has occured in the subscription service, please try again later")
12806
+ error: new Error("An error has occured in the payment service, please try again later")
12764
12807
  };
12765
12808
  }
12766
12809
  });
12767
12810
 
12768
12811
  if (_classPrivateFieldGet(this, _isPaymentGatewayInvalid).call(this, paymentGateway)) {
12769
12812
  this.paymentGateway = null;
12770
- console.error("Incompatible subscription gateway");
12813
+ console.error("Incompatible payment gateway");
12771
12814
  } else {
12772
12815
  this.paymentGateway = paymentGateway;
12773
12816
  }
12774
12817
  }
12775
12818
  /**
12776
- * @typedef subscriptionOptions
12777
- * @property {SUBSCRIPTION_TYPES} type
12819
+ * @typedef paymentOptions
12820
+ * @property {PAYMENT_TYPES} type
12778
12821
  * @property {string} token
12779
12822
  * @property {object} plan
12780
12823
  * @property {object} [product]
@@ -12785,6 +12828,7 @@ class Subscription {
12785
12828
  * @property {string} addressId
12786
12829
  * @property {number} invoiceId
12787
12830
  * @property {boolean} isExistingSource
12831
+ * @property {Array} items
12788
12832
  */
12789
12833
 
12790
12834
  /**
@@ -12795,8 +12839,8 @@ class Subscription {
12795
12839
  */
12796
12840
 
12797
12841
  /**
12798
- * Subscription execution method
12799
- * @param {subscriptionOptions} options subscription options
12842
+ * Payment execution method
12843
+ * @param {paymentOptions} options payment options
12800
12844
  * @param {executeCallback} callback
12801
12845
  * @return {void}
12802
12846
  */
@@ -12809,7 +12853,7 @@ const PAYMENT_GATEWAYS_ENUM = {
12809
12853
  vantiv: "vantiv"
12810
12854
  };
12811
12855
  /**
12812
- * Subscription Strategies
12856
+ * Payment Strategies
12813
12857
  */
12814
12858
 
12815
12859
  /**
@@ -12826,6 +12870,8 @@ var _renewSubscription = /*#__PURE__*/new WeakMap();
12826
12870
 
12827
12871
  var _renewGiftedSubscription = /*#__PURE__*/new WeakMap();
12828
12872
 
12873
+ var _purchaseEcommerceOrder = /*#__PURE__*/new WeakMap();
12874
+
12829
12875
  var _payInvoice = /*#__PURE__*/new WeakMap();
12830
12876
 
12831
12877
  class StripeGateway {
@@ -12836,7 +12882,7 @@ class StripeGateway {
12836
12882
  });
12837
12883
 
12838
12884
  _defineProperty$3(this, "execute", (options, callback) => {
12839
- const types = SUBSCRIPTION_TYPES;
12885
+ const types = PAYMENT_TYPES;
12840
12886
 
12841
12887
  switch (options.type) {
12842
12888
  case types.CREATE_SUBSCRIPTION:
@@ -12851,11 +12897,14 @@ class StripeGateway {
12851
12897
  case types.RENEW_GIFTED_SUBSCRIPTION:
12852
12898
  return _classPrivateFieldGet(this, _renewGiftedSubscription).call(this, options, callback);
12853
12899
 
12900
+ case types.PURCHASE_ECOMMERCE_ORDER:
12901
+ return _classPrivateFieldGet(this, _purchaseEcommerceOrder).call(this, options, callback);
12902
+
12854
12903
  case types.PAY_INVOICE:
12855
12904
  return _classPrivateFieldGet(this, _payInvoice).call(this, options, callback);
12856
12905
 
12857
12906
  default:
12858
- console.error("Unsupported subscriptiion method: Stripe Gateway");
12907
+ console.error("Unsupported payment method: Stripe Gateway");
12859
12908
  }
12860
12909
  });
12861
12910
 
@@ -12877,6 +12926,7 @@ class StripeGateway {
12877
12926
  auth_token: window.Pelcro.user.read().auth_token,
12878
12927
  plan_id: plan.id,
12879
12928
  coupon_code: couponCode,
12929
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
12880
12930
  address_id: product.address_required ? addressId : null
12881
12931
  }, (err, res) => {
12882
12932
  callback(err, res);
@@ -12903,6 +12953,7 @@ class StripeGateway {
12903
12953
  auth_token: window.Pelcro.user.read().auth_token,
12904
12954
  plan_id: plan.id,
12905
12955
  coupon_code: couponCode,
12956
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
12906
12957
  gift_recipient_email: giftRecipient.email,
12907
12958
  gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
12908
12959
  gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
@@ -12930,6 +12981,7 @@ class StripeGateway {
12930
12981
  stripe_token: token,
12931
12982
  auth_token: window.Pelcro.user.read().auth_token,
12932
12983
  plan_id: plan.id,
12984
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
12933
12985
  coupon_code: couponCode,
12934
12986
  subscription_id: subscriptionIdToRenew,
12935
12987
  address_id: product.address_required ? addressId : null
@@ -12963,6 +13015,36 @@ class StripeGateway {
12963
13015
  }
12964
13016
  });
12965
13017
 
13018
+ _purchaseEcommerceOrder.set(this, {
13019
+ writable: true,
13020
+ value: (options, callback) => {
13021
+ const {
13022
+ token,
13023
+ items,
13024
+ couponCode,
13025
+ addressId,
13026
+ isExistingSource
13027
+ } = options;
13028
+ const params = isExistingSource ? {
13029
+ source_id: token
13030
+ } : {
13031
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway),
13032
+ gateway_token: token
13033
+ };
13034
+ window.Pelcro.ecommerce.order.create({
13035
+ items,
13036
+ coupon_code: couponCode,
13037
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13038
+ ...params,
13039
+ ...(addressId && {
13040
+ address_id: addressId
13041
+ })
13042
+ }, (err, res) => {
13043
+ callback(err, res);
13044
+ });
13045
+ }
13046
+ });
13047
+
12966
13048
  _payInvoice.set(this, {
12967
13049
  writable: true,
12968
13050
  value: (options, callback) => {
@@ -13006,7 +13088,7 @@ class PaypalGateway {
13006
13088
  });
13007
13089
 
13008
13090
  _defineProperty$3(this, "execute", (options, callback) => {
13009
- const types = SUBSCRIPTION_TYPES;
13091
+ const types = PAYMENT_TYPES;
13010
13092
 
13011
13093
  switch (options.type) {
13012
13094
  case types.CREATE_SUBSCRIPTION:
@@ -13040,6 +13122,7 @@ class PaypalGateway {
13040
13122
  payment_gateway: _classPrivateFieldGet(this, _paymentGateway2),
13041
13123
  auth_token: window.Pelcro.user.read().auth_token,
13042
13124
  plan_id: plan.id,
13125
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13043
13126
  coupon_code: couponCode,
13044
13127
  address_id: product.address_required ? addressId : null
13045
13128
  }, (err, res) => {
@@ -13067,6 +13150,7 @@ class PaypalGateway {
13067
13150
  auth_token: window.Pelcro.user.read().auth_token,
13068
13151
  plan_id: plan.id,
13069
13152
  coupon_code: couponCode,
13153
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13070
13154
  gift_recipient_email: giftRecipient.email,
13071
13155
  gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
13072
13156
  gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
@@ -13103,6 +13187,16 @@ var _paymentGateway3 = /*#__PURE__*/new WeakMap();
13103
13187
 
13104
13188
  var _createSubscription3 = /*#__PURE__*/new WeakMap();
13105
13189
 
13190
+ var _renewSubscription2 = /*#__PURE__*/new WeakMap();
13191
+
13192
+ var _createGiftedSubscription3 = /*#__PURE__*/new WeakMap();
13193
+
13194
+ var _renewGiftedSubscription2 = /*#__PURE__*/new WeakMap();
13195
+
13196
+ var _purchaseEcommerceOrder2 = /*#__PURE__*/new WeakMap();
13197
+
13198
+ var _payInvoice3 = /*#__PURE__*/new WeakMap();
13199
+
13106
13200
  class VantivGateway {
13107
13201
  constructor() {
13108
13202
  _paymentGateway3.set(this, {
@@ -13111,14 +13205,29 @@ class VantivGateway {
13111
13205
  });
13112
13206
 
13113
13207
  _defineProperty$3(this, "execute", (options, callback) => {
13114
- const types = SUBSCRIPTION_TYPES;
13208
+ const types = PAYMENT_TYPES;
13115
13209
 
13116
13210
  switch (options.type) {
13117
13211
  case types.CREATE_SUBSCRIPTION:
13118
13212
  return _classPrivateFieldGet(this, _createSubscription3).call(this, options, callback);
13119
13213
 
13214
+ case types.RENEW_SUBSCRIPTION:
13215
+ return _classPrivateFieldGet(this, _renewSubscription2).call(this, options, callback);
13216
+
13217
+ case types.CREATE_GIFTED_SUBSCRIPTION:
13218
+ return _classPrivateFieldGet(this, _createGiftedSubscription3).call(this, options, callback);
13219
+
13220
+ case types.RENEW_GIFTED_SUBSCRIPTION:
13221
+ return _classPrivateFieldGet(this, _renewGiftedSubscription2).call(this, options, callback);
13222
+
13223
+ case types.PURCHASE_ECOMMERCE_ORDER:
13224
+ return _classPrivateFieldGet(this, _purchaseEcommerceOrder2).call(this, options, callback);
13225
+
13226
+ case types.PAY_INVOICE:
13227
+ return _classPrivateFieldGet(this, _payInvoice3).call(this, options, callback);
13228
+
13120
13229
  default:
13121
- console.error("Unsupported subscriptiion method: vantiv Gateway");
13230
+ console.error("Unsupported payment method: vantiv Gateway");
13122
13231
  }
13123
13232
  });
13124
13233
 
@@ -13131,21 +13240,180 @@ class VantivGateway {
13131
13240
  couponCode,
13132
13241
  product,
13133
13242
  quantity = 1,
13134
- addressId
13243
+ addressId,
13244
+ isExistingSource
13135
13245
  } = options;
13246
+ const params = isExistingSource ? {
13247
+ source_id: token
13248
+ } : {
13249
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13250
+ gateway_token: token
13251
+ };
13136
13252
  window.Pelcro.subscription.create({
13137
13253
  quantity,
13138
- gateway_token: token,
13254
+ auth_token: window.Pelcro.user.read().auth_token,
13255
+ plan_id: plan.id,
13256
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13257
+ coupon_code: couponCode,
13258
+ address_id: product.address_required ? addressId : null,
13259
+ ...params
13260
+ }, (err, res) => {
13261
+ callback(err, res);
13262
+ });
13263
+ }
13264
+ });
13265
+
13266
+ _renewSubscription2.set(this, {
13267
+ writable: true,
13268
+ value: (options, callback) => {
13269
+ const {
13270
+ subscriptionIdToRenew,
13271
+ token,
13272
+ plan,
13273
+ couponCode,
13274
+ product,
13275
+ addressId,
13276
+ isExistingSource
13277
+ } = options;
13278
+ const params = isExistingSource ? {
13279
+ source_id: token
13280
+ } : {
13139
13281
  payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13282
+ gateway_token: token
13283
+ };
13284
+ window.Pelcro.subscription.renew({
13140
13285
  auth_token: window.Pelcro.user.read().auth_token,
13141
13286
  plan_id: plan.id,
13142
13287
  coupon_code: couponCode,
13143
- address_id: product.address_required ? addressId : null
13288
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13289
+ subscription_id: subscriptionIdToRenew,
13290
+ address_id: product.address_required ? addressId : null,
13291
+ ...params
13292
+ }, (err, res) => {
13293
+ callback(err, res);
13294
+ });
13295
+ }
13296
+ });
13297
+
13298
+ _createGiftedSubscription3.set(this, {
13299
+ writable: true,
13300
+ value: (options, callback) => {
13301
+ const {
13302
+ token,
13303
+ plan,
13304
+ couponCode,
13305
+ product,
13306
+ giftRecipient,
13307
+ quantity = 1,
13308
+ addressId,
13309
+ isExistingSource
13310
+ } = options;
13311
+ const params = isExistingSource ? {
13312
+ source_id: token
13313
+ } : {
13314
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13315
+ gateway_token: token
13316
+ };
13317
+ window.Pelcro.subscription.create({
13318
+ quantity,
13319
+ auth_token: window.Pelcro.user.read().auth_token,
13320
+ plan_id: plan.id,
13321
+ coupon_code: couponCode,
13322
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13323
+ gift_recipient_email: giftRecipient.email,
13324
+ gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
13325
+ gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
13326
+ gift_start_date: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.startDate,
13327
+ gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
13328
+ address_id: product.address_required ? addressId : null,
13329
+ ...params
13144
13330
  }, (err, res) => {
13145
13331
  callback(err, res);
13146
13332
  });
13147
13333
  }
13148
13334
  });
13335
+
13336
+ _renewGiftedSubscription2.set(this, {
13337
+ writable: true,
13338
+ value: (options, callback) => {
13339
+ const {
13340
+ subscriptionIdToRenew,
13341
+ token,
13342
+ product,
13343
+ plan,
13344
+ couponCode,
13345
+ addressId,
13346
+ isExistingSource
13347
+ } = options;
13348
+ const params = isExistingSource ? {
13349
+ source_id: token
13350
+ } : {
13351
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13352
+ gateway_token: token
13353
+ };
13354
+ window.Pelcro.subscription.renewGift({
13355
+ auth_token: window.Pelcro.user.read().auth_token,
13356
+ plan_id: plan.id,
13357
+ coupon_code: couponCode,
13358
+ subscription_id: subscriptionIdToRenew,
13359
+ address_id: product.address_required ? addressId : null,
13360
+ ...params
13361
+ }, (err, res) => {
13362
+ callback(err, res);
13363
+ });
13364
+ }
13365
+ });
13366
+
13367
+ _purchaseEcommerceOrder2.set(this, {
13368
+ writable: true,
13369
+ value: (options, callback) => {
13370
+ const {
13371
+ token,
13372
+ items,
13373
+ couponCode,
13374
+ addressId,
13375
+ isExistingSource
13376
+ } = options;
13377
+ const params = isExistingSource ? {
13378
+ source_id: token
13379
+ } : {
13380
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13381
+ gateway_token: token
13382
+ };
13383
+ window.Pelcro.ecommerce.order.create({
13384
+ items,
13385
+ coupon_code: couponCode,
13386
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13387
+ ...params,
13388
+ ...(addressId && {
13389
+ address_id: addressId
13390
+ })
13391
+ }, (err, res) => {
13392
+ callback(err, res);
13393
+ });
13394
+ }
13395
+ });
13396
+
13397
+ _payInvoice3.set(this, {
13398
+ writable: true,
13399
+ value: (options, callback) => {
13400
+ const {
13401
+ token,
13402
+ invoiceId
13403
+ } = options;
13404
+ const params = options.isExistingSource ? {
13405
+ source_id: token,
13406
+ invoice_id: invoiceId
13407
+ } : {
13408
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13409
+ gateway_token: token,
13410
+ invoice_id: invoiceId
13411
+ };
13412
+ window.Pelcro.invoice.pay(params, (err, res) => {
13413
+ callback(err, res);
13414
+ });
13415
+ }
13416
+ });
13149
13417
  }
13150
13418
 
13151
13419
  }
@@ -13205,7 +13473,7 @@ const PaymentMethodContainerWithoutStripe = ({
13205
13473
  onFailure = () => {},
13206
13474
  ...props
13207
13475
  }) => {
13208
- var _props$product, _props$plan, _props$subscriptionId, _props$selectedAddres, _props$giftRecipient, _props$isRenewingGift, _props$invoice;
13476
+ var _props$product, _props$plan, _props$subscriptionId, _props$selectedAddres, _props$giftRecipient, _props$isGift, _props$isRenewingGift, _props$invoice;
13209
13477
 
13210
13478
  const {
13211
13479
  t
@@ -13221,6 +13489,7 @@ const PaymentMethodContainerWithoutStripe = ({
13221
13489
  const subscriptionIdToRenew = (_props$subscriptionId = props.subscriptionIdToRenew) !== null && _props$subscriptionId !== void 0 ? _props$subscriptionId : pelcroStore.subscriptionIdToRenew;
13222
13490
  const selectedAddressId = (_props$selectedAddres = props.selectedAddressId) !== null && _props$selectedAddres !== void 0 ? _props$selectedAddres : pelcroStore.selectedAddressId;
13223
13491
  const giftRecipient = (_props$giftRecipient = props.giftRecipient) !== null && _props$giftRecipient !== void 0 ? _props$giftRecipient : pelcroStore.giftRecipient;
13492
+ const isGift = (_props$isGift = props.isGift) !== null && _props$isGift !== void 0 ? _props$isGift : pelcroStore.isGift;
13224
13493
  const isRenewingGift = (_props$isRenewingGift = props.isRenewingGift) !== null && _props$isRenewingGift !== void 0 ? _props$isRenewingGift : pelcroStore.isRenewingGift;
13225
13494
  const invoice = (_props$invoice = props.invoice) !== null && _props$invoice !== void 0 ? _props$invoice : pelcroStore.invoice;
13226
13495
  React.useEffect(() => {
@@ -13237,60 +13506,185 @@ const PaymentMethodContainerWithoutStripe = ({
13237
13506
  updateTotalAmountWithTax();
13238
13507
  }, []);
13239
13508
 
13240
- function submitVantivPayment() {
13509
+ const submitUsingVantiv = () => {
13510
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
13511
+
13512
+ if (isUsingExistingPaymentMethod) {
13513
+ // no need to create a new source using vantiv
13514
+ return handleVantivPayment(null);
13515
+ }
13516
+
13241
13517
  if (!vantivInstanceRef.current) {
13242
13518
  return console.error("Vantiv sdk script wasn't loaded, you need to load vantiv sdk before rendering the vantiv payment flow");
13243
13519
  }
13244
13520
 
13245
- const orderId = `pelcro-${new Date().getTime()}`; // calls handleVantivPayment
13521
+ const orderId = `pelcro-${new Date().getTime()}`;
13522
+ /*
13523
+ calls handleVantivPayment to either handle a payment or update a source by simply creating a new source
13524
+ */
13246
13525
 
13247
13526
  vantivInstanceRef.current.getPaypageRegistrationId({
13248
13527
  id: orderId,
13249
13528
  orderId: orderId
13250
13529
  });
13251
- }
13530
+ };
13531
+
13532
+ function handleVantivPayment(paymentRequest) {
13533
+ if (paymentRequest) {
13534
+ const SUCCESS_STATUS = "870";
13535
+
13536
+ if (paymentRequest.response !== SUCCESS_STATUS) {
13537
+ return handlePaymentError({
13538
+ error: new Error(paymentRequest.message)
13539
+ });
13540
+ }
13541
+ }
13542
+
13543
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
13544
+
13545
+ if (type === "createPayment") {
13546
+ handleVantivSubscription();
13547
+ } else if (type === "orderCreate") {
13548
+ purchase(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
13549
+ } else if (type === "invoicePayment") {
13550
+ payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
13551
+ } else if (type === "updatePaymentSource") {
13552
+ createNewVantivCard();
13553
+ }
13554
+
13555
+ function createNewVantivCard() {
13556
+ window.Pelcro.source.create({
13557
+ auth_token: window.Pelcro.user.read().auth_token,
13558
+ token: paymentRequest,
13559
+ gateway: "vantiv"
13560
+ }, (err, res) => {
13561
+ dispatch({
13562
+ type: DISABLE_SUBMIT,
13563
+ payload: false
13564
+ });
13565
+ dispatch({
13566
+ type: LOADING,
13567
+ payload: false
13568
+ });
13569
+
13570
+ if (err) {
13571
+ onFailure(err);
13572
+ return dispatch({
13573
+ type: SHOW_ALERT,
13574
+ payload: {
13575
+ type: "error",
13576
+ content: getErrorMessages(err)
13577
+ }
13578
+ });
13579
+ }
13580
+
13581
+ dispatch({
13582
+ type: SHOW_ALERT,
13583
+ payload: {
13584
+ type: "success",
13585
+ content: t("messages.sourceUpdated")
13586
+ }
13587
+ });
13588
+ onSuccess(res);
13589
+ });
13590
+ }
13591
+
13592
+ function handleVantivSubscription() {
13593
+ const payment = new Payment(new VantivGateway());
13594
+ const createSubscription = !isGift && !subscriptionIdToRenew;
13595
+ const renewSubscription = !isGift && subscriptionIdToRenew;
13596
+ const giftSubscriprition = isGift && !subscriptionIdToRenew;
13597
+ const renewGift = isRenewingGift;
13598
+ const {
13599
+ couponCode
13600
+ } = state;
13601
+
13602
+ if (renewGift) {
13603
+ return payment.execute({
13604
+ type: PAYMENT_TYPES.RENEW_GIFTED_SUBSCRIPTION,
13605
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
13606
+ plan,
13607
+ couponCode,
13608
+ product,
13609
+ isExistingSource: isUsingExistingPaymentMethod,
13610
+ subscriptionIdToRenew,
13611
+ addressId: selectedAddressId
13612
+ }, (err, res) => {
13613
+ if (err) {
13614
+ return handlePaymentError(err);
13615
+ }
13616
+
13617
+ onSuccess(res);
13618
+ });
13619
+ } else if (giftSubscriprition) {
13620
+ return payment.execute({
13621
+ type: PAYMENT_TYPES.CREATE_GIFTED_SUBSCRIPTION,
13622
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
13623
+ quantity: plan.quantity,
13624
+ plan,
13625
+ couponCode,
13626
+ product,
13627
+ isExistingSource: isUsingExistingPaymentMethod,
13628
+ giftRecipient,
13629
+ addressId: selectedAddressId
13630
+ }, (err, res) => {
13631
+ if (err) {
13632
+ return handlePaymentError(err);
13633
+ }
13252
13634
 
13253
- function handleVantivPayment(paymentRequest) {
13254
- const SUCCESS_STATUS = "870";
13635
+ onSuccess(res);
13636
+ });
13637
+ } else if (renewSubscription) {
13638
+ return payment.execute({
13639
+ type: PAYMENT_TYPES.RENEW_SUBSCRIPTION,
13640
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
13641
+ quantity: plan.quantity,
13642
+ plan,
13643
+ couponCode,
13644
+ product,
13645
+ isExistingSource: isUsingExistingPaymentMethod,
13646
+ subscriptionIdToRenew,
13647
+ addressId: selectedAddressId
13648
+ }, (err, res) => {
13649
+ if (err) {
13650
+ return handlePaymentError(err);
13651
+ }
13255
13652
 
13256
- if (paymentRequest.response !== SUCCESS_STATUS) {
13257
- return handlePaymentError({
13258
- error: new Error(paymentRequest.message)
13259
- });
13260
- }
13653
+ onSuccess(res);
13654
+ });
13655
+ } else if (createSubscription) {
13656
+ return payment.execute({
13657
+ type: PAYMENT_TYPES.CREATE_SUBSCRIPTION,
13658
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
13659
+ quantity: plan.quantity,
13660
+ plan,
13661
+ couponCode,
13662
+ product,
13663
+ isExistingSource: isUsingExistingPaymentMethod,
13664
+ addressId: selectedAddressId
13665
+ }, (err, res) => {
13666
+ if (err) {
13667
+ return handlePaymentError(err);
13668
+ }
13261
13669
 
13262
- const subscription = new Subscription(new VantivGateway());
13263
- const {
13264
- couponCode
13265
- } = state;
13266
- return subscription.execute({
13267
- type: SUBSCRIPTION_TYPES.CREATE_SUBSCRIPTION,
13268
- token: paymentRequest,
13269
- quantity: plan.quantity,
13270
- plan,
13271
- couponCode,
13272
- product,
13273
- addressId: selectedAddressId
13274
- }, (err, res) => {
13275
- if (err) {
13276
- return handlePaymentError(err);
13670
+ onSuccess(res);
13671
+ });
13277
13672
  }
13278
-
13279
- onSuccess(res);
13280
- });
13673
+ }
13281
13674
  }
13282
13675
 
13283
13676
  const vantivInstanceRef = React__default['default'].useRef(null);
13284
13677
  React.useEffect(() => {
13285
13678
  const cardProcessor = getSiteCardProcessor();
13286
13679
 
13287
- if (cardProcessor === "vantiv") {
13288
- var _window$Pelcro$site$r;
13680
+ if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
13681
+ var _window$Pelcro$site$r, _window$Pelcro$site$r2;
13289
13682
 
13290
- const payPageId = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.vantiv_pay_page_id;
13683
+ const payPageId = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.vantiv_gateway_settings.pay_page_id;
13684
+ const reportGroup = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.vantiv_gateway_settings.report_group;
13291
13685
  vantivInstanceRef.current = new window.EprotectIframeClient({
13292
13686
  paypageId: payPageId,
13293
- reportGroup: payPageId,
13687
+ reportGroup: reportGroup,
13294
13688
  style: "pelcro",
13295
13689
  height: "245",
13296
13690
  timeout: 50000,
@@ -13307,7 +13701,7 @@ const PaymentMethodContainerWithoutStripe = ({
13307
13701
  }
13308
13702
  });
13309
13703
  }
13310
- }, []);
13704
+ }, [selectedPaymentMethodId]);
13311
13705
 
13312
13706
  const initPaymentRequest = (state, dispatch) => {
13313
13707
  try {
@@ -13379,9 +13773,9 @@ const PaymentMethodContainerWithoutStripe = ({
13379
13773
 
13380
13774
 
13381
13775
  const updateTotalAmountWithTax = () => {
13382
- var _window$Pelcro$site$r2;
13776
+ var _window$Pelcro$site$r3;
13383
13777
 
13384
- const taxesEnabled = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.taxes_enabled;
13778
+ const taxesEnabled = (_window$Pelcro$site$r3 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : _window$Pelcro$site$r3.taxes_enabled;
13385
13779
 
13386
13780
  if (taxesEnabled && type === "createPayment") {
13387
13781
  dispatch({
@@ -13538,6 +13932,7 @@ const PaymentMethodContainerWithoutStripe = ({
13538
13932
  window.Pelcro.order.create({
13539
13933
  auth_token: window.Pelcro.user.read().auth_token,
13540
13934
  plan_id: plan.id,
13935
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13541
13936
  coupon_code: couponCode,
13542
13937
  address_id: selectedAddressId
13543
13938
  }, handleCouponResponse);
@@ -13619,6 +14014,7 @@ const PaymentMethodContainerWithoutStripe = ({
13619
14014
  stripe_token: !stripeSource.isExistingSource ? stripeSource.id : undefined,
13620
14015
  auth_token: window.Pelcro.user.read().auth_token,
13621
14016
  plan_id: plan.id,
14017
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13622
14018
  quantity: plan.quantity,
13623
14019
  coupon_code: couponCode,
13624
14020
  gift_recipient_email: giftRecipient ? giftRecipient.email : null,
@@ -13690,6 +14086,7 @@ const PaymentMethodContainerWithoutStripe = ({
13690
14086
  stripe_token: !stripeSource.isExistingSource ? stripeSource.id : undefined,
13691
14087
  auth_token: window.Pelcro.user.read().auth_token,
13692
14088
  plan_id: plan.id,
14089
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13693
14090
  coupon_code: couponCode,
13694
14091
  subscription_id: subscriptionIdToRenew,
13695
14092
  address_id: product.address_required ? selectedAddressId : null
@@ -13731,7 +14128,7 @@ const PaymentMethodContainerWithoutStripe = ({
13731
14128
 
13732
14129
 
13733
14130
  const handlePaypalSubscription = (state, paypalNonce) => {
13734
- const subscription = new Subscription(new PaypalGateway());
14131
+ const payment = new Payment(new PaypalGateway());
13735
14132
  const {
13736
14133
  couponCode
13737
14134
  } = state;
@@ -13740,8 +14137,8 @@ const PaymentMethodContainerWithoutStripe = ({
13740
14137
  */
13741
14138
 
13742
14139
  if (giftRecipient) {
13743
- return subscription.execute({
13744
- type: SUBSCRIPTION_TYPES.CREATE_GIFTED_SUBSCRIPTION,
14140
+ return payment.execute({
14141
+ type: PAYMENT_TYPES.CREATE_GIFTED_SUBSCRIPTION,
13745
14142
  token: paypalNonce,
13746
14143
  quantity: plan.quantity,
13747
14144
  plan,
@@ -13774,8 +14171,8 @@ const PaymentMethodContainerWithoutStripe = ({
13774
14171
  });
13775
14172
  }
13776
14173
 
13777
- return subscription.execute({
13778
- type: SUBSCRIPTION_TYPES.CREATE_SUBSCRIPTION,
14174
+ return payment.execute({
14175
+ type: PAYMENT_TYPES.CREATE_SUBSCRIPTION,
13779
14176
  token: paypalNonce,
13780
14177
  quantity: plan.quantity,
13781
14178
  plan,
@@ -13807,7 +14204,7 @@ const PaymentMethodContainerWithoutStripe = ({
13807
14204
  });
13808
14205
  };
13809
14206
 
13810
- const purchase = (stripeSource, state, dispatch) => {
14207
+ const purchase = (gatewayService, gatewayToken, state, dispatch) => {
13811
14208
  const isQuickPurchase = !Array.isArray(order);
13812
14209
  const mappedOrderItems = isQuickPurchase ? [{
13813
14210
  sku_id: order.id,
@@ -13819,14 +14216,14 @@ const PaymentMethodContainerWithoutStripe = ({
13819
14216
  const {
13820
14217
  couponCode
13821
14218
  } = state;
13822
- window.Pelcro.ecommerce.order.create({
13823
- source_id: stripeSource.isExistingSource ? stripeSource.id : undefined,
13824
- stripe_token: !stripeSource.isExistingSource ? stripeSource.id : undefined,
14219
+ const payment = new Payment(gatewayService);
14220
+ payment.execute({
14221
+ type: PAYMENT_TYPES.PURCHASE_ECOMMERCE_ORDER,
14222
+ token: gatewayToken,
14223
+ isExistingSource: Boolean(selectedPaymentMethodId),
13825
14224
  items: mappedOrderItems,
13826
- coupon_code: couponCode,
13827
- ...(selectedAddressId && {
13828
- address_id: selectedAddressId
13829
- })
14225
+ addressId: selectedAddressId,
14226
+ couponCode
13830
14227
  }, (err, res) => {
13831
14228
  dispatch({
13832
14229
  type: DISABLE_SUBMIT,
@@ -13864,9 +14261,9 @@ const PaymentMethodContainerWithoutStripe = ({
13864
14261
  };
13865
14262
 
13866
14263
  const payInvoice = (gatewayService, gatewayToken, dispatch) => {
13867
- const subscription = new Subscription(gatewayService);
13868
- return subscription.execute({
13869
- type: SUBSCRIPTION_TYPES.PAY_INVOICE,
14264
+ const payment = new Payment(gatewayService);
14265
+ return payment.execute({
14266
+ type: PAYMENT_TYPES.PAY_INVOICE,
13870
14267
  token: gatewayToken,
13871
14268
  isExistingSource: Boolean(selectedPaymentMethodId),
13872
14269
  invoiceId: invoice.id
@@ -13911,7 +14308,9 @@ const PaymentMethodContainerWithoutStripe = ({
13911
14308
 
13912
14309
  if ((source === null || source === void 0 ? void 0 : (_source$card2 = source.card) === null || _source$card2 === void 0 ? void 0 : _source$card2.three_d_secure) === "required") {
13913
14310
  return handlePaymentError({
13914
- message: t("messages.cardAuthNotSupported")
14311
+ error: {
14312
+ message: t("messages.cardAuthNotSupported")
14313
+ }
13915
14314
  });
13916
14315
  }
13917
14316
 
@@ -14026,13 +14425,13 @@ const PaymentMethodContainerWithoutStripe = ({
14026
14425
 
14027
14426
 
14028
14427
  const resolveTaxCalculation = () => {
14029
- var _window$Pelcro$site$r3;
14428
+ var _window$Pelcro$site$r4;
14030
14429
 
14031
14430
  if (type === "invoicePayment") {
14032
14431
  return new Promise(resolve => resolve());
14033
14432
  }
14034
14433
 
14035
- const taxesEnabled = (_window$Pelcro$site$r3 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : _window$Pelcro$site$r3.taxes_enabled;
14434
+ 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;
14036
14435
  return new Promise((resolve, reject) => {
14037
14436
  // resolve early if taxes isn't enabled
14038
14437
  if (!taxesEnabled) {
@@ -14042,6 +14441,7 @@ const PaymentMethodContainerWithoutStripe = ({
14042
14441
  window.Pelcro.order.create({
14043
14442
  auth_token: window.Pelcro.user.read().auth_token,
14044
14443
  plan_id: plan.id,
14444
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
14045
14445
  coupon_code: state === null || state === void 0 ? void 0 : state.couponCode,
14046
14446
  address_id: selectedAddressId
14047
14447
  }, (error, res) => {
@@ -14104,7 +14504,7 @@ const PaymentMethodContainerWithoutStripe = ({
14104
14504
  if (stripeSource && type === "createPayment") {
14105
14505
  subscribe(stripeSource, state, dispatch);
14106
14506
  } else if (stripeSource && type === "orderCreate") {
14107
- purchase(stripeSource, state, dispatch);
14507
+ purchase(new StripeGateway(), stripeSource.id, state, dispatch);
14108
14508
  } else if (stripeSource && type === "invoicePayment") {
14109
14509
  payInvoice(new StripeGateway(), stripeSource.id, dispatch);
14110
14510
  }
@@ -14155,7 +14555,9 @@ const PaymentMethodContainerWithoutStripe = ({
14155
14555
 
14156
14556
  if ((source === null || source === void 0 ? void 0 : source.status) === "failed") {
14157
14557
  return handlePaymentError({
14158
- message: t("messages.cardAuthFailed")
14558
+ error: {
14559
+ message: t("messages.cardAuthFailed")
14560
+ }
14159
14561
  });
14160
14562
  }
14161
14563
 
@@ -14226,6 +14628,10 @@ const PaymentMethodContainerWithoutStripe = ({
14226
14628
  disableSubmit: true,
14227
14629
  isLoading: true
14228
14630
  }, (state, dispatch) => {
14631
+ if (getSiteCardProcessor() === "vantiv") {
14632
+ return submitUsingVantiv();
14633
+ }
14634
+
14229
14635
  if (selectedPaymentMethodId) {
14230
14636
  // pay with selected method (source) if exists already
14231
14637
  return handlePayment({
@@ -14238,10 +14644,6 @@ const PaymentMethodContainerWithoutStripe = ({
14238
14644
  return updatePaymentSource(state, dispatch);
14239
14645
  }
14240
14646
 
14241
- if (getSiteCardProcessor() === "vantiv") {
14242
- return submitVantivPayment();
14243
- }
14244
-
14245
14647
  submitPayment(state);
14246
14648
  });
14247
14649
 
@@ -14546,17 +14948,17 @@ const SubmitPaymentMethod = ({
14546
14948
  }, t("labels.pay"), " ", priceFormatted && priceFormatted) : t("labels.submit"));
14547
14949
  };
14548
14950
 
14549
- var _path$l;
14951
+ var _path$m;
14550
14952
 
14551
- function _extends$n() { _extends$n = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$n.apply(this, arguments); }
14953
+ function _extends$o() { _extends$o = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$o.apply(this, arguments); }
14552
14954
 
14553
14955
  function SvgArrowLeft(props) {
14554
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$n({
14956
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$o({
14555
14957
  xmlns: "http://www.w3.org/2000/svg",
14556
14958
  fill: "none",
14557
14959
  viewBox: "0 0 24 24",
14558
14960
  stroke: "currentColor"
14559
- }, props), _path$l || (_path$l = /*#__PURE__*/React__namespace.createElement("path", {
14961
+ }, props), _path$m || (_path$m = /*#__PURE__*/React__namespace.createElement("path", {
14560
14962
  strokeLinecap: "round",
14561
14963
  strokeLinejoin: "round",
14562
14964
  strokeWidth: 2,
@@ -14638,17 +15040,17 @@ const CouponCodeField = props => {
14638
15040
  }, props));
14639
15041
  };
14640
15042
 
14641
- var _path$k;
15043
+ var _path$l;
14642
15044
 
14643
- function _extends$m() { _extends$m = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$m.apply(this, arguments); }
15045
+ function _extends$n() { _extends$n = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$n.apply(this, arguments); }
14644
15046
 
14645
15047
  function SvgTicket(props) {
14646
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$m({
15048
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$n({
14647
15049
  xmlns: "http://www.w3.org/2000/svg",
14648
15050
  fill: "none",
14649
15051
  viewBox: "0 0 24 24",
14650
15052
  stroke: "currentColor"
14651
- }, props), _path$k || (_path$k = /*#__PURE__*/React__namespace.createElement("path", {
15053
+ }, props), _path$l || (_path$l = /*#__PURE__*/React__namespace.createElement("path", {
14652
15054
  strokeLinecap: "round",
14653
15055
  strokeLinejoin: "round",
14654
15056
  strokeWidth: 2,
@@ -14937,7 +15339,7 @@ const PaypalSubscribeButton = props => {
14937
15339
  const selectedAddress = getAddressById((_props$selectedAddres = props.selectedAddressId) !== null && _props$selectedAddres !== void 0 ? _props$selectedAddres : selectedAddressId); // initialize paypal client, then render paypal button.
14938
15340
 
14939
15341
  const initializePaypal = async () => {
14940
- var _props$buttonElementI, _props$product$addres, _props$product, _props$plan2;
15342
+ var _props$buttonElementI, _props$product$addres, _props$product;
14941
15343
 
14942
15344
  const paypalCheckoutInstance = new PaypalClient({
14943
15345
  buttonElementID: (_props$buttonElementI = props.buttonElementID) !== null && _props$buttonElementI !== void 0 ? _props$buttonElementI : "pelcro-paypal-button",
@@ -14947,12 +15349,33 @@ const PaypalSubscribeButton = props => {
14947
15349
  displayName: props.merchantDisplayName,
14948
15350
  locale: props.locale,
14949
15351
  billingAgreementDescription: props.billingDescription
14950
- }); // Await building paypal instance
15352
+ });
15353
+
15354
+ const getProduct = () => {
15355
+ if (invoice) {
15356
+ invoice.plan = null;
15357
+
15358
+ if (invoice.plan) {
15359
+ return invoice.plan;
15360
+ } else {
15361
+ // standalone invoices dont have a plan
15362
+ return {
15363
+ currency: invoice.currency,
15364
+ nickname: `invoice #${invoice.id}`
15365
+ };
15366
+ }
15367
+ } else if (props.plan) {
15368
+ return props.plan;
15369
+ } else {
15370
+ return plan;
15371
+ }
15372
+ }; // Await building paypal instance
15373
+
14951
15374
 
14952
15375
  await paypalCheckoutInstance.build(); // Create paypal payment
14953
15376
 
14954
15377
  paypalCheckoutInstance.createPayment({
14955
- product: invoice ? invoice.plan : (_props$plan2 = props.plan) !== null && _props$plan2 !== void 0 ? _props$plan2 : plan,
15378
+ product: getProduct(),
14956
15379
  amount: updatedPrice,
14957
15380
  address: invoice ? null : selectedAddress,
14958
15381
  onButtonClick: () => {
@@ -15008,16 +15431,16 @@ const BankRedirection = () => {
15008
15431
  }));
15009
15432
  };
15010
15433
 
15011
- var _path$j;
15434
+ var _path$k;
15012
15435
 
15013
- function _extends$l() { _extends$l = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$l.apply(this, arguments); }
15436
+ function _extends$m() { _extends$m = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$m.apply(this, arguments); }
15014
15437
 
15015
15438
  function SvgLock(props) {
15016
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$l({
15439
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$m({
15017
15440
  xmlns: "http://www.w3.org/2000/svg",
15018
15441
  viewBox: "0 0 20 20",
15019
15442
  fill: "currentColor"
15020
- }, props), _path$j || (_path$j = /*#__PURE__*/React__namespace.createElement("path", {
15443
+ }, props), _path$k || (_path$k = /*#__PURE__*/React__namespace.createElement("path", {
15021
15444
  fillRule: "evenodd",
15022
15445
  d: "M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z",
15023
15446
  clipRule: "evenodd"
@@ -15240,12 +15663,12 @@ function SubscriptionRenewModal({
15240
15663
  }
15241
15664
  SubscriptionRenewModal.viewId = "subscription-renew";
15242
15665
 
15243
- var _path$i;
15666
+ var _path$j;
15244
15667
 
15245
- function _extends$k() { _extends$k = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$k.apply(this, arguments); }
15668
+ function _extends$l() { _extends$l = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$l.apply(this, arguments); }
15246
15669
 
15247
15670
  function SvgGift(props) {
15248
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$k({
15671
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$l({
15249
15672
  className: "plc-w-6 plc-h-6 plc-mr-2",
15250
15673
  fill: "none",
15251
15674
  stroke: "currentColor",
@@ -15254,7 +15677,7 @@ function SvgGift(props) {
15254
15677
  strokeWidth: 2,
15255
15678
  viewBox: "0 0 24 24",
15256
15679
  xmlns: "http://www.w3.org/2000/svg"
15257
- }, props), _path$i || (_path$i = /*#__PURE__*/React__namespace.createElement("path", {
15680
+ }, props), _path$j || (_path$j = /*#__PURE__*/React__namespace.createElement("path", {
15258
15681
  d: "M20 12v10H4V12M2 7h20v5H2zM12 22V7M12 7H7.5a2.5 2.5 0 010-5C11 2 12 7 12 7zM12 7h4.5a2.5 2.5 0 000-5C13 2 12 7 12 7z"
15259
15682
  })));
15260
15683
  }
@@ -16263,17 +16686,17 @@ const UserUpdatePhone = props => /*#__PURE__*/React__default['default'].createEl
16263
16686
 
16264
16687
  var userSolidIcon = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20class%3D%22plc-h-5%20plc-w-5%22%20viewBox%3D%220%200%2020%2020%22%20fill%3D%22white%22%3E%20%20%3Cpath%20transform%3D%22translate%280%2C2%29%22%20fill-rule%3D%22evenodd%22%20d%3D%22M10%209a3%203%200%20100-6%203%203%200%20000%206zm-7%209a7%207%200%201114%200H3z%22%20clip-rule%3D%22evenodd%22%20%2F%3E%3C%2Fsvg%3E";
16265
16688
 
16266
- var _path$h;
16689
+ var _path$i;
16267
16690
 
16268
- function _extends$j() { _extends$j = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$j.apply(this, arguments); }
16691
+ function _extends$k() { _extends$k = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$k.apply(this, arguments); }
16269
16692
 
16270
16693
  function SvgEdit(props) {
16271
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$j({
16694
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$k({
16272
16695
  className: "plc-w-6 plc-h-6",
16273
16696
  xmlns: "http://www.w3.org/2000/svg",
16274
16697
  viewBox: "0 0 20 20",
16275
16698
  fill: "currentColor"
16276
- }, props), _path$h || (_path$h = /*#__PURE__*/React__namespace.createElement("path", {
16699
+ }, props), _path$i || (_path$i = /*#__PURE__*/React__namespace.createElement("path", {
16277
16700
  d: "M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zm-2.207 2.207L3 14.172V17h2.828l8.38-8.379-2.83-2.828z"
16278
16701
  })));
16279
16702
  }
@@ -19383,18 +19806,18 @@ const GiftCreateLastName = props => /*#__PURE__*/React__default['default'].creat
19383
19806
  store: store$6
19384
19807
  }, props));
19385
19808
 
19386
- var _path$g;
19809
+ var _path$h;
19387
19810
 
19388
- function _extends$i() { _extends$i = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$i.apply(this, arguments); }
19811
+ function _extends$j() { _extends$j = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$j.apply(this, arguments); }
19389
19812
 
19390
19813
  function SvgInfoCircle(props) {
19391
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$i({
19814
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$j({
19392
19815
  xmlns: "http://www.w3.org/2000/svg",
19393
19816
  className: "plc-w-5 plc-h-5",
19394
19817
  fill: "none",
19395
19818
  viewBox: "0 0 24 24",
19396
19819
  stroke: "currentColor"
19397
- }, props), _path$g || (_path$g = /*#__PURE__*/React__namespace.createElement("path", {
19820
+ }, props), _path$h || (_path$h = /*#__PURE__*/React__namespace.createElement("path", {
19398
19821
  strokeLinecap: "round",
19399
19822
  strokeLinejoin: "round",
19400
19823
  strokeWidth: 2,
@@ -20406,8 +20829,8 @@ const PaymentMethodSelectModal = ({
20406
20829
  };
20407
20830
  PaymentMethodSelectModal.viewId = "payment-method-select";
20408
20831
 
20409
- function _extends$h() {
20410
- _extends$h = Object.assign || function (target) {
20832
+ function _extends$i() {
20833
+ _extends$i = Object.assign || function (target) {
20411
20834
  for (var i = 1; i < arguments.length; i++) {
20412
20835
  var source = arguments[i];
20413
20836
 
@@ -20421,7 +20844,7 @@ function _extends$h() {
20421
20844
  return target;
20422
20845
  };
20423
20846
 
20424
- return _extends$h.apply(this, arguments);
20847
+ return _extends$i.apply(this, arguments);
20425
20848
  }
20426
20849
 
20427
20850
  function _objectWithoutPropertiesLoose(source, excluded) {
@@ -20605,7 +21028,7 @@ function render(props, propsBag, defaultTag, features, visible) {
20605
21028
  return match(strategy, (_match = {}, _match[RenderStrategy.Unmount] = function () {
20606
21029
  return null;
20607
21030
  }, _match[RenderStrategy.Hidden] = function () {
20608
- return _render(_extends$h({}, _rest, {
21031
+ return _render(_extends$i({}, _rest, {
20609
21032
  hidden: true,
20610
21033
  style: {
20611
21034
  display: 'none'
@@ -21133,7 +21556,7 @@ function TransitionChild(props) {
21133
21556
  var passthroughProps = rest;
21134
21557
  return React__default['default'].createElement(NestingContext.Provider, {
21135
21558
  value: nesting
21136
- }, render(_extends$h({}, passthroughProps, propsWeControl), propsBag, DEFAULT_TRANSITION_CHILD_TAG, TransitionChildRenderFeatures, state === TreeStates.Visible));
21559
+ }, render(_extends$i({}, passthroughProps, propsWeControl), propsBag, DEFAULT_TRANSITION_CHILD_TAG, TransitionChildRenderFeatures, state === TreeStates.Visible));
21137
21560
  }
21138
21561
 
21139
21562
  function Transition(props) {
@@ -21177,7 +21600,7 @@ function Transition(props) {
21177
21600
  value: nestingBag
21178
21601
  }, React__default['default'].createElement(TransitionContext.Provider, {
21179
21602
  value: transitionBag
21180
- }, render(_extends$h({}, sharedProps, {
21603
+ }, render(_extends$i({}, sharedProps, {
21181
21604
  as: React.Fragment,
21182
21605
  children: React__default['default'].createElement(TransitionChild, Object.assign({}, sharedProps, passthroughProps))
21183
21606
  }), propsBag, React.Fragment, TransitionChildRenderFeatures, state === TreeStates.Visible)));
@@ -21304,12 +21727,12 @@ var ActionTypes;
21304
21727
  })(ActionTypes || (ActionTypes = {}));
21305
21728
 
21306
21729
  (_reducers = {}, _reducers[ActionTypes.CloseMenu] = function (state) {
21307
- return _extends$h({}, state, {
21730
+ return _extends$i({}, state, {
21308
21731
  activeItemIndex: null,
21309
21732
  menuState: MenuStates.Closed
21310
21733
  });
21311
21734
  }, _reducers[ActionTypes.OpenMenu] = function (state) {
21312
- return _extends$h({}, state, {
21735
+ return _extends$i({}, state, {
21313
21736
  menuState: MenuStates.Open
21314
21737
  });
21315
21738
  }, _reducers[ActionTypes.GoToItem] = function (state, action) {
@@ -21328,7 +21751,7 @@ var ActionTypes;
21328
21751
  }
21329
21752
  });
21330
21753
  if (state.searchQuery === '' && state.activeItemIndex === activeItemIndex) return state;
21331
- return _extends$h({}, state, {
21754
+ return _extends$i({}, state, {
21332
21755
  searchQuery: '',
21333
21756
  activeItemIndex: activeItemIndex
21334
21757
  });
@@ -21339,19 +21762,19 @@ var ActionTypes;
21339
21762
 
21340
21763
  return ((_item$dataRef$current = item.dataRef.current.textValue) == null ? void 0 : _item$dataRef$current.startsWith(searchQuery)) && !item.dataRef.current.disabled;
21341
21764
  });
21342
- if (match === -1 || match === state.activeItemIndex) return _extends$h({}, state, {
21765
+ if (match === -1 || match === state.activeItemIndex) return _extends$i({}, state, {
21343
21766
  searchQuery: searchQuery
21344
21767
  });
21345
- return _extends$h({}, state, {
21768
+ return _extends$i({}, state, {
21346
21769
  searchQuery: searchQuery,
21347
21770
  activeItemIndex: match
21348
21771
  });
21349
21772
  }, _reducers[ActionTypes.ClearSearch] = function (state) {
21350
- return _extends$h({}, state, {
21773
+ return _extends$i({}, state, {
21351
21774
  searchQuery: ''
21352
21775
  });
21353
21776
  }, _reducers[ActionTypes.RegisterItem] = function (state, action) {
21354
- return _extends$h({}, state, {
21777
+ return _extends$i({}, state, {
21355
21778
  items: [].concat(state.items, [{
21356
21779
  id: action.id,
21357
21780
  dataRef: action.dataRef
@@ -21364,7 +21787,7 @@ var ActionTypes;
21364
21787
  return a.id === action.id;
21365
21788
  });
21366
21789
  if (idx !== -1) nextItems.splice(idx, 1);
21367
- return _extends$h({}, state, {
21790
+ return _extends$i({}, state, {
21368
21791
  items: nextItems,
21369
21792
  activeItemIndex: function () {
21370
21793
  if (idx === state.activeItemIndex) return null;
@@ -21403,19 +21826,19 @@ var ActionTypes$1;
21403
21826
  (_reducers$1 = {}, _reducers$1[ActionTypes$1.CloseListbox] = function (state) {
21404
21827
  if (state.disabled) return state;
21405
21828
  if (state.listboxState === ListboxStates.Closed) return state;
21406
- return _extends$h({}, state, {
21829
+ return _extends$i({}, state, {
21407
21830
  activeOptionIndex: null,
21408
21831
  listboxState: ListboxStates.Closed
21409
21832
  });
21410
21833
  }, _reducers$1[ActionTypes$1.OpenListbox] = function (state) {
21411
21834
  if (state.disabled) return state;
21412
21835
  if (state.listboxState === ListboxStates.Open) return state;
21413
- return _extends$h({}, state, {
21836
+ return _extends$i({}, state, {
21414
21837
  listboxState: ListboxStates.Open
21415
21838
  });
21416
21839
  }, _reducers$1[ActionTypes$1.SetDisabled] = function (state, action) {
21417
21840
  if (state.disabled === action.disabled) return state;
21418
- return _extends$h({}, state, {
21841
+ return _extends$i({}, state, {
21419
21842
  disabled: action.disabled
21420
21843
  });
21421
21844
  }, _reducers$1[ActionTypes$1.GoToOption] = function (state, action) {
@@ -21436,7 +21859,7 @@ var ActionTypes$1;
21436
21859
  }
21437
21860
  });
21438
21861
  if (state.searchQuery === '' && state.activeOptionIndex === activeOptionIndex) return state;
21439
- return _extends$h({}, state, {
21862
+ return _extends$i({}, state, {
21440
21863
  searchQuery: '',
21441
21864
  activeOptionIndex: activeOptionIndex
21442
21865
  });
@@ -21449,10 +21872,10 @@ var ActionTypes$1;
21449
21872
 
21450
21873
  return !option.dataRef.current.disabled && ((_option$dataRef$curre = option.dataRef.current.textValue) == null ? void 0 : _option$dataRef$curre.startsWith(searchQuery));
21451
21874
  });
21452
- if (match === -1 || match === state.activeOptionIndex) return _extends$h({}, state, {
21875
+ if (match === -1 || match === state.activeOptionIndex) return _extends$i({}, state, {
21453
21876
  searchQuery: searchQuery
21454
21877
  });
21455
- return _extends$h({}, state, {
21878
+ return _extends$i({}, state, {
21456
21879
  searchQuery: searchQuery,
21457
21880
  activeOptionIndex: match
21458
21881
  });
@@ -21460,11 +21883,11 @@ var ActionTypes$1;
21460
21883
  if (state.disabled) return state;
21461
21884
  if (state.listboxState === ListboxStates.Closed) return state;
21462
21885
  if (state.searchQuery === '') return state;
21463
- return _extends$h({}, state, {
21886
+ return _extends$i({}, state, {
21464
21887
  searchQuery: ''
21465
21888
  });
21466
21889
  }, _reducers$1[ActionTypes$1.RegisterOption] = function (state, action) {
21467
- return _extends$h({}, state, {
21890
+ return _extends$i({}, state, {
21468
21891
  options: [].concat(state.options, [{
21469
21892
  id: action.id,
21470
21893
  dataRef: action.dataRef
@@ -21477,7 +21900,7 @@ var ActionTypes$1;
21477
21900
  return a.id === action.id;
21478
21901
  });
21479
21902
  if (idx !== -1) nextOptions.splice(idx, 1);
21480
- return _extends$h({}, state, {
21903
+ return _extends$i({}, state, {
21481
21904
  options: nextOptions,
21482
21905
  activeOptionIndex: function () {
21483
21906
  if (idx === state.activeOptionIndex) return null;
@@ -21538,18 +21961,18 @@ const getPaymentCardIcon = name => {
21538
21961
  }));
21539
21962
  };
21540
21963
 
21541
- var _path$f;
21964
+ var _path$g;
21542
21965
 
21543
- function _extends$g() { _extends$g = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$g.apply(this, arguments); }
21966
+ function _extends$h() { _extends$h = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$h.apply(this, arguments); }
21544
21967
 
21545
21968
  function SvgChevronRight(props) {
21546
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$g({
21969
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$h({
21547
21970
  className: "plc-w-6 plc-h-6",
21548
21971
  xmlns: "http://www.w3.org/2000/svg",
21549
21972
  fill: "none",
21550
21973
  viewBox: "0 0 24 24",
21551
21974
  stroke: "currentColor"
21552
- }, props), _path$f || (_path$f = /*#__PURE__*/React__namespace.createElement("path", {
21975
+ }, props), _path$g || (_path$g = /*#__PURE__*/React__namespace.createElement("path", {
21553
21976
  strokeLinecap: "round",
21554
21977
  strokeLinejoin: "round",
21555
21978
  strokeWidth: 2,
@@ -21765,18 +22188,18 @@ const SavedItems = ({
21765
22188
  });
21766
22189
  };
21767
22190
 
21768
- var _path$e;
22191
+ var _path$f;
21769
22192
 
21770
- function _extends$f() { _extends$f = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$f.apply(this, arguments); }
22193
+ function _extends$g() { _extends$g = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$g.apply(this, arguments); }
21771
22194
 
21772
22195
  function SvgRefresh(props) {
21773
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$f({
22196
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$g({
21774
22197
  className: "plc-w-4 plc-h-4 plc-mr-1",
21775
22198
  xmlns: "http://www.w3.org/2000/svg",
21776
22199
  fill: "none",
21777
22200
  viewBox: "0 0 24 24",
21778
22201
  stroke: "currentColor"
21779
- }, props), _path$e || (_path$e = /*#__PURE__*/React__namespace.createElement("path", {
22202
+ }, props), _path$f || (_path$f = /*#__PURE__*/React__namespace.createElement("path", {
21780
22203
  strokeLinecap: "round",
21781
22204
  strokeLinejoin: "round",
21782
22205
  strokeWidth: 2,
@@ -21784,35 +22207,35 @@ function SvgRefresh(props) {
21784
22207
  })));
21785
22208
  }
21786
22209
 
21787
- var _path$d;
22210
+ var _path$e;
21788
22211
 
21789
- function _extends$e() { _extends$e = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$e.apply(this, arguments); }
22212
+ function _extends$f() { _extends$f = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$f.apply(this, arguments); }
21790
22213
 
21791
22214
  function SvgCalendar(props) {
21792
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$e({
22215
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$f({
21793
22216
  xmlns: "http://www.w3.org/2000/svg",
21794
22217
  className: "plc-h-4 plc-w-4 plc-mr-1",
21795
22218
  viewBox: "0 0 20 20",
21796
22219
  fill: "currentColor"
21797
- }, props), _path$d || (_path$d = /*#__PURE__*/React__namespace.createElement("path", {
22220
+ }, props), _path$e || (_path$e = /*#__PURE__*/React__namespace.createElement("path", {
21798
22221
  fillRule: "evenodd",
21799
22222
  d: "M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z",
21800
22223
  clipRule: "evenodd"
21801
22224
  })));
21802
22225
  }
21803
22226
 
21804
- var _path$c;
22227
+ var _path$d;
21805
22228
 
21806
- function _extends$d() { _extends$d = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$d.apply(this, arguments); }
22229
+ function _extends$e() { _extends$e = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$e.apply(this, arguments); }
21807
22230
 
21808
22231
  function SvgPlus(props) {
21809
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$d({
22232
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$e({
21810
22233
  className: "plc-w-5 plc-h-5",
21811
22234
  xmlns: "http://www.w3.org/2000/svg",
21812
22235
  fill: "none",
21813
22236
  viewBox: "0 0 24 24",
21814
22237
  stroke: "currentColor"
21815
- }, props), _path$c || (_path$c = /*#__PURE__*/React__namespace.createElement("path", {
22238
+ }, props), _path$d || (_path$d = /*#__PURE__*/React__namespace.createElement("path", {
21816
22239
  strokeLinecap: "round",
21817
22240
  strokeLinejoin: "round",
21818
22241
  strokeWidth: 2,
@@ -21820,17 +22243,17 @@ function SvgPlus(props) {
21820
22243
  })));
21821
22244
  }
21822
22245
 
21823
- var _path$b;
22246
+ var _path$c;
21824
22247
 
21825
- function _extends$c() { _extends$c = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$c.apply(this, arguments); }
22248
+ function _extends$d() { _extends$d = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$d.apply(this, arguments); }
21826
22249
 
21827
22250
  function SvgCheckMark(props) {
21828
- return /*#__PURE__*/React__namespace.createElement("svg", _extends$c({
22251
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$d({
21829
22252
  className: "plc-w-4 plc-h-4 plc-mr-1",
21830
22253
  xmlns: "http://www.w3.org/2000/svg",
21831
22254
  viewBox: "0 0 20 20",
21832
22255
  fill: "currentColor"
21833
- }, props), _path$b || (_path$b = /*#__PURE__*/React__namespace.createElement("path", {
22256
+ }, props), _path$c || (_path$c = /*#__PURE__*/React__namespace.createElement("path", {
21834
22257
  fillRule: "evenodd",
21835
22258
  d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",
21836
22259
  clipRule: "evenodd"
@@ -22125,13 +22548,31 @@ Accordion.item = function AccordionItem({
22125
22548
  }, content)) : null;
22126
22549
  };
22127
22550
 
22551
+ var _path$b;
22552
+
22553
+ function _extends$c() { _extends$c = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$c.apply(this, arguments); }
22554
+
22555
+ function SvgExit(props) {
22556
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends$c({
22557
+ className: "plc-w-6 plc-h-6",
22558
+ xmlns: "http://www.w3.org/2000/svg",
22559
+ fill: "none",
22560
+ viewBox: "0 0 24 24",
22561
+ stroke: "currentColor"
22562
+ }, props), _path$b || (_path$b = /*#__PURE__*/React__namespace.createElement("path", {
22563
+ strokeLinecap: "round",
22564
+ strokeLinejoin: "round",
22565
+ strokeWidth: 2,
22566
+ d: "M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"
22567
+ })));
22568
+ }
22569
+
22128
22570
  var _path$a;
22129
22571
 
22130
22572
  function _extends$b() { _extends$b = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$b.apply(this, arguments); }
22131
22573
 
22132
- function SvgExit(props) {
22574
+ function SvgUser(props) {
22133
22575
  return /*#__PURE__*/React__namespace.createElement("svg", _extends$b({
22134
- className: "plc-w-6 plc-h-6",
22135
22576
  xmlns: "http://www.w3.org/2000/svg",
22136
22577
  fill: "none",
22137
22578
  viewBox: "0 0 24 24",
@@ -22140,7 +22581,7 @@ function SvgExit(props) {
22140
22581
  strokeLinecap: "round",
22141
22582
  strokeLinejoin: "round",
22142
22583
  strokeWidth: 2,
22143
- d: "M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"
22584
+ d: "M16 7a4 4 0 11-8 0 4 4 0 018 0zm-4 7a7 7 0 00-7 7h14a7 7 0 00-7-7z"
22144
22585
  })));
22145
22586
  }
22146
22587
 
@@ -22148,9 +22589,10 @@ var _path$9;
22148
22589
 
22149
22590
  function _extends$a() { _extends$a = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$a.apply(this, arguments); }
22150
22591
 
22151
- function SvgUser(props) {
22592
+ function SvgNewsletter(props) {
22152
22593
  return /*#__PURE__*/React__namespace.createElement("svg", _extends$a({
22153
22594
  xmlns: "http://www.w3.org/2000/svg",
22595
+ className: "plc-h-5 plc-w-5",
22154
22596
  fill: "none",
22155
22597
  viewBox: "0 0 24 24",
22156
22598
  stroke: "currentColor"
@@ -22158,7 +22600,7 @@ function SvgUser(props) {
22158
22600
  strokeLinecap: "round",
22159
22601
  strokeLinejoin: "round",
22160
22602
  strokeWidth: 2,
22161
- d: "M16 7a4 4 0 11-8 0 4 4 0 018 0zm-4 7a7 7 0 00-7 7h14a7 7 0 00-7-7z"
22603
+ d: "M19 20H5a2 2 0 01-2-2V6a2 2 0 012-2h10a2 2 0 012 2v1m2 13a2 2 0 01-2-2V7m2 13a2 2 0 002-2V9a2 2 0 00-2-2h-2m-4-3H9M7 16h6M7 8h6v4H7V8z"
22162
22604
  })));
22163
22605
  }
22164
22606
 
@@ -22166,10 +22608,10 @@ var _path$8;
22166
22608
 
22167
22609
  function _extends$9() { _extends$9 = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends$9.apply(this, arguments); }
22168
22610
 
22169
- function SvgNewsletter(props) {
22611
+ function SvgDocument(props) {
22170
22612
  return /*#__PURE__*/React__namespace.createElement("svg", _extends$9({
22171
22613
  xmlns: "http://www.w3.org/2000/svg",
22172
- className: "plc-h-5 plc-w-5",
22614
+ className: "plc-h-6 plc-w-6 plc-mr-2",
22173
22615
  fill: "none",
22174
22616
  viewBox: "0 0 24 24",
22175
22617
  stroke: "currentColor"
@@ -22177,7 +22619,7 @@ function SvgNewsletter(props) {
22177
22619
  strokeLinecap: "round",
22178
22620
  strokeLinejoin: "round",
22179
22621
  strokeWidth: 2,
22180
- d: "M19 20H5a2 2 0 01-2-2V6a2 2 0 012-2h10a2 2 0 012 2v1m2 13a2 2 0 01-2-2V7m2 13a2 2 0 002-2V9a2 2 0 00-2-2h-2m-4-3H9M7 16h6M7 8h6v4H7V8z"
22622
+ d: "M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"
22181
22623
  })));
22182
22624
  }
22183
22625
 
@@ -22357,6 +22799,138 @@ function formatStartDate(date) {
22357
22799
  return new Intl.DateTimeFormat("en-CA").format(startDate);
22358
22800
  }
22359
22801
 
22802
+ const InvoicesMenu = props => {
22803
+ const {
22804
+ t
22805
+ } = useTranslation("dashboard");
22806
+ return /*#__PURE__*/React__default['default'].createElement("table", {
22807
+ className: "plc-w-full plc-table-fixed"
22808
+ }, /*#__PURE__*/React__default['default'].createElement("thead", {
22809
+ className: "plc-text-xs plc-font-semibold plc-tracking-wider plc-text-gray-400 plc-uppercase "
22810
+ }, /*#__PURE__*/React__default['default'].createElement("tr", null, /*#__PURE__*/React__default['default'].createElement("th", {
22811
+ className: "plc-w-4/12 "
22812
+ }, t("labels.details")), /*#__PURE__*/React__default['default'].createElement("th", {
22813
+ className: "plc-w-4/12 "
22814
+ }, t("labels.status.title")), /*#__PURE__*/React__default['default'].createElement("th", {
22815
+ className: "plc-w-3/12 "
22816
+ }, t("labels.actions")))), /*#__PURE__*/React__default['default'].createElement("tbody", null, /*#__PURE__*/React__default['default'].createElement("tr", {
22817
+ className: "plc-h-4"
22818
+ }), /*#__PURE__*/React__default['default'].createElement(InvoicesItems, props)));
22819
+ };
22820
+
22821
+ const InvoicesItems = () => {
22822
+ var _window$Pelcro$invoic, _window$Pelcro$invoic2;
22823
+
22824
+ const {
22825
+ t
22826
+ } = useTranslation("dashboard");
22827
+ const {
22828
+ setInvoice,
22829
+ switchView
22830
+ } = usePelcro();
22831
+ const invoices = (_window$Pelcro$invoic = (_window$Pelcro$invoic2 = window.Pelcro.invoice.list()) === null || _window$Pelcro$invoic2 === void 0 ? void 0 : _window$Pelcro$invoic2.filter(invoice => invoice.total > 0)) !== null && _window$Pelcro$invoic !== void 0 ? _window$Pelcro$invoic : [];
22832
+
22833
+ const showInvoiceDetails = event => {
22834
+ if (setInvoice(event.target.dataset.id)) {
22835
+ switchView("invoice-details");
22836
+ }
22837
+ };
22838
+
22839
+ if (invoices.length === 0) return null;
22840
+ return invoices.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime()).map(invoice => {
22841
+ const invoiceStatus = getInvoiceStatus(invoice);
22842
+ const formattedCreationDate = new Intl.DateTimeFormat("en-CA").format(new Date(invoice.created_at));
22843
+ return /*#__PURE__*/React__default['default'].createElement("tr", {
22844
+ key: invoice.id,
22845
+ className: `plc-w-full plc-align-middle plc-cursor-pointer accordion-header hover:plc-bg-gray-50`
22846
+ }, /*#__PURE__*/React__default['default'].createElement("td", {
22847
+ className: "plc-truncate"
22848
+ }, /*#__PURE__*/React__default['default'].createElement("span", {
22849
+ className: "plc-font-semibold plc-text-gray-500"
22850
+ }, `#${invoice.id}`), /*#__PURE__*/React__default['default'].createElement("br", null), /*#__PURE__*/React__default['default'].createElement("span", {
22851
+ className: "plc-text-sm plc-text-gray-500"
22852
+ }, getFormattedPriceByLocal(invoice.total, invoice.currency, getPageOrDefaultLanguage())), /*#__PURE__*/React__default['default'].createElement("br", null), /*#__PURE__*/React__default['default'].createElement("span", {
22853
+ className: "plc-text-sm plc-text-gray-500"
22854
+ }, formattedCreationDate)), /*#__PURE__*/React__default['default'].createElement("td", {
22855
+ className: "plc-py-2"
22856
+ }, /*#__PURE__*/React__default['default'].createElement("span", {
22857
+ className: `plc-inline-flex plc-p-1 plc-text-xs plc-font-semibold ${invoiceStatus.bgColor} plc-uppercase ${invoiceStatus.textColor} plc-rounded-lg`
22858
+ }, invoiceStatus.icon, invoiceStatus.title)), /*#__PURE__*/React__default['default'].createElement("td", null, /*#__PURE__*/React__default['default'].createElement(Button, {
22859
+ variant: "ghost",
22860
+ className: "plc-text-blue-400 focus:plc-ring-blue-400 pelcro-dashboard-view-invoice-button",
22861
+ icon: /*#__PURE__*/React__default['default'].createElement(SvgDocument, {
22862
+ className: "plc-w-4 plc-h-4"
22863
+ }),
22864
+ onClick: showInvoiceDetails,
22865
+ "data-id": invoice.id
22866
+ }, t("labels.view"))));
22867
+ });
22868
+ };
22869
+
22870
+ function getInvoiceStatus(invoice) {
22871
+ const translations = i18next.t("dashboard:labels", {
22872
+ returnObjects: true
22873
+ });
22874
+
22875
+ switch (invoice.status) {
22876
+ case "paid":
22877
+ return {
22878
+ textColor: "plc-text-green-700",
22879
+ bgColor: "plc-bg-green-100",
22880
+ icon: /*#__PURE__*/React__default['default'].createElement(SvgCheckMark, null),
22881
+ title: translations.paid
22882
+ };
22883
+
22884
+ case "past_due":
22885
+ return {
22886
+ textColor: "plc-text-orange-700",
22887
+ bgColor: "plc-bg-orange-100",
22888
+ icon: /*#__PURE__*/React__default['default'].createElement(SvgExclamation, null),
22889
+ title: translations.pastDue
22890
+ };
22891
+
22892
+ case "open":
22893
+ return {
22894
+ textColor: "plc-text-yellow-700",
22895
+ bgColor: "plc-bg-yellow-100",
22896
+ icon: /*#__PURE__*/React__default['default'].createElement(SvgExclamation, null),
22897
+ title: translations.open
22898
+ };
22899
+
22900
+ case "draft":
22901
+ return {
22902
+ textColor: "plc-text-blue-700",
22903
+ bgColor: "plc-bg-blue-100",
22904
+ icon: /*#__PURE__*/React__default['default'].createElement(SvgEdit, null),
22905
+ title: translations.draft
22906
+ };
22907
+
22908
+ case "scheduled":
22909
+ return {
22910
+ textColor: "plc-text-blue-700",
22911
+ bgColor: "plc-bg-blue-100",
22912
+ icon: /*#__PURE__*/React__default['default'].createElement(SvgCalendar, null),
22913
+ title: translations.scheduled
22914
+ };
22915
+
22916
+ case "uncollectible":
22917
+ return {
22918
+ textColor: "plc-text-red-700",
22919
+ bgColor: "plc-bg-red-100",
22920
+ icon: /*#__PURE__*/React__default['default'].createElement(SvgXIconSolid, null),
22921
+ title: translations.uncollectible
22922
+ };
22923
+
22924
+ case "void":
22925
+ return {
22926
+ textColor: "plc-text-gray-700",
22927
+ bgColor: "plc-bg-gray-100",
22928
+ icon: /*#__PURE__*/React__default['default'].createElement(SvgXIconSolid, null),
22929
+ title: translations.void
22930
+ };
22931
+ }
22932
+ }
22933
+
22360
22934
  const SUB_MENUS = {
22361
22935
  PROFILE: "profile",
22362
22936
  SUBSCRIPTIONS: "subscriptions",
@@ -22910,6 +23484,12 @@ class Dashboard extends React.Component {
22910
23484
  icon: /*#__PURE__*/React__default['default'].createElement(SvgShopping, null),
22911
23485
  title: this.locale("labels.orders.label"),
22912
23486
  content: /*#__PURE__*/React__default['default'].createElement(OrdersMenu, null)
23487
+ }), /*#__PURE__*/React__default['default'].createElement(Accordion.item, {
23488
+ show: hasInvoices(),
23489
+ name: SUB_MENUS.INVOICES,
23490
+ icon: /*#__PURE__*/React__default['default'].createElement(SvgDocument, null),
23491
+ title: this.locale("labels.invoices"),
23492
+ content: /*#__PURE__*/React__default['default'].createElement(InvoicesMenu, null)
22913
23493
  }), /*#__PURE__*/React__default['default'].createElement(Accordion.item, {
22914
23494
  name: SUB_MENUS.SAVED_ITEMS,
22915
23495
  icon: /*#__PURE__*/React__default['default'].createElement(SvgBookmark, null),
@@ -22925,6 +23505,13 @@ class Dashboard extends React.Component {
22925
23505
 
22926
23506
  }
22927
23507
 
23508
+ function hasInvoices() {
23509
+ var _window$Pelcro$invoic, _window$Pelcro$invoic2;
23510
+
23511
+ const invoices = (_window$Pelcro$invoic = (_window$Pelcro$invoic2 = window.Pelcro.invoice.list()) === null || _window$Pelcro$invoic2 === void 0 ? void 0 : _window$Pelcro$invoic2.filter(invoice => invoice.total > 0)) !== null && _window$Pelcro$invoic !== void 0 ? _window$Pelcro$invoic : [];
23512
+ return invoices.length > 0;
23513
+ }
23514
+
22928
23515
  function hasDonationSubs() {
22929
23516
  var _window$Pelcro$subscr, _window$Pelcro$subscr2, _window$Pelcro$subscr3, _window$Pelcro$user$r4, _window$Pelcro$user$r5;
22930
23517
 
@@ -25098,6 +25685,8 @@ const InvoiceDetailsView = props => {
25098
25685
  invoice
25099
25686
  } = usePelcro();
25100
25687
  const showPayButton = canPayInvoice(invoice);
25688
+ const showDownloadButton = Boolean(invoice === null || invoice === void 0 ? void 0 : invoice.invoice_pdf);
25689
+ const hasPlanDetails = Boolean(invoice.plan);
25101
25690
  const creationDate = new Date(invoice === null || invoice === void 0 ? void 0 : invoice.created_at);
25102
25691
  const formattedCreationDate = new Intl.DateTimeFormat("en-CA").format(creationDate);
25103
25692
  return /*#__PURE__*/React__default['default'].createElement("div", {
@@ -25115,7 +25704,7 @@ const InvoiceDetailsView = props => {
25115
25704
  className: "plc-font-bold pelcro-invoice-summary-title"
25116
25705
  }, t("labels.summary")), invoice && /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement("p", {
25117
25706
  className: "plc-mr-2 pelcro-invoice-creation-date"
25118
- }, `${t("labels.creationDate")} ${formattedCreationDate}`), /*#__PURE__*/React__default['default'].createElement("div", {
25707
+ }, `${t("labels.creationDate")} ${formattedCreationDate}`), hasPlanDetails && /*#__PURE__*/React__default['default'].createElement("div", {
25119
25708
  className: "plc-flex plc-items-center plc-pt-2 plc-mt-2 plc-border-t plc-border-gray-400 plc-min-h-12 plc-justify-between pelcro-invoice-plan-wrapper"
25120
25709
  }, /*#__PURE__*/React__default['default'].createElement("div", {
25121
25710
  className: "plc-break-words pelcro-invoice-plan-name"
@@ -25141,7 +25730,7 @@ const InvoiceDetailsView = props => {
25141
25730
  className: "plc-font-semibold pelcro-invoice-total"
25142
25731
  }, getFormattedPriceByLocal(invoice.amount_remaining, invoice.currency, getPageOrDefaultLanguage())))))), /*#__PURE__*/React__default['default'].createElement("div", {
25143
25732
  className: "plc-flex plc-items-center plc-justify-center plc-mt-4"
25144
- }, /*#__PURE__*/React__default['default'].createElement(InvoiceDetailsDownloadButton, {
25733
+ }, showDownloadButton && /*#__PURE__*/React__default['default'].createElement(InvoiceDetailsDownloadButton, {
25145
25734
  url: invoice === null || invoice === void 0 ? void 0 : invoice.invoice_pdf,
25146
25735
  className: "plc-w-full plc-text-center"
25147
25736
  }), showPayButton && /*#__PURE__*/React__default['default'].createElement(InvoiceDetailsPayButton, {