@pelcro/react-pelcro-js 3.0.0-beta.10 → 3.0.0-beta.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -3670,6 +3670,7 @@ var successfully$1 = "successfully";
3670
3670
  var entitlement$1 = "Some of the content on this page is available with one or more of our plans. <1>Subscribe</1> now to get full page access.";
3671
3671
  var recaptcha$1 = "This site is protected by reCAPTCHA and the Google <1>Privacy Policy</1> and <3>Terms of Service</3> apply.";
3672
3672
  var invalidInvoice$1 = "Invalid invoice ID, please contact support";
3673
+ var zeroTotalInvoice$1 = "You can't view an invoice of 0$";
3673
3674
  var messages_en = {
3674
3675
  youAreSafe: youAreSafe$1,
3675
3676
  cancel: cancel$1,
@@ -3677,7 +3678,8 @@ var messages_en = {
3677
3678
  successfully: successfully$1,
3678
3679
  entitlement: entitlement$1,
3679
3680
  recaptcha: recaptcha$1,
3680
- invalidInvoice: invalidInvoice$1
3681
+ invalidInvoice: invalidInvoice$1,
3682
+ zeroTotalInvoice: zeroTotalInvoice$1
3681
3683
  };
3682
3684
 
3683
3685
  var youAreSafe = "Vous êtes en sécurité - PCI conforme 128 SSL par";
@@ -3687,6 +3689,7 @@ var successfully = "avec succès.";
3687
3689
  var entitlement = "Une partie du contenu de cette page est disponible sous un ou plusieurs de nos plans. <1>Abonnez-vous</1> à l'un de nos plans disponibles pour accéder à plus de contenu";
3688
3690
  var recaptcha = "Ce site est protégé par reCAPTCHA - les <1>règles de confidentialité</1> Google ainsi que les <3>conditions d'utilisation</3> s'appliquent.";
3689
3691
  var invalidInvoice = "Invalid invoice ID, please contact support";
3692
+ var zeroTotalInvoice = "You can't view an invoice of 0$";
3690
3693
  var messages_fr = {
3691
3694
  youAreSafe: youAreSafe,
3692
3695
  cancel: cancel,
@@ -3694,7 +3697,8 @@ var messages_fr = {
3694
3697
  successfully: successfully,
3695
3698
  entitlement: entitlement,
3696
3699
  recaptcha: recaptcha,
3697
- invalidInvoice: invalidInvoice
3700
+ invalidInvoice: invalidInvoice,
3701
+ zeroTotalInvoice: zeroTotalInvoice
3698
3702
  };
3699
3703
 
3700
3704
  var labels$j = {
@@ -3808,7 +3812,7 @@ var gift$1 = {
3808
3812
  lastName: "Last name",
3809
3813
  email: "Email",
3810
3814
  startDate: "Gift date",
3811
- giftMessage: "Gift message (200 characters max)",
3815
+ giftMessage: "Gift message ({{count}} characters remaining)",
3812
3816
  required: "required",
3813
3817
  firstNamePlaceholder: "First name",
3814
3818
  lastNamePlaceholder: "Last name",
@@ -3904,7 +3908,7 @@ var gift = {
3904
3908
  lastName: "Nom de famille",
3905
3909
  email: "Adresse courriel",
3906
3910
  startDate: "Date de début",
3907
- giftMessage: "Message du cadeau (200 caractères max)",
3911
+ giftMessage: "Message du cadeau ({{count}} caractères restants)",
3908
3912
  required: "Champs obligatoires",
3909
3913
  firstNamePlaceholder: "Prénom",
3910
3914
  lastNamePlaceholder: "Nom de famille",
@@ -8625,7 +8629,6 @@ var pure_1 = pure.loadStripe;
8625
8629
  * @param {Object} error Error object
8626
8630
  * @return {string}
8627
8631
  */
8628
-
8629
8632
  const getErrorMessages = error => {
8630
8633
  var _error$error, _error$response, _error$response$data, _error$response3, _error$response3$data, _error$response3$data2, _error$response5, _error$response5$data;
8631
8634
 
@@ -8680,20 +8683,6 @@ const debounce = (func, waitTime) => {
8680
8683
  timeout = setTimeout(later, waitTime);
8681
8684
  };
8682
8685
  };
8683
- function getSiteCardProcessor() {
8684
- var _window$Pelcro$site$r;
8685
-
8686
- const {
8687
- view
8688
- } = usePelcro.getStore();
8689
- const temp_ONLY_USE_VANTIV_WITH_SUBSCRIPTION_CREATE = view === "subscription-create";
8690
-
8691
- if (temp_ONLY_USE_VANTIV_WITH_SUBSCRIPTION_CREATE && (_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_pay_page_id) {
8692
- return "vantiv";
8693
- }
8694
-
8695
- return "stripe";
8696
- }
8697
8686
 
8698
8687
  /**
8699
8688
  * @typedef {Object} OptionsType
@@ -8774,26 +8763,13 @@ const loadPaymentSDKs = () => {
8774
8763
  if (!window.Stripe) {
8775
8764
  pure_1(window.Pelcro.environment.stripe);
8776
8765
  }
8777
- }); // Load PayPal SDKs
8766
+ }); // Load PayPal SDK's
8778
8767
 
8779
8768
  const supportsPaypal = Boolean(window.Pelcro.site.read().braintree_tokenization);
8780
8769
 
8781
8770
  if (supportsPaypal) {
8782
8771
  window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.69.0/js/client.min.js", "braintree-sdk");
8783
8772
  window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.69.0/js/paypal-checkout.min.js", "braintree-paypal-sdk");
8784
- } // Load Vantiv SDKs
8785
-
8786
-
8787
- const supportsVantiv = Boolean(window.Pelcro.site.read().vantiv_pay_page_id);
8788
-
8789
- if (supportsVantiv) {
8790
- if (!window.jQuery) {
8791
- window.Pelcro.helpers.loadSDK("https://code.jquery.com/jquery-3.6.0.slim.min.js", "vantiv-jquery-sdk");
8792
- }
8793
-
8794
- if (!window.EprotectIframeClient) {
8795
- window.Pelcro.helpers.loadSDK("https://request.eprotect.vantivprelive.com/eProtect/js/eProtect-iframe-client.min.js", "vantiv-eprotect-sdk");
8796
- }
8797
8773
  }
8798
8774
  };
8799
8775
  const loadAuth0SDK = () => {
@@ -9154,6 +9130,17 @@ const showInvoiceDetailsFromUrl = () => {
9154
9130
  return notify.error(errorMessage);
9155
9131
  }
9156
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
+
9157
9144
  return switchView("invoice-details");
9158
9145
  });
9159
9146
  };
@@ -12757,7 +12744,7 @@ var _generateUserError = /*#__PURE__*/new WeakMap();
12757
12744
  class Subscription {
12758
12745
  /**
12759
12746
  * Subscription service constructor
12760
- * @param {(StripeGateway|PaypalGateway|VantivGateway)} paymentGateway
12747
+ * @param {(StripeGateway|PaypalGateWay)} paymentGateway
12761
12748
  */
12762
12749
  constructor(paymentGateway) {
12763
12750
  _defineProperty$3(this, "execute", (options, callback) => {
@@ -12778,7 +12765,7 @@ class Subscription {
12778
12765
  _isPaymentGatewayInvalid.set(this, {
12779
12766
  writable: true,
12780
12767
  value: gateway => {
12781
- return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway);
12768
+ return gateway && !(gateway instanceof StripeGateway) && gateway && !(gateway instanceof PaypalGateWay);
12782
12769
  }
12783
12770
  });
12784
12771
 
@@ -12810,6 +12797,7 @@ class Subscription {
12810
12797
  * @property {number} [quantity]
12811
12798
  * @property {string} addressId
12812
12799
  * @property {number} invoiceId
12800
+ * @property {boolean} isExistingSource
12813
12801
  */
12814
12802
 
12815
12803
  /**
@@ -12830,8 +12818,7 @@ class Subscription {
12830
12818
  }
12831
12819
  const PAYMENT_GATEWAYS_ENUM = {
12832
12820
  stripe: "stripe",
12833
- paypal: "braintree",
12834
- vantiv: "vantiv"
12821
+ paypal: "braintree"
12835
12822
  };
12836
12823
  /**
12837
12824
  * Subscription Strategies
@@ -12995,11 +12982,15 @@ class StripeGateway {
12995
12982
  token,
12996
12983
  invoiceId
12997
12984
  } = options;
12998
- window.Pelcro.invoice.pay({
12985
+ const params = options.isExistingSource ? {
12986
+ source_id: token,
12987
+ invoice_id: invoiceId
12988
+ } : {
12999
12989
  payment_gateway: _classPrivateFieldGet(this, _paymentGateway),
13000
12990
  gateway_token: token,
13001
12991
  invoice_id: invoiceId
13002
- }, (err, res) => {
12992
+ };
12993
+ window.Pelcro.invoice.pay(params, (err, res) => {
13003
12994
  callback(err, res);
13004
12995
  });
13005
12996
  }
@@ -13019,7 +13010,7 @@ var _createGiftedSubscription2 = /*#__PURE__*/new WeakMap();
13019
13010
 
13020
13011
  var _payInvoice2 = /*#__PURE__*/new WeakMap();
13021
13012
 
13022
- class PaypalGateway {
13013
+ class PaypalGateWay {
13023
13014
  constructor() {
13024
13015
  _paymentGateway2.set(this, {
13025
13016
  writable: true,
@@ -13120,57 +13111,6 @@ class PaypalGateway {
13120
13111
 
13121
13112
  }
13122
13113
 
13123
- var _paymentGateway3 = /*#__PURE__*/new WeakMap();
13124
-
13125
- var _createSubscription3 = /*#__PURE__*/new WeakMap();
13126
-
13127
- class VantivGateway {
13128
- constructor() {
13129
- _paymentGateway3.set(this, {
13130
- writable: true,
13131
- value: PAYMENT_GATEWAYS_ENUM["vantiv"]
13132
- });
13133
-
13134
- _defineProperty$3(this, "execute", (options, callback) => {
13135
- const types = SUBSCRIPTION_TYPES;
13136
-
13137
- switch (options.type) {
13138
- case types.CREATE_SUBSCRIPTION:
13139
- return _classPrivateFieldGet(this, _createSubscription3).call(this, options, callback);
13140
-
13141
- default:
13142
- console.error("Unsupported subscriptiion method: vantiv Gateway");
13143
- }
13144
- });
13145
-
13146
- _createSubscription3.set(this, {
13147
- writable: true,
13148
- value: (options, callback) => {
13149
- const {
13150
- token,
13151
- plan,
13152
- couponCode,
13153
- product,
13154
- quantity = 1,
13155
- addressId
13156
- } = options;
13157
- window.Pelcro.subscription.create({
13158
- quantity,
13159
- gateway_token: token,
13160
- payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13161
- auth_token: window.Pelcro.user.read().auth_token,
13162
- plan_id: plan.id,
13163
- coupon_code: couponCode,
13164
- address_id: product.address_required ? addressId : null
13165
- }, (err, res) => {
13166
- callback(err, res);
13167
- });
13168
- }
13169
- });
13170
- }
13171
-
13172
- }
13173
-
13174
13114
  /**
13175
13115
  * @typedef {Object} PaymentStateType
13176
13116
  * @property {boolean} disableSubmit
@@ -13258,78 +13198,6 @@ const PaymentMethodContainerWithoutStripe = ({
13258
13198
  updateTotalAmountWithTax();
13259
13199
  }, []);
13260
13200
 
13261
- function submitVantivPayment() {
13262
- if (!vantivInstanceRef.current) {
13263
- return console.error("Vantiv sdk script wasn't loaded, you need to load vantiv sdk before rendering the vantiv payment flow");
13264
- }
13265
-
13266
- const orderId = `pelcro-${new Date().getTime()}`; // calls handleVantivPayment
13267
-
13268
- vantivInstanceRef.current.getPaypageRegistrationId({
13269
- id: orderId,
13270
- orderId: orderId
13271
- });
13272
- }
13273
-
13274
- function handleVantivPayment(paymentRequest) {
13275
- const SUCCESS_STATUS = "870";
13276
-
13277
- if (paymentRequest.response !== SUCCESS_STATUS) {
13278
- return handlePaymentError({
13279
- error: new Error(paymentRequest.message)
13280
- });
13281
- }
13282
-
13283
- const subscription = new Subscription(new VantivGateway());
13284
- const {
13285
- couponCode
13286
- } = state;
13287
- return subscription.execute({
13288
- type: SUBSCRIPTION_TYPES.CREATE_SUBSCRIPTION,
13289
- token: paymentRequest,
13290
- quantity: plan.quantity,
13291
- plan,
13292
- couponCode,
13293
- product,
13294
- addressId: selectedAddressId
13295
- }, (err, res) => {
13296
- if (err) {
13297
- return handlePaymentError(err);
13298
- }
13299
-
13300
- onSuccess(res);
13301
- });
13302
- }
13303
-
13304
- const vantivInstanceRef = React__default['default'].useRef(null);
13305
- React.useEffect(() => {
13306
- const cardProcessor = getSiteCardProcessor();
13307
-
13308
- if (cardProcessor === "vantiv") {
13309
- var _window$Pelcro$site$r;
13310
-
13311
- 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;
13312
- vantivInstanceRef.current = new window.EprotectIframeClient({
13313
- paypageId: payPageId,
13314
- reportGroup: payPageId,
13315
- style: "pelcro",
13316
- height: "245",
13317
- timeout: 50000,
13318
- div: "eProtectiframe",
13319
- callback: handleVantivPayment,
13320
- showCvv: true,
13321
- numYears: 8,
13322
- placeholderText: {
13323
- cvv: "CVV",
13324
- accountNumber: "1234 1234 1234 1234"
13325
- },
13326
- enhancedUxFeatures: {
13327
- inlineFieldValidations: true
13328
- }
13329
- });
13330
- }
13331
- }, []);
13332
-
13333
13201
  const initPaymentRequest = (state, dispatch) => {
13334
13202
  try {
13335
13203
  const paymentRequest = stripe.paymentRequest({
@@ -13400,9 +13268,9 @@ const PaymentMethodContainerWithoutStripe = ({
13400
13268
 
13401
13269
 
13402
13270
  const updateTotalAmountWithTax = () => {
13403
- var _window$Pelcro$site$r2;
13271
+ var _window$Pelcro$site$r;
13404
13272
 
13405
- 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;
13273
+ const taxesEnabled = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.taxes_enabled;
13406
13274
 
13407
13275
  if (taxesEnabled && type === "createPayment") {
13408
13276
  dispatch({
@@ -13752,7 +13620,7 @@ const PaymentMethodContainerWithoutStripe = ({
13752
13620
 
13753
13621
 
13754
13622
  const handlePaypalSubscription = (state, paypalNonce) => {
13755
- const subscription = new Subscription(new PaypalGateway());
13623
+ const subscription = new Subscription(new PaypalGateWay());
13756
13624
  const {
13757
13625
  couponCode
13758
13626
  } = state;
@@ -13889,6 +13757,7 @@ const PaymentMethodContainerWithoutStripe = ({
13889
13757
  return subscription.execute({
13890
13758
  type: SUBSCRIPTION_TYPES.PAY_INVOICE,
13891
13759
  token: gatewayToken,
13760
+ isExistingSource: Boolean(selectedPaymentMethodId),
13892
13761
  invoiceId: invoice.id
13893
13762
  }, (err, res) => {
13894
13763
  dispatch({
@@ -13911,9 +13780,6 @@ const PaymentMethodContainerWithoutStripe = ({
13911
13780
  });
13912
13781
  }
13913
13782
 
13914
- set({
13915
- invoice: null
13916
- });
13917
13783
  onSuccess(res);
13918
13784
  });
13919
13785
  };
@@ -14018,7 +13884,7 @@ const PaymentMethodContainerWithoutStripe = ({
14018
13884
  }, 0);
14019
13885
  };
14020
13886
 
14021
- const totalAmount = (_ref = (_ref2 = (_state$updatedPrice = state === null || state === void 0 ? void 0 : state.updatedPrice) !== null && _state$updatedPrice !== void 0 ? _state$updatedPrice : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref2 !== void 0 ? _ref2 : invoice.amount_remaining) !== null && _ref !== void 0 ? _ref : getOrderItemsTotal();
13887
+ const totalAmount = (_ref = (_ref2 = (_state$updatedPrice = state === null || state === void 0 ? void 0 : state.updatedPrice) !== null && _state$updatedPrice !== void 0 ? _state$updatedPrice : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref2 !== void 0 ? _ref2 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref !== void 0 ? _ref : getOrderItemsTotal();
14022
13888
 
14023
13889
  if ((source === null || source === void 0 ? void 0 : (_source$card3 = source.card) === null || _source$card3 === void 0 ? void 0 : _source$card3.three_d_secure) === "required" && totalAmount > 0) {
14024
13890
  return resolveTaxCalculation().then(res => {
@@ -14049,13 +13915,13 @@ const PaymentMethodContainerWithoutStripe = ({
14049
13915
 
14050
13916
 
14051
13917
  const resolveTaxCalculation = () => {
14052
- var _window$Pelcro$site$r3;
13918
+ var _window$Pelcro$site$r2;
14053
13919
 
14054
13920
  if (type === "invoicePayment") {
14055
13921
  return new Promise(resolve => resolve());
14056
13922
  }
14057
13923
 
14058
- 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;
13924
+ 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;
14059
13925
  return new Promise((resolve, reject) => {
14060
13926
  // resolve early if taxes isn't enabled
14061
13927
  if (!taxesEnabled) {
@@ -14134,8 +14000,6 @@ const PaymentMethodContainerWithoutStripe = ({
14134
14000
  };
14135
14001
 
14136
14002
  const handlePaymentError = error => {
14137
- var _getErrorMessages;
14138
-
14139
14003
  if (error.type === "validation_error" && // Subscription creation & renewal
14140
14004
  type === "createPayment") {
14141
14005
  var _state$couponObject;
@@ -14154,7 +14018,7 @@ const PaymentMethodContainerWithoutStripe = ({
14154
14018
  type: SHOW_ALERT,
14155
14019
  payload: {
14156
14020
  type: "error",
14157
- content: (_getErrorMessages = getErrorMessages(error)) !== null && _getErrorMessages !== void 0 ? _getErrorMessages : error === null || error === void 0 ? void 0 : error.message
14021
+ content: error === null || error === void 0 ? void 0 : error.message
14158
14022
  }
14159
14023
  });
14160
14024
  dispatch({
@@ -14258,20 +14122,16 @@ const PaymentMethodContainerWithoutStripe = ({
14258
14122
  }
14259
14123
 
14260
14124
  if (type === "updatePaymentSource") {
14261
- return updatePaymentSource(state, dispatch);
14262
- }
14263
-
14264
- if (getSiteCardProcessor() === "vantiv") {
14265
- return submitVantivPayment();
14125
+ updatePaymentSource(state, dispatch);
14126
+ } else {
14127
+ submitPayment(state);
14266
14128
  }
14267
-
14268
- submitPayment(state);
14269
14129
  });
14270
14130
 
14271
14131
  case HANDLE_PAYPAL_SUBSCRIPTION:
14272
14132
  return lib_5(state, (state, dispatch) => {
14273
14133
  if (type === "invoicePayment") {
14274
- payInvoice(new PaypalGateWay(), action.payload, dispatch);
14134
+ payInvoice(new PaypalGateway(), action.payload, dispatch);
14275
14135
  } else {
14276
14136
  handlePaypalSubscription(state, action.payload);
14277
14137
  }
@@ -14454,35 +14314,19 @@ const CheckoutForm = () => {
14454
14314
  const {
14455
14315
  selectedPaymentMethodId
14456
14316
  } = usePelcro();
14457
- const cardProcessor = getSiteCardProcessor();
14458
-
14459
- if (selectedPaymentMethodId) {
14460
- return null;
14461
- }
14462
-
14463
- if (cardProcessor === "vantiv") {
14464
- return /*#__PURE__*/React__default['default'].createElement("div", {
14465
- id: "eProtectiframe"
14466
- });
14467
- }
14468
-
14469
- if (cardProcessor === "stripe") {
14470
- return /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(PelcroCardNumber, {
14471
- autoFocus: true
14472
- }), /*#__PURE__*/React__default['default'].createElement("img", {
14473
- alt: "credit_cards",
14474
- className: "plc-w-auto plc-h-4 plc-mt-2",
14475
- src: "https://js.pelcro.com/ui/plugin/main/images/credit_cards.png"
14476
- }), /*#__PURE__*/React__default['default'].createElement("div", {
14477
- className: "plc-flex plc-items-end plc-justify-between plc-my-2"
14478
- }, /*#__PURE__*/React__default['default'].createElement("div", {
14479
- className: "plc-w-6/12 plc-pr-4"
14480
- }, /*#__PURE__*/React__default['default'].createElement(PelcroCardExpiry, null)), /*#__PURE__*/React__default['default'].createElement("div", {
14481
- className: "plc-w-6/12 plc-pl-4"
14482
- }, /*#__PURE__*/React__default['default'].createElement(PelcroCardCVC, null))));
14483
- }
14484
-
14485
- return null;
14317
+ return !selectedPaymentMethodId && /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(PelcroCardNumber, {
14318
+ autoFocus: true
14319
+ }), /*#__PURE__*/React__default['default'].createElement("img", {
14320
+ alt: "credit_cards",
14321
+ className: "plc-h-4 plc-w-auto plc-mt-2",
14322
+ src: "https://js.pelcro.com/ui/plugin/main/images/credit_cards.png"
14323
+ }), /*#__PURE__*/React__default['default'].createElement("div", {
14324
+ className: "plc-flex plc-justify-between plc-my-2 plc-items-end"
14325
+ }, /*#__PURE__*/React__default['default'].createElement("div", {
14326
+ className: "plc-w-6/12 plc-pr-4"
14327
+ }, /*#__PURE__*/React__default['default'].createElement(PelcroCardExpiry, null)), /*#__PURE__*/React__default['default'].createElement("div", {
14328
+ className: "plc-w-6/12 plc-pl-4"
14329
+ }, /*#__PURE__*/React__default['default'].createElement(PelcroCardCVC, null))));
14486
14330
  };
14487
14331
 
14488
14332
  const DiscountedPrice = props => {
@@ -15132,10 +14976,9 @@ function PaymentMethodView({
15132
14976
  const {
15133
14977
  t
15134
14978
  } = useTranslation("checkoutForm");
15135
- const cardProcessor = getSiteCardProcessor();
15136
14979
  return /*#__PURE__*/React__default['default'].createElement("div", {
15137
14980
  className: "plc-flex plc-flex-col plc-items-center plc-mt-4 sm:plc-px-8 pelcro-payment-block"
15138
- }, cardProcessor === "stripe" && /*#__PURE__*/React__default['default'].createElement("div", {
14981
+ }, /*#__PURE__*/React__default['default'].createElement("div", {
15139
14982
  className: "plc-flex plc-items-center plc-w-full plc-px-4 plc-py-2 plc-text-center plc-text-green-600 plc-border plc-border-green-400 plc-rounded plc-bg-green-50"
15140
14983
  }, /*#__PURE__*/React__default['default'].createElement(SvgLock, {
15141
14984
  className: "plc-w-5 plc-h-5 plc-mr-1"
@@ -19553,6 +19396,8 @@ function TextArea({
19553
19396
  */
19554
19397
 
19555
19398
  function GiftCreateMessage(props) {
19399
+ var _ref, _state$giftMessage;
19400
+
19556
19401
  const {
19557
19402
  t
19558
19403
  } = useTranslation("register");
@@ -19560,6 +19405,8 @@ function GiftCreateMessage(props) {
19560
19405
  dispatch,
19561
19406
  state
19562
19407
  } = React.useContext(store$6);
19408
+ const MAX_CHARS_COUNT = 200;
19409
+ const remainingCharsCount = (_ref = MAX_CHARS_COUNT - ((_state$giftMessage = state.giftMessage) === null || _state$giftMessage === void 0 ? void 0 : _state$giftMessage.length)) !== null && _ref !== void 0 ? _ref : 0;
19563
19410
 
19564
19411
  const handleInputChange = value => {
19565
19412
  dispatch({
@@ -19577,6 +19424,9 @@ function GiftCreateMessage(props) {
19577
19424
  value: state.giftMessage,
19578
19425
  maxLength: "200",
19579
19426
  rows: 3,
19427
+ label: t("gift.labels.giftMessage", {
19428
+ count: remainingCharsCount
19429
+ }),
19580
19430
  tooltipText: t("gift.messages.giftMessageInfo")
19581
19431
  }, props));
19582
19432
  }
@@ -19626,8 +19476,7 @@ const GiftCreateView = props => {
19626
19476
  }, /*#__PURE__*/React__default['default'].createElement(GiftCreateMessage, {
19627
19477
  autoComplete: "gift-message",
19628
19478
  id: "pelcro-input-gift-message",
19629
- errorId: "pelcro-input-gift-message-error",
19630
- label: t("gift.labels.giftMessage")
19479
+ errorId: "pelcro-input-gift-message-error"
19631
19480
  })), /*#__PURE__*/React__default['default'].createElement("p", {
19632
19481
  className: "plc-text-gray-900 pelcro-footnote"
19633
19482
  }, "* ", t("gift.labels.required")), /*#__PURE__*/React__default['default'].createElement(GiftCreateSubmitButton, {
@@ -22399,7 +22248,7 @@ const InvoicesMenu = props => {
22399
22248
  };
22400
22249
 
22401
22250
  const InvoicesItems = () => {
22402
- var _window$Pelcro$invoic;
22251
+ var _window$Pelcro$invoic, _window$Pelcro$invoic2;
22403
22252
 
22404
22253
  const {
22405
22254
  t
@@ -22408,7 +22257,7 @@ const InvoicesItems = () => {
22408
22257
  setInvoice,
22409
22258
  switchView
22410
22259
  } = usePelcro();
22411
- const invoices = (_window$Pelcro$invoic = window.Pelcro.invoice.list()) !== null && _window$Pelcro$invoic !== void 0 ? _window$Pelcro$invoic : [];
22260
+ 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 : [];
22412
22261
 
22413
22262
  const showInvoiceDetails = event => {
22414
22263
  if (setInvoice(event.target.dataset.id)) {
@@ -23084,9 +22933,9 @@ class Dashboard extends React.Component {
23084
22933
  }
23085
22934
 
23086
22935
  function hasInvoices() {
23087
- var _window$Pelcro$invoic;
22936
+ var _window$Pelcro$invoic, _window$Pelcro$invoic2;
23088
22937
 
23089
- const invoices = (_window$Pelcro$invoic = window.Pelcro.invoice.list()) !== null && _window$Pelcro$invoic !== void 0 ? _window$Pelcro$invoic : [];
22938
+ 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 : [];
23090
22939
  return invoices.length > 0;
23091
22940
  }
23092
22941
 
@@ -25281,11 +25130,11 @@ const InvoiceDetailsView = props => {
25281
25130
  }, t("labels.summary")), invoice && /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement("p", {
25282
25131
  className: "plc-mr-2 pelcro-invoice-creation-date"
25283
25132
  }, `${t("labels.creationDate")} ${formattedCreationDate}`), /*#__PURE__*/React__default['default'].createElement("div", {
25284
- 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-evenly pelcro-invoice-plan-wrapper"
25133
+ 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"
25285
25134
  }, /*#__PURE__*/React__default['default'].createElement("div", {
25286
- className: "plc-w-1/2 plc-break-words pelcro-invoice-plan-name"
25135
+ className: "plc-break-words pelcro-invoice-plan-name"
25287
25136
  }, invoice.plan.nickname), /*#__PURE__*/React__default['default'].createElement("div", {
25288
- className: "plc-w-1/5 plc-text-center pelcro-invoice-summary-price"
25137
+ className: "plc-text-center pelcro-invoice-summary-price"
25289
25138
  }, calcAndFormatItemsTotal([invoice.plan], invoice.currency))), /*#__PURE__*/React__default['default'].createElement("div", {
25290
25139
  className: "plc-flex plc-justify-end plc-pt-2 plc-mt-2 plc-font-bold plc-border-t plc-border-gray-400 pelcro-invoice-total-wrapper"
25291
25140
  }, /*#__PURE__*/React__default['default'].createElement("div", {
package/dist/index.esm.js CHANGED
@@ -3640,6 +3640,7 @@ var successfully$1 = "successfully";
3640
3640
  var entitlement$1 = "Some of the content on this page is available with one or more of our plans. <1>Subscribe</1> now to get full page access.";
3641
3641
  var recaptcha$1 = "This site is protected by reCAPTCHA and the Google <1>Privacy Policy</1> and <3>Terms of Service</3> apply.";
3642
3642
  var invalidInvoice$1 = "Invalid invoice ID, please contact support";
3643
+ var zeroTotalInvoice$1 = "You can't view an invoice of 0$";
3643
3644
  var messages_en = {
3644
3645
  youAreSafe: youAreSafe$1,
3645
3646
  cancel: cancel$1,
@@ -3647,7 +3648,8 @@ var messages_en = {
3647
3648
  successfully: successfully$1,
3648
3649
  entitlement: entitlement$1,
3649
3650
  recaptcha: recaptcha$1,
3650
- invalidInvoice: invalidInvoice$1
3651
+ invalidInvoice: invalidInvoice$1,
3652
+ zeroTotalInvoice: zeroTotalInvoice$1
3651
3653
  };
3652
3654
 
3653
3655
  var youAreSafe = "Vous êtes en sécurité - PCI conforme 128 SSL par";
@@ -3657,6 +3659,7 @@ var successfully = "avec succès.";
3657
3659
  var entitlement = "Une partie du contenu de cette page est disponible sous un ou plusieurs de nos plans. <1>Abonnez-vous</1> à l'un de nos plans disponibles pour accéder à plus de contenu";
3658
3660
  var recaptcha = "Ce site est protégé par reCAPTCHA - les <1>règles de confidentialité</1> Google ainsi que les <3>conditions d'utilisation</3> s'appliquent.";
3659
3661
  var invalidInvoice = "Invalid invoice ID, please contact support";
3662
+ var zeroTotalInvoice = "You can't view an invoice of 0$";
3660
3663
  var messages_fr = {
3661
3664
  youAreSafe: youAreSafe,
3662
3665
  cancel: cancel,
@@ -3664,7 +3667,8 @@ var messages_fr = {
3664
3667
  successfully: successfully,
3665
3668
  entitlement: entitlement,
3666
3669
  recaptcha: recaptcha,
3667
- invalidInvoice: invalidInvoice
3670
+ invalidInvoice: invalidInvoice,
3671
+ zeroTotalInvoice: zeroTotalInvoice
3668
3672
  };
3669
3673
 
3670
3674
  var labels$j = {
@@ -3778,7 +3782,7 @@ var gift$1 = {
3778
3782
  lastName: "Last name",
3779
3783
  email: "Email",
3780
3784
  startDate: "Gift date",
3781
- giftMessage: "Gift message (200 characters max)",
3785
+ giftMessage: "Gift message ({{count}} characters remaining)",
3782
3786
  required: "required",
3783
3787
  firstNamePlaceholder: "First name",
3784
3788
  lastNamePlaceholder: "Last name",
@@ -3874,7 +3878,7 @@ var gift = {
3874
3878
  lastName: "Nom de famille",
3875
3879
  email: "Adresse courriel",
3876
3880
  startDate: "Date de début",
3877
- giftMessage: "Message du cadeau (200 caractères max)",
3881
+ giftMessage: "Message du cadeau ({{count}} caractères restants)",
3878
3882
  required: "Champs obligatoires",
3879
3883
  firstNamePlaceholder: "Prénom",
3880
3884
  lastNamePlaceholder: "Nom de famille",
@@ -8595,7 +8599,6 @@ var pure_1 = pure.loadStripe;
8595
8599
  * @param {Object} error Error object
8596
8600
  * @return {string}
8597
8601
  */
8598
-
8599
8602
  const getErrorMessages = error => {
8600
8603
  var _error$error, _error$response, _error$response$data, _error$response3, _error$response3$data, _error$response3$data2, _error$response5, _error$response5$data;
8601
8604
 
@@ -8650,20 +8653,6 @@ const debounce = (func, waitTime) => {
8650
8653
  timeout = setTimeout(later, waitTime);
8651
8654
  };
8652
8655
  };
8653
- function getSiteCardProcessor() {
8654
- var _window$Pelcro$site$r;
8655
-
8656
- const {
8657
- view
8658
- } = usePelcro.getStore();
8659
- const temp_ONLY_USE_VANTIV_WITH_SUBSCRIPTION_CREATE = view === "subscription-create";
8660
-
8661
- if (temp_ONLY_USE_VANTIV_WITH_SUBSCRIPTION_CREATE && (_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_pay_page_id) {
8662
- return "vantiv";
8663
- }
8664
-
8665
- return "stripe";
8666
- }
8667
8656
 
8668
8657
  /**
8669
8658
  * @typedef {Object} OptionsType
@@ -8744,26 +8733,13 @@ const loadPaymentSDKs = () => {
8744
8733
  if (!window.Stripe) {
8745
8734
  pure_1(window.Pelcro.environment.stripe);
8746
8735
  }
8747
- }); // Load PayPal SDKs
8736
+ }); // Load PayPal SDK's
8748
8737
 
8749
8738
  const supportsPaypal = Boolean(window.Pelcro.site.read().braintree_tokenization);
8750
8739
 
8751
8740
  if (supportsPaypal) {
8752
8741
  window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.69.0/js/client.min.js", "braintree-sdk");
8753
8742
  window.Pelcro.helpers.loadSDK("https://js.braintreegateway.com/web/3.69.0/js/paypal-checkout.min.js", "braintree-paypal-sdk");
8754
- } // Load Vantiv SDKs
8755
-
8756
-
8757
- const supportsVantiv = Boolean(window.Pelcro.site.read().vantiv_pay_page_id);
8758
-
8759
- if (supportsVantiv) {
8760
- if (!window.jQuery) {
8761
- window.Pelcro.helpers.loadSDK("https://code.jquery.com/jquery-3.6.0.slim.min.js", "vantiv-jquery-sdk");
8762
- }
8763
-
8764
- if (!window.EprotectIframeClient) {
8765
- window.Pelcro.helpers.loadSDK("https://request.eprotect.vantivprelive.com/eProtect/js/eProtect-iframe-client.min.js", "vantiv-eprotect-sdk");
8766
- }
8767
8743
  }
8768
8744
  };
8769
8745
  const loadAuth0SDK = () => {
@@ -9124,6 +9100,17 @@ const showInvoiceDetailsFromUrl = () => {
9124
9100
  return notify.error(errorMessage);
9125
9101
  }
9126
9102
 
9103
+ const {
9104
+ invoice
9105
+ } = usePelcro.getStore();
9106
+
9107
+ if (invoice.total === 0) {
9108
+ const errorMessage = i18next.t("messages:zeroTotalInvoice", {
9109
+ returnObjects: true
9110
+ });
9111
+ return notify.error(errorMessage);
9112
+ }
9113
+
9127
9114
  return switchView("invoice-details");
9128
9115
  });
9129
9116
  };
@@ -12727,7 +12714,7 @@ var _generateUserError = /*#__PURE__*/new WeakMap();
12727
12714
  class Subscription {
12728
12715
  /**
12729
12716
  * Subscription service constructor
12730
- * @param {(StripeGateway|PaypalGateway|VantivGateway)} paymentGateway
12717
+ * @param {(StripeGateway|PaypalGateWay)} paymentGateway
12731
12718
  */
12732
12719
  constructor(paymentGateway) {
12733
12720
  _defineProperty$3(this, "execute", (options, callback) => {
@@ -12748,7 +12735,7 @@ class Subscription {
12748
12735
  _isPaymentGatewayInvalid.set(this, {
12749
12736
  writable: true,
12750
12737
  value: gateway => {
12751
- return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway);
12738
+ return gateway && !(gateway instanceof StripeGateway) && gateway && !(gateway instanceof PaypalGateWay);
12752
12739
  }
12753
12740
  });
12754
12741
 
@@ -12780,6 +12767,7 @@ class Subscription {
12780
12767
  * @property {number} [quantity]
12781
12768
  * @property {string} addressId
12782
12769
  * @property {number} invoiceId
12770
+ * @property {boolean} isExistingSource
12783
12771
  */
12784
12772
 
12785
12773
  /**
@@ -12800,8 +12788,7 @@ class Subscription {
12800
12788
  }
12801
12789
  const PAYMENT_GATEWAYS_ENUM = {
12802
12790
  stripe: "stripe",
12803
- paypal: "braintree",
12804
- vantiv: "vantiv"
12791
+ paypal: "braintree"
12805
12792
  };
12806
12793
  /**
12807
12794
  * Subscription Strategies
@@ -12965,11 +12952,15 @@ class StripeGateway {
12965
12952
  token,
12966
12953
  invoiceId
12967
12954
  } = options;
12968
- window.Pelcro.invoice.pay({
12955
+ const params = options.isExistingSource ? {
12956
+ source_id: token,
12957
+ invoice_id: invoiceId
12958
+ } : {
12969
12959
  payment_gateway: _classPrivateFieldGet(this, _paymentGateway),
12970
12960
  gateway_token: token,
12971
12961
  invoice_id: invoiceId
12972
- }, (err, res) => {
12962
+ };
12963
+ window.Pelcro.invoice.pay(params, (err, res) => {
12973
12964
  callback(err, res);
12974
12965
  });
12975
12966
  }
@@ -12989,7 +12980,7 @@ var _createGiftedSubscription2 = /*#__PURE__*/new WeakMap();
12989
12980
 
12990
12981
  var _payInvoice2 = /*#__PURE__*/new WeakMap();
12991
12982
 
12992
- class PaypalGateway {
12983
+ class PaypalGateWay {
12993
12984
  constructor() {
12994
12985
  _paymentGateway2.set(this, {
12995
12986
  writable: true,
@@ -13090,57 +13081,6 @@ class PaypalGateway {
13090
13081
 
13091
13082
  }
13092
13083
 
13093
- var _paymentGateway3 = /*#__PURE__*/new WeakMap();
13094
-
13095
- var _createSubscription3 = /*#__PURE__*/new WeakMap();
13096
-
13097
- class VantivGateway {
13098
- constructor() {
13099
- _paymentGateway3.set(this, {
13100
- writable: true,
13101
- value: PAYMENT_GATEWAYS_ENUM["vantiv"]
13102
- });
13103
-
13104
- _defineProperty$3(this, "execute", (options, callback) => {
13105
- const types = SUBSCRIPTION_TYPES;
13106
-
13107
- switch (options.type) {
13108
- case types.CREATE_SUBSCRIPTION:
13109
- return _classPrivateFieldGet(this, _createSubscription3).call(this, options, callback);
13110
-
13111
- default:
13112
- console.error("Unsupported subscriptiion method: vantiv Gateway");
13113
- }
13114
- });
13115
-
13116
- _createSubscription3.set(this, {
13117
- writable: true,
13118
- value: (options, callback) => {
13119
- const {
13120
- token,
13121
- plan,
13122
- couponCode,
13123
- product,
13124
- quantity = 1,
13125
- addressId
13126
- } = options;
13127
- window.Pelcro.subscription.create({
13128
- quantity,
13129
- gateway_token: token,
13130
- payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13131
- auth_token: window.Pelcro.user.read().auth_token,
13132
- plan_id: plan.id,
13133
- coupon_code: couponCode,
13134
- address_id: product.address_required ? addressId : null
13135
- }, (err, res) => {
13136
- callback(err, res);
13137
- });
13138
- }
13139
- });
13140
- }
13141
-
13142
- }
13143
-
13144
13084
  /**
13145
13085
  * @typedef {Object} PaymentStateType
13146
13086
  * @property {boolean} disableSubmit
@@ -13228,78 +13168,6 @@ const PaymentMethodContainerWithoutStripe = ({
13228
13168
  updateTotalAmountWithTax();
13229
13169
  }, []);
13230
13170
 
13231
- function submitVantivPayment() {
13232
- if (!vantivInstanceRef.current) {
13233
- return console.error("Vantiv sdk script wasn't loaded, you need to load vantiv sdk before rendering the vantiv payment flow");
13234
- }
13235
-
13236
- const orderId = `pelcro-${new Date().getTime()}`; // calls handleVantivPayment
13237
-
13238
- vantivInstanceRef.current.getPaypageRegistrationId({
13239
- id: orderId,
13240
- orderId: orderId
13241
- });
13242
- }
13243
-
13244
- function handleVantivPayment(paymentRequest) {
13245
- const SUCCESS_STATUS = "870";
13246
-
13247
- if (paymentRequest.response !== SUCCESS_STATUS) {
13248
- return handlePaymentError({
13249
- error: new Error(paymentRequest.message)
13250
- });
13251
- }
13252
-
13253
- const subscription = new Subscription(new VantivGateway());
13254
- const {
13255
- couponCode
13256
- } = state;
13257
- return subscription.execute({
13258
- type: SUBSCRIPTION_TYPES.CREATE_SUBSCRIPTION,
13259
- token: paymentRequest,
13260
- quantity: plan.quantity,
13261
- plan,
13262
- couponCode,
13263
- product,
13264
- addressId: selectedAddressId
13265
- }, (err, res) => {
13266
- if (err) {
13267
- return handlePaymentError(err);
13268
- }
13269
-
13270
- onSuccess(res);
13271
- });
13272
- }
13273
-
13274
- const vantivInstanceRef = React__default.useRef(null);
13275
- useEffect(() => {
13276
- const cardProcessor = getSiteCardProcessor();
13277
-
13278
- if (cardProcessor === "vantiv") {
13279
- var _window$Pelcro$site$r;
13280
-
13281
- 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;
13282
- vantivInstanceRef.current = new window.EprotectIframeClient({
13283
- paypageId: payPageId,
13284
- reportGroup: payPageId,
13285
- style: "pelcro",
13286
- height: "245",
13287
- timeout: 50000,
13288
- div: "eProtectiframe",
13289
- callback: handleVantivPayment,
13290
- showCvv: true,
13291
- numYears: 8,
13292
- placeholderText: {
13293
- cvv: "CVV",
13294
- accountNumber: "1234 1234 1234 1234"
13295
- },
13296
- enhancedUxFeatures: {
13297
- inlineFieldValidations: true
13298
- }
13299
- });
13300
- }
13301
- }, []);
13302
-
13303
13171
  const initPaymentRequest = (state, dispatch) => {
13304
13172
  try {
13305
13173
  const paymentRequest = stripe.paymentRequest({
@@ -13370,9 +13238,9 @@ const PaymentMethodContainerWithoutStripe = ({
13370
13238
 
13371
13239
 
13372
13240
  const updateTotalAmountWithTax = () => {
13373
- var _window$Pelcro$site$r2;
13241
+ var _window$Pelcro$site$r;
13374
13242
 
13375
- 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;
13243
+ const taxesEnabled = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.taxes_enabled;
13376
13244
 
13377
13245
  if (taxesEnabled && type === "createPayment") {
13378
13246
  dispatch({
@@ -13722,7 +13590,7 @@ const PaymentMethodContainerWithoutStripe = ({
13722
13590
 
13723
13591
 
13724
13592
  const handlePaypalSubscription = (state, paypalNonce) => {
13725
- const subscription = new Subscription(new PaypalGateway());
13593
+ const subscription = new Subscription(new PaypalGateWay());
13726
13594
  const {
13727
13595
  couponCode
13728
13596
  } = state;
@@ -13859,6 +13727,7 @@ const PaymentMethodContainerWithoutStripe = ({
13859
13727
  return subscription.execute({
13860
13728
  type: SUBSCRIPTION_TYPES.PAY_INVOICE,
13861
13729
  token: gatewayToken,
13730
+ isExistingSource: Boolean(selectedPaymentMethodId),
13862
13731
  invoiceId: invoice.id
13863
13732
  }, (err, res) => {
13864
13733
  dispatch({
@@ -13881,9 +13750,6 @@ const PaymentMethodContainerWithoutStripe = ({
13881
13750
  });
13882
13751
  }
13883
13752
 
13884
- set({
13885
- invoice: null
13886
- });
13887
13753
  onSuccess(res);
13888
13754
  });
13889
13755
  };
@@ -13988,7 +13854,7 @@ const PaymentMethodContainerWithoutStripe = ({
13988
13854
  }, 0);
13989
13855
  };
13990
13856
 
13991
- const totalAmount = (_ref = (_ref2 = (_state$updatedPrice = state === null || state === void 0 ? void 0 : state.updatedPrice) !== null && _state$updatedPrice !== void 0 ? _state$updatedPrice : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref2 !== void 0 ? _ref2 : invoice.amount_remaining) !== null && _ref !== void 0 ? _ref : getOrderItemsTotal();
13857
+ const totalAmount = (_ref = (_ref2 = (_state$updatedPrice = state === null || state === void 0 ? void 0 : state.updatedPrice) !== null && _state$updatedPrice !== void 0 ? _state$updatedPrice : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref2 !== void 0 ? _ref2 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref !== void 0 ? _ref : getOrderItemsTotal();
13992
13858
 
13993
13859
  if ((source === null || source === void 0 ? void 0 : (_source$card3 = source.card) === null || _source$card3 === void 0 ? void 0 : _source$card3.three_d_secure) === "required" && totalAmount > 0) {
13994
13860
  return resolveTaxCalculation().then(res => {
@@ -14019,13 +13885,13 @@ const PaymentMethodContainerWithoutStripe = ({
14019
13885
 
14020
13886
 
14021
13887
  const resolveTaxCalculation = () => {
14022
- var _window$Pelcro$site$r3;
13888
+ var _window$Pelcro$site$r2;
14023
13889
 
14024
13890
  if (type === "invoicePayment") {
14025
13891
  return new Promise(resolve => resolve());
14026
13892
  }
14027
13893
 
14028
- 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;
13894
+ 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;
14029
13895
  return new Promise((resolve, reject) => {
14030
13896
  // resolve early if taxes isn't enabled
14031
13897
  if (!taxesEnabled) {
@@ -14104,8 +13970,6 @@ const PaymentMethodContainerWithoutStripe = ({
14104
13970
  };
14105
13971
 
14106
13972
  const handlePaymentError = error => {
14107
- var _getErrorMessages;
14108
-
14109
13973
  if (error.type === "validation_error" && // Subscription creation & renewal
14110
13974
  type === "createPayment") {
14111
13975
  var _state$couponObject;
@@ -14124,7 +13988,7 @@ const PaymentMethodContainerWithoutStripe = ({
14124
13988
  type: SHOW_ALERT,
14125
13989
  payload: {
14126
13990
  type: "error",
14127
- content: (_getErrorMessages = getErrorMessages(error)) !== null && _getErrorMessages !== void 0 ? _getErrorMessages : error === null || error === void 0 ? void 0 : error.message
13991
+ content: error === null || error === void 0 ? void 0 : error.message
14128
13992
  }
14129
13993
  });
14130
13994
  dispatch({
@@ -14228,20 +14092,16 @@ const PaymentMethodContainerWithoutStripe = ({
14228
14092
  }
14229
14093
 
14230
14094
  if (type === "updatePaymentSource") {
14231
- return updatePaymentSource(state, dispatch);
14232
- }
14233
-
14234
- if (getSiteCardProcessor() === "vantiv") {
14235
- return submitVantivPayment();
14095
+ updatePaymentSource(state, dispatch);
14096
+ } else {
14097
+ submitPayment(state);
14236
14098
  }
14237
-
14238
- submitPayment(state);
14239
14099
  });
14240
14100
 
14241
14101
  case HANDLE_PAYPAL_SUBSCRIPTION:
14242
14102
  return lib_5(state, (state, dispatch) => {
14243
14103
  if (type === "invoicePayment") {
14244
- payInvoice(new PaypalGateWay(), action.payload, dispatch);
14104
+ payInvoice(new PaypalGateway(), action.payload, dispatch);
14245
14105
  } else {
14246
14106
  handlePaypalSubscription(state, action.payload);
14247
14107
  }
@@ -14424,35 +14284,19 @@ const CheckoutForm = () => {
14424
14284
  const {
14425
14285
  selectedPaymentMethodId
14426
14286
  } = usePelcro();
14427
- const cardProcessor = getSiteCardProcessor();
14428
-
14429
- if (selectedPaymentMethodId) {
14430
- return null;
14431
- }
14432
-
14433
- if (cardProcessor === "vantiv") {
14434
- return /*#__PURE__*/React__default.createElement("div", {
14435
- id: "eProtectiframe"
14436
- });
14437
- }
14438
-
14439
- if (cardProcessor === "stripe") {
14440
- return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(PelcroCardNumber, {
14441
- autoFocus: true
14442
- }), /*#__PURE__*/React__default.createElement("img", {
14443
- alt: "credit_cards",
14444
- className: "plc-w-auto plc-h-4 plc-mt-2",
14445
- src: "https://js.pelcro.com/ui/plugin/main/images/credit_cards.png"
14446
- }), /*#__PURE__*/React__default.createElement("div", {
14447
- className: "plc-flex plc-items-end plc-justify-between plc-my-2"
14448
- }, /*#__PURE__*/React__default.createElement("div", {
14449
- className: "plc-w-6/12 plc-pr-4"
14450
- }, /*#__PURE__*/React__default.createElement(PelcroCardExpiry, null)), /*#__PURE__*/React__default.createElement("div", {
14451
- className: "plc-w-6/12 plc-pl-4"
14452
- }, /*#__PURE__*/React__default.createElement(PelcroCardCVC, null))));
14453
- }
14454
-
14455
- return null;
14287
+ return !selectedPaymentMethodId && /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(PelcroCardNumber, {
14288
+ autoFocus: true
14289
+ }), /*#__PURE__*/React__default.createElement("img", {
14290
+ alt: "credit_cards",
14291
+ className: "plc-h-4 plc-w-auto plc-mt-2",
14292
+ src: "https://js.pelcro.com/ui/plugin/main/images/credit_cards.png"
14293
+ }), /*#__PURE__*/React__default.createElement("div", {
14294
+ className: "plc-flex plc-justify-between plc-my-2 plc-items-end"
14295
+ }, /*#__PURE__*/React__default.createElement("div", {
14296
+ className: "plc-w-6/12 plc-pr-4"
14297
+ }, /*#__PURE__*/React__default.createElement(PelcroCardExpiry, null)), /*#__PURE__*/React__default.createElement("div", {
14298
+ className: "plc-w-6/12 plc-pl-4"
14299
+ }, /*#__PURE__*/React__default.createElement(PelcroCardCVC, null))));
14456
14300
  };
14457
14301
 
14458
14302
  const DiscountedPrice = props => {
@@ -15102,10 +14946,9 @@ function PaymentMethodView({
15102
14946
  const {
15103
14947
  t
15104
14948
  } = useTranslation("checkoutForm");
15105
- const cardProcessor = getSiteCardProcessor();
15106
14949
  return /*#__PURE__*/React__default.createElement("div", {
15107
14950
  className: "plc-flex plc-flex-col plc-items-center plc-mt-4 sm:plc-px-8 pelcro-payment-block"
15108
- }, cardProcessor === "stripe" && /*#__PURE__*/React__default.createElement("div", {
14951
+ }, /*#__PURE__*/React__default.createElement("div", {
15109
14952
  className: "plc-flex plc-items-center plc-w-full plc-px-4 plc-py-2 plc-text-center plc-text-green-600 plc-border plc-border-green-400 plc-rounded plc-bg-green-50"
15110
14953
  }, /*#__PURE__*/React__default.createElement(SvgLock, {
15111
14954
  className: "plc-w-5 plc-h-5 plc-mr-1"
@@ -19523,6 +19366,8 @@ function TextArea({
19523
19366
  */
19524
19367
 
19525
19368
  function GiftCreateMessage(props) {
19369
+ var _ref, _state$giftMessage;
19370
+
19526
19371
  const {
19527
19372
  t
19528
19373
  } = useTranslation("register");
@@ -19530,6 +19375,8 @@ function GiftCreateMessage(props) {
19530
19375
  dispatch,
19531
19376
  state
19532
19377
  } = useContext(store$6);
19378
+ const MAX_CHARS_COUNT = 200;
19379
+ const remainingCharsCount = (_ref = MAX_CHARS_COUNT - ((_state$giftMessage = state.giftMessage) === null || _state$giftMessage === void 0 ? void 0 : _state$giftMessage.length)) !== null && _ref !== void 0 ? _ref : 0;
19533
19380
 
19534
19381
  const handleInputChange = value => {
19535
19382
  dispatch({
@@ -19547,6 +19394,9 @@ function GiftCreateMessage(props) {
19547
19394
  value: state.giftMessage,
19548
19395
  maxLength: "200",
19549
19396
  rows: 3,
19397
+ label: t("gift.labels.giftMessage", {
19398
+ count: remainingCharsCount
19399
+ }),
19550
19400
  tooltipText: t("gift.messages.giftMessageInfo")
19551
19401
  }, props));
19552
19402
  }
@@ -19596,8 +19446,7 @@ const GiftCreateView = props => {
19596
19446
  }, /*#__PURE__*/React__default.createElement(GiftCreateMessage, {
19597
19447
  autoComplete: "gift-message",
19598
19448
  id: "pelcro-input-gift-message",
19599
- errorId: "pelcro-input-gift-message-error",
19600
- label: t("gift.labels.giftMessage")
19449
+ errorId: "pelcro-input-gift-message-error"
19601
19450
  })), /*#__PURE__*/React__default.createElement("p", {
19602
19451
  className: "plc-text-gray-900 pelcro-footnote"
19603
19452
  }, "* ", t("gift.labels.required")), /*#__PURE__*/React__default.createElement(GiftCreateSubmitButton, {
@@ -22369,7 +22218,7 @@ const InvoicesMenu = props => {
22369
22218
  };
22370
22219
 
22371
22220
  const InvoicesItems = () => {
22372
- var _window$Pelcro$invoic;
22221
+ var _window$Pelcro$invoic, _window$Pelcro$invoic2;
22373
22222
 
22374
22223
  const {
22375
22224
  t
@@ -22378,7 +22227,7 @@ const InvoicesItems = () => {
22378
22227
  setInvoice,
22379
22228
  switchView
22380
22229
  } = usePelcro();
22381
- const invoices = (_window$Pelcro$invoic = window.Pelcro.invoice.list()) !== null && _window$Pelcro$invoic !== void 0 ? _window$Pelcro$invoic : [];
22230
+ 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 : [];
22382
22231
 
22383
22232
  const showInvoiceDetails = event => {
22384
22233
  if (setInvoice(event.target.dataset.id)) {
@@ -23054,9 +22903,9 @@ class Dashboard extends Component {
23054
22903
  }
23055
22904
 
23056
22905
  function hasInvoices() {
23057
- var _window$Pelcro$invoic;
22906
+ var _window$Pelcro$invoic, _window$Pelcro$invoic2;
23058
22907
 
23059
- const invoices = (_window$Pelcro$invoic = window.Pelcro.invoice.list()) !== null && _window$Pelcro$invoic !== void 0 ? _window$Pelcro$invoic : [];
22908
+ 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 : [];
23060
22909
  return invoices.length > 0;
23061
22910
  }
23062
22911
 
@@ -25251,11 +25100,11 @@ const InvoiceDetailsView = props => {
25251
25100
  }, t("labels.summary")), invoice && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("p", {
25252
25101
  className: "plc-mr-2 pelcro-invoice-creation-date"
25253
25102
  }, `${t("labels.creationDate")} ${formattedCreationDate}`), /*#__PURE__*/React__default.createElement("div", {
25254
- 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-evenly pelcro-invoice-plan-wrapper"
25103
+ 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"
25255
25104
  }, /*#__PURE__*/React__default.createElement("div", {
25256
- className: "plc-w-1/2 plc-break-words pelcro-invoice-plan-name"
25105
+ className: "plc-break-words pelcro-invoice-plan-name"
25257
25106
  }, invoice.plan.nickname), /*#__PURE__*/React__default.createElement("div", {
25258
- className: "plc-w-1/5 plc-text-center pelcro-invoice-summary-price"
25107
+ className: "plc-text-center pelcro-invoice-summary-price"
25259
25108
  }, calcAndFormatItemsTotal([invoice.plan], invoice.currency))), /*#__PURE__*/React__default.createElement("div", {
25260
25109
  className: "plc-flex plc-justify-end plc-pt-2 plc-mt-2 plc-font-bold plc-border-t plc-border-gray-400 pelcro-invoice-total-wrapper"
25261
25110
  }, /*#__PURE__*/React__default.createElement("div", {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pelcro/react-pelcro-js",
3
3
  "description": "Pelcro's React UI Elements",
4
- "version": "3.0.0-beta.10",
4
+ "version": "3.0.0-beta.13",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",