@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.esm.js CHANGED
@@ -4654,17 +4654,17 @@ var invoiceDetails_en = {
4654
4654
  buttons: buttons$1
4655
4655
  };
4656
4656
 
4657
- var title = "Invoice details";
4657
+ var title = "Détails de la facture";
4658
4658
  var labels = {
4659
- summary: "Summary",
4659
+ summary: "Résumé",
4660
4660
  total: "Total",
4661
- amountPaid: "Amount paid",
4662
- amountDue: "Amount due",
4663
- creationDate: "Created on:"
4661
+ amountPaid: "Montant payé",
4662
+ amountDue: "Montant ",
4663
+ creationDate: "Créé le:"
4664
4664
  };
4665
4665
  var buttons = {
4666
- download: "Download",
4667
- pay: "Pay now"
4666
+ download: "Télécharger",
4667
+ pay: "Payer"
4668
4668
  };
4669
4669
  var invoiceDetails_fr = {
4670
4670
  title: title,
@@ -7064,8 +7064,8 @@ const saveToMetadataButton = new SaveToMetadataButtonClass();
7064
7064
 
7065
7065
  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}}
7066
7066
 
7067
- function _extends$y() {
7068
- _extends$y = Object.assign || function (target) {
7067
+ function _extends$z() {
7068
+ _extends$z = Object.assign || function (target) {
7069
7069
  for (var i = 1; i < arguments.length; i++) {
7070
7070
  var source = arguments[i];
7071
7071
 
@@ -7079,7 +7079,7 @@ function _extends$y() {
7079
7079
  return target;
7080
7080
  };
7081
7081
 
7082
- return _extends$y.apply(this, arguments);
7082
+ return _extends$z.apply(this, arguments);
7083
7083
  }
7084
7084
 
7085
7085
  function _taggedTemplateLiteralLoose(strings, raw) {
@@ -7169,7 +7169,7 @@ var clearFromRemoveQueue = function clearFromRemoveQueue(toastId) {
7169
7169
  var reducer = function reducer(state, action) {
7170
7170
  switch (action.type) {
7171
7171
  case ActionType.ADD_TOAST:
7172
- return _extends$y({}, state, {
7172
+ return _extends$z({}, state, {
7173
7173
  toasts: [action.toast].concat(state.toasts).slice(0, TOAST_LIMIT)
7174
7174
  });
7175
7175
 
@@ -7179,9 +7179,9 @@ var reducer = function reducer(state, action) {
7179
7179
  clearFromRemoveQueue(action.toast.id);
7180
7180
  }
7181
7181
 
7182
- return _extends$y({}, state, {
7182
+ return _extends$z({}, state, {
7183
7183
  toasts: state.toasts.map(function (t) {
7184
- return t.id === action.toast.id ? _extends$y({}, t, action.toast) : t;
7184
+ return t.id === action.toast.id ? _extends$z({}, t, action.toast) : t;
7185
7185
  })
7186
7186
  });
7187
7187
 
@@ -7208,9 +7208,9 @@ var reducer = function reducer(state, action) {
7208
7208
  });
7209
7209
  }
7210
7210
 
7211
- return _extends$y({}, state, {
7211
+ return _extends$z({}, state, {
7212
7212
  toasts: state.toasts.map(function (t) {
7213
- return t.id === toastId || toastId === undefined ? _extends$y({}, t, {
7213
+ return t.id === toastId || toastId === undefined ? _extends$z({}, t, {
7214
7214
  visible: false
7215
7215
  }) : t;
7216
7216
  })
@@ -7218,28 +7218,28 @@ var reducer = function reducer(state, action) {
7218
7218
 
7219
7219
  case ActionType.REMOVE_TOAST:
7220
7220
  if (action.toastId === undefined) {
7221
- return _extends$y({}, state, {
7221
+ return _extends$z({}, state, {
7222
7222
  toasts: []
7223
7223
  });
7224
7224
  }
7225
7225
 
7226
- return _extends$y({}, state, {
7226
+ return _extends$z({}, state, {
7227
7227
  toasts: state.toasts.filter(function (t) {
7228
7228
  return t.id !== action.toastId;
7229
7229
  })
7230
7230
  });
7231
7231
 
7232
7232
  case ActionType.START_PAUSE:
7233
- return _extends$y({}, state, {
7233
+ return _extends$z({}, state, {
7234
7234
  pausedAt: action.time
7235
7235
  });
7236
7236
 
7237
7237
  case ActionType.END_PAUSE:
7238
7238
  var diff = action.time - (state.pausedAt || 0);
7239
- return _extends$y({}, state, {
7239
+ return _extends$z({}, state, {
7240
7240
  pausedAt: undefined,
7241
7241
  toasts: state.toasts.map(function (t) {
7242
- return _extends$y({}, t, {
7242
+ return _extends$z({}, t, {
7243
7243
  pauseDuration: t.pauseDuration + diff
7244
7244
  });
7245
7245
  })
@@ -7286,12 +7286,12 @@ var useStore = function useStore(toastOptions) {
7286
7286
  var mergedToasts = state.toasts.map(function (t) {
7287
7287
  var _toastOptions$t$type, _toastOptions, _toastOptions$t$type2;
7288
7288
 
7289
- return _extends$y({}, toastOptions, toastOptions[t.type], t, {
7289
+ return _extends$z({}, toastOptions, toastOptions[t.type], t, {
7290
7290
  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],
7291
- style: _extends$y({}, toastOptions.style, (_toastOptions$t$type2 = toastOptions[t.type]) == null ? void 0 : _toastOptions$t$type2.style, t.style)
7291
+ style: _extends$z({}, toastOptions.style, (_toastOptions$t$type2 = toastOptions[t.type]) == null ? void 0 : _toastOptions$t$type2.style, t.style)
7292
7292
  });
7293
7293
  });
7294
- return _extends$y({}, state, {
7294
+ return _extends$z({}, state, {
7295
7295
  toasts: mergedToasts
7296
7296
  });
7297
7297
  };
@@ -7301,7 +7301,7 @@ var createToast = function createToast(message, type, opts) {
7301
7301
  type = 'blank';
7302
7302
  }
7303
7303
 
7304
- return _extends$y({
7304
+ return _extends$z({
7305
7305
  createdAt: Date.now(),
7306
7306
  visible: true,
7307
7307
  type: type,
@@ -7351,14 +7351,14 @@ toast.remove = function (toastId) {
7351
7351
  };
7352
7352
 
7353
7353
  toast.promise = function (promise, msgs, opts) {
7354
- var id = toast.loading(msgs.loading, _extends$y({}, opts, opts == null ? void 0 : opts.loading));
7354
+ var id = toast.loading(msgs.loading, _extends$z({}, opts, opts == null ? void 0 : opts.loading));
7355
7355
  promise.then(function (p) {
7356
- toast.success(resolveValue(msgs.success, p), _extends$y({
7356
+ toast.success(resolveValue(msgs.success, p), _extends$z({
7357
7357
  id: id
7358
7358
  }, opts, opts == null ? void 0 : opts.success));
7359
7359
  return p;
7360
7360
  })["catch"](function (e) {
7361
- toast.error(resolveValue(msgs.error, e), _extends$y({
7361
+ toast.error(resolveValue(msgs.error, e), _extends$z({
7362
7362
  id: id
7363
7363
  }, opts, opts == null ? void 0 : opts.error));
7364
7364
  });
@@ -7697,7 +7697,7 @@ var ToastBar = /*#__PURE__*/memo(function (_ref2) {
7697
7697
  var message = createElement(Message, Object.assign({}, toast.ariaProps), resolveValue(toast.message, toast));
7698
7698
  return createElement(ToastBarBase, {
7699
7699
  className: toast.className,
7700
- style: _extends$y({}, animationStyle, style, toast.style)
7700
+ style: _extends$z({}, animationStyle, style, toast.style)
7701
7701
  }, typeof children === 'function' ? children({
7702
7702
  icon: icon,
7703
7703
  message: message
@@ -7727,7 +7727,7 @@ var getPositionStyle = function getPositionStyle(position, offset) {
7727
7727
  } : position.includes('right') ? {
7728
7728
  justifyContent: 'flex-end'
7729
7729
  } : {};
7730
- return _extends$y({
7730
+ return _extends$z({
7731
7731
  left: 0,
7732
7732
  right: 0,
7733
7733
  display: 'flex',
@@ -7754,7 +7754,7 @@ var Toaster = function Toaster(_ref) {
7754
7754
  handlers = _useToaster.handlers;
7755
7755
 
7756
7756
  return createElement("div", {
7757
- style: _extends$y({
7757
+ style: _extends$z({
7758
7758
  position: 'fixed',
7759
7759
  zIndex: 9999,
7760
7760
  top: DEFAULT_OFFSET,
@@ -7789,82 +7789,82 @@ var Toaster = function Toaster(_ref) {
7789
7789
  }));
7790
7790
  };
7791
7791
 
7792
- var _path$v;
7792
+ var _path$w;
7793
7793
 
7794
- 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); }
7794
+ 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); }
7795
7795
 
7796
7796
  function SvgCheckSolid(props) {
7797
- return /*#__PURE__*/React.createElement("svg", _extends$x({
7797
+ return /*#__PURE__*/React.createElement("svg", _extends$y({
7798
7798
  xmlns: "http://www.w3.org/2000/svg",
7799
7799
  className: "h-5 w-5",
7800
7800
  viewBox: "0 0 20 20",
7801
7801
  fill: "currentColor"
7802
- }, props), _path$v || (_path$v = /*#__PURE__*/React.createElement("path", {
7802
+ }, props), _path$w || (_path$w = /*#__PURE__*/React.createElement("path", {
7803
7803
  fillRule: "evenodd",
7804
7804
  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",
7805
7805
  clipRule: "evenodd"
7806
7806
  })));
7807
7807
  }
7808
7808
 
7809
- var _path$u;
7809
+ var _path$v;
7810
7810
 
7811
- 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); }
7811
+ 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); }
7812
7812
 
7813
7813
  function SvgXIcon(props) {
7814
- return /*#__PURE__*/React.createElement("svg", _extends$w({
7814
+ return /*#__PURE__*/React.createElement("svg", _extends$x({
7815
7815
  xmlns: "http://www.w3.org/2000/svg",
7816
7816
  viewBox: "0 0 20 20",
7817
7817
  fill: "currentColor"
7818
- }, props), _path$u || (_path$u = /*#__PURE__*/React.createElement("path", {
7818
+ }, props), _path$v || (_path$v = /*#__PURE__*/React.createElement("path", {
7819
7819
  fill: "evenodd",
7820
7820
  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",
7821
7821
  clipRule: "evenodd"
7822
7822
  })));
7823
7823
  }
7824
7824
 
7825
- var _path$t;
7825
+ var _path$u;
7826
7826
 
7827
- 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); }
7827
+ 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); }
7828
7828
 
7829
7829
  function SvgXIconSolid(props) {
7830
- return /*#__PURE__*/React.createElement("svg", _extends$v({
7830
+ return /*#__PURE__*/React.createElement("svg", _extends$w({
7831
7831
  className: "plc-w-4 plc-h-4",
7832
7832
  fill: "currentColor",
7833
7833
  xmlns: "http://www.w3.org/2000/svg",
7834
7834
  viewBox: "0 0 100 100"
7835
- }, props), _path$t || (_path$t = /*#__PURE__*/React.createElement("path", {
7835
+ }, props), _path$u || (_path$u = /*#__PURE__*/React.createElement("path", {
7836
7836
  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"
7837
7837
  })));
7838
7838
  }
7839
7839
 
7840
- var _path$s;
7840
+ var _path$t;
7841
7841
 
7842
- 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); }
7842
+ 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); }
7843
7843
 
7844
7844
  function SvgExclamation(props) {
7845
- return /*#__PURE__*/React.createElement("svg", _extends$u({
7845
+ return /*#__PURE__*/React.createElement("svg", _extends$v({
7846
7846
  className: "plc-w-4 plc-h-4 plc-mr-1",
7847
7847
  xmlns: "http://www.w3.org/2000/svg",
7848
7848
  viewBox: "0 0 20 20",
7849
7849
  fill: "currentColor"
7850
- }, props), _path$s || (_path$s = /*#__PURE__*/React.createElement("path", {
7850
+ }, props), _path$t || (_path$t = /*#__PURE__*/React.createElement("path", {
7851
7851
  fillRule: "evenodd",
7852
7852
  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",
7853
7853
  clipRule: "evenodd"
7854
7854
  })));
7855
7855
  }
7856
7856
 
7857
- var _path$r, _path2$4;
7857
+ var _path$s, _path2$4;
7858
7858
 
7859
- 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); }
7859
+ 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); }
7860
7860
 
7861
7861
  function SvgSpinner(props) {
7862
- return /*#__PURE__*/React.createElement("svg", _extends$t({
7862
+ return /*#__PURE__*/React.createElement("svg", _extends$u({
7863
7863
  className: "plc-animate-spin",
7864
7864
  viewBox: "0 0 24 24",
7865
7865
  fill: "currentColor",
7866
7866
  xmlns: "http://www.w3.org/2000/svg"
7867
- }, props), _path$r || (_path$r = /*#__PURE__*/React.createElement("path", {
7867
+ }, props), _path$s || (_path$s = /*#__PURE__*/React.createElement("path", {
7868
7868
  opacity: 0.2,
7869
7869
  fill: "evenodd",
7870
7870
  clipRule: "evenodd",
@@ -8619,6 +8619,10 @@ const getErrorMessages = error => {
8619
8619
  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;
8620
8620
  }
8621
8621
 
8622
+ if (error !== null && error !== void 0 && error.message) {
8623
+ return error.message;
8624
+ }
8625
+
8622
8626
  const errorMessages = []; // enumerable error (ex: validation errors)
8623
8627
 
8624
8628
  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]) => {
@@ -8657,7 +8661,7 @@ const debounce = (func, waitTime) => {
8657
8661
  function getSiteCardProcessor() {
8658
8662
  var _window$Pelcro$site$r;
8659
8663
 
8660
- if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_pay_page_id) {
8664
+ if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_gateway_settings) {
8661
8665
  return "vantiv";
8662
8666
  }
8663
8667
 
@@ -8753,7 +8757,7 @@ const loadPaymentSDKs = () => {
8753
8757
  } // Load Vantiv SDKs
8754
8758
 
8755
8759
 
8756
- const supportsVantiv = Boolean(window.Pelcro.site.read().vantiv_pay_page_id);
8760
+ const supportsVantiv = Boolean(window.Pelcro.site.read().vantiv_gateway_settings);
8757
8761
 
8758
8762
  if (supportsVantiv) {
8759
8763
  if (!window.jQuery) {
@@ -8761,7 +8765,10 @@ const loadPaymentSDKs = () => {
8761
8765
  }
8762
8766
 
8763
8767
  if (!window.EprotectIframeClient) {
8764
- window.Pelcro.helpers.loadSDK("https://request.eprotect.vantivprelive.com/eProtect/js/eProtect-iframe-client.min.js", "vantiv-eprotect-sdk");
8768
+ const PRELIVE_URL = "https://request.eprotect.vantivprelive.com/eProtect/js/eProtect-iframe-client.min.js";
8769
+ const PRODUCTION_URL = "https://request.eprotect.vantivcnp.com/eProtect/js/eProtect-iframe-client4.min.js";
8770
+ const scriptUrlToUse = window.Pelcro.site.read().vantiv_gateway_settings.environment === "production" ? PRODUCTION_URL : PRELIVE_URL;
8771
+ window.Pelcro.helpers.loadSDK(scriptUrlToUse, "vantiv-eprotect-sdk");
8765
8772
  }
8766
8773
  }
8767
8774
  };
@@ -8922,8 +8929,7 @@ const initViewFromURL = () => {
8922
8929
  }
8923
8930
 
8924
8931
  if (view === "invoice-details") {
8925
- // FIXME: commented out to remove from the release
8926
- return false; // return showInvoiceDetailsFromUrl();
8932
+ return showInvoiceDetailsFromUrl();
8927
8933
  }
8928
8934
 
8929
8935
  switchView(view);
@@ -9102,6 +9108,43 @@ const verifyEmailTokenFromUrl = () => {
9102
9108
  });
9103
9109
  };
9104
9110
 
9111
+ const showInvoiceDetailsFromUrl = () => {
9112
+ const {
9113
+ isAuthenticated,
9114
+ setInvoice,
9115
+ whenSiteReady,
9116
+ switchView
9117
+ } = usePelcro.getStore();
9118
+ whenSiteReady(() => {
9119
+ if (!isAuthenticated()) {
9120
+ return switchView("login");
9121
+ }
9122
+
9123
+ const invoiceId = window.Pelcro.helpers.getURLParameter("id");
9124
+ const wasSetSuccessfully = setInvoice(invoiceId);
9125
+
9126
+ if (!wasSetSuccessfully) {
9127
+ const errorMessage = i18next.t("messages:invalidInvoice", {
9128
+ returnObjects: true
9129
+ });
9130
+ return notify.error(errorMessage);
9131
+ }
9132
+
9133
+ const {
9134
+ invoice
9135
+ } = usePelcro.getStore();
9136
+
9137
+ if (invoice.total === 0) {
9138
+ const errorMessage = i18next.t("messages:zeroTotalInvoice", {
9139
+ returnObjects: true
9140
+ });
9141
+ return notify.error(errorMessage);
9142
+ }
9143
+
9144
+ return switchView("invoice-details");
9145
+ });
9146
+ };
9147
+
9105
9148
  const defaultOptions = {
9106
9149
  loadPaymentSDKs: true,
9107
9150
  loadAuth0SDK: true,
@@ -9871,16 +9914,16 @@ const LoginPassword = props => /*#__PURE__*/React__default.createElement(Passwor
9871
9914
  store: store$h
9872
9915
  }, props));
9873
9916
 
9874
- var _path$q;
9917
+ var _path$r;
9875
9918
 
9876
- 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); }
9919
+ 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); }
9877
9920
 
9878
9921
  function SvgCheck(props) {
9879
- return /*#__PURE__*/React.createElement("svg", _extends$s({
9922
+ return /*#__PURE__*/React.createElement("svg", _extends$t({
9880
9923
  xmlns: "http://www.w3.org/2000/svg",
9881
9924
  fill: "currentColor",
9882
9925
  viewBox: "0 0 20 20"
9883
- }, props), _path$q || (_path$q = /*#__PURE__*/React.createElement("path", {
9926
+ }, props), _path$r || (_path$r = /*#__PURE__*/React.createElement("path", {
9884
9927
  fillRule: "evenodd",
9885
9928
  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",
9886
9929
  clipRule: "evenodd"
@@ -10199,15 +10242,15 @@ function hasSecurityTokenEnabled$1() {
10199
10242
  return hasSecuritySdkLoaded;
10200
10243
  }
10201
10244
 
10202
- var _path$p;
10245
+ var _path$q;
10203
10246
 
10204
- 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); }
10247
+ 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); }
10205
10248
 
10206
10249
  function SvgFacebookLogo(props) {
10207
- return /*#__PURE__*/React.createElement("svg", _extends$r({
10250
+ return /*#__PURE__*/React.createElement("svg", _extends$s({
10208
10251
  xmlns: "http://www.w3.org/2000/svg",
10209
10252
  viewBox: "88.428 12.828 107.543 207.085"
10210
- }, props), _path$p || (_path$p = /*#__PURE__*/React.createElement("path", {
10253
+ }, props), _path$q || (_path$q = /*#__PURE__*/React.createElement("path", {
10211
10254
  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",
10212
10255
  fill: "#3c5a9a"
10213
10256
  })));
@@ -10280,15 +10323,15 @@ var googleLogin = createCommonjsModule(function (module, exports) {
10280
10323
  unwrapExports(googleLogin);
10281
10324
  var googleLogin_1 = googleLogin.GoogleLogin;
10282
10325
 
10283
- var _path$o, _path2$3, _path3$1, _path4;
10326
+ var _path$p, _path2$3, _path3$1, _path4;
10284
10327
 
10285
- 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); }
10328
+ 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); }
10286
10329
 
10287
10330
  function SvgGoogleLogo(props) {
10288
- return /*#__PURE__*/React.createElement("svg", _extends$q({
10331
+ return /*#__PURE__*/React.createElement("svg", _extends$r({
10289
10332
  viewBox: "0 0 24 24",
10290
10333
  xmlns: "http://www.w3.org/2000/svg"
10291
- }, props), _path$o || (_path$o = /*#__PURE__*/React.createElement("path", {
10334
+ }, props), _path$p || (_path$p = /*#__PURE__*/React.createElement("path", {
10292
10335
  fill: "#4285F4",
10293
10336
  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"
10294
10337
  })), _path2$3 || (_path2$3 = /*#__PURE__*/React.createElement("path", {
@@ -10365,15 +10408,15 @@ const GoogleLoginButton = ({
10365
10408
  }) : null;
10366
10409
  };
10367
10410
 
10368
- var _path$n;
10411
+ var _path$o;
10369
10412
 
10370
- 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); }
10413
+ 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); }
10371
10414
 
10372
10415
  function SvgAuth0Logo(props) {
10373
- return /*#__PURE__*/React.createElement("svg", _extends$p({
10416
+ return /*#__PURE__*/React.createElement("svg", _extends$q({
10374
10417
  viewBox: "0 0 256 285",
10375
10418
  xmlns: "http://www.w3.org/2000/svg"
10376
- }, props), _path$n || (_path$n = /*#__PURE__*/React.createElement("path", {
10419
+ }, props), _path$o || (_path$o = /*#__PURE__*/React.createElement("path", {
10377
10420
  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"
10378
10421
  })));
10379
10422
  }
@@ -10549,15 +10592,15 @@ function LoginView(props) {
10549
10592
  }, /*#__PURE__*/React__default.createElement(GoogleLoginButton, null), /*#__PURE__*/React__default.createElement(FacebookLoginButton, null), /*#__PURE__*/React__default.createElement(Auth0LoginButton, null))))));
10550
10593
  }
10551
10594
 
10552
- var _path$m, _path2$2, _path3;
10595
+ var _path$n, _path2$2, _path3;
10553
10596
 
10554
- 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); }
10597
+ 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); }
10555
10598
 
10556
10599
  function SvgPelcroAuthorship(props) {
10557
- return /*#__PURE__*/React.createElement("svg", _extends$o({
10600
+ return /*#__PURE__*/React.createElement("svg", _extends$p({
10558
10601
  xmlns: "http://www.w3.org/2000/svg",
10559
10602
  viewBox: "0 -80.652 497.072 179.991"
10560
- }, props), _path$m || (_path$m = /*#__PURE__*/React.createElement("path", {
10603
+ }, props), _path$n || (_path$n = /*#__PURE__*/React.createElement("path", {
10561
10604
  fill: "none",
10562
10605
  stroke: "#4a4a4a",
10563
10606
  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"
@@ -12677,20 +12720,21 @@ var es_12 = es.injectStripe;
12677
12720
  var es_13 = es.StripeProvider;
12678
12721
 
12679
12722
  /**
12680
- * @TODO: All subscription related business logic should end up moving
12723
+ * @TODO: All payment related business logic should end up moving
12681
12724
  * to this service, and out of react components.
12682
12725
  */
12683
12726
 
12684
12727
  /**
12685
- * Enum for subscription types
12728
+ * Enum for payment types
12686
12729
  * @readonly
12687
12730
  * @enum {string}
12688
12731
  */
12689
- const SUBSCRIPTION_TYPES = {
12732
+ const PAYMENT_TYPES = {
12690
12733
  CREATE_SUBSCRIPTION: "CREATE_SUBSCRIPTION",
12691
12734
  CREATE_GIFTED_SUBSCRIPTION: "CREATE_GIFTED_SUBSCRIPTION",
12692
12735
  RENEW_SUBSCRIPTION: "RENEW_SUBSCRIPTION",
12693
12736
  RENEW_GIFTED_SUBSCRIPTION: "RENEW_GIFTED_SUBSCRIPTION",
12737
+ PURCHASE_ECOMMERCE_ORDER: "PURCHASE_ECOMMERCE_ORDER",
12694
12738
  PAY_INVOICE: "PAY_INVOICE"
12695
12739
  };
12696
12740
 
@@ -12698,9 +12742,8 @@ var _isPaymentGatewayInvalid = /*#__PURE__*/new WeakMap();
12698
12742
 
12699
12743
  var _generateUserError = /*#__PURE__*/new WeakMap();
12700
12744
 
12701
- class Subscription {
12745
+ class Payment {
12702
12746
  /**
12703
- * Subscription service constructor
12704
12747
  * @param {(StripeGateway|PaypalGateway|VantivGateway)} paymentGateway
12705
12748
  */
12706
12749
  constructor(paymentGateway) {
@@ -12712,7 +12755,7 @@ class Subscription {
12712
12755
 
12713
12756
  if (!options.type) {
12714
12757
  callback(_classPrivateFieldGet(this, _generateUserError).call(this), null);
12715
- return console.error("No subscription type provided");
12758
+ return console.error("No payment type provided");
12716
12759
  } // delegate execution to paymentgateway
12717
12760
 
12718
12761
 
@@ -12730,21 +12773,21 @@ class Subscription {
12730
12773
  writable: true,
12731
12774
  value: () => {
12732
12775
  return {
12733
- error: new Error("An error has occured in the subscription service, please try again later")
12776
+ error: new Error("An error has occured in the payment service, please try again later")
12734
12777
  };
12735
12778
  }
12736
12779
  });
12737
12780
 
12738
12781
  if (_classPrivateFieldGet(this, _isPaymentGatewayInvalid).call(this, paymentGateway)) {
12739
12782
  this.paymentGateway = null;
12740
- console.error("Incompatible subscription gateway");
12783
+ console.error("Incompatible payment gateway");
12741
12784
  } else {
12742
12785
  this.paymentGateway = paymentGateway;
12743
12786
  }
12744
12787
  }
12745
12788
  /**
12746
- * @typedef subscriptionOptions
12747
- * @property {SUBSCRIPTION_TYPES} type
12789
+ * @typedef paymentOptions
12790
+ * @property {PAYMENT_TYPES} type
12748
12791
  * @property {string} token
12749
12792
  * @property {object} plan
12750
12793
  * @property {object} [product]
@@ -12755,6 +12798,7 @@ class Subscription {
12755
12798
  * @property {string} addressId
12756
12799
  * @property {number} invoiceId
12757
12800
  * @property {boolean} isExistingSource
12801
+ * @property {Array} items
12758
12802
  */
12759
12803
 
12760
12804
  /**
@@ -12765,8 +12809,8 @@ class Subscription {
12765
12809
  */
12766
12810
 
12767
12811
  /**
12768
- * Subscription execution method
12769
- * @param {subscriptionOptions} options subscription options
12812
+ * Payment execution method
12813
+ * @param {paymentOptions} options payment options
12770
12814
  * @param {executeCallback} callback
12771
12815
  * @return {void}
12772
12816
  */
@@ -12779,7 +12823,7 @@ const PAYMENT_GATEWAYS_ENUM = {
12779
12823
  vantiv: "vantiv"
12780
12824
  };
12781
12825
  /**
12782
- * Subscription Strategies
12826
+ * Payment Strategies
12783
12827
  */
12784
12828
 
12785
12829
  /**
@@ -12796,6 +12840,8 @@ var _renewSubscription = /*#__PURE__*/new WeakMap();
12796
12840
 
12797
12841
  var _renewGiftedSubscription = /*#__PURE__*/new WeakMap();
12798
12842
 
12843
+ var _purchaseEcommerceOrder = /*#__PURE__*/new WeakMap();
12844
+
12799
12845
  var _payInvoice = /*#__PURE__*/new WeakMap();
12800
12846
 
12801
12847
  class StripeGateway {
@@ -12806,7 +12852,7 @@ class StripeGateway {
12806
12852
  });
12807
12853
 
12808
12854
  _defineProperty$3(this, "execute", (options, callback) => {
12809
- const types = SUBSCRIPTION_TYPES;
12855
+ const types = PAYMENT_TYPES;
12810
12856
 
12811
12857
  switch (options.type) {
12812
12858
  case types.CREATE_SUBSCRIPTION:
@@ -12821,11 +12867,14 @@ class StripeGateway {
12821
12867
  case types.RENEW_GIFTED_SUBSCRIPTION:
12822
12868
  return _classPrivateFieldGet(this, _renewGiftedSubscription).call(this, options, callback);
12823
12869
 
12870
+ case types.PURCHASE_ECOMMERCE_ORDER:
12871
+ return _classPrivateFieldGet(this, _purchaseEcommerceOrder).call(this, options, callback);
12872
+
12824
12873
  case types.PAY_INVOICE:
12825
12874
  return _classPrivateFieldGet(this, _payInvoice).call(this, options, callback);
12826
12875
 
12827
12876
  default:
12828
- console.error("Unsupported subscriptiion method: Stripe Gateway");
12877
+ console.error("Unsupported payment method: Stripe Gateway");
12829
12878
  }
12830
12879
  });
12831
12880
 
@@ -12847,6 +12896,7 @@ class StripeGateway {
12847
12896
  auth_token: window.Pelcro.user.read().auth_token,
12848
12897
  plan_id: plan.id,
12849
12898
  coupon_code: couponCode,
12899
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
12850
12900
  address_id: product.address_required ? addressId : null
12851
12901
  }, (err, res) => {
12852
12902
  callback(err, res);
@@ -12873,6 +12923,7 @@ class StripeGateway {
12873
12923
  auth_token: window.Pelcro.user.read().auth_token,
12874
12924
  plan_id: plan.id,
12875
12925
  coupon_code: couponCode,
12926
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
12876
12927
  gift_recipient_email: giftRecipient.email,
12877
12928
  gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
12878
12929
  gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
@@ -12900,6 +12951,7 @@ class StripeGateway {
12900
12951
  stripe_token: token,
12901
12952
  auth_token: window.Pelcro.user.read().auth_token,
12902
12953
  plan_id: plan.id,
12954
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
12903
12955
  coupon_code: couponCode,
12904
12956
  subscription_id: subscriptionIdToRenew,
12905
12957
  address_id: product.address_required ? addressId : null
@@ -12933,6 +12985,36 @@ class StripeGateway {
12933
12985
  }
12934
12986
  });
12935
12987
 
12988
+ _purchaseEcommerceOrder.set(this, {
12989
+ writable: true,
12990
+ value: (options, callback) => {
12991
+ const {
12992
+ token,
12993
+ items,
12994
+ couponCode,
12995
+ addressId,
12996
+ isExistingSource
12997
+ } = options;
12998
+ const params = isExistingSource ? {
12999
+ source_id: token
13000
+ } : {
13001
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway),
13002
+ gateway_token: token
13003
+ };
13004
+ window.Pelcro.ecommerce.order.create({
13005
+ items,
13006
+ coupon_code: couponCode,
13007
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13008
+ ...params,
13009
+ ...(addressId && {
13010
+ address_id: addressId
13011
+ })
13012
+ }, (err, res) => {
13013
+ callback(err, res);
13014
+ });
13015
+ }
13016
+ });
13017
+
12936
13018
  _payInvoice.set(this, {
12937
13019
  writable: true,
12938
13020
  value: (options, callback) => {
@@ -12976,7 +13058,7 @@ class PaypalGateway {
12976
13058
  });
12977
13059
 
12978
13060
  _defineProperty$3(this, "execute", (options, callback) => {
12979
- const types = SUBSCRIPTION_TYPES;
13061
+ const types = PAYMENT_TYPES;
12980
13062
 
12981
13063
  switch (options.type) {
12982
13064
  case types.CREATE_SUBSCRIPTION:
@@ -13010,6 +13092,7 @@ class PaypalGateway {
13010
13092
  payment_gateway: _classPrivateFieldGet(this, _paymentGateway2),
13011
13093
  auth_token: window.Pelcro.user.read().auth_token,
13012
13094
  plan_id: plan.id,
13095
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13013
13096
  coupon_code: couponCode,
13014
13097
  address_id: product.address_required ? addressId : null
13015
13098
  }, (err, res) => {
@@ -13037,6 +13120,7 @@ class PaypalGateway {
13037
13120
  auth_token: window.Pelcro.user.read().auth_token,
13038
13121
  plan_id: plan.id,
13039
13122
  coupon_code: couponCode,
13123
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13040
13124
  gift_recipient_email: giftRecipient.email,
13041
13125
  gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
13042
13126
  gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
@@ -13073,6 +13157,16 @@ var _paymentGateway3 = /*#__PURE__*/new WeakMap();
13073
13157
 
13074
13158
  var _createSubscription3 = /*#__PURE__*/new WeakMap();
13075
13159
 
13160
+ var _renewSubscription2 = /*#__PURE__*/new WeakMap();
13161
+
13162
+ var _createGiftedSubscription3 = /*#__PURE__*/new WeakMap();
13163
+
13164
+ var _renewGiftedSubscription2 = /*#__PURE__*/new WeakMap();
13165
+
13166
+ var _purchaseEcommerceOrder2 = /*#__PURE__*/new WeakMap();
13167
+
13168
+ var _payInvoice3 = /*#__PURE__*/new WeakMap();
13169
+
13076
13170
  class VantivGateway {
13077
13171
  constructor() {
13078
13172
  _paymentGateway3.set(this, {
@@ -13081,14 +13175,29 @@ class VantivGateway {
13081
13175
  });
13082
13176
 
13083
13177
  _defineProperty$3(this, "execute", (options, callback) => {
13084
- const types = SUBSCRIPTION_TYPES;
13178
+ const types = PAYMENT_TYPES;
13085
13179
 
13086
13180
  switch (options.type) {
13087
13181
  case types.CREATE_SUBSCRIPTION:
13088
13182
  return _classPrivateFieldGet(this, _createSubscription3).call(this, options, callback);
13089
13183
 
13184
+ case types.RENEW_SUBSCRIPTION:
13185
+ return _classPrivateFieldGet(this, _renewSubscription2).call(this, options, callback);
13186
+
13187
+ case types.CREATE_GIFTED_SUBSCRIPTION:
13188
+ return _classPrivateFieldGet(this, _createGiftedSubscription3).call(this, options, callback);
13189
+
13190
+ case types.RENEW_GIFTED_SUBSCRIPTION:
13191
+ return _classPrivateFieldGet(this, _renewGiftedSubscription2).call(this, options, callback);
13192
+
13193
+ case types.PURCHASE_ECOMMERCE_ORDER:
13194
+ return _classPrivateFieldGet(this, _purchaseEcommerceOrder2).call(this, options, callback);
13195
+
13196
+ case types.PAY_INVOICE:
13197
+ return _classPrivateFieldGet(this, _payInvoice3).call(this, options, callback);
13198
+
13090
13199
  default:
13091
- console.error("Unsupported subscriptiion method: vantiv Gateway");
13200
+ console.error("Unsupported payment method: vantiv Gateway");
13092
13201
  }
13093
13202
  });
13094
13203
 
@@ -13101,21 +13210,180 @@ class VantivGateway {
13101
13210
  couponCode,
13102
13211
  product,
13103
13212
  quantity = 1,
13104
- addressId
13213
+ addressId,
13214
+ isExistingSource
13105
13215
  } = options;
13216
+ const params = isExistingSource ? {
13217
+ source_id: token
13218
+ } : {
13219
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13220
+ gateway_token: token
13221
+ };
13106
13222
  window.Pelcro.subscription.create({
13107
13223
  quantity,
13108
- gateway_token: token,
13224
+ auth_token: window.Pelcro.user.read().auth_token,
13225
+ plan_id: plan.id,
13226
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13227
+ coupon_code: couponCode,
13228
+ address_id: product.address_required ? addressId : null,
13229
+ ...params
13230
+ }, (err, res) => {
13231
+ callback(err, res);
13232
+ });
13233
+ }
13234
+ });
13235
+
13236
+ _renewSubscription2.set(this, {
13237
+ writable: true,
13238
+ value: (options, callback) => {
13239
+ const {
13240
+ subscriptionIdToRenew,
13241
+ token,
13242
+ plan,
13243
+ couponCode,
13244
+ product,
13245
+ addressId,
13246
+ isExistingSource
13247
+ } = options;
13248
+ const params = isExistingSource ? {
13249
+ source_id: token
13250
+ } : {
13109
13251
  payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13252
+ gateway_token: token
13253
+ };
13254
+ window.Pelcro.subscription.renew({
13110
13255
  auth_token: window.Pelcro.user.read().auth_token,
13111
13256
  plan_id: plan.id,
13112
13257
  coupon_code: couponCode,
13113
- address_id: product.address_required ? addressId : null
13258
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13259
+ subscription_id: subscriptionIdToRenew,
13260
+ address_id: product.address_required ? addressId : null,
13261
+ ...params
13262
+ }, (err, res) => {
13263
+ callback(err, res);
13264
+ });
13265
+ }
13266
+ });
13267
+
13268
+ _createGiftedSubscription3.set(this, {
13269
+ writable: true,
13270
+ value: (options, callback) => {
13271
+ const {
13272
+ token,
13273
+ plan,
13274
+ couponCode,
13275
+ product,
13276
+ giftRecipient,
13277
+ quantity = 1,
13278
+ addressId,
13279
+ isExistingSource
13280
+ } = options;
13281
+ const params = isExistingSource ? {
13282
+ source_id: token
13283
+ } : {
13284
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13285
+ gateway_token: token
13286
+ };
13287
+ window.Pelcro.subscription.create({
13288
+ quantity,
13289
+ auth_token: window.Pelcro.user.read().auth_token,
13290
+ plan_id: plan.id,
13291
+ coupon_code: couponCode,
13292
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13293
+ gift_recipient_email: giftRecipient.email,
13294
+ gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
13295
+ gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
13296
+ gift_start_date: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.startDate,
13297
+ gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
13298
+ address_id: product.address_required ? addressId : null,
13299
+ ...params
13114
13300
  }, (err, res) => {
13115
13301
  callback(err, res);
13116
13302
  });
13117
13303
  }
13118
13304
  });
13305
+
13306
+ _renewGiftedSubscription2.set(this, {
13307
+ writable: true,
13308
+ value: (options, callback) => {
13309
+ const {
13310
+ subscriptionIdToRenew,
13311
+ token,
13312
+ product,
13313
+ plan,
13314
+ couponCode,
13315
+ addressId,
13316
+ isExistingSource
13317
+ } = options;
13318
+ const params = isExistingSource ? {
13319
+ source_id: token
13320
+ } : {
13321
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13322
+ gateway_token: token
13323
+ };
13324
+ window.Pelcro.subscription.renewGift({
13325
+ auth_token: window.Pelcro.user.read().auth_token,
13326
+ plan_id: plan.id,
13327
+ coupon_code: couponCode,
13328
+ subscription_id: subscriptionIdToRenew,
13329
+ address_id: product.address_required ? addressId : null,
13330
+ ...params
13331
+ }, (err, res) => {
13332
+ callback(err, res);
13333
+ });
13334
+ }
13335
+ });
13336
+
13337
+ _purchaseEcommerceOrder2.set(this, {
13338
+ writable: true,
13339
+ value: (options, callback) => {
13340
+ const {
13341
+ token,
13342
+ items,
13343
+ couponCode,
13344
+ addressId,
13345
+ isExistingSource
13346
+ } = options;
13347
+ const params = isExistingSource ? {
13348
+ source_id: token
13349
+ } : {
13350
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13351
+ gateway_token: token
13352
+ };
13353
+ window.Pelcro.ecommerce.order.create({
13354
+ items,
13355
+ coupon_code: couponCode,
13356
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13357
+ ...params,
13358
+ ...(addressId && {
13359
+ address_id: addressId
13360
+ })
13361
+ }, (err, res) => {
13362
+ callback(err, res);
13363
+ });
13364
+ }
13365
+ });
13366
+
13367
+ _payInvoice3.set(this, {
13368
+ writable: true,
13369
+ value: (options, callback) => {
13370
+ const {
13371
+ token,
13372
+ invoiceId
13373
+ } = options;
13374
+ const params = options.isExistingSource ? {
13375
+ source_id: token,
13376
+ invoice_id: invoiceId
13377
+ } : {
13378
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13379
+ gateway_token: token,
13380
+ invoice_id: invoiceId
13381
+ };
13382
+ window.Pelcro.invoice.pay(params, (err, res) => {
13383
+ callback(err, res);
13384
+ });
13385
+ }
13386
+ });
13119
13387
  }
13120
13388
 
13121
13389
  }
@@ -13175,7 +13443,7 @@ const PaymentMethodContainerWithoutStripe = ({
13175
13443
  onFailure = () => {},
13176
13444
  ...props
13177
13445
  }) => {
13178
- var _props$product, _props$plan, _props$subscriptionId, _props$selectedAddres, _props$giftRecipient, _props$isRenewingGift, _props$invoice;
13446
+ var _props$product, _props$plan, _props$subscriptionId, _props$selectedAddres, _props$giftRecipient, _props$isGift, _props$isRenewingGift, _props$invoice;
13179
13447
 
13180
13448
  const {
13181
13449
  t
@@ -13191,6 +13459,7 @@ const PaymentMethodContainerWithoutStripe = ({
13191
13459
  const subscriptionIdToRenew = (_props$subscriptionId = props.subscriptionIdToRenew) !== null && _props$subscriptionId !== void 0 ? _props$subscriptionId : pelcroStore.subscriptionIdToRenew;
13192
13460
  const selectedAddressId = (_props$selectedAddres = props.selectedAddressId) !== null && _props$selectedAddres !== void 0 ? _props$selectedAddres : pelcroStore.selectedAddressId;
13193
13461
  const giftRecipient = (_props$giftRecipient = props.giftRecipient) !== null && _props$giftRecipient !== void 0 ? _props$giftRecipient : pelcroStore.giftRecipient;
13462
+ const isGift = (_props$isGift = props.isGift) !== null && _props$isGift !== void 0 ? _props$isGift : pelcroStore.isGift;
13194
13463
  const isRenewingGift = (_props$isRenewingGift = props.isRenewingGift) !== null && _props$isRenewingGift !== void 0 ? _props$isRenewingGift : pelcroStore.isRenewingGift;
13195
13464
  const invoice = (_props$invoice = props.invoice) !== null && _props$invoice !== void 0 ? _props$invoice : pelcroStore.invoice;
13196
13465
  useEffect(() => {
@@ -13207,60 +13476,185 @@ const PaymentMethodContainerWithoutStripe = ({
13207
13476
  updateTotalAmountWithTax();
13208
13477
  }, []);
13209
13478
 
13210
- function submitVantivPayment() {
13479
+ const submitUsingVantiv = () => {
13480
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
13481
+
13482
+ if (isUsingExistingPaymentMethod) {
13483
+ // no need to create a new source using vantiv
13484
+ return handleVantivPayment(null);
13485
+ }
13486
+
13211
13487
  if (!vantivInstanceRef.current) {
13212
13488
  return console.error("Vantiv sdk script wasn't loaded, you need to load vantiv sdk before rendering the vantiv payment flow");
13213
13489
  }
13214
13490
 
13215
- const orderId = `pelcro-${new Date().getTime()}`; // calls handleVantivPayment
13491
+ const orderId = `pelcro-${new Date().getTime()}`;
13492
+ /*
13493
+ calls handleVantivPayment to either handle a payment or update a source by simply creating a new source
13494
+ */
13216
13495
 
13217
13496
  vantivInstanceRef.current.getPaypageRegistrationId({
13218
13497
  id: orderId,
13219
13498
  orderId: orderId
13220
13499
  });
13221
- }
13500
+ };
13501
+
13502
+ function handleVantivPayment(paymentRequest) {
13503
+ if (paymentRequest) {
13504
+ const SUCCESS_STATUS = "870";
13505
+
13506
+ if (paymentRequest.response !== SUCCESS_STATUS) {
13507
+ return handlePaymentError({
13508
+ error: new Error(paymentRequest.message)
13509
+ });
13510
+ }
13511
+ }
13512
+
13513
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
13514
+
13515
+ if (type === "createPayment") {
13516
+ handleVantivSubscription();
13517
+ } else if (type === "orderCreate") {
13518
+ purchase(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
13519
+ } else if (type === "invoicePayment") {
13520
+ payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
13521
+ } else if (type === "updatePaymentSource") {
13522
+ createNewVantivCard();
13523
+ }
13524
+
13525
+ function createNewVantivCard() {
13526
+ window.Pelcro.source.create({
13527
+ auth_token: window.Pelcro.user.read().auth_token,
13528
+ token: paymentRequest,
13529
+ gateway: "vantiv"
13530
+ }, (err, res) => {
13531
+ dispatch({
13532
+ type: DISABLE_SUBMIT,
13533
+ payload: false
13534
+ });
13535
+ dispatch({
13536
+ type: LOADING,
13537
+ payload: false
13538
+ });
13539
+
13540
+ if (err) {
13541
+ onFailure(err);
13542
+ return dispatch({
13543
+ type: SHOW_ALERT,
13544
+ payload: {
13545
+ type: "error",
13546
+ content: getErrorMessages(err)
13547
+ }
13548
+ });
13549
+ }
13550
+
13551
+ dispatch({
13552
+ type: SHOW_ALERT,
13553
+ payload: {
13554
+ type: "success",
13555
+ content: t("messages.sourceUpdated")
13556
+ }
13557
+ });
13558
+ onSuccess(res);
13559
+ });
13560
+ }
13561
+
13562
+ function handleVantivSubscription() {
13563
+ const payment = new Payment(new VantivGateway());
13564
+ const createSubscription = !isGift && !subscriptionIdToRenew;
13565
+ const renewSubscription = !isGift && subscriptionIdToRenew;
13566
+ const giftSubscriprition = isGift && !subscriptionIdToRenew;
13567
+ const renewGift = isRenewingGift;
13568
+ const {
13569
+ couponCode
13570
+ } = state;
13571
+
13572
+ if (renewGift) {
13573
+ return payment.execute({
13574
+ type: PAYMENT_TYPES.RENEW_GIFTED_SUBSCRIPTION,
13575
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
13576
+ plan,
13577
+ couponCode,
13578
+ product,
13579
+ isExistingSource: isUsingExistingPaymentMethod,
13580
+ subscriptionIdToRenew,
13581
+ addressId: selectedAddressId
13582
+ }, (err, res) => {
13583
+ if (err) {
13584
+ return handlePaymentError(err);
13585
+ }
13586
+
13587
+ onSuccess(res);
13588
+ });
13589
+ } else if (giftSubscriprition) {
13590
+ return payment.execute({
13591
+ type: PAYMENT_TYPES.CREATE_GIFTED_SUBSCRIPTION,
13592
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
13593
+ quantity: plan.quantity,
13594
+ plan,
13595
+ couponCode,
13596
+ product,
13597
+ isExistingSource: isUsingExistingPaymentMethod,
13598
+ giftRecipient,
13599
+ addressId: selectedAddressId
13600
+ }, (err, res) => {
13601
+ if (err) {
13602
+ return handlePaymentError(err);
13603
+ }
13222
13604
 
13223
- function handleVantivPayment(paymentRequest) {
13224
- const SUCCESS_STATUS = "870";
13605
+ onSuccess(res);
13606
+ });
13607
+ } else if (renewSubscription) {
13608
+ return payment.execute({
13609
+ type: PAYMENT_TYPES.RENEW_SUBSCRIPTION,
13610
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
13611
+ quantity: plan.quantity,
13612
+ plan,
13613
+ couponCode,
13614
+ product,
13615
+ isExistingSource: isUsingExistingPaymentMethod,
13616
+ subscriptionIdToRenew,
13617
+ addressId: selectedAddressId
13618
+ }, (err, res) => {
13619
+ if (err) {
13620
+ return handlePaymentError(err);
13621
+ }
13225
13622
 
13226
- if (paymentRequest.response !== SUCCESS_STATUS) {
13227
- return handlePaymentError({
13228
- error: new Error(paymentRequest.message)
13229
- });
13230
- }
13623
+ onSuccess(res);
13624
+ });
13625
+ } else if (createSubscription) {
13626
+ return payment.execute({
13627
+ type: PAYMENT_TYPES.CREATE_SUBSCRIPTION,
13628
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
13629
+ quantity: plan.quantity,
13630
+ plan,
13631
+ couponCode,
13632
+ product,
13633
+ isExistingSource: isUsingExistingPaymentMethod,
13634
+ addressId: selectedAddressId
13635
+ }, (err, res) => {
13636
+ if (err) {
13637
+ return handlePaymentError(err);
13638
+ }
13231
13639
 
13232
- const subscription = new Subscription(new VantivGateway());
13233
- const {
13234
- couponCode
13235
- } = state;
13236
- return subscription.execute({
13237
- type: SUBSCRIPTION_TYPES.CREATE_SUBSCRIPTION,
13238
- token: paymentRequest,
13239
- quantity: plan.quantity,
13240
- plan,
13241
- couponCode,
13242
- product,
13243
- addressId: selectedAddressId
13244
- }, (err, res) => {
13245
- if (err) {
13246
- return handlePaymentError(err);
13640
+ onSuccess(res);
13641
+ });
13247
13642
  }
13248
-
13249
- onSuccess(res);
13250
- });
13643
+ }
13251
13644
  }
13252
13645
 
13253
13646
  const vantivInstanceRef = React__default.useRef(null);
13254
13647
  useEffect(() => {
13255
13648
  const cardProcessor = getSiteCardProcessor();
13256
13649
 
13257
- if (cardProcessor === "vantiv") {
13258
- var _window$Pelcro$site$r;
13650
+ if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
13651
+ var _window$Pelcro$site$r, _window$Pelcro$site$r2;
13259
13652
 
13260
- 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;
13653
+ 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;
13654
+ 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;
13261
13655
  vantivInstanceRef.current = new window.EprotectIframeClient({
13262
13656
  paypageId: payPageId,
13263
- reportGroup: payPageId,
13657
+ reportGroup: reportGroup,
13264
13658
  style: "pelcro",
13265
13659
  height: "245",
13266
13660
  timeout: 50000,
@@ -13277,7 +13671,7 @@ const PaymentMethodContainerWithoutStripe = ({
13277
13671
  }
13278
13672
  });
13279
13673
  }
13280
- }, []);
13674
+ }, [selectedPaymentMethodId]);
13281
13675
 
13282
13676
  const initPaymentRequest = (state, dispatch) => {
13283
13677
  try {
@@ -13349,9 +13743,9 @@ const PaymentMethodContainerWithoutStripe = ({
13349
13743
 
13350
13744
 
13351
13745
  const updateTotalAmountWithTax = () => {
13352
- var _window$Pelcro$site$r2;
13746
+ var _window$Pelcro$site$r3;
13353
13747
 
13354
- 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;
13748
+ 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;
13355
13749
 
13356
13750
  if (taxesEnabled && type === "createPayment") {
13357
13751
  dispatch({
@@ -13508,6 +13902,7 @@ const PaymentMethodContainerWithoutStripe = ({
13508
13902
  window.Pelcro.order.create({
13509
13903
  auth_token: window.Pelcro.user.read().auth_token,
13510
13904
  plan_id: plan.id,
13905
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13511
13906
  coupon_code: couponCode,
13512
13907
  address_id: selectedAddressId
13513
13908
  }, handleCouponResponse);
@@ -13589,6 +13984,7 @@ const PaymentMethodContainerWithoutStripe = ({
13589
13984
  stripe_token: !stripeSource.isExistingSource ? stripeSource.id : undefined,
13590
13985
  auth_token: window.Pelcro.user.read().auth_token,
13591
13986
  plan_id: plan.id,
13987
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13592
13988
  quantity: plan.quantity,
13593
13989
  coupon_code: couponCode,
13594
13990
  gift_recipient_email: giftRecipient ? giftRecipient.email : null,
@@ -13660,6 +14056,7 @@ const PaymentMethodContainerWithoutStripe = ({
13660
14056
  stripe_token: !stripeSource.isExistingSource ? stripeSource.id : undefined,
13661
14057
  auth_token: window.Pelcro.user.read().auth_token,
13662
14058
  plan_id: plan.id,
14059
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13663
14060
  coupon_code: couponCode,
13664
14061
  subscription_id: subscriptionIdToRenew,
13665
14062
  address_id: product.address_required ? selectedAddressId : null
@@ -13701,7 +14098,7 @@ const PaymentMethodContainerWithoutStripe = ({
13701
14098
 
13702
14099
 
13703
14100
  const handlePaypalSubscription = (state, paypalNonce) => {
13704
- const subscription = new Subscription(new PaypalGateway());
14101
+ const payment = new Payment(new PaypalGateway());
13705
14102
  const {
13706
14103
  couponCode
13707
14104
  } = state;
@@ -13710,8 +14107,8 @@ const PaymentMethodContainerWithoutStripe = ({
13710
14107
  */
13711
14108
 
13712
14109
  if (giftRecipient) {
13713
- return subscription.execute({
13714
- type: SUBSCRIPTION_TYPES.CREATE_GIFTED_SUBSCRIPTION,
14110
+ return payment.execute({
14111
+ type: PAYMENT_TYPES.CREATE_GIFTED_SUBSCRIPTION,
13715
14112
  token: paypalNonce,
13716
14113
  quantity: plan.quantity,
13717
14114
  plan,
@@ -13744,8 +14141,8 @@ const PaymentMethodContainerWithoutStripe = ({
13744
14141
  });
13745
14142
  }
13746
14143
 
13747
- return subscription.execute({
13748
- type: SUBSCRIPTION_TYPES.CREATE_SUBSCRIPTION,
14144
+ return payment.execute({
14145
+ type: PAYMENT_TYPES.CREATE_SUBSCRIPTION,
13749
14146
  token: paypalNonce,
13750
14147
  quantity: plan.quantity,
13751
14148
  plan,
@@ -13777,7 +14174,7 @@ const PaymentMethodContainerWithoutStripe = ({
13777
14174
  });
13778
14175
  };
13779
14176
 
13780
- const purchase = (stripeSource, state, dispatch) => {
14177
+ const purchase = (gatewayService, gatewayToken, state, dispatch) => {
13781
14178
  const isQuickPurchase = !Array.isArray(order);
13782
14179
  const mappedOrderItems = isQuickPurchase ? [{
13783
14180
  sku_id: order.id,
@@ -13789,14 +14186,14 @@ const PaymentMethodContainerWithoutStripe = ({
13789
14186
  const {
13790
14187
  couponCode
13791
14188
  } = state;
13792
- window.Pelcro.ecommerce.order.create({
13793
- source_id: stripeSource.isExistingSource ? stripeSource.id : undefined,
13794
- stripe_token: !stripeSource.isExistingSource ? stripeSource.id : undefined,
14189
+ const payment = new Payment(gatewayService);
14190
+ payment.execute({
14191
+ type: PAYMENT_TYPES.PURCHASE_ECOMMERCE_ORDER,
14192
+ token: gatewayToken,
14193
+ isExistingSource: Boolean(selectedPaymentMethodId),
13795
14194
  items: mappedOrderItems,
13796
- coupon_code: couponCode,
13797
- ...(selectedAddressId && {
13798
- address_id: selectedAddressId
13799
- })
14195
+ addressId: selectedAddressId,
14196
+ couponCode
13800
14197
  }, (err, res) => {
13801
14198
  dispatch({
13802
14199
  type: DISABLE_SUBMIT,
@@ -13834,9 +14231,9 @@ const PaymentMethodContainerWithoutStripe = ({
13834
14231
  };
13835
14232
 
13836
14233
  const payInvoice = (gatewayService, gatewayToken, dispatch) => {
13837
- const subscription = new Subscription(gatewayService);
13838
- return subscription.execute({
13839
- type: SUBSCRIPTION_TYPES.PAY_INVOICE,
14234
+ const payment = new Payment(gatewayService);
14235
+ return payment.execute({
14236
+ type: PAYMENT_TYPES.PAY_INVOICE,
13840
14237
  token: gatewayToken,
13841
14238
  isExistingSource: Boolean(selectedPaymentMethodId),
13842
14239
  invoiceId: invoice.id
@@ -13881,7 +14278,9 @@ const PaymentMethodContainerWithoutStripe = ({
13881
14278
 
13882
14279
  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") {
13883
14280
  return handlePaymentError({
13884
- message: t("messages.cardAuthNotSupported")
14281
+ error: {
14282
+ message: t("messages.cardAuthNotSupported")
14283
+ }
13885
14284
  });
13886
14285
  }
13887
14286
 
@@ -13996,13 +14395,13 @@ const PaymentMethodContainerWithoutStripe = ({
13996
14395
 
13997
14396
 
13998
14397
  const resolveTaxCalculation = () => {
13999
- var _window$Pelcro$site$r3;
14398
+ var _window$Pelcro$site$r4;
14000
14399
 
14001
14400
  if (type === "invoicePayment") {
14002
14401
  return new Promise(resolve => resolve());
14003
14402
  }
14004
14403
 
14005
- 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;
14404
+ 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;
14006
14405
  return new Promise((resolve, reject) => {
14007
14406
  // resolve early if taxes isn't enabled
14008
14407
  if (!taxesEnabled) {
@@ -14012,6 +14411,7 @@ const PaymentMethodContainerWithoutStripe = ({
14012
14411
  window.Pelcro.order.create({
14013
14412
  auth_token: window.Pelcro.user.read().auth_token,
14014
14413
  plan_id: plan.id,
14414
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
14015
14415
  coupon_code: state === null || state === void 0 ? void 0 : state.couponCode,
14016
14416
  address_id: selectedAddressId
14017
14417
  }, (error, res) => {
@@ -14074,7 +14474,7 @@ const PaymentMethodContainerWithoutStripe = ({
14074
14474
  if (stripeSource && type === "createPayment") {
14075
14475
  subscribe(stripeSource, state, dispatch);
14076
14476
  } else if (stripeSource && type === "orderCreate") {
14077
- purchase(stripeSource, state, dispatch);
14477
+ purchase(new StripeGateway(), stripeSource.id, state, dispatch);
14078
14478
  } else if (stripeSource && type === "invoicePayment") {
14079
14479
  payInvoice(new StripeGateway(), stripeSource.id, dispatch);
14080
14480
  }
@@ -14125,7 +14525,9 @@ const PaymentMethodContainerWithoutStripe = ({
14125
14525
 
14126
14526
  if ((source === null || source === void 0 ? void 0 : source.status) === "failed") {
14127
14527
  return handlePaymentError({
14128
- message: t("messages.cardAuthFailed")
14528
+ error: {
14529
+ message: t("messages.cardAuthFailed")
14530
+ }
14129
14531
  });
14130
14532
  }
14131
14533
 
@@ -14196,6 +14598,10 @@ const PaymentMethodContainerWithoutStripe = ({
14196
14598
  disableSubmit: true,
14197
14599
  isLoading: true
14198
14600
  }, (state, dispatch) => {
14601
+ if (getSiteCardProcessor() === "vantiv") {
14602
+ return submitUsingVantiv();
14603
+ }
14604
+
14199
14605
  if (selectedPaymentMethodId) {
14200
14606
  // pay with selected method (source) if exists already
14201
14607
  return handlePayment({
@@ -14208,10 +14614,6 @@ const PaymentMethodContainerWithoutStripe = ({
14208
14614
  return updatePaymentSource(state, dispatch);
14209
14615
  }
14210
14616
 
14211
- if (getSiteCardProcessor() === "vantiv") {
14212
- return submitVantivPayment();
14213
- }
14214
-
14215
14617
  submitPayment(state);
14216
14618
  });
14217
14619
 
@@ -14516,17 +14918,17 @@ const SubmitPaymentMethod = ({
14516
14918
  }, t("labels.pay"), " ", priceFormatted && priceFormatted) : t("labels.submit"));
14517
14919
  };
14518
14920
 
14519
- var _path$l;
14921
+ var _path$m;
14520
14922
 
14521
- 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); }
14923
+ 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); }
14522
14924
 
14523
14925
  function SvgArrowLeft(props) {
14524
- return /*#__PURE__*/React.createElement("svg", _extends$n({
14926
+ return /*#__PURE__*/React.createElement("svg", _extends$o({
14525
14927
  xmlns: "http://www.w3.org/2000/svg",
14526
14928
  fill: "none",
14527
14929
  viewBox: "0 0 24 24",
14528
14930
  stroke: "currentColor"
14529
- }, props), _path$l || (_path$l = /*#__PURE__*/React.createElement("path", {
14931
+ }, props), _path$m || (_path$m = /*#__PURE__*/React.createElement("path", {
14530
14932
  strokeLinecap: "round",
14531
14933
  strokeLinejoin: "round",
14532
14934
  strokeWidth: 2,
@@ -14608,17 +15010,17 @@ const CouponCodeField = props => {
14608
15010
  }, props));
14609
15011
  };
14610
15012
 
14611
- var _path$k;
15013
+ var _path$l;
14612
15014
 
14613
- 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); }
15015
+ 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); }
14614
15016
 
14615
15017
  function SvgTicket(props) {
14616
- return /*#__PURE__*/React.createElement("svg", _extends$m({
15018
+ return /*#__PURE__*/React.createElement("svg", _extends$n({
14617
15019
  xmlns: "http://www.w3.org/2000/svg",
14618
15020
  fill: "none",
14619
15021
  viewBox: "0 0 24 24",
14620
15022
  stroke: "currentColor"
14621
- }, props), _path$k || (_path$k = /*#__PURE__*/React.createElement("path", {
15023
+ }, props), _path$l || (_path$l = /*#__PURE__*/React.createElement("path", {
14622
15024
  strokeLinecap: "round",
14623
15025
  strokeLinejoin: "round",
14624
15026
  strokeWidth: 2,
@@ -14907,7 +15309,7 @@ const PaypalSubscribeButton = props => {
14907
15309
  const selectedAddress = getAddressById((_props$selectedAddres = props.selectedAddressId) !== null && _props$selectedAddres !== void 0 ? _props$selectedAddres : selectedAddressId); // initialize paypal client, then render paypal button.
14908
15310
 
14909
15311
  const initializePaypal = async () => {
14910
- var _props$buttonElementI, _props$product$addres, _props$product, _props$plan2;
15312
+ var _props$buttonElementI, _props$product$addres, _props$product;
14911
15313
 
14912
15314
  const paypalCheckoutInstance = new PaypalClient({
14913
15315
  buttonElementID: (_props$buttonElementI = props.buttonElementID) !== null && _props$buttonElementI !== void 0 ? _props$buttonElementI : "pelcro-paypal-button",
@@ -14917,12 +15319,33 @@ const PaypalSubscribeButton = props => {
14917
15319
  displayName: props.merchantDisplayName,
14918
15320
  locale: props.locale,
14919
15321
  billingAgreementDescription: props.billingDescription
14920
- }); // Await building paypal instance
15322
+ });
15323
+
15324
+ const getProduct = () => {
15325
+ if (invoice) {
15326
+ invoice.plan = null;
15327
+
15328
+ if (invoice.plan) {
15329
+ return invoice.plan;
15330
+ } else {
15331
+ // standalone invoices dont have a plan
15332
+ return {
15333
+ currency: invoice.currency,
15334
+ nickname: `invoice #${invoice.id}`
15335
+ };
15336
+ }
15337
+ } else if (props.plan) {
15338
+ return props.plan;
15339
+ } else {
15340
+ return plan;
15341
+ }
15342
+ }; // Await building paypal instance
15343
+
14921
15344
 
14922
15345
  await paypalCheckoutInstance.build(); // Create paypal payment
14923
15346
 
14924
15347
  paypalCheckoutInstance.createPayment({
14925
- product: invoice ? invoice.plan : (_props$plan2 = props.plan) !== null && _props$plan2 !== void 0 ? _props$plan2 : plan,
15348
+ product: getProduct(),
14926
15349
  amount: updatedPrice,
14927
15350
  address: invoice ? null : selectedAddress,
14928
15351
  onButtonClick: () => {
@@ -14978,16 +15401,16 @@ const BankRedirection = () => {
14978
15401
  }));
14979
15402
  };
14980
15403
 
14981
- var _path$j;
15404
+ var _path$k;
14982
15405
 
14983
- 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); }
15406
+ 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); }
14984
15407
 
14985
15408
  function SvgLock(props) {
14986
- return /*#__PURE__*/React.createElement("svg", _extends$l({
15409
+ return /*#__PURE__*/React.createElement("svg", _extends$m({
14987
15410
  xmlns: "http://www.w3.org/2000/svg",
14988
15411
  viewBox: "0 0 20 20",
14989
15412
  fill: "currentColor"
14990
- }, props), _path$j || (_path$j = /*#__PURE__*/React.createElement("path", {
15413
+ }, props), _path$k || (_path$k = /*#__PURE__*/React.createElement("path", {
14991
15414
  fillRule: "evenodd",
14992
15415
  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",
14993
15416
  clipRule: "evenodd"
@@ -15210,12 +15633,12 @@ function SubscriptionRenewModal({
15210
15633
  }
15211
15634
  SubscriptionRenewModal.viewId = "subscription-renew";
15212
15635
 
15213
- var _path$i;
15636
+ var _path$j;
15214
15637
 
15215
- 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); }
15638
+ 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); }
15216
15639
 
15217
15640
  function SvgGift(props) {
15218
- return /*#__PURE__*/React.createElement("svg", _extends$k({
15641
+ return /*#__PURE__*/React.createElement("svg", _extends$l({
15219
15642
  className: "plc-w-6 plc-h-6 plc-mr-2",
15220
15643
  fill: "none",
15221
15644
  stroke: "currentColor",
@@ -15224,7 +15647,7 @@ function SvgGift(props) {
15224
15647
  strokeWidth: 2,
15225
15648
  viewBox: "0 0 24 24",
15226
15649
  xmlns: "http://www.w3.org/2000/svg"
15227
- }, props), _path$i || (_path$i = /*#__PURE__*/React.createElement("path", {
15650
+ }, props), _path$j || (_path$j = /*#__PURE__*/React.createElement("path", {
15228
15651
  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"
15229
15652
  })));
15230
15653
  }
@@ -16233,17 +16656,17 @@ const UserUpdatePhone = props => /*#__PURE__*/React__default.createElement(Phone
16233
16656
 
16234
16657
  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";
16235
16658
 
16236
- var _path$h;
16659
+ var _path$i;
16237
16660
 
16238
- 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); }
16661
+ 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); }
16239
16662
 
16240
16663
  function SvgEdit(props) {
16241
- return /*#__PURE__*/React.createElement("svg", _extends$j({
16664
+ return /*#__PURE__*/React.createElement("svg", _extends$k({
16242
16665
  className: "plc-w-6 plc-h-6",
16243
16666
  xmlns: "http://www.w3.org/2000/svg",
16244
16667
  viewBox: "0 0 20 20",
16245
16668
  fill: "currentColor"
16246
- }, props), _path$h || (_path$h = /*#__PURE__*/React.createElement("path", {
16669
+ }, props), _path$i || (_path$i = /*#__PURE__*/React.createElement("path", {
16247
16670
  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"
16248
16671
  })));
16249
16672
  }
@@ -19353,18 +19776,18 @@ const GiftCreateLastName = props => /*#__PURE__*/React__default.createElement(La
19353
19776
  store: store$6
19354
19777
  }, props));
19355
19778
 
19356
- var _path$g;
19779
+ var _path$h;
19357
19780
 
19358
- 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); }
19781
+ 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); }
19359
19782
 
19360
19783
  function SvgInfoCircle(props) {
19361
- return /*#__PURE__*/React.createElement("svg", _extends$i({
19784
+ return /*#__PURE__*/React.createElement("svg", _extends$j({
19362
19785
  xmlns: "http://www.w3.org/2000/svg",
19363
19786
  className: "plc-w-5 plc-h-5",
19364
19787
  fill: "none",
19365
19788
  viewBox: "0 0 24 24",
19366
19789
  stroke: "currentColor"
19367
- }, props), _path$g || (_path$g = /*#__PURE__*/React.createElement("path", {
19790
+ }, props), _path$h || (_path$h = /*#__PURE__*/React.createElement("path", {
19368
19791
  strokeLinecap: "round",
19369
19792
  strokeLinejoin: "round",
19370
19793
  strokeWidth: 2,
@@ -20376,8 +20799,8 @@ const PaymentMethodSelectModal = ({
20376
20799
  };
20377
20800
  PaymentMethodSelectModal.viewId = "payment-method-select";
20378
20801
 
20379
- function _extends$h() {
20380
- _extends$h = Object.assign || function (target) {
20802
+ function _extends$i() {
20803
+ _extends$i = Object.assign || function (target) {
20381
20804
  for (var i = 1; i < arguments.length; i++) {
20382
20805
  var source = arguments[i];
20383
20806
 
@@ -20391,7 +20814,7 @@ function _extends$h() {
20391
20814
  return target;
20392
20815
  };
20393
20816
 
20394
- return _extends$h.apply(this, arguments);
20817
+ return _extends$i.apply(this, arguments);
20395
20818
  }
20396
20819
 
20397
20820
  function _objectWithoutPropertiesLoose(source, excluded) {
@@ -20575,7 +20998,7 @@ function render(props, propsBag, defaultTag, features, visible) {
20575
20998
  return match(strategy, (_match = {}, _match[RenderStrategy.Unmount] = function () {
20576
20999
  return null;
20577
21000
  }, _match[RenderStrategy.Hidden] = function () {
20578
- return _render(_extends$h({}, _rest, {
21001
+ return _render(_extends$i({}, _rest, {
20579
21002
  hidden: true,
20580
21003
  style: {
20581
21004
  display: 'none'
@@ -21103,7 +21526,7 @@ function TransitionChild(props) {
21103
21526
  var passthroughProps = rest;
21104
21527
  return React__default.createElement(NestingContext.Provider, {
21105
21528
  value: nesting
21106
- }, render(_extends$h({}, passthroughProps, propsWeControl), propsBag, DEFAULT_TRANSITION_CHILD_TAG, TransitionChildRenderFeatures, state === TreeStates.Visible));
21529
+ }, render(_extends$i({}, passthroughProps, propsWeControl), propsBag, DEFAULT_TRANSITION_CHILD_TAG, TransitionChildRenderFeatures, state === TreeStates.Visible));
21107
21530
  }
21108
21531
 
21109
21532
  function Transition(props) {
@@ -21147,7 +21570,7 @@ function Transition(props) {
21147
21570
  value: nestingBag
21148
21571
  }, React__default.createElement(TransitionContext.Provider, {
21149
21572
  value: transitionBag
21150
- }, render(_extends$h({}, sharedProps, {
21573
+ }, render(_extends$i({}, sharedProps, {
21151
21574
  as: Fragment,
21152
21575
  children: React__default.createElement(TransitionChild, Object.assign({}, sharedProps, passthroughProps))
21153
21576
  }), propsBag, Fragment, TransitionChildRenderFeatures, state === TreeStates.Visible)));
@@ -21274,12 +21697,12 @@ var ActionTypes;
21274
21697
  })(ActionTypes || (ActionTypes = {}));
21275
21698
 
21276
21699
  (_reducers = {}, _reducers[ActionTypes.CloseMenu] = function (state) {
21277
- return _extends$h({}, state, {
21700
+ return _extends$i({}, state, {
21278
21701
  activeItemIndex: null,
21279
21702
  menuState: MenuStates.Closed
21280
21703
  });
21281
21704
  }, _reducers[ActionTypes.OpenMenu] = function (state) {
21282
- return _extends$h({}, state, {
21705
+ return _extends$i({}, state, {
21283
21706
  menuState: MenuStates.Open
21284
21707
  });
21285
21708
  }, _reducers[ActionTypes.GoToItem] = function (state, action) {
@@ -21298,7 +21721,7 @@ var ActionTypes;
21298
21721
  }
21299
21722
  });
21300
21723
  if (state.searchQuery === '' && state.activeItemIndex === activeItemIndex) return state;
21301
- return _extends$h({}, state, {
21724
+ return _extends$i({}, state, {
21302
21725
  searchQuery: '',
21303
21726
  activeItemIndex: activeItemIndex
21304
21727
  });
@@ -21309,19 +21732,19 @@ var ActionTypes;
21309
21732
 
21310
21733
  return ((_item$dataRef$current = item.dataRef.current.textValue) == null ? void 0 : _item$dataRef$current.startsWith(searchQuery)) && !item.dataRef.current.disabled;
21311
21734
  });
21312
- if (match === -1 || match === state.activeItemIndex) return _extends$h({}, state, {
21735
+ if (match === -1 || match === state.activeItemIndex) return _extends$i({}, state, {
21313
21736
  searchQuery: searchQuery
21314
21737
  });
21315
- return _extends$h({}, state, {
21738
+ return _extends$i({}, state, {
21316
21739
  searchQuery: searchQuery,
21317
21740
  activeItemIndex: match
21318
21741
  });
21319
21742
  }, _reducers[ActionTypes.ClearSearch] = function (state) {
21320
- return _extends$h({}, state, {
21743
+ return _extends$i({}, state, {
21321
21744
  searchQuery: ''
21322
21745
  });
21323
21746
  }, _reducers[ActionTypes.RegisterItem] = function (state, action) {
21324
- return _extends$h({}, state, {
21747
+ return _extends$i({}, state, {
21325
21748
  items: [].concat(state.items, [{
21326
21749
  id: action.id,
21327
21750
  dataRef: action.dataRef
@@ -21334,7 +21757,7 @@ var ActionTypes;
21334
21757
  return a.id === action.id;
21335
21758
  });
21336
21759
  if (idx !== -1) nextItems.splice(idx, 1);
21337
- return _extends$h({}, state, {
21760
+ return _extends$i({}, state, {
21338
21761
  items: nextItems,
21339
21762
  activeItemIndex: function () {
21340
21763
  if (idx === state.activeItemIndex) return null;
@@ -21373,19 +21796,19 @@ var ActionTypes$1;
21373
21796
  (_reducers$1 = {}, _reducers$1[ActionTypes$1.CloseListbox] = function (state) {
21374
21797
  if (state.disabled) return state;
21375
21798
  if (state.listboxState === ListboxStates.Closed) return state;
21376
- return _extends$h({}, state, {
21799
+ return _extends$i({}, state, {
21377
21800
  activeOptionIndex: null,
21378
21801
  listboxState: ListboxStates.Closed
21379
21802
  });
21380
21803
  }, _reducers$1[ActionTypes$1.OpenListbox] = function (state) {
21381
21804
  if (state.disabled) return state;
21382
21805
  if (state.listboxState === ListboxStates.Open) return state;
21383
- return _extends$h({}, state, {
21806
+ return _extends$i({}, state, {
21384
21807
  listboxState: ListboxStates.Open
21385
21808
  });
21386
21809
  }, _reducers$1[ActionTypes$1.SetDisabled] = function (state, action) {
21387
21810
  if (state.disabled === action.disabled) return state;
21388
- return _extends$h({}, state, {
21811
+ return _extends$i({}, state, {
21389
21812
  disabled: action.disabled
21390
21813
  });
21391
21814
  }, _reducers$1[ActionTypes$1.GoToOption] = function (state, action) {
@@ -21406,7 +21829,7 @@ var ActionTypes$1;
21406
21829
  }
21407
21830
  });
21408
21831
  if (state.searchQuery === '' && state.activeOptionIndex === activeOptionIndex) return state;
21409
- return _extends$h({}, state, {
21832
+ return _extends$i({}, state, {
21410
21833
  searchQuery: '',
21411
21834
  activeOptionIndex: activeOptionIndex
21412
21835
  });
@@ -21419,10 +21842,10 @@ var ActionTypes$1;
21419
21842
 
21420
21843
  return !option.dataRef.current.disabled && ((_option$dataRef$curre = option.dataRef.current.textValue) == null ? void 0 : _option$dataRef$curre.startsWith(searchQuery));
21421
21844
  });
21422
- if (match === -1 || match === state.activeOptionIndex) return _extends$h({}, state, {
21845
+ if (match === -1 || match === state.activeOptionIndex) return _extends$i({}, state, {
21423
21846
  searchQuery: searchQuery
21424
21847
  });
21425
- return _extends$h({}, state, {
21848
+ return _extends$i({}, state, {
21426
21849
  searchQuery: searchQuery,
21427
21850
  activeOptionIndex: match
21428
21851
  });
@@ -21430,11 +21853,11 @@ var ActionTypes$1;
21430
21853
  if (state.disabled) return state;
21431
21854
  if (state.listboxState === ListboxStates.Closed) return state;
21432
21855
  if (state.searchQuery === '') return state;
21433
- return _extends$h({}, state, {
21856
+ return _extends$i({}, state, {
21434
21857
  searchQuery: ''
21435
21858
  });
21436
21859
  }, _reducers$1[ActionTypes$1.RegisterOption] = function (state, action) {
21437
- return _extends$h({}, state, {
21860
+ return _extends$i({}, state, {
21438
21861
  options: [].concat(state.options, [{
21439
21862
  id: action.id,
21440
21863
  dataRef: action.dataRef
@@ -21447,7 +21870,7 @@ var ActionTypes$1;
21447
21870
  return a.id === action.id;
21448
21871
  });
21449
21872
  if (idx !== -1) nextOptions.splice(idx, 1);
21450
- return _extends$h({}, state, {
21873
+ return _extends$i({}, state, {
21451
21874
  options: nextOptions,
21452
21875
  activeOptionIndex: function () {
21453
21876
  if (idx === state.activeOptionIndex) return null;
@@ -21508,18 +21931,18 @@ const getPaymentCardIcon = name => {
21508
21931
  }));
21509
21932
  };
21510
21933
 
21511
- var _path$f;
21934
+ var _path$g;
21512
21935
 
21513
- 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); }
21936
+ 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); }
21514
21937
 
21515
21938
  function SvgChevronRight(props) {
21516
- return /*#__PURE__*/React.createElement("svg", _extends$g({
21939
+ return /*#__PURE__*/React.createElement("svg", _extends$h({
21517
21940
  className: "plc-w-6 plc-h-6",
21518
21941
  xmlns: "http://www.w3.org/2000/svg",
21519
21942
  fill: "none",
21520
21943
  viewBox: "0 0 24 24",
21521
21944
  stroke: "currentColor"
21522
- }, props), _path$f || (_path$f = /*#__PURE__*/React.createElement("path", {
21945
+ }, props), _path$g || (_path$g = /*#__PURE__*/React.createElement("path", {
21523
21946
  strokeLinecap: "round",
21524
21947
  strokeLinejoin: "round",
21525
21948
  strokeWidth: 2,
@@ -21735,18 +22158,18 @@ const SavedItems = ({
21735
22158
  });
21736
22159
  };
21737
22160
 
21738
- var _path$e;
22161
+ var _path$f;
21739
22162
 
21740
- 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); }
22163
+ 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); }
21741
22164
 
21742
22165
  function SvgRefresh(props) {
21743
- return /*#__PURE__*/React.createElement("svg", _extends$f({
22166
+ return /*#__PURE__*/React.createElement("svg", _extends$g({
21744
22167
  className: "plc-w-4 plc-h-4 plc-mr-1",
21745
22168
  xmlns: "http://www.w3.org/2000/svg",
21746
22169
  fill: "none",
21747
22170
  viewBox: "0 0 24 24",
21748
22171
  stroke: "currentColor"
21749
- }, props), _path$e || (_path$e = /*#__PURE__*/React.createElement("path", {
22172
+ }, props), _path$f || (_path$f = /*#__PURE__*/React.createElement("path", {
21750
22173
  strokeLinecap: "round",
21751
22174
  strokeLinejoin: "round",
21752
22175
  strokeWidth: 2,
@@ -21754,35 +22177,35 @@ function SvgRefresh(props) {
21754
22177
  })));
21755
22178
  }
21756
22179
 
21757
- var _path$d;
22180
+ var _path$e;
21758
22181
 
21759
- 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); }
22182
+ 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); }
21760
22183
 
21761
22184
  function SvgCalendar(props) {
21762
- return /*#__PURE__*/React.createElement("svg", _extends$e({
22185
+ return /*#__PURE__*/React.createElement("svg", _extends$f({
21763
22186
  xmlns: "http://www.w3.org/2000/svg",
21764
22187
  className: "plc-h-4 plc-w-4 plc-mr-1",
21765
22188
  viewBox: "0 0 20 20",
21766
22189
  fill: "currentColor"
21767
- }, props), _path$d || (_path$d = /*#__PURE__*/React.createElement("path", {
22190
+ }, props), _path$e || (_path$e = /*#__PURE__*/React.createElement("path", {
21768
22191
  fillRule: "evenodd",
21769
22192
  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",
21770
22193
  clipRule: "evenodd"
21771
22194
  })));
21772
22195
  }
21773
22196
 
21774
- var _path$c;
22197
+ var _path$d;
21775
22198
 
21776
- 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); }
22199
+ 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); }
21777
22200
 
21778
22201
  function SvgPlus(props) {
21779
- return /*#__PURE__*/React.createElement("svg", _extends$d({
22202
+ return /*#__PURE__*/React.createElement("svg", _extends$e({
21780
22203
  className: "plc-w-5 plc-h-5",
21781
22204
  xmlns: "http://www.w3.org/2000/svg",
21782
22205
  fill: "none",
21783
22206
  viewBox: "0 0 24 24",
21784
22207
  stroke: "currentColor"
21785
- }, props), _path$c || (_path$c = /*#__PURE__*/React.createElement("path", {
22208
+ }, props), _path$d || (_path$d = /*#__PURE__*/React.createElement("path", {
21786
22209
  strokeLinecap: "round",
21787
22210
  strokeLinejoin: "round",
21788
22211
  strokeWidth: 2,
@@ -21790,17 +22213,17 @@ function SvgPlus(props) {
21790
22213
  })));
21791
22214
  }
21792
22215
 
21793
- var _path$b;
22216
+ var _path$c;
21794
22217
 
21795
- 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); }
22218
+ 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); }
21796
22219
 
21797
22220
  function SvgCheckMark(props) {
21798
- return /*#__PURE__*/React.createElement("svg", _extends$c({
22221
+ return /*#__PURE__*/React.createElement("svg", _extends$d({
21799
22222
  className: "plc-w-4 plc-h-4 plc-mr-1",
21800
22223
  xmlns: "http://www.w3.org/2000/svg",
21801
22224
  viewBox: "0 0 20 20",
21802
22225
  fill: "currentColor"
21803
- }, props), _path$b || (_path$b = /*#__PURE__*/React.createElement("path", {
22226
+ }, props), _path$c || (_path$c = /*#__PURE__*/React.createElement("path", {
21804
22227
  fillRule: "evenodd",
21805
22228
  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",
21806
22229
  clipRule: "evenodd"
@@ -22095,13 +22518,31 @@ Accordion.item = function AccordionItem({
22095
22518
  }, content)) : null;
22096
22519
  };
22097
22520
 
22521
+ var _path$b;
22522
+
22523
+ 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); }
22524
+
22525
+ function SvgExit(props) {
22526
+ return /*#__PURE__*/React.createElement("svg", _extends$c({
22527
+ className: "plc-w-6 plc-h-6",
22528
+ xmlns: "http://www.w3.org/2000/svg",
22529
+ fill: "none",
22530
+ viewBox: "0 0 24 24",
22531
+ stroke: "currentColor"
22532
+ }, props), _path$b || (_path$b = /*#__PURE__*/React.createElement("path", {
22533
+ strokeLinecap: "round",
22534
+ strokeLinejoin: "round",
22535
+ strokeWidth: 2,
22536
+ 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"
22537
+ })));
22538
+ }
22539
+
22098
22540
  var _path$a;
22099
22541
 
22100
22542
  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); }
22101
22543
 
22102
- function SvgExit(props) {
22544
+ function SvgUser(props) {
22103
22545
  return /*#__PURE__*/React.createElement("svg", _extends$b({
22104
- className: "plc-w-6 plc-h-6",
22105
22546
  xmlns: "http://www.w3.org/2000/svg",
22106
22547
  fill: "none",
22107
22548
  viewBox: "0 0 24 24",
@@ -22110,7 +22551,7 @@ function SvgExit(props) {
22110
22551
  strokeLinecap: "round",
22111
22552
  strokeLinejoin: "round",
22112
22553
  strokeWidth: 2,
22113
- 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"
22554
+ 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"
22114
22555
  })));
22115
22556
  }
22116
22557
 
@@ -22118,9 +22559,10 @@ var _path$9;
22118
22559
 
22119
22560
  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); }
22120
22561
 
22121
- function SvgUser(props) {
22562
+ function SvgNewsletter(props) {
22122
22563
  return /*#__PURE__*/React.createElement("svg", _extends$a({
22123
22564
  xmlns: "http://www.w3.org/2000/svg",
22565
+ className: "plc-h-5 plc-w-5",
22124
22566
  fill: "none",
22125
22567
  viewBox: "0 0 24 24",
22126
22568
  stroke: "currentColor"
@@ -22128,7 +22570,7 @@ function SvgUser(props) {
22128
22570
  strokeLinecap: "round",
22129
22571
  strokeLinejoin: "round",
22130
22572
  strokeWidth: 2,
22131
- 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"
22573
+ 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"
22132
22574
  })));
22133
22575
  }
22134
22576
 
@@ -22136,10 +22578,10 @@ var _path$8;
22136
22578
 
22137
22579
  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); }
22138
22580
 
22139
- function SvgNewsletter(props) {
22581
+ function SvgDocument(props) {
22140
22582
  return /*#__PURE__*/React.createElement("svg", _extends$9({
22141
22583
  xmlns: "http://www.w3.org/2000/svg",
22142
- className: "plc-h-5 plc-w-5",
22584
+ className: "plc-h-6 plc-w-6 plc-mr-2",
22143
22585
  fill: "none",
22144
22586
  viewBox: "0 0 24 24",
22145
22587
  stroke: "currentColor"
@@ -22147,7 +22589,7 @@ function SvgNewsletter(props) {
22147
22589
  strokeLinecap: "round",
22148
22590
  strokeLinejoin: "round",
22149
22591
  strokeWidth: 2,
22150
- 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"
22592
+ 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"
22151
22593
  })));
22152
22594
  }
22153
22595
 
@@ -22327,6 +22769,138 @@ function formatStartDate(date) {
22327
22769
  return new Intl.DateTimeFormat("en-CA").format(startDate);
22328
22770
  }
22329
22771
 
22772
+ const InvoicesMenu = props => {
22773
+ const {
22774
+ t
22775
+ } = useTranslation("dashboard");
22776
+ return /*#__PURE__*/React__default.createElement("table", {
22777
+ className: "plc-w-full plc-table-fixed"
22778
+ }, /*#__PURE__*/React__default.createElement("thead", {
22779
+ className: "plc-text-xs plc-font-semibold plc-tracking-wider plc-text-gray-400 plc-uppercase "
22780
+ }, /*#__PURE__*/React__default.createElement("tr", null, /*#__PURE__*/React__default.createElement("th", {
22781
+ className: "plc-w-4/12 "
22782
+ }, t("labels.details")), /*#__PURE__*/React__default.createElement("th", {
22783
+ className: "plc-w-4/12 "
22784
+ }, t("labels.status.title")), /*#__PURE__*/React__default.createElement("th", {
22785
+ className: "plc-w-3/12 "
22786
+ }, t("labels.actions")))), /*#__PURE__*/React__default.createElement("tbody", null, /*#__PURE__*/React__default.createElement("tr", {
22787
+ className: "plc-h-4"
22788
+ }), /*#__PURE__*/React__default.createElement(InvoicesItems, props)));
22789
+ };
22790
+
22791
+ const InvoicesItems = () => {
22792
+ var _window$Pelcro$invoic, _window$Pelcro$invoic2;
22793
+
22794
+ const {
22795
+ t
22796
+ } = useTranslation("dashboard");
22797
+ const {
22798
+ setInvoice,
22799
+ switchView
22800
+ } = usePelcro();
22801
+ 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 : [];
22802
+
22803
+ const showInvoiceDetails = event => {
22804
+ if (setInvoice(event.target.dataset.id)) {
22805
+ switchView("invoice-details");
22806
+ }
22807
+ };
22808
+
22809
+ if (invoices.length === 0) return null;
22810
+ return invoices.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime()).map(invoice => {
22811
+ const invoiceStatus = getInvoiceStatus(invoice);
22812
+ const formattedCreationDate = new Intl.DateTimeFormat("en-CA").format(new Date(invoice.created_at));
22813
+ return /*#__PURE__*/React__default.createElement("tr", {
22814
+ key: invoice.id,
22815
+ className: `plc-w-full plc-align-middle plc-cursor-pointer accordion-header hover:plc-bg-gray-50`
22816
+ }, /*#__PURE__*/React__default.createElement("td", {
22817
+ className: "plc-truncate"
22818
+ }, /*#__PURE__*/React__default.createElement("span", {
22819
+ className: "plc-font-semibold plc-text-gray-500"
22820
+ }, `#${invoice.id}`), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("span", {
22821
+ className: "plc-text-sm plc-text-gray-500"
22822
+ }, getFormattedPriceByLocal(invoice.total, invoice.currency, getPageOrDefaultLanguage())), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement("span", {
22823
+ className: "plc-text-sm plc-text-gray-500"
22824
+ }, formattedCreationDate)), /*#__PURE__*/React__default.createElement("td", {
22825
+ className: "plc-py-2"
22826
+ }, /*#__PURE__*/React__default.createElement("span", {
22827
+ className: `plc-inline-flex plc-p-1 plc-text-xs plc-font-semibold ${invoiceStatus.bgColor} plc-uppercase ${invoiceStatus.textColor} plc-rounded-lg`
22828
+ }, invoiceStatus.icon, invoiceStatus.title)), /*#__PURE__*/React__default.createElement("td", null, /*#__PURE__*/React__default.createElement(Button, {
22829
+ variant: "ghost",
22830
+ className: "plc-text-blue-400 focus:plc-ring-blue-400 pelcro-dashboard-view-invoice-button",
22831
+ icon: /*#__PURE__*/React__default.createElement(SvgDocument, {
22832
+ className: "plc-w-4 plc-h-4"
22833
+ }),
22834
+ onClick: showInvoiceDetails,
22835
+ "data-id": invoice.id
22836
+ }, t("labels.view"))));
22837
+ });
22838
+ };
22839
+
22840
+ function getInvoiceStatus(invoice) {
22841
+ const translations = i18next.t("dashboard:labels", {
22842
+ returnObjects: true
22843
+ });
22844
+
22845
+ switch (invoice.status) {
22846
+ case "paid":
22847
+ return {
22848
+ textColor: "plc-text-green-700",
22849
+ bgColor: "plc-bg-green-100",
22850
+ icon: /*#__PURE__*/React__default.createElement(SvgCheckMark, null),
22851
+ title: translations.paid
22852
+ };
22853
+
22854
+ case "past_due":
22855
+ return {
22856
+ textColor: "plc-text-orange-700",
22857
+ bgColor: "plc-bg-orange-100",
22858
+ icon: /*#__PURE__*/React__default.createElement(SvgExclamation, null),
22859
+ title: translations.pastDue
22860
+ };
22861
+
22862
+ case "open":
22863
+ return {
22864
+ textColor: "plc-text-yellow-700",
22865
+ bgColor: "plc-bg-yellow-100",
22866
+ icon: /*#__PURE__*/React__default.createElement(SvgExclamation, null),
22867
+ title: translations.open
22868
+ };
22869
+
22870
+ case "draft":
22871
+ return {
22872
+ textColor: "plc-text-blue-700",
22873
+ bgColor: "plc-bg-blue-100",
22874
+ icon: /*#__PURE__*/React__default.createElement(SvgEdit, null),
22875
+ title: translations.draft
22876
+ };
22877
+
22878
+ case "scheduled":
22879
+ return {
22880
+ textColor: "plc-text-blue-700",
22881
+ bgColor: "plc-bg-blue-100",
22882
+ icon: /*#__PURE__*/React__default.createElement(SvgCalendar, null),
22883
+ title: translations.scheduled
22884
+ };
22885
+
22886
+ case "uncollectible":
22887
+ return {
22888
+ textColor: "plc-text-red-700",
22889
+ bgColor: "plc-bg-red-100",
22890
+ icon: /*#__PURE__*/React__default.createElement(SvgXIconSolid, null),
22891
+ title: translations.uncollectible
22892
+ };
22893
+
22894
+ case "void":
22895
+ return {
22896
+ textColor: "plc-text-gray-700",
22897
+ bgColor: "plc-bg-gray-100",
22898
+ icon: /*#__PURE__*/React__default.createElement(SvgXIconSolid, null),
22899
+ title: translations.void
22900
+ };
22901
+ }
22902
+ }
22903
+
22330
22904
  const SUB_MENUS = {
22331
22905
  PROFILE: "profile",
22332
22906
  SUBSCRIPTIONS: "subscriptions",
@@ -22880,6 +23454,12 @@ class Dashboard extends Component {
22880
23454
  icon: /*#__PURE__*/React__default.createElement(SvgShopping, null),
22881
23455
  title: this.locale("labels.orders.label"),
22882
23456
  content: /*#__PURE__*/React__default.createElement(OrdersMenu, null)
23457
+ }), /*#__PURE__*/React__default.createElement(Accordion.item, {
23458
+ show: hasInvoices(),
23459
+ name: SUB_MENUS.INVOICES,
23460
+ icon: /*#__PURE__*/React__default.createElement(SvgDocument, null),
23461
+ title: this.locale("labels.invoices"),
23462
+ content: /*#__PURE__*/React__default.createElement(InvoicesMenu, null)
22883
23463
  }), /*#__PURE__*/React__default.createElement(Accordion.item, {
22884
23464
  name: SUB_MENUS.SAVED_ITEMS,
22885
23465
  icon: /*#__PURE__*/React__default.createElement(SvgBookmark, null),
@@ -22895,6 +23475,13 @@ class Dashboard extends Component {
22895
23475
 
22896
23476
  }
22897
23477
 
23478
+ function hasInvoices() {
23479
+ var _window$Pelcro$invoic, _window$Pelcro$invoic2;
23480
+
23481
+ 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 : [];
23482
+ return invoices.length > 0;
23483
+ }
23484
+
22898
23485
  function hasDonationSubs() {
22899
23486
  var _window$Pelcro$subscr, _window$Pelcro$subscr2, _window$Pelcro$subscr3, _window$Pelcro$user$r4, _window$Pelcro$user$r5;
22900
23487
 
@@ -25068,6 +25655,8 @@ const InvoiceDetailsView = props => {
25068
25655
  invoice
25069
25656
  } = usePelcro();
25070
25657
  const showPayButton = canPayInvoice(invoice);
25658
+ const showDownloadButton = Boolean(invoice === null || invoice === void 0 ? void 0 : invoice.invoice_pdf);
25659
+ const hasPlanDetails = Boolean(invoice.plan);
25071
25660
  const creationDate = new Date(invoice === null || invoice === void 0 ? void 0 : invoice.created_at);
25072
25661
  const formattedCreationDate = new Intl.DateTimeFormat("en-CA").format(creationDate);
25073
25662
  return /*#__PURE__*/React__default.createElement("div", {
@@ -25085,7 +25674,7 @@ const InvoiceDetailsView = props => {
25085
25674
  className: "plc-font-bold pelcro-invoice-summary-title"
25086
25675
  }, t("labels.summary")), invoice && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("p", {
25087
25676
  className: "plc-mr-2 pelcro-invoice-creation-date"
25088
- }, `${t("labels.creationDate")} ${formattedCreationDate}`), /*#__PURE__*/React__default.createElement("div", {
25677
+ }, `${t("labels.creationDate")} ${formattedCreationDate}`), hasPlanDetails && /*#__PURE__*/React__default.createElement("div", {
25089
25678
  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"
25090
25679
  }, /*#__PURE__*/React__default.createElement("div", {
25091
25680
  className: "plc-break-words pelcro-invoice-plan-name"
@@ -25111,7 +25700,7 @@ const InvoiceDetailsView = props => {
25111
25700
  className: "plc-font-semibold pelcro-invoice-total"
25112
25701
  }, getFormattedPriceByLocal(invoice.amount_remaining, invoice.currency, getPageOrDefaultLanguage())))))), /*#__PURE__*/React__default.createElement("div", {
25113
25702
  className: "plc-flex plc-items-center plc-justify-center plc-mt-4"
25114
- }, /*#__PURE__*/React__default.createElement(InvoiceDetailsDownloadButton, {
25703
+ }, showDownloadButton && /*#__PURE__*/React__default.createElement(InvoiceDetailsDownloadButton, {
25115
25704
  url: invoice === null || invoice === void 0 ? void 0 : invoice.invoice_pdf,
25116
25705
  className: "plc-w-full plc-text-center"
25117
25706
  }), showPayButton && /*#__PURE__*/React__default.createElement(InvoiceDetailsPayButton, {