@pelcro/react-pelcro-js 3.2.0-beta.2 → 3.2.0-beta.22

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
@@ -3214,7 +3214,8 @@ function withTranslation(ns) {
3214
3214
  var validation$1 = {
3215
3215
  validEmail: "le courriel n’est pas valide",
3216
3216
  enterEmail: "Un courriel est requis.",
3217
- enterPassword: "Mot de passe requis."
3217
+ enterPassword: "Mot de passe requis.",
3218
+ confirmPassword: "Confirmer le mot de passe requis."
3218
3219
  };
3219
3220
  var buttons$9 = {
3220
3221
  account: "Accès abonné(e)s",
@@ -3302,7 +3303,8 @@ var common_fr = {
3302
3303
  var validation = {
3303
3304
  validEmail: "Email address is not valid.",
3304
3305
  enterEmail: "Email address is required.",
3305
- enterPassword: "Password is required."
3306
+ enterPassword: "Password is required.",
3307
+ confirmPassword: "Confirm password is required."
3306
3308
  };
3307
3309
  var buttons$8 = {
3308
3310
  account: "My account",
@@ -3434,7 +3436,7 @@ var paymentMethod_fr = {
3434
3436
  var title$f = "Enter your email to subscribe to our newsletter";
3435
3437
  var updateTitle$1 = "Update newsletter selections";
3436
3438
  var subtitle$7 = "We may use your email for other marketing communication";
3437
- var labels$p = {
3439
+ var labels$r = {
3438
3440
  submit: "Submit",
3439
3441
  firstName: "First name",
3440
3442
  lastName: "Last name",
@@ -3442,7 +3444,7 @@ var labels$p = {
3442
3444
  postalCode: "Postal code",
3443
3445
  required: "required"
3444
3446
  };
3445
- var messages$r = {
3447
+ var messages$t = {
3446
3448
  alreadyHaveAccount: "Already have an account?",
3447
3449
  success: "Newsletters were successfully updated",
3448
3450
  loginHere: "Login here.",
@@ -3453,14 +3455,14 @@ var newsletter_en = {
3453
3455
  title: title$f,
3454
3456
  updateTitle: updateTitle$1,
3455
3457
  subtitle: subtitle$7,
3456
- labels: labels$p,
3457
- messages: messages$r
3458
+ labels: labels$r,
3459
+ messages: messages$t
3458
3460
  };
3459
3461
 
3460
3462
  var title$e = "Entrez votre adresse courriel pour vous abonner à notre infolettre";
3461
3463
  var updateTitle = "Mettre à jour son choix d'infolettres";
3462
3464
  var subtitle$6 = "Nous pouvons utiliser votre adresse courriel pour d’autres communications marketing";
3463
- var labels$o = {
3465
+ var labels$q = {
3464
3466
  submit: "Lire l’article !",
3465
3467
  firstName: "Prénom",
3466
3468
  lastName: "Nom de famille",
@@ -3468,7 +3470,7 @@ var labels$o = {
3468
3470
  postalCode: "Code postal",
3469
3471
  required: "Champs obligatoires"
3470
3472
  };
3471
- var messages$q = {
3473
+ var messages$s = {
3472
3474
  alreadyHaveAccount: "Vous avez déjà un compte ?",
3473
3475
  success: "Votre choix d'infolettres à été mis à jour",
3474
3476
  loginHere: "Connectez-vous ici",
@@ -3479,14 +3481,14 @@ var newsletter_fr = {
3479
3481
  title: title$e,
3480
3482
  updateTitle: updateTitle,
3481
3483
  subtitle: subtitle$6,
3482
- labels: labels$o,
3483
- messages: messages$q
3484
+ labels: labels$q,
3485
+ messages: messages$s
3484
3486
  };
3485
3487
 
3486
- var labels$n = {
3488
+ var labels$p = {
3487
3489
  "continue": "Continue to content"
3488
3490
  };
3489
- var messages$p = {
3491
+ var messages$r = {
3490
3492
  yourFreeTrial: "Subscription successful!",
3491
3493
  youHaveAccess: "Hope you enjoy the subscription. Please contact us if you have any questions or concerns.",
3492
3494
  clickToLearn: {
@@ -3512,15 +3514,15 @@ var errors$9 = {
3512
3514
  "": ""
3513
3515
  };
3514
3516
  var success_en = {
3515
- labels: labels$n,
3516
- messages: messages$p,
3517
+ labels: labels$p,
3518
+ messages: messages$r,
3517
3519
  errors: errors$9
3518
3520
  };
3519
3521
 
3520
- var labels$m = {
3522
+ var labels$o = {
3521
3523
  "continue": "Abonnement réussi !"
3522
3524
  };
3523
- var messages$o = {
3525
+ var messages$q = {
3524
3526
  yourFreeTrial: "Votre essai gratuit vient de débuter",
3525
3527
  youHaveAccess: "Nous espérons que vous allez apprécier votre abonnement. Veuillez nous contacter si vous avez des questions ou des préoccupations.",
3526
3528
  clickToLearn: {
@@ -3546,12 +3548,12 @@ var errors$8 = {
3546
3548
  "": ""
3547
3549
  };
3548
3550
  var success_fr = {
3549
- labels: labels$m,
3550
- messages: messages$o,
3551
+ labels: labels$o,
3552
+ messages: messages$q,
3551
3553
  errors: errors$8
3552
3554
  };
3553
3555
 
3554
- var messages$n = {
3556
+ var messages$p = {
3555
3557
  freeVisits: "Free visits left:",
3556
3558
  subscribeNow: "Subscribe",
3557
3559
  alreadyHaveAccount: "Already have an account?",
@@ -3561,11 +3563,11 @@ var errors$7 = {
3561
3563
  "": ""
3562
3564
  };
3563
3565
  var meter_en = {
3564
- messages: messages$n,
3566
+ messages: messages$p,
3565
3567
  errors: errors$7
3566
3568
  };
3567
3569
 
3568
- var messages$m = {
3570
+ var messages$o = {
3569
3571
  freeVisits: "Visites gratuites restantes:",
3570
3572
  subscribeNow: "Abonnez-vous maintenant !",
3571
3573
  alreadyHaveAccount: "Vous avez déjà un compte ?",
@@ -3575,15 +3577,15 @@ var errors$6 = {
3575
3577
  "": ""
3576
3578
  };
3577
3579
  var meter_fr = {
3578
- messages: messages$m,
3580
+ messages: messages$o,
3579
3581
  errors: errors$6
3580
3582
  };
3581
3583
 
3582
- var messages$l = {
3584
+ var messages$n = {
3583
3585
  youAreSafe: "You're safe - PCI compliant 128 SSL by",
3584
3586
  bankRedirection: "Please hold, redirecting you to your bank."
3585
3587
  };
3586
- var labels$l = {
3588
+ var labels$n = {
3587
3589
  card: "Enter card number",
3588
3590
  date: "Expiration date",
3589
3591
  CVC: "CVC",
@@ -3602,15 +3604,15 @@ var labels$l = {
3602
3604
  removeCoupon: "REMOVE"
3603
3605
  };
3604
3606
  var checkoutForm_en = {
3605
- messages: messages$l,
3606
- labels: labels$l
3607
+ messages: messages$n,
3608
+ labels: labels$n
3607
3609
  };
3608
3610
 
3609
- var messages$k = {
3611
+ var messages$m = {
3610
3612
  youAreSafe: "Vous êtes en sécurité - PCI conforme 128 SSL par",
3611
3613
  bankRedirection: "Veuillez patienter, nous vous redirigeons vers votre banque."
3612
3614
  };
3613
- var labels$k = {
3615
+ var labels$m = {
3614
3616
  card: "Entrez le numéro de carte",
3615
3617
  date: "Date d’expiration",
3616
3618
  CVC: "CVC",
@@ -3629,8 +3631,8 @@ var labels$k = {
3629
3631
  removeCoupon: "RETIRER"
3630
3632
  };
3631
3633
  var checkoutForm_fr = {
3632
- messages: messages$k,
3633
- labels: labels$k
3634
+ messages: messages$m,
3635
+ labels: labels$m
3634
3636
  };
3635
3637
 
3636
3638
  var youAreSafe$1 = "You're safe - PCI compliant 128 SSL by";
@@ -3671,7 +3673,7 @@ var messages_fr = {
3671
3673
  zeroTotalInvoice: zeroTotalInvoice
3672
3674
  };
3673
3675
 
3674
- var labels$j = {
3676
+ var labels$l = {
3675
3677
  email: "Enter email",
3676
3678
  password: "Enter password",
3677
3679
  required: "required",
@@ -3679,7 +3681,7 @@ var labels$j = {
3679
3681
  passwordPlaceholder: "Password",
3680
3682
  login: "Login"
3681
3683
  };
3682
- var messages$j = {
3684
+ var messages$l = {
3683
3685
  loginTo: "Login to your account",
3684
3686
  welcome: "Welcome back, sign in with your existing account.",
3685
3687
  dontHaveAccount: "Don't have an account yet?",
@@ -3698,12 +3700,12 @@ var errors$5 = {
3698
3700
  "": ""
3699
3701
  };
3700
3702
  var login_en = {
3701
- labels: labels$j,
3702
- messages: messages$j,
3703
+ labels: labels$l,
3704
+ messages: messages$l,
3703
3705
  errors: errors$5
3704
3706
  };
3705
3707
 
3706
- var labels$i = {
3708
+ var labels$k = {
3707
3709
  email: "Entrez votre adresse courriel",
3708
3710
  password: "Entrez votre mot de passe",
3709
3711
  required: "Champs obligatoires",
@@ -3711,7 +3713,7 @@ var labels$i = {
3711
3713
  passwordPlaceholder: "Mot de passe",
3712
3714
  login: "Connexion"
3713
3715
  };
3714
- var messages$i = {
3716
+ var messages$k = {
3715
3717
  loginTo: "Connectez-vous à votre compte",
3716
3718
  welcome: "Bienvenue, connectez-vous avec votre compte existant.",
3717
3719
  dontHaveAccount: "Vous n’avez pas encore de compte ?",
@@ -3730,11 +3732,39 @@ var errors$4 = {
3730
3732
  "": ""
3731
3733
  };
3732
3734
  var login_fr = {
3733
- labels: labels$i,
3734
- messages: messages$i,
3735
+ labels: labels$k,
3736
+ messages: messages$k,
3735
3737
  errors: errors$4
3736
3738
  };
3737
3739
 
3740
+ var labels$j = {
3741
+ title: "Verifying Magin Link",
3742
+ instructions: "You're on your way!\nLet's confirm your email address.\nClick on the verification link we've sent to your email:",
3743
+ resend: "Resend email"
3744
+ };
3745
+ var messages$j = {
3746
+ resent: "Resent successfully",
3747
+ success: "Link verified successfully!"
3748
+ };
3749
+ var verifyLinkToken_en = {
3750
+ labels: labels$j,
3751
+ messages: messages$j
3752
+ };
3753
+
3754
+ var labels$i = {
3755
+ title: "Confirmez votre courriel",
3756
+ instructions: "Confirmez votre courriel.\nVeuillez cliquer sur le lien de vérification, qui vous a été envoyé à:",
3757
+ resend: "Renvoyer le courriel"
3758
+ };
3759
+ var messages$i = {
3760
+ resent: "Renvoyé avec succès",
3761
+ success: "Lien vérifiée avec succès"
3762
+ };
3763
+ var verifyLinkToken_fr = {
3764
+ labels: labels$i,
3765
+ messages: messages$i
3766
+ };
3767
+
3738
3768
  var title$d = "Create an account";
3739
3769
  var subtitle$5 = "Enter your email and password below";
3740
3770
  var labels$h = {
@@ -4654,17 +4684,17 @@ var invoiceDetails_en = {
4654
4684
  buttons: buttons$1
4655
4685
  };
4656
4686
 
4657
- var title = "Invoice details";
4687
+ var title = "Détails de la facture";
4658
4688
  var labels = {
4659
- summary: "Summary",
4689
+ summary: "Résumé",
4660
4690
  total: "Total",
4661
- amountPaid: "Amount paid",
4662
- amountDue: "Amount due",
4663
- creationDate: "Created on:"
4691
+ amountPaid: "Montant payé",
4692
+ amountDue: "Montant ",
4693
+ creationDate: "Créé le:"
4664
4694
  };
4665
4695
  var buttons = {
4666
- download: "Download",
4667
- pay: "Pay now"
4696
+ download: "Télécharger",
4697
+ pay: "Payer"
4668
4698
  };
4669
4699
  var invoiceDetails_fr = {
4670
4700
  title: title,
@@ -6021,7 +6051,7 @@ class PelcroActions {
6021
6051
  view,
6022
6052
  cartItems,
6023
6053
  ...otherStateFields
6024
- } = initialState$i;
6054
+ } = initialState$j;
6025
6055
  this.set(otherStateFields);
6026
6056
  });
6027
6057
 
@@ -6340,7 +6370,7 @@ class PelcroCallbacks {
6340
6370
 
6341
6371
  }
6342
6372
 
6343
- const initialState$i = {
6373
+ const initialState$j = {
6344
6374
  // View
6345
6375
  view: null,
6346
6376
  // Plans
@@ -6370,7 +6400,7 @@ const createPelcroStore = () => createStore(middleware_3((set, get) => {
6370
6400
  return {
6371
6401
  // Store setter
6372
6402
  set,
6373
- ...initialState$i,
6403
+ ...initialState$j,
6374
6404
  // State actions
6375
6405
  ...actions,
6376
6406
  // Callbacks
@@ -6406,6 +6436,19 @@ if (process.env.NODE_ENV === "development") {
6406
6436
  c$1("Pelcro Store", usePelcro);
6407
6437
  }
6408
6438
 
6439
+ /**
6440
+ * List of zero-decimal currencies.
6441
+ * @see https://stripe.com/docs/currencies#zero-decimal
6442
+ *
6443
+ */
6444
+
6445
+ const ZERO_DECIMAL_CURRENCIES = ['BIF', 'CLP', 'DJF', 'GNF', 'JPY', 'KMF', 'KRW', 'MGA', 'PYG', 'RWF', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF'];
6446
+ /**
6447
+ * @param {string}
6448
+ * @return {boolean}
6449
+ */
6450
+
6451
+ const isCurrencyZeroDecimal = currency => ZERO_DECIMAL_CURRENCIES.includes(currency);
6409
6452
  const sortCountries = countries => {
6410
6453
  const sortable = [];
6411
6454
  delete countries.CA;
@@ -6492,7 +6535,7 @@ const getFormattedPriceByLocal = (amount, currency = "USD", locale = "en") => {
6492
6535
  style: "currency",
6493
6536
  currency
6494
6537
  });
6495
- return formatter.format(amount / 100);
6538
+ return isCurrencyZeroDecimal(currency) ? formatter.format(amount) : formatter.format(amount / 100);
6496
6539
  };
6497
6540
  /** check wether or not the user have any addresses
6498
6541
  * @return {boolean} true if the user have at least one address, false otherwise
@@ -6509,7 +6552,7 @@ const calcAndFormatItemsTotal = (items, currency) => {
6509
6552
  let totalWithoutDividingBy100 = 0;
6510
6553
 
6511
6554
  for (const item of items) {
6512
- totalWithoutDividingBy100 += parseFloat(item.price ? (item.price * item.quantity).toFixed(2) : item.amount.toFixed(2));
6555
+ totalWithoutDividingBy100 += parseFloat(item.price ? isCurrencyZeroDecimal(currency) ? item.price * item.quantity : (item.price * item.quantity).toFixed(2) : isCurrencyZeroDecimal(currency) ? item.amount : item.amount.toFixed(2));
6513
6556
  }
6514
6557
 
6515
6558
  return getFormattedPriceByLocal(totalWithoutDividingBy100, currency, getPageOrDefaultLanguage());
@@ -6521,7 +6564,7 @@ const calcAndFormatItemsTotal = (items, currency) => {
6521
6564
  */
6522
6565
 
6523
6566
  const isValidViewFromURL = viewID => {
6524
- if (["login", "register", "plan-select", "gift-redeem", "password-forgot", "password-reset", "password-change", "payment-method-update", "user-edit", "newsletter", "address-create", "order-create", "cart", "email-verify", "invoice-details"].includes(viewID) || hasValidNewsletterUpdateUrl()) {
6567
+ if (["login", "register", "plan-select", "gift-redeem", "password-forgot", "password-reset", "password-change", "passwordless-login", "payment-method-update", "user-edit", "newsletter", "address-create", "order-create", "cart", "email-verify", "invoice-details"].includes(viewID) || hasValidNewsletterUpdateUrl()) {
6525
6568
  return true;
6526
6569
  }
6527
6570
 
@@ -6589,7 +6632,7 @@ const disableScroll = () => {
6589
6632
  }
6590
6633
  };
6591
6634
  const trackSubscriptionOnGA = () => {
6592
- var _ReactGA$set, _window$Pelcro$user$r5, _window$Pelcro$user$r6, _ReactGA$plugin, _ReactGA$plugin$execu, _ReactGA$plugin2, _ReactGA$plugin2$exec, _ReactGA$plugin3, _ReactGA$plugin3$exec, _ReactGA$event;
6635
+ var _window$Pelcro$user$r5, _window$Pelcro$user$r6, _ReactGA$set, _ReactGA$plugin, _ReactGA$plugin$execu, _ReactGA$plugin2, _ReactGA$plugin2$exec, _ReactGA$plugin3, _ReactGA$plugin3$exec, _ReactGA$event;
6593
6636
 
6594
6637
  const {
6595
6638
  product,
@@ -6610,13 +6653,14 @@ const trackSubscriptionOnGA = () => {
6610
6653
  return;
6611
6654
  }
6612
6655
 
6656
+ const currencyCode = (_window$Pelcro$user$r5 = (_window$Pelcro$user$r6 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r6 === void 0 ? void 0 : _window$Pelcro$user$r6.currency) !== null && _window$Pelcro$user$r5 !== void 0 ? _window$Pelcro$user$r5 : plan.currency;
6613
6657
  ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$set = ReactGA.set) === null || _ReactGA$set === void 0 ? void 0 : _ReactGA$set.call(ReactGA, {
6614
- currencyCode: (_window$Pelcro$user$r5 = (_window$Pelcro$user$r6 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r6 === void 0 ? void 0 : _window$Pelcro$user$r6.currency) !== null && _window$Pelcro$user$r5 !== void 0 ? _window$Pelcro$user$r5 : plan.currency
6658
+ currencyCode: currencyCode
6615
6659
  });
6616
6660
  ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$plugin = ReactGA.plugin) === null || _ReactGA$plugin === void 0 ? void 0 : (_ReactGA$plugin$execu = _ReactGA$plugin.execute) === null || _ReactGA$plugin$execu === void 0 ? void 0 : _ReactGA$plugin$execu.call(_ReactGA$plugin, "ecommerce", "addTransaction", {
6617
6661
  id: lastSubscriptionId,
6618
6662
  affiliation: "Pelcro",
6619
- revenue: plan !== null && plan !== void 0 && plan.amount ? plan.amount / 100 : 0,
6663
+ revenue: plan !== null && plan !== void 0 && plan.amount ? isCurrencyZeroDecimal(currencyCode) ? plan.amount : plan.amount / 100 : 0,
6620
6664
  coupon: couponCode
6621
6665
  });
6622
6666
  ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$plugin2 = ReactGA.plugin) === null || _ReactGA$plugin2 === void 0 ? void 0 : (_ReactGA$plugin2$exec = _ReactGA$plugin2.execute) === null || _ReactGA$plugin2$exec === void 0 ? void 0 : _ReactGA$plugin2$exec.call(_ReactGA$plugin2, "ecommerce", "addItem", {
@@ -6624,7 +6668,7 @@ const trackSubscriptionOnGA = () => {
6624
6668
  name: product.name,
6625
6669
  category: product.description,
6626
6670
  variant: plan.nickname,
6627
- price: plan !== null && plan !== void 0 && plan.amount ? plan.amount / 100 : 0,
6671
+ price: plan !== null && plan !== void 0 && plan.amount ? isCurrencyZeroDecimal(currencyCode) ? plan.amount : plan.amount / 100 : 0,
6628
6672
  quantity: 1
6629
6673
  });
6630
6674
  ReactGA === null || ReactGA === void 0 ? void 0 : (_ReactGA$plugin3 = ReactGA.plugin) === null || _ReactGA$plugin3 === void 0 ? void 0 : (_ReactGA$plugin3$exec = _ReactGA$plugin3.execute) === null || _ReactGA$plugin3$exec === void 0 ? void 0 : _ReactGA$plugin3$exec.call(_ReactGA$plugin3, "ecommerce", "send");
@@ -6736,6 +6780,7 @@ const resources = {
6736
6780
  checkoutForm: checkoutForm_en,
6737
6781
  messages: messages_en,
6738
6782
  login: login_en,
6783
+ verifyLinkToken: verifyLinkToken_en,
6739
6784
  register: register_en,
6740
6785
  userEdit: userEdit_en,
6741
6786
  address: address_en,
@@ -6760,6 +6805,7 @@ const resources = {
6760
6805
  checkoutForm: checkoutForm_fr,
6761
6806
  messages: messages_fr,
6762
6807
  login: login_fr,
6808
+ verifyLinkToken: verifyLinkToken_fr,
6763
6809
  register: register_fr,
6764
6810
  userEdit: userEdit_fr,
6765
6811
  address: address_fr,
@@ -8619,13 +8665,21 @@ const getErrorMessages = error => {
8619
8665
  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
8666
  }
8621
8667
 
8622
- const errorMessages = []; // enumerable error (ex: validation errors)
8668
+ if (error !== null && error !== void 0 && (_error$response5 = error.response) !== null && _error$response5 !== void 0 && (_error$response5$data = _error$response5.data) !== null && _error$response5$data !== void 0 && _error$response5$data.errors) {
8669
+ var _error$response6, _error$response6$data;
8670
+
8671
+ const errorMessages = []; // enumerable error (ex: validation errors)
8623
8672
 
8624
- 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]) => {
8625
- errorMessages.push(errorMessage);
8626
- }); // convert to multiline string
8673
+ Object.values(error === null || error === void 0 ? void 0 : (_error$response6 = error.response) === null || _error$response6 === void 0 ? void 0 : (_error$response6$data = _error$response6.data) === null || _error$response6$data === void 0 ? void 0 : _error$response6$data.errors).forEach(([errorMessage]) => {
8674
+ errorMessages.push(errorMessage);
8675
+ }); // convert to multiline string
8676
+
8677
+ return errorMessages.join("\n");
8678
+ }
8627
8679
 
8628
- return errorMessages.join("\n");
8680
+ if (error !== null && error !== void 0 && error.message) {
8681
+ return error.message;
8682
+ }
8629
8683
  };
8630
8684
  /**
8631
8685
  * Executes function after a wait time of inactivity
@@ -8657,7 +8711,7 @@ const debounce = (func, waitTime) => {
8657
8711
  function getSiteCardProcessor() {
8658
8712
  var _window$Pelcro$site$r;
8659
8713
 
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) {
8714
+ if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_gateway_settings) {
8661
8715
  return "vantiv";
8662
8716
  }
8663
8717
 
@@ -8753,7 +8807,7 @@ const loadPaymentSDKs = () => {
8753
8807
  } // Load Vantiv SDKs
8754
8808
 
8755
8809
 
8756
- const supportsVantiv = Boolean(window.Pelcro.site.read().vantiv_pay_page_id);
8810
+ const supportsVantiv = Boolean(window.Pelcro.site.read().vantiv_gateway_settings);
8757
8811
 
8758
8812
  if (supportsVantiv) {
8759
8813
  if (!window.jQuery) {
@@ -8761,7 +8815,10 @@ const loadPaymentSDKs = () => {
8761
8815
  }
8762
8816
 
8763
8817
  if (!window.EprotectIframeClient) {
8764
- window.Pelcro.helpers.loadSDK("https://request.eprotect.vantivprelive.com/eProtect/js/eProtect-iframe-client.min.js", "vantiv-eprotect-sdk");
8818
+ const PRELIVE_URL = "https://request.eprotect.vantivprelive.com/eProtect/js/eProtect-iframe-client.min.js";
8819
+ const PRODUCTION_URL = "https://request.eprotect.vantivcnp.com/eProtect/js/eProtect-iframe-client4.min.js";
8820
+ const scriptUrlToUse = window.Pelcro.site.read().vantiv_gateway_settings.environment === "production" ? PRODUCTION_URL : PRELIVE_URL;
8821
+ window.Pelcro.helpers.loadSDK(scriptUrlToUse, "vantiv-eprotect-sdk");
8765
8822
  }
8766
8823
  }
8767
8824
  };
@@ -8921,6 +8978,10 @@ const initViewFromURL = () => {
8921
8978
  return verifyEmailTokenFromUrl();
8922
8979
  }
8923
8980
 
8981
+ if (view === "passwordless-login") {
8982
+ return verifyLinkTokenFromUrl();
8983
+ }
8984
+
8924
8985
  if (view === "invoice-details") {
8925
8986
  return showInvoiceDetailsFromUrl();
8926
8987
  }
@@ -9101,6 +9162,18 @@ const verifyEmailTokenFromUrl = () => {
9101
9162
  });
9102
9163
  };
9103
9164
 
9165
+ const verifyLinkTokenFromUrl = () => {
9166
+ var _window$Pelcro$user$i, _window$Pelcro$user;
9167
+
9168
+ const isAlreadyLoggedIn = (_window$Pelcro$user$i = (_window$Pelcro$user = window.Pelcro.user) === null || _window$Pelcro$user === void 0 ? void 0 : _window$Pelcro$user.isAuthenticated()) !== null && _window$Pelcro$user$i !== void 0 ? _window$Pelcro$user$i : false;
9169
+ const loginToken = window.Pelcro.helpers.getURLParameter("token");
9170
+ if (isAlreadyLoggedIn || !loginToken) return;
9171
+ const {
9172
+ switchView
9173
+ } = usePelcro.getStore();
9174
+ return switchView("passwordless-login");
9175
+ };
9176
+
9104
9177
  const showInvoiceDetailsFromUrl = () => {
9105
9178
  const {
9106
9179
  isAuthenticated,
@@ -9476,8 +9549,9 @@ const LOAD_PAYMENT_METHODS = "LOAD_PAYMENT_METHODS";
9476
9549
  const GET_NEWSLETTERS_FETCH = "GET_NEWSLETTERS_FETCH";
9477
9550
  const GET_NEWSLETTERS_SUCCESS = "GET_NEWSLETTERS_SUCCESS";
9478
9551
  const SWITCH_TO_UPDATE = "SWITCH_TO_UPDATE";
9552
+ const LINK_TOKEN_VERIFY = "LINK_TOKEN_VERIFY";
9479
9553
 
9480
- const initialState$h = {
9554
+ const initialState$i = {
9481
9555
  email: "",
9482
9556
  password: "",
9483
9557
  emailError: null,
@@ -9488,10 +9562,10 @@ const initialState$h = {
9488
9562
  content: ""
9489
9563
  }
9490
9564
  };
9491
- const store$h = /*#__PURE__*/createContext(initialState$h);
9565
+ const store$i = /*#__PURE__*/createContext(initialState$i);
9492
9566
  const {
9493
- Provider: Provider$h
9494
- } = store$h;
9567
+ Provider: Provider$i
9568
+ } = store$i;
9495
9569
 
9496
9570
  const LoginContainer = ({
9497
9571
  style,
@@ -9598,7 +9672,7 @@ const LoginContainer = ({
9598
9672
  });
9599
9673
 
9600
9674
  case RESET_LOGIN_FORM:
9601
- return initialState$h;
9675
+ return initialState$i;
9602
9676
 
9603
9677
  case DISABLE_LOGIN_BUTTON:
9604
9678
  return lib_7({ ...state,
@@ -9616,12 +9690,12 @@ const LoginContainer = ({
9616
9690
  default:
9617
9691
  return state;
9618
9692
  }
9619
- }, initialState$h);
9693
+ }, initialState$i);
9620
9694
  return /*#__PURE__*/React__default.createElement("div", {
9621
9695
  style: { ...style
9622
9696
  },
9623
9697
  className: `pelcro-container pelcro-login-container ${className}`
9624
- }, /*#__PURE__*/React__default.createElement(Provider$h, {
9698
+ }, /*#__PURE__*/React__default.createElement(Provider$i, {
9625
9699
  value: {
9626
9700
  state,
9627
9701
  dispatch
@@ -9629,12 +9703,12 @@ const LoginContainer = ({
9629
9703
  }, children.length ? children.map((child, i) => {
9630
9704
  if (child) {
9631
9705
  return /*#__PURE__*/React__default.cloneElement(child, {
9632
- store: store$h,
9706
+ store: store$i,
9633
9707
  key: i
9634
9708
  });
9635
9709
  }
9636
9710
  }) : /*#__PURE__*/React__default.cloneElement(children, {
9637
- store: store$h
9711
+ store: store$i
9638
9712
  })));
9639
9713
  };
9640
9714
 
@@ -9672,6 +9746,7 @@ function Email({
9672
9746
  initWithUserEmail = true,
9673
9747
  disableEmailValidation,
9674
9748
  store,
9749
+ enableEmailEdit,
9675
9750
  ...otherProps
9676
9751
  }) {
9677
9752
  const {
@@ -9697,6 +9772,10 @@ function Email({
9697
9772
  }
9698
9773
 
9699
9774
  if (isEmailValid(email)) {
9775
+ dispatch({
9776
+ type: SET_EMAIL_ERROR,
9777
+ payload: null
9778
+ });
9700
9779
  return dispatch({
9701
9780
  type: SET_EMAIL,
9702
9781
  payload: email
@@ -9717,6 +9796,11 @@ function Email({
9717
9796
  }
9718
9797
  }
9719
9798
  }, [dispatch, email, finishedTyping]);
9799
+ useEffect(() => {
9800
+ if (!enableEmailEdit) {
9801
+ loadEmailIntoField();
9802
+ }
9803
+ }, [enableEmailEdit]);
9720
9804
  useEffect(() => {
9721
9805
  handleInputChange(email);
9722
9806
  }, [finishedTyping, email, handleInputChange]); // Initialize email field with user's email
@@ -9804,6 +9888,9 @@ function ConfirmPassword({
9804
9888
  store,
9805
9889
  ...otherProps
9806
9890
  }) {
9891
+ const {
9892
+ t
9893
+ } = useTranslation("common");
9807
9894
  const {
9808
9895
  dispatch,
9809
9896
  state: {
@@ -9828,7 +9915,7 @@ function ConfirmPassword({
9828
9915
  } else if (finishedTyping) {
9829
9916
  dispatch({
9830
9917
  type: SET_CONFIRM_PASSWORD_ERROR,
9831
- payload: "Confirm password is required."
9918
+ payload: t("validation.confirmPassword")
9832
9919
  });
9833
9920
  }
9834
9921
  }, [dispatch, password, finishedTyping]);
@@ -9879,7 +9966,7 @@ const LoginButton = ({
9879
9966
  buttonDisabled
9880
9967
  },
9881
9968
  dispatch
9882
- } = useContext(store$h);
9969
+ } = useContext(store$i);
9883
9970
  const {
9884
9971
  t
9885
9972
  } = useTranslation("login");
@@ -9900,11 +9987,11 @@ const LoginButton = ({
9900
9987
  };
9901
9988
 
9902
9989
  const LoginEmail = props => /*#__PURE__*/React__default.createElement(Email, Object.assign({
9903
- store: store$h
9990
+ store: store$i
9904
9991
  }, props));
9905
9992
 
9906
9993
  const LoginPassword = props => /*#__PURE__*/React__default.createElement(Password, Object.assign({
9907
- store: store$h
9994
+ store: store$i
9908
9995
  }, props));
9909
9996
 
9910
9997
  var _path$r;
@@ -9981,7 +10068,7 @@ var facebookLoginRenderProps = createCommonjsModule(function (module, exports) {
9981
10068
  var FacebookLogin = unwrapExports(facebookLoginRenderProps);
9982
10069
  facebookLoginRenderProps.FacebookLogin;
9983
10070
 
9984
- const initialState$g = {
10071
+ const initialState$h = {
9985
10072
  email: "",
9986
10073
  password: "",
9987
10074
  emailError: null,
@@ -9998,10 +10085,10 @@ const initialState$g = {
9998
10085
  content: ""
9999
10086
  }
10000
10087
  };
10001
- const store$g = /*#__PURE__*/createContext(initialState$g);
10088
+ const store$h = /*#__PURE__*/createContext(initialState$h);
10002
10089
  const {
10003
- Provider: Provider$g
10004
- } = store$g;
10090
+ Provider: Provider$h
10091
+ } = store$h;
10005
10092
 
10006
10093
  const RegisterContainer = ({
10007
10094
  style,
@@ -10184,7 +10271,7 @@ const RegisterContainer = ({
10184
10271
  });
10185
10272
 
10186
10273
  case RESET_LOGIN_FORM:
10187
- return initialState$g;
10274
+ return initialState$h;
10188
10275
 
10189
10276
  case DISABLE_REGISTRATION_BUTTON:
10190
10277
  return lib_7({ ...state,
@@ -10202,12 +10289,12 @@ const RegisterContainer = ({
10202
10289
  default:
10203
10290
  return state;
10204
10291
  }
10205
- }, initialState$g);
10292
+ }, initialState$h);
10206
10293
  return /*#__PURE__*/React__default.createElement("div", {
10207
10294
  style: { ...style
10208
10295
  },
10209
10296
  className: `pelcro-container pelcro-register-container ${className}`
10210
- }, /*#__PURE__*/React__default.createElement(Provider$g, {
10297
+ }, /*#__PURE__*/React__default.createElement(Provider$h, {
10211
10298
  value: {
10212
10299
  state,
10213
10300
  dispatch
@@ -10215,12 +10302,12 @@ const RegisterContainer = ({
10215
10302
  }, children.length ? children.map((child, i) => {
10216
10303
  if (child) {
10217
10304
  return /*#__PURE__*/React__default.cloneElement(child, {
10218
- store: store$g,
10305
+ store: store$h,
10219
10306
  key: i
10220
10307
  });
10221
10308
  }
10222
10309
  }) : /*#__PURE__*/React__default.cloneElement(children, {
10223
- store: store$g
10310
+ store: store$h
10224
10311
  })));
10225
10312
  };
10226
10313
  /**
@@ -10260,10 +10347,10 @@ const FacebookLoginButton = ({
10260
10347
  const facebookLoginEnabled = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.facebook_app_id;
10261
10348
  const {
10262
10349
  dispatch: loginDispatch
10263
- } = useContext(store$h);
10350
+ } = useContext(store$i);
10264
10351
  const {
10265
10352
  dispatch: registerDispatch
10266
- } = useContext(store$g);
10353
+ } = useContext(store$h);
10267
10354
 
10268
10355
  const onSuccess = facebookUser => {
10269
10356
  loginDispatch === null || loginDispatch === void 0 ? void 0 : loginDispatch({
@@ -10350,10 +10437,10 @@ const GoogleLoginButton = ({
10350
10437
  const googleLoginEnabled = (_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.google_app_id;
10351
10438
  const {
10352
10439
  dispatch: loginDispatch
10353
- } = useContext(store$h);
10440
+ } = useContext(store$i);
10354
10441
  const {
10355
10442
  dispatch: registerDispatch
10356
- } = useContext(store$g);
10443
+ } = useContext(store$h);
10357
10444
 
10358
10445
  const onSuccess = response => {
10359
10446
  var _response$getAuthResp, _profile$getEmail, _profile$getGivenName, _profile$getFamilyNam, _profile$getEmail2, _profile$getGivenName2, _profile$getFamilyNam2;
@@ -10449,10 +10536,10 @@ const Auth0LoginButton = ({
10449
10536
  }, [auth0Enabled, auth0Loaded]);
10450
10537
  const {
10451
10538
  dispatch: loginDispatch
10452
- } = useContext(store$h);
10539
+ } = useContext(store$i);
10453
10540
  const {
10454
10541
  dispatch: registerDispatch
10455
- } = useContext(store$g);
10542
+ } = useContext(store$h);
10456
10543
 
10457
10544
  function handleClick() {
10458
10545
  var _auth0InstanceRef$cur, _auth0InstanceRef$cur2, _auth0InstanceRef$cur3;
@@ -10740,11 +10827,11 @@ function LoginModal({
10740
10827
  LoginModal.viewId = "login";
10741
10828
 
10742
10829
  const RegisterEmail = props => /*#__PURE__*/React__default.createElement(Email, Object.assign({
10743
- store: store$g
10830
+ store: store$h
10744
10831
  }, props));
10745
10832
 
10746
10833
  const RegisterPassword = props => /*#__PURE__*/React__default.createElement(Password, Object.assign({
10747
- store: store$g
10834
+ store: store$h
10748
10835
  }, props));
10749
10836
 
10750
10837
  const RegisterButton = ({
@@ -10764,7 +10851,7 @@ const RegisterButton = ({
10764
10851
  buttonDisabled
10765
10852
  },
10766
10853
  dispatch
10767
- } = useContext(store$g);
10854
+ } = useContext(store$h);
10768
10855
  const {
10769
10856
  t
10770
10857
  } = useTranslation("register");
@@ -10902,7 +10989,7 @@ function FirstName({
10902
10989
  }
10903
10990
 
10904
10991
  const RegisterFirstName = props => /*#__PURE__*/React__default.createElement(FirstName, Object.assign({
10905
- store: store$g
10992
+ store: store$h
10906
10993
  }, props));
10907
10994
 
10908
10995
  function LastName({
@@ -10933,7 +11020,7 @@ function LastName({
10933
11020
  }
10934
11021
 
10935
11022
  const RegisterLastName = props => /*#__PURE__*/React__default.createElement(LastName, Object.assign({
10936
- store: store$g
11023
+ store: store$h
10937
11024
  }, props));
10938
11025
 
10939
11026
  /**
@@ -11057,7 +11144,7 @@ function TextInput({
11057
11144
 
11058
11145
  const RegisterTextInput = props => {
11059
11146
  return /*#__PURE__*/React__default.createElement(TextInput, Object.assign({}, props, {
11060
- store: store$g
11147
+ store: store$h
11061
11148
  }));
11062
11149
  };
11063
11150
 
@@ -12713,20 +12800,21 @@ var es_12 = es.injectStripe;
12713
12800
  var es_13 = es.StripeProvider;
12714
12801
 
12715
12802
  /**
12716
- * @TODO: All subscription related business logic should end up moving
12803
+ * @TODO: All payment related business logic should end up moving
12717
12804
  * to this service, and out of react components.
12718
12805
  */
12719
12806
 
12720
12807
  /**
12721
- * Enum for subscription types
12808
+ * Enum for payment types
12722
12809
  * @readonly
12723
12810
  * @enum {string}
12724
12811
  */
12725
- const SUBSCRIPTION_TYPES = {
12812
+ const PAYMENT_TYPES = {
12726
12813
  CREATE_SUBSCRIPTION: "CREATE_SUBSCRIPTION",
12727
12814
  CREATE_GIFTED_SUBSCRIPTION: "CREATE_GIFTED_SUBSCRIPTION",
12728
12815
  RENEW_SUBSCRIPTION: "RENEW_SUBSCRIPTION",
12729
12816
  RENEW_GIFTED_SUBSCRIPTION: "RENEW_GIFTED_SUBSCRIPTION",
12817
+ PURCHASE_ECOMMERCE_ORDER: "PURCHASE_ECOMMERCE_ORDER",
12730
12818
  PAY_INVOICE: "PAY_INVOICE"
12731
12819
  };
12732
12820
 
@@ -12734,9 +12822,8 @@ var _isPaymentGatewayInvalid = /*#__PURE__*/new WeakMap();
12734
12822
 
12735
12823
  var _generateUserError = /*#__PURE__*/new WeakMap();
12736
12824
 
12737
- class Subscription {
12825
+ class Payment {
12738
12826
  /**
12739
- * Subscription service constructor
12740
12827
  * @param {(StripeGateway|PaypalGateway|VantivGateway)} paymentGateway
12741
12828
  */
12742
12829
  constructor(paymentGateway) {
@@ -12748,7 +12835,7 @@ class Subscription {
12748
12835
 
12749
12836
  if (!options.type) {
12750
12837
  callback(_classPrivateFieldGet(this, _generateUserError).call(this), null);
12751
- return console.error("No subscription type provided");
12838
+ return console.error("No payment type provided");
12752
12839
  } // delegate execution to paymentgateway
12753
12840
 
12754
12841
 
@@ -12766,21 +12853,21 @@ class Subscription {
12766
12853
  writable: true,
12767
12854
  value: () => {
12768
12855
  return {
12769
- error: new Error("An error has occured in the subscription service, please try again later")
12856
+ error: new Error("An error has occured in the payment service, please try again later")
12770
12857
  };
12771
12858
  }
12772
12859
  });
12773
12860
 
12774
12861
  if (_classPrivateFieldGet(this, _isPaymentGatewayInvalid).call(this, paymentGateway)) {
12775
12862
  this.paymentGateway = null;
12776
- console.error("Incompatible subscription gateway");
12863
+ console.error("Incompatible payment gateway");
12777
12864
  } else {
12778
12865
  this.paymentGateway = paymentGateway;
12779
12866
  }
12780
12867
  }
12781
12868
  /**
12782
- * @typedef subscriptionOptions
12783
- * @property {SUBSCRIPTION_TYPES} type
12869
+ * @typedef paymentOptions
12870
+ * @property {PAYMENT_TYPES} type
12784
12871
  * @property {string} token
12785
12872
  * @property {object} plan
12786
12873
  * @property {object} [product]
@@ -12791,6 +12878,7 @@ class Subscription {
12791
12878
  * @property {string} addressId
12792
12879
  * @property {number} invoiceId
12793
12880
  * @property {boolean} isExistingSource
12881
+ * @property {Array} items
12794
12882
  */
12795
12883
 
12796
12884
  /**
@@ -12801,8 +12889,8 @@ class Subscription {
12801
12889
  */
12802
12890
 
12803
12891
  /**
12804
- * Subscription execution method
12805
- * @param {subscriptionOptions} options subscription options
12892
+ * Payment execution method
12893
+ * @param {paymentOptions} options payment options
12806
12894
  * @param {executeCallback} callback
12807
12895
  * @return {void}
12808
12896
  */
@@ -12815,7 +12903,7 @@ const PAYMENT_GATEWAYS_ENUM = {
12815
12903
  vantiv: "vantiv"
12816
12904
  };
12817
12905
  /**
12818
- * Subscription Strategies
12906
+ * Payment Strategies
12819
12907
  */
12820
12908
 
12821
12909
  /**
@@ -12832,6 +12920,8 @@ var _renewSubscription = /*#__PURE__*/new WeakMap();
12832
12920
 
12833
12921
  var _renewGiftedSubscription = /*#__PURE__*/new WeakMap();
12834
12922
 
12923
+ var _purchaseEcommerceOrder = /*#__PURE__*/new WeakMap();
12924
+
12835
12925
  var _payInvoice = /*#__PURE__*/new WeakMap();
12836
12926
 
12837
12927
  class StripeGateway {
@@ -12842,7 +12932,7 @@ class StripeGateway {
12842
12932
  });
12843
12933
 
12844
12934
  _defineProperty$3(this, "execute", (options, callback) => {
12845
- const types = SUBSCRIPTION_TYPES;
12935
+ const types = PAYMENT_TYPES;
12846
12936
 
12847
12937
  switch (options.type) {
12848
12938
  case types.CREATE_SUBSCRIPTION:
@@ -12857,11 +12947,14 @@ class StripeGateway {
12857
12947
  case types.RENEW_GIFTED_SUBSCRIPTION:
12858
12948
  return _classPrivateFieldGet(this, _renewGiftedSubscription).call(this, options, callback);
12859
12949
 
12950
+ case types.PURCHASE_ECOMMERCE_ORDER:
12951
+ return _classPrivateFieldGet(this, _purchaseEcommerceOrder).call(this, options, callback);
12952
+
12860
12953
  case types.PAY_INVOICE:
12861
12954
  return _classPrivateFieldGet(this, _payInvoice).call(this, options, callback);
12862
12955
 
12863
12956
  default:
12864
- console.error("Unsupported subscriptiion method: Stripe Gateway");
12957
+ console.error("Unsupported payment method: Stripe Gateway");
12865
12958
  }
12866
12959
  });
12867
12960
 
@@ -12883,6 +12976,7 @@ class StripeGateway {
12883
12976
  auth_token: window.Pelcro.user.read().auth_token,
12884
12977
  plan_id: plan.id,
12885
12978
  coupon_code: couponCode,
12979
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
12886
12980
  address_id: product.address_required ? addressId : null
12887
12981
  }, (err, res) => {
12888
12982
  callback(err, res);
@@ -12909,6 +13003,7 @@ class StripeGateway {
12909
13003
  auth_token: window.Pelcro.user.read().auth_token,
12910
13004
  plan_id: plan.id,
12911
13005
  coupon_code: couponCode,
13006
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
12912
13007
  gift_recipient_email: giftRecipient.email,
12913
13008
  gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
12914
13009
  gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
@@ -12936,6 +13031,7 @@ class StripeGateway {
12936
13031
  stripe_token: token,
12937
13032
  auth_token: window.Pelcro.user.read().auth_token,
12938
13033
  plan_id: plan.id,
13034
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
12939
13035
  coupon_code: couponCode,
12940
13036
  subscription_id: subscriptionIdToRenew,
12941
13037
  address_id: product.address_required ? addressId : null
@@ -12969,6 +13065,36 @@ class StripeGateway {
12969
13065
  }
12970
13066
  });
12971
13067
 
13068
+ _purchaseEcommerceOrder.set(this, {
13069
+ writable: true,
13070
+ value: (options, callback) => {
13071
+ const {
13072
+ token,
13073
+ items,
13074
+ couponCode,
13075
+ addressId,
13076
+ isExistingSource
13077
+ } = options;
13078
+ const params = isExistingSource ? {
13079
+ source_id: token
13080
+ } : {
13081
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway),
13082
+ gateway_token: token
13083
+ };
13084
+ window.Pelcro.ecommerce.order.create({
13085
+ items,
13086
+ coupon_code: couponCode,
13087
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13088
+ ...params,
13089
+ ...(addressId && {
13090
+ address_id: addressId
13091
+ })
13092
+ }, (err, res) => {
13093
+ callback(err, res);
13094
+ });
13095
+ }
13096
+ });
13097
+
12972
13098
  _payInvoice.set(this, {
12973
13099
  writable: true,
12974
13100
  value: (options, callback) => {
@@ -13012,7 +13138,7 @@ class PaypalGateway {
13012
13138
  });
13013
13139
 
13014
13140
  _defineProperty$3(this, "execute", (options, callback) => {
13015
- const types = SUBSCRIPTION_TYPES;
13141
+ const types = PAYMENT_TYPES;
13016
13142
 
13017
13143
  switch (options.type) {
13018
13144
  case types.CREATE_SUBSCRIPTION:
@@ -13046,6 +13172,7 @@ class PaypalGateway {
13046
13172
  payment_gateway: _classPrivateFieldGet(this, _paymentGateway2),
13047
13173
  auth_token: window.Pelcro.user.read().auth_token,
13048
13174
  plan_id: plan.id,
13175
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13049
13176
  coupon_code: couponCode,
13050
13177
  address_id: product.address_required ? addressId : null
13051
13178
  }, (err, res) => {
@@ -13073,6 +13200,7 @@ class PaypalGateway {
13073
13200
  auth_token: window.Pelcro.user.read().auth_token,
13074
13201
  plan_id: plan.id,
13075
13202
  coupon_code: couponCode,
13203
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13076
13204
  gift_recipient_email: giftRecipient.email,
13077
13205
  gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
13078
13206
  gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
@@ -13109,6 +13237,16 @@ var _paymentGateway3 = /*#__PURE__*/new WeakMap();
13109
13237
 
13110
13238
  var _createSubscription3 = /*#__PURE__*/new WeakMap();
13111
13239
 
13240
+ var _renewSubscription2 = /*#__PURE__*/new WeakMap();
13241
+
13242
+ var _createGiftedSubscription3 = /*#__PURE__*/new WeakMap();
13243
+
13244
+ var _renewGiftedSubscription2 = /*#__PURE__*/new WeakMap();
13245
+
13246
+ var _purchaseEcommerceOrder2 = /*#__PURE__*/new WeakMap();
13247
+
13248
+ var _payInvoice3 = /*#__PURE__*/new WeakMap();
13249
+
13112
13250
  class VantivGateway {
13113
13251
  constructor() {
13114
13252
  _paymentGateway3.set(this, {
@@ -13117,14 +13255,29 @@ class VantivGateway {
13117
13255
  });
13118
13256
 
13119
13257
  _defineProperty$3(this, "execute", (options, callback) => {
13120
- const types = SUBSCRIPTION_TYPES;
13258
+ const types = PAYMENT_TYPES;
13121
13259
 
13122
13260
  switch (options.type) {
13123
13261
  case types.CREATE_SUBSCRIPTION:
13124
13262
  return _classPrivateFieldGet(this, _createSubscription3).call(this, options, callback);
13125
13263
 
13264
+ case types.RENEW_SUBSCRIPTION:
13265
+ return _classPrivateFieldGet(this, _renewSubscription2).call(this, options, callback);
13266
+
13267
+ case types.CREATE_GIFTED_SUBSCRIPTION:
13268
+ return _classPrivateFieldGet(this, _createGiftedSubscription3).call(this, options, callback);
13269
+
13270
+ case types.RENEW_GIFTED_SUBSCRIPTION:
13271
+ return _classPrivateFieldGet(this, _renewGiftedSubscription2).call(this, options, callback);
13272
+
13273
+ case types.PURCHASE_ECOMMERCE_ORDER:
13274
+ return _classPrivateFieldGet(this, _purchaseEcommerceOrder2).call(this, options, callback);
13275
+
13276
+ case types.PAY_INVOICE:
13277
+ return _classPrivateFieldGet(this, _payInvoice3).call(this, options, callback);
13278
+
13126
13279
  default:
13127
- console.error("Unsupported subscriptiion method: vantiv Gateway");
13280
+ console.error("Unsupported payment method: vantiv Gateway");
13128
13281
  }
13129
13282
  });
13130
13283
 
@@ -13137,38 +13290,197 @@ class VantivGateway {
13137
13290
  couponCode,
13138
13291
  product,
13139
13292
  quantity = 1,
13140
- addressId
13293
+ addressId,
13294
+ isExistingSource
13141
13295
  } = options;
13296
+ const params = isExistingSource ? {
13297
+ source_id: token
13298
+ } : {
13299
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13300
+ gateway_token: token
13301
+ };
13142
13302
  window.Pelcro.subscription.create({
13143
13303
  quantity,
13144
- gateway_token: token,
13304
+ auth_token: window.Pelcro.user.read().auth_token,
13305
+ plan_id: plan.id,
13306
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13307
+ coupon_code: couponCode,
13308
+ address_id: product.address_required ? addressId : null,
13309
+ ...params
13310
+ }, (err, res) => {
13311
+ callback(err, res);
13312
+ });
13313
+ }
13314
+ });
13315
+
13316
+ _renewSubscription2.set(this, {
13317
+ writable: true,
13318
+ value: (options, callback) => {
13319
+ const {
13320
+ subscriptionIdToRenew,
13321
+ token,
13322
+ plan,
13323
+ couponCode,
13324
+ product,
13325
+ addressId,
13326
+ isExistingSource
13327
+ } = options;
13328
+ const params = isExistingSource ? {
13329
+ source_id: token
13330
+ } : {
13145
13331
  payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13332
+ gateway_token: token
13333
+ };
13334
+ window.Pelcro.subscription.renew({
13146
13335
  auth_token: window.Pelcro.user.read().auth_token,
13147
13336
  plan_id: plan.id,
13148
13337
  coupon_code: couponCode,
13149
- address_id: product.address_required ? addressId : null
13338
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13339
+ subscription_id: subscriptionIdToRenew,
13340
+ address_id: product.address_required ? addressId : null,
13341
+ ...params
13150
13342
  }, (err, res) => {
13151
13343
  callback(err, res);
13152
13344
  });
13153
13345
  }
13154
13346
  });
13155
- }
13156
13347
 
13157
- }
13348
+ _createGiftedSubscription3.set(this, {
13349
+ writable: true,
13350
+ value: (options, callback) => {
13351
+ const {
13352
+ token,
13353
+ plan,
13354
+ couponCode,
13355
+ product,
13356
+ giftRecipient,
13357
+ quantity = 1,
13358
+ addressId,
13359
+ isExistingSource
13360
+ } = options;
13361
+ const params = isExistingSource ? {
13362
+ source_id: token
13363
+ } : {
13364
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13365
+ gateway_token: token
13366
+ };
13367
+ window.Pelcro.subscription.create({
13368
+ quantity,
13369
+ auth_token: window.Pelcro.user.read().auth_token,
13370
+ plan_id: plan.id,
13371
+ coupon_code: couponCode,
13372
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13373
+ gift_recipient_email: giftRecipient.email,
13374
+ gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
13375
+ gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
13376
+ gift_start_date: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.startDate,
13377
+ gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
13378
+ address_id: product.address_required ? addressId : null,
13379
+ ...params
13380
+ }, (err, res) => {
13381
+ callback(err, res);
13382
+ });
13383
+ }
13384
+ });
13158
13385
 
13159
- /**
13160
- * @typedef {Object} PaymentStateType
13161
- * @property {boolean} disableSubmit
13162
- * @property {boolean} isLoading
13163
- * @property {boolean} disableCouponButton
13164
- * @property {object} couponObject
13165
- * @property {string} couponCode
13166
- * @property {string} couponError
13167
- * @property {boolean} enableCouponField
13168
- * @property {string} percentOff
13169
- * @property {unknown} canMakePayment
13170
- * @property {unknown} paymentRequest
13171
- * @property {number} updatedPrice
13386
+ _renewGiftedSubscription2.set(this, {
13387
+ writable: true,
13388
+ value: (options, callback) => {
13389
+ const {
13390
+ subscriptionIdToRenew,
13391
+ token,
13392
+ product,
13393
+ plan,
13394
+ couponCode,
13395
+ addressId,
13396
+ isExistingSource
13397
+ } = options;
13398
+ const params = isExistingSource ? {
13399
+ source_id: token
13400
+ } : {
13401
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13402
+ gateway_token: token
13403
+ };
13404
+ window.Pelcro.subscription.renewGift({
13405
+ auth_token: window.Pelcro.user.read().auth_token,
13406
+ plan_id: plan.id,
13407
+ coupon_code: couponCode,
13408
+ subscription_id: subscriptionIdToRenew,
13409
+ address_id: product.address_required ? addressId : null,
13410
+ ...params
13411
+ }, (err, res) => {
13412
+ callback(err, res);
13413
+ });
13414
+ }
13415
+ });
13416
+
13417
+ _purchaseEcommerceOrder2.set(this, {
13418
+ writable: true,
13419
+ value: (options, callback) => {
13420
+ const {
13421
+ token,
13422
+ items,
13423
+ couponCode,
13424
+ addressId,
13425
+ isExistingSource
13426
+ } = options;
13427
+ const params = isExistingSource ? {
13428
+ source_id: token
13429
+ } : {
13430
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13431
+ gateway_token: token
13432
+ };
13433
+ window.Pelcro.ecommerce.order.create({
13434
+ items,
13435
+ coupon_code: couponCode,
13436
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13437
+ ...params,
13438
+ ...(addressId && {
13439
+ address_id: addressId
13440
+ })
13441
+ }, (err, res) => {
13442
+ callback(err, res);
13443
+ });
13444
+ }
13445
+ });
13446
+
13447
+ _payInvoice3.set(this, {
13448
+ writable: true,
13449
+ value: (options, callback) => {
13450
+ const {
13451
+ token,
13452
+ invoiceId
13453
+ } = options;
13454
+ const params = options.isExistingSource ? {
13455
+ source_id: token,
13456
+ invoice_id: invoiceId
13457
+ } : {
13458
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway3),
13459
+ gateway_token: token,
13460
+ invoice_id: invoiceId
13461
+ };
13462
+ window.Pelcro.invoice.pay(params, (err, res) => {
13463
+ callback(err, res);
13464
+ });
13465
+ }
13466
+ });
13467
+ }
13468
+
13469
+ }
13470
+
13471
+ /**
13472
+ * @typedef {Object} PaymentStateType
13473
+ * @property {boolean} disableSubmit
13474
+ * @property {boolean} isLoading
13475
+ * @property {boolean} disableCouponButton
13476
+ * @property {object} couponObject
13477
+ * @property {string} couponCode
13478
+ * @property {string} couponError
13479
+ * @property {boolean} enableCouponField
13480
+ * @property {string} percentOff
13481
+ * @property {unknown} canMakePayment
13482
+ * @property {unknown} paymentRequest
13483
+ * @property {number} updatedPrice
13172
13484
  * @property {number} taxAmount
13173
13485
  * @property {object} currentPlan
13174
13486
  * @property {object} alert
@@ -13176,7 +13488,7 @@ class VantivGateway {
13176
13488
 
13177
13489
  /** @type {PaymentStateType} */
13178
13490
 
13179
- const initialState$f = {
13491
+ const initialState$g = {
13180
13492
  disableSubmit: false,
13181
13493
  isLoading: false,
13182
13494
  disableCouponButton: false,
@@ -13195,10 +13507,10 @@ const initialState$f = {
13195
13507
  content: ""
13196
13508
  }
13197
13509
  };
13198
- const store$f = /*#__PURE__*/createContext(initialState$f);
13510
+ const store$g = /*#__PURE__*/createContext(initialState$g);
13199
13511
  const {
13200
- Provider: Provider$f
13201
- } = store$f;
13512
+ Provider: Provider$g
13513
+ } = store$g;
13202
13514
 
13203
13515
  const PaymentMethodContainerWithoutStripe = ({
13204
13516
  style,
@@ -13211,7 +13523,7 @@ const PaymentMethodContainerWithoutStripe = ({
13211
13523
  onFailure = () => {},
13212
13524
  ...props
13213
13525
  }) => {
13214
- var _props$product, _props$plan, _props$subscriptionId, _props$selectedAddres, _props$giftRecipient, _props$isRenewingGift, _props$invoice;
13526
+ var _props$product, _props$plan, _props$subscriptionId, _props$selectedAddres, _props$giftRecipient, _props$isGift, _props$isRenewingGift, _props$invoice;
13215
13527
 
13216
13528
  const {
13217
13529
  t
@@ -13227,6 +13539,7 @@ const PaymentMethodContainerWithoutStripe = ({
13227
13539
  const subscriptionIdToRenew = (_props$subscriptionId = props.subscriptionIdToRenew) !== null && _props$subscriptionId !== void 0 ? _props$subscriptionId : pelcroStore.subscriptionIdToRenew;
13228
13540
  const selectedAddressId = (_props$selectedAddres = props.selectedAddressId) !== null && _props$selectedAddres !== void 0 ? _props$selectedAddres : pelcroStore.selectedAddressId;
13229
13541
  const giftRecipient = (_props$giftRecipient = props.giftRecipient) !== null && _props$giftRecipient !== void 0 ? _props$giftRecipient : pelcroStore.giftRecipient;
13542
+ const isGift = (_props$isGift = props.isGift) !== null && _props$isGift !== void 0 ? _props$isGift : pelcroStore.isGift;
13230
13543
  const isRenewingGift = (_props$isRenewingGift = props.isRenewingGift) !== null && _props$isRenewingGift !== void 0 ? _props$isRenewingGift : pelcroStore.isRenewingGift;
13231
13544
  const invoice = (_props$invoice = props.invoice) !== null && _props$invoice !== void 0 ? _props$invoice : pelcroStore.invoice;
13232
13545
  useEffect(() => {
@@ -13243,60 +13556,185 @@ const PaymentMethodContainerWithoutStripe = ({
13243
13556
  updateTotalAmountWithTax();
13244
13557
  }, []);
13245
13558
 
13246
- function submitVantivPayment() {
13559
+ const submitUsingVantiv = () => {
13560
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
13561
+
13562
+ if (isUsingExistingPaymentMethod) {
13563
+ // no need to create a new source using vantiv
13564
+ return handleVantivPayment(null);
13565
+ }
13566
+
13247
13567
  if (!vantivInstanceRef.current) {
13248
13568
  return console.error("Vantiv sdk script wasn't loaded, you need to load vantiv sdk before rendering the vantiv payment flow");
13249
13569
  }
13250
13570
 
13251
- const orderId = `pelcro-${new Date().getTime()}`; // calls handleVantivPayment
13571
+ const orderId = `pelcro-${new Date().getTime()}`;
13572
+ /*
13573
+ calls handleVantivPayment to either handle a payment or update a source by simply creating a new source
13574
+ */
13252
13575
 
13253
13576
  vantivInstanceRef.current.getPaypageRegistrationId({
13254
13577
  id: orderId,
13255
13578
  orderId: orderId
13256
13579
  });
13257
- }
13580
+ };
13258
13581
 
13259
13582
  function handleVantivPayment(paymentRequest) {
13260
- const SUCCESS_STATUS = "870";
13583
+ if (paymentRequest) {
13584
+ const SUCCESS_STATUS = "870";
13585
+
13586
+ if (paymentRequest.response !== SUCCESS_STATUS) {
13587
+ return handlePaymentError({
13588
+ error: new Error(paymentRequest.message)
13589
+ });
13590
+ }
13591
+ }
13592
+
13593
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
13594
+
13595
+ if (type === "createPayment") {
13596
+ handleVantivSubscription();
13597
+ } else if (type === "orderCreate") {
13598
+ purchase(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
13599
+ } else if (type === "invoicePayment") {
13600
+ payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
13601
+ } else if (type === "updatePaymentSource") {
13602
+ createNewVantivCard();
13603
+ }
13604
+
13605
+ function createNewVantivCard() {
13606
+ window.Pelcro.source.create({
13607
+ auth_token: window.Pelcro.user.read().auth_token,
13608
+ token: paymentRequest,
13609
+ gateway: "vantiv"
13610
+ }, (err, res) => {
13611
+ dispatch({
13612
+ type: DISABLE_SUBMIT,
13613
+ payload: false
13614
+ });
13615
+ dispatch({
13616
+ type: LOADING,
13617
+ payload: false
13618
+ });
13619
+
13620
+ if (err) {
13621
+ onFailure(err);
13622
+ return dispatch({
13623
+ type: SHOW_ALERT,
13624
+ payload: {
13625
+ type: "error",
13626
+ content: getErrorMessages(err)
13627
+ }
13628
+ });
13629
+ }
13261
13630
 
13262
- if (paymentRequest.response !== SUCCESS_STATUS) {
13263
- return handlePaymentError({
13264
- error: new Error(paymentRequest.message)
13631
+ dispatch({
13632
+ type: SHOW_ALERT,
13633
+ payload: {
13634
+ type: "success",
13635
+ content: t("messages.sourceUpdated")
13636
+ }
13637
+ });
13638
+ onSuccess(res);
13265
13639
  });
13266
13640
  }
13267
13641
 
13268
- const subscription = new Subscription(new VantivGateway());
13269
- const {
13270
- couponCode
13271
- } = state;
13272
- return subscription.execute({
13273
- type: SUBSCRIPTION_TYPES.CREATE_SUBSCRIPTION,
13274
- token: paymentRequest,
13275
- quantity: plan.quantity,
13276
- plan,
13277
- couponCode,
13278
- product,
13279
- addressId: selectedAddressId
13280
- }, (err, res) => {
13281
- if (err) {
13282
- return handlePaymentError(err);
13283
- }
13642
+ function handleVantivSubscription() {
13643
+ const payment = new Payment(new VantivGateway());
13644
+ const createSubscription = !isGift && !subscriptionIdToRenew;
13645
+ const renewSubscription = !isGift && subscriptionIdToRenew;
13646
+ const giftSubscriprition = isGift && !subscriptionIdToRenew;
13647
+ const renewGift = isRenewingGift;
13648
+ const {
13649
+ couponCode
13650
+ } = state;
13284
13651
 
13285
- onSuccess(res);
13286
- });
13652
+ if (renewGift) {
13653
+ return payment.execute({
13654
+ type: PAYMENT_TYPES.RENEW_GIFTED_SUBSCRIPTION,
13655
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
13656
+ plan,
13657
+ couponCode,
13658
+ product,
13659
+ isExistingSource: isUsingExistingPaymentMethod,
13660
+ subscriptionIdToRenew,
13661
+ addressId: selectedAddressId
13662
+ }, (err, res) => {
13663
+ if (err) {
13664
+ return handlePaymentError(err);
13665
+ }
13666
+
13667
+ onSuccess(res);
13668
+ });
13669
+ } else if (giftSubscriprition) {
13670
+ return payment.execute({
13671
+ type: PAYMENT_TYPES.CREATE_GIFTED_SUBSCRIPTION,
13672
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
13673
+ quantity: plan.quantity,
13674
+ plan,
13675
+ couponCode,
13676
+ product,
13677
+ isExistingSource: isUsingExistingPaymentMethod,
13678
+ giftRecipient,
13679
+ addressId: selectedAddressId
13680
+ }, (err, res) => {
13681
+ if (err) {
13682
+ return handlePaymentError(err);
13683
+ }
13684
+
13685
+ onSuccess(res);
13686
+ });
13687
+ } else if (renewSubscription) {
13688
+ return payment.execute({
13689
+ type: PAYMENT_TYPES.RENEW_SUBSCRIPTION,
13690
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
13691
+ quantity: plan.quantity,
13692
+ plan,
13693
+ couponCode,
13694
+ product,
13695
+ isExistingSource: isUsingExistingPaymentMethod,
13696
+ subscriptionIdToRenew,
13697
+ addressId: selectedAddressId
13698
+ }, (err, res) => {
13699
+ if (err) {
13700
+ return handlePaymentError(err);
13701
+ }
13702
+
13703
+ onSuccess(res);
13704
+ });
13705
+ } else if (createSubscription) {
13706
+ return payment.execute({
13707
+ type: PAYMENT_TYPES.CREATE_SUBSCRIPTION,
13708
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
13709
+ quantity: plan.quantity,
13710
+ plan,
13711
+ couponCode,
13712
+ product,
13713
+ isExistingSource: isUsingExistingPaymentMethod,
13714
+ addressId: selectedAddressId
13715
+ }, (err, res) => {
13716
+ if (err) {
13717
+ return handlePaymentError(err);
13718
+ }
13719
+
13720
+ onSuccess(res);
13721
+ });
13722
+ }
13723
+ }
13287
13724
  }
13288
13725
 
13289
13726
  const vantivInstanceRef = React__default.useRef(null);
13290
13727
  useEffect(() => {
13291
13728
  const cardProcessor = getSiteCardProcessor();
13292
13729
 
13293
- if (cardProcessor === "vantiv") {
13294
- var _window$Pelcro$site$r;
13730
+ if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
13731
+ var _window$Pelcro$site$r, _window$Pelcro$site$r2;
13295
13732
 
13296
- 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;
13733
+ 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;
13734
+ 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;
13297
13735
  vantivInstanceRef.current = new window.EprotectIframeClient({
13298
13736
  paypageId: payPageId,
13299
- reportGroup: payPageId,
13737
+ reportGroup: reportGroup,
13300
13738
  style: "pelcro",
13301
13739
  height: "245",
13302
13740
  timeout: 50000,
@@ -13313,7 +13751,7 @@ const PaymentMethodContainerWithoutStripe = ({
13313
13751
  }
13314
13752
  });
13315
13753
  }
13316
- }, []);
13754
+ }, [selectedPaymentMethodId]);
13317
13755
 
13318
13756
  const initPaymentRequest = (state, dispatch) => {
13319
13757
  try {
@@ -13385,9 +13823,9 @@ const PaymentMethodContainerWithoutStripe = ({
13385
13823
 
13386
13824
 
13387
13825
  const updateTotalAmountWithTax = () => {
13388
- var _window$Pelcro$site$r2;
13826
+ var _window$Pelcro$site$r3;
13389
13827
 
13390
- 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;
13828
+ 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;
13391
13829
 
13392
13830
  if (taxesEnabled && type === "createPayment") {
13393
13831
  dispatch({
@@ -13544,6 +13982,7 @@ const PaymentMethodContainerWithoutStripe = ({
13544
13982
  window.Pelcro.order.create({
13545
13983
  auth_token: window.Pelcro.user.read().auth_token,
13546
13984
  plan_id: plan.id,
13985
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13547
13986
  coupon_code: couponCode,
13548
13987
  address_id: selectedAddressId
13549
13988
  }, handleCouponResponse);
@@ -13625,6 +14064,7 @@ const PaymentMethodContainerWithoutStripe = ({
13625
14064
  stripe_token: !stripeSource.isExistingSource ? stripeSource.id : undefined,
13626
14065
  auth_token: window.Pelcro.user.read().auth_token,
13627
14066
  plan_id: plan.id,
14067
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13628
14068
  quantity: plan.quantity,
13629
14069
  coupon_code: couponCode,
13630
14070
  gift_recipient_email: giftRecipient ? giftRecipient.email : null,
@@ -13696,6 +14136,7 @@ const PaymentMethodContainerWithoutStripe = ({
13696
14136
  stripe_token: !stripeSource.isExistingSource ? stripeSource.id : undefined,
13697
14137
  auth_token: window.Pelcro.user.read().auth_token,
13698
14138
  plan_id: plan.id,
14139
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13699
14140
  coupon_code: couponCode,
13700
14141
  subscription_id: subscriptionIdToRenew,
13701
14142
  address_id: product.address_required ? selectedAddressId : null
@@ -13737,7 +14178,7 @@ const PaymentMethodContainerWithoutStripe = ({
13737
14178
 
13738
14179
 
13739
14180
  const handlePaypalSubscription = (state, paypalNonce) => {
13740
- const subscription = new Subscription(new PaypalGateway());
14181
+ const payment = new Payment(new PaypalGateway());
13741
14182
  const {
13742
14183
  couponCode
13743
14184
  } = state;
@@ -13746,8 +14187,8 @@ const PaymentMethodContainerWithoutStripe = ({
13746
14187
  */
13747
14188
 
13748
14189
  if (giftRecipient) {
13749
- return subscription.execute({
13750
- type: SUBSCRIPTION_TYPES.CREATE_GIFTED_SUBSCRIPTION,
14190
+ return payment.execute({
14191
+ type: PAYMENT_TYPES.CREATE_GIFTED_SUBSCRIPTION,
13751
14192
  token: paypalNonce,
13752
14193
  quantity: plan.quantity,
13753
14194
  plan,
@@ -13780,8 +14221,8 @@ const PaymentMethodContainerWithoutStripe = ({
13780
14221
  });
13781
14222
  }
13782
14223
 
13783
- return subscription.execute({
13784
- type: SUBSCRIPTION_TYPES.CREATE_SUBSCRIPTION,
14224
+ return payment.execute({
14225
+ type: PAYMENT_TYPES.CREATE_SUBSCRIPTION,
13785
14226
  token: paypalNonce,
13786
14227
  quantity: plan.quantity,
13787
14228
  plan,
@@ -13813,7 +14254,7 @@ const PaymentMethodContainerWithoutStripe = ({
13813
14254
  });
13814
14255
  };
13815
14256
 
13816
- const purchase = (stripeSource, state, dispatch) => {
14257
+ const purchase = (gatewayService, gatewayToken, state, dispatch) => {
13817
14258
  const isQuickPurchase = !Array.isArray(order);
13818
14259
  const mappedOrderItems = isQuickPurchase ? [{
13819
14260
  sku_id: order.id,
@@ -13825,14 +14266,14 @@ const PaymentMethodContainerWithoutStripe = ({
13825
14266
  const {
13826
14267
  couponCode
13827
14268
  } = state;
13828
- window.Pelcro.ecommerce.order.create({
13829
- source_id: stripeSource.isExistingSource ? stripeSource.id : undefined,
13830
- stripe_token: !stripeSource.isExistingSource ? stripeSource.id : undefined,
14269
+ const payment = new Payment(gatewayService);
14270
+ payment.execute({
14271
+ type: PAYMENT_TYPES.PURCHASE_ECOMMERCE_ORDER,
14272
+ token: gatewayToken,
14273
+ isExistingSource: Boolean(selectedPaymentMethodId),
13831
14274
  items: mappedOrderItems,
13832
- coupon_code: couponCode,
13833
- ...(selectedAddressId && {
13834
- address_id: selectedAddressId
13835
- })
14275
+ addressId: selectedAddressId,
14276
+ couponCode
13836
14277
  }, (err, res) => {
13837
14278
  dispatch({
13838
14279
  type: DISABLE_SUBMIT,
@@ -13870,9 +14311,9 @@ const PaymentMethodContainerWithoutStripe = ({
13870
14311
  };
13871
14312
 
13872
14313
  const payInvoice = (gatewayService, gatewayToken, dispatch) => {
13873
- const subscription = new Subscription(gatewayService);
13874
- return subscription.execute({
13875
- type: SUBSCRIPTION_TYPES.PAY_INVOICE,
14314
+ const payment = new Payment(gatewayService);
14315
+ return payment.execute({
14316
+ type: PAYMENT_TYPES.PAY_INVOICE,
13876
14317
  token: gatewayToken,
13877
14318
  isExistingSource: Boolean(selectedPaymentMethodId),
13878
14319
  invoiceId: invoice.id
@@ -13917,7 +14358,9 @@ const PaymentMethodContainerWithoutStripe = ({
13917
14358
 
13918
14359
  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") {
13919
14360
  return handlePaymentError({
13920
- message: t("messages.cardAuthNotSupported")
14361
+ error: {
14362
+ message: t("messages.cardAuthNotSupported")
14363
+ }
13921
14364
  });
13922
14365
  }
13923
14366
 
@@ -14032,13 +14475,13 @@ const PaymentMethodContainerWithoutStripe = ({
14032
14475
 
14033
14476
 
14034
14477
  const resolveTaxCalculation = () => {
14035
- var _window$Pelcro$site$r3;
14478
+ var _window$Pelcro$site$r4;
14036
14479
 
14037
14480
  if (type === "invoicePayment") {
14038
14481
  return new Promise(resolve => resolve());
14039
14482
  }
14040
14483
 
14041
- 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;
14484
+ 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;
14042
14485
  return new Promise((resolve, reject) => {
14043
14486
  // resolve early if taxes isn't enabled
14044
14487
  if (!taxesEnabled) {
@@ -14048,6 +14491,7 @@ const PaymentMethodContainerWithoutStripe = ({
14048
14491
  window.Pelcro.order.create({
14049
14492
  auth_token: window.Pelcro.user.read().auth_token,
14050
14493
  plan_id: plan.id,
14494
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
14051
14495
  coupon_code: state === null || state === void 0 ? void 0 : state.couponCode,
14052
14496
  address_id: selectedAddressId
14053
14497
  }, (error, res) => {
@@ -14110,7 +14554,7 @@ const PaymentMethodContainerWithoutStripe = ({
14110
14554
  if (stripeSource && type === "createPayment") {
14111
14555
  subscribe(stripeSource, state, dispatch);
14112
14556
  } else if (stripeSource && type === "orderCreate") {
14113
- purchase(stripeSource, state, dispatch);
14557
+ purchase(new StripeGateway(), stripeSource.id, state, dispatch);
14114
14558
  } else if (stripeSource && type === "invoicePayment") {
14115
14559
  payInvoice(new StripeGateway(), stripeSource.id, dispatch);
14116
14560
  }
@@ -14161,7 +14605,9 @@ const PaymentMethodContainerWithoutStripe = ({
14161
14605
 
14162
14606
  if ((source === null || source === void 0 ? void 0 : source.status) === "failed") {
14163
14607
  return handlePaymentError({
14164
- message: t("messages.cardAuthFailed")
14608
+ error: {
14609
+ message: t("messages.cardAuthFailed")
14610
+ }
14165
14611
  });
14166
14612
  }
14167
14613
 
@@ -14232,6 +14678,10 @@ const PaymentMethodContainerWithoutStripe = ({
14232
14678
  disableSubmit: true,
14233
14679
  isLoading: true
14234
14680
  }, (state, dispatch) => {
14681
+ if (getSiteCardProcessor() === "vantiv") {
14682
+ return submitUsingVantiv();
14683
+ }
14684
+
14235
14685
  if (selectedPaymentMethodId) {
14236
14686
  // pay with selected method (source) if exists already
14237
14687
  return handlePayment({
@@ -14244,10 +14694,6 @@ const PaymentMethodContainerWithoutStripe = ({
14244
14694
  return updatePaymentSource(state, dispatch);
14245
14695
  }
14246
14696
 
14247
- if (getSiteCardProcessor() === "vantiv") {
14248
- return submitVantivPayment();
14249
- }
14250
-
14251
14697
  submitPayment(state);
14252
14698
  });
14253
14699
 
@@ -14316,21 +14762,21 @@ const PaymentMethodContainerWithoutStripe = ({
14316
14762
  default:
14317
14763
  return state;
14318
14764
  }
14319
- }, initialState$f);
14765
+ }, initialState$g);
14320
14766
  return /*#__PURE__*/React__default.createElement("div", {
14321
14767
  style: { ...style
14322
14768
  },
14323
14769
  className: `pelcro-container pelcro-payment-container ${className}`
14324
- }, /*#__PURE__*/React__default.createElement(Provider$f, {
14770
+ }, /*#__PURE__*/React__default.createElement(Provider$g, {
14325
14771
  value: {
14326
14772
  state,
14327
14773
  dispatch
14328
14774
  }
14329
14775
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default.cloneElement(child, {
14330
- store: store$f,
14776
+ store: store$g,
14331
14777
  key: i
14332
14778
  })) : /*#__PURE__*/React__default.cloneElement(children, {
14333
- store: store$f
14779
+ store: store$g
14334
14780
  })));
14335
14781
  };
14336
14782
 
@@ -14352,7 +14798,7 @@ const PaymentMethodContainer = props => {
14352
14798
  stripeAccount: window.Pelcro.site.read().account_id,
14353
14799
  locale: getPageOrDefaultLanguage()
14354
14800
  }, /*#__PURE__*/React__default.createElement(es_11, null, /*#__PURE__*/React__default.createElement(UnwrappedForm, Object.assign({
14355
- store: store$f
14801
+ store: store$g
14356
14802
  }, props))));
14357
14803
  }
14358
14804
 
@@ -14405,7 +14851,7 @@ const PelcroPaymentRequestButton = props => {
14405
14851
  currentPlan,
14406
14852
  updatedPrice
14407
14853
  }
14408
- } = useContext(store$f);
14854
+ } = useContext(store$g);
14409
14855
 
14410
14856
  const updatePaymentRequest = () => {
14411
14857
  // Make sure payment request is up to date, eg. user added a coupon code.
@@ -14481,7 +14927,7 @@ const DiscountedPrice = props => {
14481
14927
  taxAmount,
14482
14928
  percentOff
14483
14929
  }
14484
- } = useContext(store$f);
14930
+ } = useContext(store$g);
14485
14931
  const {
14486
14932
  order,
14487
14933
  plan
@@ -14531,7 +14977,7 @@ const SubmitPaymentMethod = ({
14531
14977
  isLoading,
14532
14978
  updatedPrice
14533
14979
  }
14534
- } = useContext(store$f);
14980
+ } = useContext(store$g);
14535
14981
  const planQuantity = (_plan$quantity = plan === null || plan === void 0 ? void 0 : plan.quantity) !== null && _plan$quantity !== void 0 ? _plan$quantity : 1;
14536
14982
  const price = updatedPrice !== null && updatedPrice !== void 0 ? updatedPrice : plan === null || plan === void 0 ? void 0 : plan.amount;
14537
14983
  const priceFormatted = getFormattedPriceByLocal(price * planQuantity, plan === null || plan === void 0 ? void 0 : plan.currency, getPageOrDefaultLanguage());
@@ -14581,7 +15027,7 @@ const ApplyCouponButton = ({
14581
15027
  disableCouponButton
14582
15028
  },
14583
15029
  dispatch
14584
- } = useContext(store$f);
15030
+ } = useContext(store$g);
14585
15031
  const {
14586
15032
  t
14587
15033
  } = useTranslation("checkoutForm");
@@ -14615,7 +15061,7 @@ const CouponCodeField = props => {
14615
15061
  couponCode,
14616
15062
  couponError
14617
15063
  }
14618
- } = useContext(store$f);
15064
+ } = useContext(store$g);
14619
15065
 
14620
15066
  const onCouponCodeChange = e => {
14621
15067
  dispatch({
@@ -14671,7 +15117,7 @@ const CouponCode = ({
14671
15117
  state: {
14672
15118
  enableCouponField
14673
15119
  }
14674
- } = useContext(store$f);
15120
+ } = useContext(store$g);
14675
15121
  const {
14676
15122
  t
14677
15123
  } = useTranslation("checkoutForm");
@@ -14928,7 +15374,7 @@ const PaypalSubscribeButton = props => {
14928
15374
  const {
14929
15375
  dispatch,
14930
15376
  state
14931
- } = useContext(store$f);
15377
+ } = useContext(store$g);
14932
15378
  const {
14933
15379
  product,
14934
15380
  plan,
@@ -14943,7 +15389,7 @@ const PaypalSubscribeButton = props => {
14943
15389
  const selectedAddress = getAddressById((_props$selectedAddres = props.selectedAddressId) !== null && _props$selectedAddres !== void 0 ? _props$selectedAddres : selectedAddressId); // initialize paypal client, then render paypal button.
14944
15390
 
14945
15391
  const initializePaypal = async () => {
14946
- var _props$buttonElementI, _props$product$addres, _props$product, _props$plan2;
15392
+ var _props$buttonElementI, _props$product$addres, _props$product;
14947
15393
 
14948
15394
  const paypalCheckoutInstance = new PaypalClient({
14949
15395
  buttonElementID: (_props$buttonElementI = props.buttonElementID) !== null && _props$buttonElementI !== void 0 ? _props$buttonElementI : "pelcro-paypal-button",
@@ -14953,12 +15399,33 @@ const PaypalSubscribeButton = props => {
14953
15399
  displayName: props.merchantDisplayName,
14954
15400
  locale: props.locale,
14955
15401
  billingAgreementDescription: props.billingDescription
14956
- }); // Await building paypal instance
15402
+ });
15403
+
15404
+ const getProduct = () => {
15405
+ if (invoice) {
15406
+ invoice.plan = null;
15407
+
15408
+ if (invoice.plan) {
15409
+ return invoice.plan;
15410
+ } else {
15411
+ // standalone invoices dont have a plan
15412
+ return {
15413
+ currency: invoice.currency,
15414
+ nickname: `invoice #${invoice.id}`
15415
+ };
15416
+ }
15417
+ } else if (props.plan) {
15418
+ return props.plan;
15419
+ } else {
15420
+ return plan;
15421
+ }
15422
+ }; // Await building paypal instance
15423
+
14957
15424
 
14958
15425
  await paypalCheckoutInstance.build(); // Create paypal payment
14959
15426
 
14960
15427
  paypalCheckoutInstance.createPayment({
14961
- product: invoice ? invoice.plan : (_props$plan2 = props.plan) !== null && _props$plan2 !== void 0 ? _props$plan2 : plan,
15428
+ product: getProduct(),
14962
15429
  amount: updatedPrice,
14963
15430
  address: invoice ? null : selectedAddress,
14964
15431
  onButtonClick: () => {
@@ -15040,7 +15507,7 @@ const SelectedPaymentMethod = () => {
15040
15507
  state: {
15041
15508
  isLoading
15042
15509
  }
15043
- } = useContext(store$f);
15510
+ } = useContext(store$g);
15044
15511
  const {
15045
15512
  switchView,
15046
15513
  selectedPaymentMethodId
@@ -15082,7 +15549,7 @@ const TaxAmount = () => {
15082
15549
  state: {
15083
15550
  taxAmount
15084
15551
  }
15085
- } = useContext(store$f);
15552
+ } = useContext(store$g);
15086
15553
  const {
15087
15554
  plan
15088
15555
  } = usePelcro();
@@ -15601,7 +16068,7 @@ class DefaultNewsLetter extends Component {
15601
16068
 
15602
16069
  const NewsLetter = withTranslation("newsletter")(DefaultNewsLetter);
15603
16070
 
15604
- const initialState$e = {
16071
+ const initialState$f = {
15605
16072
  didSubToNewslettersBefore: false,
15606
16073
  newsletters: [],
15607
16074
  isListLoading: true,
@@ -15611,10 +16078,10 @@ const initialState$e = {
15611
16078
  content: ""
15612
16079
  }
15613
16080
  };
15614
- const store$e = /*#__PURE__*/createContext(initialState$e);
16081
+ const store$f = /*#__PURE__*/createContext(initialState$f);
15615
16082
  const {
15616
- Provider: Provider$e
15617
- } = store$e;
16083
+ Provider: Provider$f
16084
+ } = store$f;
15618
16085
 
15619
16086
  const NewsletterUpdateContainer = ({
15620
16087
  style,
@@ -15727,7 +16194,7 @@ const NewsletterUpdateContainer = ({
15727
16194
  default:
15728
16195
  return state;
15729
16196
  }
15730
- }, initialState$e);
16197
+ }, initialState$f);
15731
16198
  useEffect(() => {
15732
16199
  const getUserNewsletters = () => {
15733
16200
  var _window$Pelcro$user$r3, _window$Pelcro$user$r4;
@@ -15771,7 +16238,7 @@ const NewsletterUpdateContainer = ({
15771
16238
  style: { ...style
15772
16239
  },
15773
16240
  className: `pelcro-container pelcro-newsletter-update-container ${className}`
15774
- }, /*#__PURE__*/React__default.createElement(Provider$e, {
16241
+ }, /*#__PURE__*/React__default.createElement(Provider$f, {
15775
16242
  value: {
15776
16243
  state,
15777
16244
  dispatch
@@ -15779,12 +16246,12 @@ const NewsletterUpdateContainer = ({
15779
16246
  }, children.length ? children.map((child, i) => {
15780
16247
  if (child) {
15781
16248
  return /*#__PURE__*/React__default.cloneElement(child, {
15782
- store: store$e,
16249
+ store: store$f,
15783
16250
  key: i
15784
16251
  });
15785
16252
  }
15786
16253
  }) : /*#__PURE__*/React__default.cloneElement(children, {
15787
- store: store$e
16254
+ store: store$f
15788
16255
  })));
15789
16256
  };
15790
16257
 
@@ -15799,7 +16266,7 @@ const NewsletterUpdateButton = ({
15799
16266
  isSubmitting,
15800
16267
  isListLoading
15801
16268
  }
15802
- } = useContext(store$e);
16269
+ } = useContext(store$f);
15803
16270
  const {
15804
16271
  t
15805
16272
  } = useTranslation("newsletter");
@@ -15829,7 +16296,7 @@ const NewsletterUpdateList = () => {
15829
16296
  newsletters,
15830
16297
  isListLoading
15831
16298
  }
15832
- } = useContext(store$e);
16299
+ } = useContext(store$f);
15833
16300
 
15834
16301
  if (isListLoading) {
15835
16302
  return /*#__PURE__*/React__default.createElement(Loader, {
@@ -16033,8 +16500,9 @@ function SubscriptionCreateModal({
16033
16500
  SubscriptionCreateModal.viewId = "subscription-create";
16034
16501
 
16035
16502
  var _window$Pelcro$user$r, _window$Pelcro$user$r2, _window$Pelcro$user$r3, _window$Pelcro$user$r4, _window$Pelcro$user$r5;
16036
- const initialState$d = {
16503
+ const initialState$e = {
16037
16504
  email: (_window$Pelcro$user$r = window.Pelcro.user.read()) === null || _window$Pelcro$user$r === void 0 ? void 0 : _window$Pelcro$user$r.email,
16505
+ emailError: null,
16038
16506
  firstName: (_window$Pelcro$user$r2 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r2 === void 0 ? void 0 : _window$Pelcro$user$r2.first_name,
16039
16507
  lastName: (_window$Pelcro$user$r3 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r3 === void 0 ? void 0 : _window$Pelcro$user$r3.last_name,
16040
16508
  displayName: (_window$Pelcro$user$r4 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r4 === void 0 ? void 0 : _window$Pelcro$user$r4.display_name,
@@ -16046,10 +16514,10 @@ const initialState$d = {
16046
16514
  content: ""
16047
16515
  }
16048
16516
  };
16049
- const store$d = /*#__PURE__*/createContext(initialState$d);
16517
+ const store$e = /*#__PURE__*/createContext(initialState$e);
16050
16518
  const {
16051
- Provider: Provider$d
16052
- } = store$d;
16519
+ Provider: Provider$e
16520
+ } = store$e;
16053
16521
 
16054
16522
  const UserUpdateContainer = ({
16055
16523
  style,
@@ -16069,20 +16537,23 @@ const UserUpdateContainer = ({
16069
16537
  }, []);
16070
16538
 
16071
16539
  const loadUserDataIntoFields = () => {
16072
- var _window$Pelcro$user$r6, _window$Pelcro$user$r7, _window$Pelcro$user$r8, _window$Pelcro$user$r9;
16540
+ var _window$Pelcro$user$r6, _window$Pelcro$user$r7, _window$Pelcro$user$r8, _window$Pelcro$user$r9, _window$Pelcro$user$r10;
16073
16541
 
16074
16542
  const fields = [{
16543
+ type: SET_EMAIL,
16544
+ payload: (_window$Pelcro$user$r6 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r6 === void 0 ? void 0 : _window$Pelcro$user$r6.email
16545
+ }, {
16075
16546
  type: SET_FIRST_NAME,
16076
- payload: (_window$Pelcro$user$r6 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r6 === void 0 ? void 0 : _window$Pelcro$user$r6.first_name
16547
+ payload: (_window$Pelcro$user$r7 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r7 === void 0 ? void 0 : _window$Pelcro$user$r7.first_name
16077
16548
  }, {
16078
16549
  type: SET_LAST_NAME,
16079
- payload: (_window$Pelcro$user$r7 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r7 === void 0 ? void 0 : _window$Pelcro$user$r7.last_name
16550
+ payload: (_window$Pelcro$user$r8 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r8 === void 0 ? void 0 : _window$Pelcro$user$r8.last_name
16080
16551
  }, {
16081
16552
  type: SET_DISPLAY_NAME,
16082
- payload: (_window$Pelcro$user$r8 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r8 === void 0 ? void 0 : _window$Pelcro$user$r8.display_name
16553
+ payload: (_window$Pelcro$user$r9 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r9 === void 0 ? void 0 : _window$Pelcro$user$r9.display_name
16083
16554
  }, {
16084
16555
  type: SET_PHONE,
16085
- payload: (_window$Pelcro$user$r9 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r9 === void 0 ? void 0 : _window$Pelcro$user$r9.phone
16556
+ payload: (_window$Pelcro$user$r10 = window.Pelcro.user.read()) === null || _window$Pelcro$user$r10 === void 0 ? void 0 : _window$Pelcro$user$r10.phone
16086
16557
  }];
16087
16558
  fields.filter(field => Boolean(field.payload)).forEach(field => {
16088
16559
  dispatch(field);
@@ -16090,6 +16561,7 @@ const UserUpdateContainer = ({
16090
16561
  };
16091
16562
 
16092
16563
  const handleUpdateUser = ({
16564
+ email,
16093
16565
  firstName,
16094
16566
  lastName,
16095
16567
  phone,
@@ -16098,6 +16570,7 @@ const UserUpdateContainer = ({
16098
16570
  }, dispatch) => {
16099
16571
  window.Pelcro.user.update({
16100
16572
  auth_token: window.Pelcro.user.read().auth_token,
16573
+ email: email,
16101
16574
  first_name: firstName,
16102
16575
  last_name: lastName,
16103
16576
  display_name: displayName,
@@ -16143,6 +16616,16 @@ const UserUpdateContainer = ({
16143
16616
  }
16144
16617
  });
16145
16618
 
16619
+ case SET_EMAIL:
16620
+ return lib_7({ ...state,
16621
+ email: action.payload
16622
+ });
16623
+
16624
+ case SET_EMAIL_ERROR:
16625
+ return lib_7({ ...state,
16626
+ emailError: action.payload
16627
+ });
16628
+
16146
16629
  case SET_FIRST_NAME:
16147
16630
  return lib_7({ ...state,
16148
16631
  firstName: action.payload
@@ -16181,28 +16664,85 @@ const UserUpdateContainer = ({
16181
16664
  default:
16182
16665
  return state;
16183
16666
  }
16184
- }, initialState$d);
16667
+ }, initialState$e);
16185
16668
  return /*#__PURE__*/React__default.createElement("div", {
16186
16669
  style: { ...style
16187
16670
  },
16188
16671
  className: `pelcro-container pelcro-user-update-container ${className}`
16189
- }, /*#__PURE__*/React__default.createElement(Provider$d, {
16672
+ }, /*#__PURE__*/React__default.createElement(Provider$e, {
16190
16673
  value: {
16191
16674
  state,
16192
16675
  dispatch
16193
16676
  }
16194
16677
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default.cloneElement(child, {
16195
- store: store$d,
16678
+ store: store$e,
16196
16679
  key: i
16197
16680
  })) : /*#__PURE__*/React__default.cloneElement(children, {
16198
- store: store$d
16681
+ store: store$e
16199
16682
  })));
16200
16683
  };
16201
16684
 
16202
- const UserUpdateEmail = props => /*#__PURE__*/React__default.createElement(Email, Object.assign({
16203
- disabled: true,
16204
- store: store$d
16205
- }, props));
16685
+ var _path$i;
16686
+
16687
+ 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); }
16688
+
16689
+ function SvgEdit(props) {
16690
+ return /*#__PURE__*/React.createElement("svg", _extends$k({
16691
+ className: "plc-w-6 plc-h-6",
16692
+ xmlns: "http://www.w3.org/2000/svg",
16693
+ viewBox: "0 0 20 20",
16694
+ fill: "currentColor"
16695
+ }, props), _path$i || (_path$i = /*#__PURE__*/React.createElement("path", {
16696
+ 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"
16697
+ })));
16698
+ }
16699
+
16700
+ const UserUpdateEmail = props => {
16701
+ const {
16702
+ dispatch,
16703
+ state: {
16704
+ email,
16705
+ emailError
16706
+ }
16707
+ } = useContext(store$e);
16708
+ const [enableEmailEdit, setEnableEmailEdit] = useState(false);
16709
+ const {
16710
+ t
16711
+ } = useTranslation("userEdit");
16712
+
16713
+ const handleEnableEmailEdit = () => {
16714
+ if (enableEmailEdit) {
16715
+ dispatch({
16716
+ type: SET_EMAIL,
16717
+ payload: email
16718
+ });
16719
+ dispatch({
16720
+ type: SET_EMAIL_ERROR,
16721
+ payload: null
16722
+ });
16723
+ setEnableEmailEdit(false);
16724
+ } else {
16725
+ setEnableEmailEdit(true);
16726
+ }
16727
+ };
16728
+
16729
+ return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("div", {
16730
+ className: "plc-flex plc-items-start plc-relative"
16731
+ }, /*#__PURE__*/React__default.createElement(Email, Object.assign({
16732
+ disabled: !enableEmailEdit,
16733
+ store: store$e,
16734
+ label: t("labels.email"),
16735
+ enableEmailEdit: enableEmailEdit
16736
+ }, props)), /*#__PURE__*/React__default.createElement(Button, {
16737
+ variant: "icon",
16738
+ className: "plc-absolute plc-rounded-none plc-text-gray-500 plc-w-10 plc-h-10 plc-top-7 plc-right-0 hover:plc-text-gray-900 hover:plc-bg-transparent focus:plc-ring-0 focus:plc-shadow-none",
16739
+ icon: enableEmailEdit ? /*#__PURE__*/React__default.createElement(SvgXIcon, {
16740
+ className: "plc-w-6"
16741
+ }) : /*#__PURE__*/React__default.createElement(SvgEdit, null),
16742
+ id: "pelcro-user-update-picture-button",
16743
+ onClick: handleEnableEmailEdit
16744
+ })));
16745
+ };
16206
16746
 
16207
16747
  const UserUpdateButton = ({
16208
16748
  name,
@@ -16211,10 +16751,11 @@ const UserUpdateButton = ({
16211
16751
  }) => {
16212
16752
  const {
16213
16753
  state: {
16214
- buttonDisabled
16754
+ buttonDisabled,
16755
+ emailError
16215
16756
  },
16216
16757
  dispatch
16217
- } = useContext(store$d);
16758
+ } = useContext(store$e);
16218
16759
  const {
16219
16760
  t
16220
16761
  } = useTranslation("userEdit");
@@ -16225,17 +16766,17 @@ const UserUpdateButton = ({
16225
16766
  });
16226
16767
  onClick === null || onClick === void 0 ? void 0 : onClick();
16227
16768
  },
16228
- disabled: buttonDisabled,
16229
- isLoading: buttonDisabled
16769
+ disabled: buttonDisabled || emailError,
16770
+ isLoading: buttonDisabled && !emailError
16230
16771
  }, otherProps), name !== null && name !== void 0 ? name : t("labels.submit"));
16231
16772
  };
16232
16773
 
16233
16774
  const UserUpdateFirstName = props => /*#__PURE__*/React__default.createElement(FirstName, Object.assign({
16234
- store: store$d
16775
+ store: store$e
16235
16776
  }, props));
16236
16777
 
16237
16778
  const UserUpdateLastName = props => /*#__PURE__*/React__default.createElement(LastName, Object.assign({
16238
- store: store$d
16779
+ store: store$e
16239
16780
  }, props));
16240
16781
 
16241
16782
  function Phone({
@@ -16264,26 +16805,11 @@ function Phone({
16264
16805
  }
16265
16806
 
16266
16807
  const UserUpdatePhone = props => /*#__PURE__*/React__default.createElement(Phone, Object.assign({
16267
- store: store$d
16808
+ store: store$e
16268
16809
  }, props));
16269
16810
 
16270
16811
  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";
16271
16812
 
16272
- var _path$i;
16273
-
16274
- 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); }
16275
-
16276
- function SvgEdit(props) {
16277
- return /*#__PURE__*/React.createElement("svg", _extends$k({
16278
- className: "plc-w-6 plc-h-6",
16279
- xmlns: "http://www.w3.org/2000/svg",
16280
- viewBox: "0 0 20 20",
16281
- fill: "currentColor"
16282
- }, props), _path$i || (_path$i = /*#__PURE__*/React.createElement("path", {
16283
- 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"
16284
- })));
16285
- }
16286
-
16287
16813
  const UserUpdateProfilePic = ({
16288
16814
  onClick,
16289
16815
  ...otherProps
@@ -16302,7 +16828,7 @@ const UserUpdateProfilePic = ({
16302
16828
  onClick: onClick
16303
16829
  }, otherProps)), /*#__PURE__*/React__default.createElement(Button, {
16304
16830
  variant: "icon",
16305
- className: "plc-absolute plc-bg-gray-500 plc-text-white plc-w-10 plc-h-10 plc-top-24 plc-right-2 hover:plc-bg-gray-600",
16831
+ className: "plc-absolute plc-bg-gray-500 plc-text-white plc-w-10 plc-h-10 plc-top-24 plc-right-2 hover:plc-bg-gray-600 hover:plc-text-white",
16306
16832
  icon: /*#__PURE__*/React__default.createElement(SvgEdit, null),
16307
16833
  id: "pelcro-user-update-picture-button",
16308
16834
  onClick: onClick
@@ -16324,11 +16850,7 @@ const UserUpdateView = props => {
16324
16850
  className: "plc-mt-2 pelcro-form"
16325
16851
  }, /*#__PURE__*/React__default.createElement(UserUpdateContainer, props, /*#__PURE__*/React__default.createElement(AlertWithContext, null), /*#__PURE__*/React__default.createElement(UserUpdateProfilePic, {
16326
16852
  onClick: props.onPictureClick
16327
- }), /*#__PURE__*/React__default.createElement("div", {
16328
- className: "plc-flex plc-items-start"
16329
- }, /*#__PURE__*/React__default.createElement(UserUpdateEmail, {
16330
- label: t("labels.email")
16331
- })), /*#__PURE__*/React__default.createElement("div", {
16853
+ }), /*#__PURE__*/React__default.createElement(UserUpdateEmail, null), /*#__PURE__*/React__default.createElement("div", {
16332
16854
  className: "plc-flex plc-items-start"
16333
16855
  }, /*#__PURE__*/React__default.createElement(UserUpdateFirstName, {
16334
16856
  autoComplete: "first-name",
@@ -16411,16 +16933,16 @@ function DisplayName({
16411
16933
  }
16412
16934
 
16413
16935
  const UserUpdateDisplayName = props => /*#__PURE__*/React__default.createElement(DisplayName, Object.assign({
16414
- store: store$d
16936
+ store: store$e
16415
16937
  }, props));
16416
16938
 
16417
16939
  const UserUpdateTextInput = props => {
16418
16940
  return /*#__PURE__*/React__default.createElement(TextInput, Object.assign({}, props, {
16419
- store: store$d
16941
+ store: store$e
16420
16942
  }));
16421
16943
  };
16422
16944
 
16423
- const initialState$c = {
16945
+ const initialState$d = {
16424
16946
  isSubmitting: false,
16425
16947
  firstName: "",
16426
16948
  firstNameError: "",
@@ -16445,10 +16967,10 @@ const initialState$c = {
16445
16967
  content: ""
16446
16968
  }
16447
16969
  };
16448
- const store$c = /*#__PURE__*/createContext(initialState$c);
16970
+ const store$d = /*#__PURE__*/createContext(initialState$d);
16449
16971
  const {
16450
- Provider: Provider$c
16451
- } = store$c;
16972
+ Provider: Provider$d
16973
+ } = store$d;
16452
16974
 
16453
16975
  const getNewlyCreatedAddress = addresses => addresses[addresses.length - 1];
16454
16976
 
@@ -16655,7 +17177,7 @@ const AddressCreateContainer = ({
16655
17177
  default:
16656
17178
  return state;
16657
17179
  }
16658
- }, initialState$c);
17180
+ }, initialState$d);
16659
17181
  useEffect(() => {
16660
17182
  const getStates = () => {
16661
17183
  dispatch({
@@ -16687,16 +17209,16 @@ const AddressCreateContainer = ({
16687
17209
  style: { ...style
16688
17210
  },
16689
17211
  className: `pelcro-container pelcro-address-create-container ${className}`
16690
- }, /*#__PURE__*/React__default.createElement(Provider$c, {
17212
+ }, /*#__PURE__*/React__default.createElement(Provider$d, {
16691
17213
  value: {
16692
17214
  state,
16693
17215
  dispatch
16694
17216
  }
16695
17217
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default.cloneElement(child, {
16696
- store: store$c,
17218
+ store: store$d,
16697
17219
  key: i
16698
17220
  })) : /*#__PURE__*/React__default.cloneElement(children, {
16699
- store: store$c
17221
+ store: store$d
16700
17222
  })));
16701
17223
  };
16702
17224
 
@@ -16707,7 +17229,7 @@ function AddressCreateFirstName(props) {
16707
17229
  firstName,
16708
17230
  firstNameError
16709
17231
  }
16710
- } = useContext(store$c);
17232
+ } = useContext(store$d);
16711
17233
 
16712
17234
  const handleBlur = () => {
16713
17235
  return dispatch({
@@ -16750,7 +17272,7 @@ function AddressCreateLastName(props) {
16750
17272
  lastName,
16751
17273
  lastNameError
16752
17274
  }
16753
- } = useContext(store$c);
17275
+ } = useContext(store$d);
16754
17276
 
16755
17277
  const handleBlur = () => {
16756
17278
  return dispatch({
@@ -16793,7 +17315,7 @@ function AddressCreateLine1(props) {
16793
17315
  line1,
16794
17316
  line1Error
16795
17317
  }
16796
- } = useContext(store$c);
17318
+ } = useContext(store$d);
16797
17319
 
16798
17320
  const handleBlur = () => {
16799
17321
  return dispatch({
@@ -16836,7 +17358,7 @@ function AddressCreateCity(props) {
16836
17358
  city,
16837
17359
  cityError
16838
17360
  }
16839
- } = useContext(store$c);
17361
+ } = useContext(store$d);
16840
17362
 
16841
17363
  const handleBlur = () => {
16842
17364
  return dispatch({
@@ -16879,7 +17401,7 @@ function AddressCreatePostalCode(props) {
16879
17401
  postalCode,
16880
17402
  postalCodeError
16881
17403
  }
16882
- } = useContext(store$c);
17404
+ } = useContext(store$d);
16883
17405
 
16884
17406
  const handleBlur = () => {
16885
17407
  return dispatch({
@@ -16925,7 +17447,7 @@ const AddressCreateSubmit = ({
16925
17447
  state: {
16926
17448
  isSubmitting
16927
17449
  }
16928
- } = useContext(store$c);
17450
+ } = useContext(store$d);
16929
17451
  const {
16930
17452
  t
16931
17453
  } = useTranslation("address");
@@ -17036,7 +17558,7 @@ function CountrySelect({
17036
17558
  }
17037
17559
 
17038
17560
  const AddressCreateCountrySelect = props => /*#__PURE__*/React__default.createElement(CountrySelect, Object.assign({
17039
- store: store$c
17561
+ store: store$d
17040
17562
  }, props));
17041
17563
 
17042
17564
  function StateSelect({
@@ -17124,7 +17646,7 @@ function StateSelect({
17124
17646
  }
17125
17647
 
17126
17648
  const AddressCreateStateSelect = props => /*#__PURE__*/React__default.createElement(StateSelect, Object.assign({
17127
- store: store$c
17649
+ store: store$d
17128
17650
  }, props));
17129
17651
 
17130
17652
  const AddressCreateView = props => {
@@ -17229,18 +17751,18 @@ AddressCreateModal.viewId = "address-create";
17229
17751
 
17230
17752
  const AddressCreateTextInput = props => {
17231
17753
  return /*#__PURE__*/React__default.createElement(TextInput, Object.assign({}, props, {
17232
- store: store$c
17754
+ store: store$d
17233
17755
  }));
17234
17756
  };
17235
17757
 
17236
17758
  const AddressCreateLine2 = props => {
17237
17759
  return /*#__PURE__*/React__default.createElement(TextInput, Object.assign({
17238
17760
  fieldName: "line2",
17239
- store: store$c
17761
+ store: store$d
17240
17762
  }, props));
17241
17763
  };
17242
17764
 
17243
- const initialState$b = {
17765
+ const initialState$c = {
17244
17766
  isSubmitting: false,
17245
17767
  firstName: "",
17246
17768
  firstNameError: "",
@@ -17265,10 +17787,10 @@ const initialState$b = {
17265
17787
  content: ""
17266
17788
  }
17267
17789
  };
17268
- const store$b = /*#__PURE__*/createContext(initialState$b);
17790
+ const store$c = /*#__PURE__*/createContext(initialState$c);
17269
17791
  const {
17270
- Provider: Provider$b
17271
- } = store$b;
17792
+ Provider: Provider$c
17793
+ } = store$c;
17272
17794
 
17273
17795
  const AddressUpdateContainer = ({
17274
17796
  style,
@@ -17320,7 +17842,7 @@ const AddressUpdateContainer = ({
17320
17842
  const thisAddress = addresses[address];
17321
17843
 
17322
17844
  if (+thisAddress.id === +addressId) {
17323
- const newState = { ...initialState$b,
17845
+ const newState = { ...initialState$c,
17324
17846
  firstName: thisAddress.first_name,
17325
17847
  lastName: thisAddress.last_name,
17326
17848
  line1: thisAddress.line1,
@@ -17453,7 +17975,7 @@ const AddressUpdateContainer = ({
17453
17975
  default:
17454
17976
  return state;
17455
17977
  }
17456
- }, initialState$b);
17978
+ }, initialState$c);
17457
17979
  useEffect(() => {
17458
17980
  const getStates = () => {
17459
17981
  dispatch({
@@ -17485,21 +18007,21 @@ const AddressUpdateContainer = ({
17485
18007
  style: { ...style
17486
18008
  },
17487
18009
  className: `pelcro-container pelcro-address-update-container ${className}`
17488
- }, /*#__PURE__*/React__default.createElement(Provider$b, {
18010
+ }, /*#__PURE__*/React__default.createElement(Provider$c, {
17489
18011
  value: {
17490
18012
  state,
17491
18013
  dispatch
17492
18014
  }
17493
18015
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default.cloneElement(child, {
17494
- store: store$b,
18016
+ store: store$c,
17495
18017
  key: i
17496
18018
  })) : /*#__PURE__*/React__default.cloneElement(children, {
17497
- store: store$b
18019
+ store: store$c
17498
18020
  })));
17499
18021
  };
17500
18022
 
17501
18023
  const AddressUpdateCountrySelect = props => /*#__PURE__*/React__default.createElement(CountrySelect, Object.assign({
17502
- store: store$b
18024
+ store: store$c
17503
18025
  }, props));
17504
18026
 
17505
18027
  function AddressUpdateFirstName(props) {
@@ -17509,7 +18031,7 @@ function AddressUpdateFirstName(props) {
17509
18031
  firstName,
17510
18032
  firstNameError
17511
18033
  }
17512
- } = useContext(store$b);
18034
+ } = useContext(store$c);
17513
18035
 
17514
18036
  const handleBlur = () => {
17515
18037
  return dispatch({
@@ -17552,7 +18074,7 @@ function AddressUpdateLastName(props) {
17552
18074
  lastName,
17553
18075
  lastNameError
17554
18076
  }
17555
- } = useContext(store$b);
18077
+ } = useContext(store$c);
17556
18078
 
17557
18079
  const handleBlur = () => {
17558
18080
  return dispatch({
@@ -17595,7 +18117,7 @@ function AddressUpdateLine1(props) {
17595
18117
  line1,
17596
18118
  line1Error
17597
18119
  }
17598
- } = useContext(store$b);
18120
+ } = useContext(store$c);
17599
18121
 
17600
18122
  const handleBlur = () => {
17601
18123
  return dispatch({
@@ -17635,7 +18157,7 @@ const AddressUpdateLine2 = props => {
17635
18157
  return /*#__PURE__*/React__default.createElement(TextInput, Object.assign({
17636
18158
  fieldName: "line2"
17637
18159
  }, props, {
17638
- store: store$b
18160
+ store: store$c
17639
18161
  }));
17640
18162
  };
17641
18163
 
@@ -17646,7 +18168,7 @@ function AddressUpdateCity(props) {
17646
18168
  city,
17647
18169
  cityError
17648
18170
  }
17649
- } = useContext(store$b);
18171
+ } = useContext(store$c);
17650
18172
 
17651
18173
  const handleBlur = () => {
17652
18174
  return dispatch({
@@ -17689,7 +18211,7 @@ function AddressUpdatePostalCode(props) {
17689
18211
  postalCode,
17690
18212
  postalCodeError
17691
18213
  }
17692
- } = useContext(store$b);
18214
+ } = useContext(store$c);
17693
18215
 
17694
18216
  const handleBlur = () => {
17695
18217
  return dispatch({
@@ -17735,7 +18257,7 @@ const AddressUpdateSubmit = ({
17735
18257
  state: {
17736
18258
  isSubmitting
17737
18259
  }
17738
- } = useContext(store$b);
18260
+ } = useContext(store$c);
17739
18261
  const {
17740
18262
  t
17741
18263
  } = useTranslation("address");
@@ -17751,7 +18273,7 @@ const AddressUpdateSubmit = ({
17751
18273
  };
17752
18274
 
17753
18275
  const AddressUpdateStateSelect = props => /*#__PURE__*/React__default.createElement(StateSelect, Object.assign({
17754
- store: store$b
18276
+ store: store$c
17755
18277
  }, props));
17756
18278
 
17757
18279
  const AddressUpdateView = props => {
@@ -17834,7 +18356,7 @@ AddressUpdateModal.viewId = "address-edit";
17834
18356
 
17835
18357
  const AddressUpdateTextInput = props => {
17836
18358
  return /*#__PURE__*/React__default.createElement(TextInput, Object.assign({}, props, {
17837
- store: store$b
18359
+ store: store$c
17838
18360
  }));
17839
18361
  };
17840
18362
 
@@ -17917,7 +18439,7 @@ const PaymentMethodUpdateModal = props => {
17917
18439
  };
17918
18440
  PaymentMethodUpdateModal.viewId = "payment-method-update";
17919
18441
 
17920
- const initialState$a = {
18442
+ const initialState$b = {
17921
18443
  email: "",
17922
18444
  password: "",
17923
18445
  passwordError: null,
@@ -17930,10 +18452,10 @@ const initialState$a = {
17930
18452
  content: ""
17931
18453
  }
17932
18454
  };
17933
- const store$a = /*#__PURE__*/createContext(initialState$a);
18455
+ const store$b = /*#__PURE__*/createContext(initialState$b);
17934
18456
  const {
17935
- Provider: Provider$a
17936
- } = store$a;
18457
+ Provider: Provider$b
18458
+ } = store$b;
17937
18459
 
17938
18460
  const PasswordResetContainer = ({
17939
18461
  style,
@@ -17990,7 +18512,7 @@ const PasswordResetContainer = ({
17990
18512
  type: SET_EMAIL,
17991
18513
  payload: window.Pelcro.helpers.getURLParameter("email")
17992
18514
  });
17993
- initialState$a.email = window.Pelcro.helpers.getURLParameter("email");
18515
+ initialState$b.email = window.Pelcro.helpers.getURLParameter("email");
17994
18516
  dispatch({
17995
18517
  type: SET_TOKEN,
17996
18518
  payload: window.Pelcro.helpers.getURLParameter("token")
@@ -18050,26 +18572,26 @@ const PasswordResetContainer = ({
18050
18572
  default:
18051
18573
  return state;
18052
18574
  }
18053
- }, initialState$a);
18575
+ }, initialState$b);
18054
18576
  return /*#__PURE__*/React__default.createElement("div", {
18055
18577
  style: { ...style
18056
18578
  },
18057
18579
  className: `pelcro-container pelcro-password-reset-container ${className}`
18058
- }, /*#__PURE__*/React__default.createElement(Provider$a, {
18580
+ }, /*#__PURE__*/React__default.createElement(Provider$b, {
18059
18581
  value: {
18060
18582
  state,
18061
18583
  dispatch
18062
18584
  }
18063
18585
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default.cloneElement(child, {
18064
- store: store$a,
18586
+ store: store$b,
18065
18587
  key: i
18066
18588
  })) : /*#__PURE__*/React__default.cloneElement(children, {
18067
- store: store$a
18589
+ store: store$b
18068
18590
  })));
18069
18591
  };
18070
18592
 
18071
18593
  const PasswordResetPassword = props => /*#__PURE__*/React__default.createElement(Password, Object.assign({
18072
- store: store$a
18594
+ store: store$b
18073
18595
  }, props));
18074
18596
 
18075
18597
  const PasswordResetButton = ({
@@ -18082,7 +18604,7 @@ const PasswordResetButton = ({
18082
18604
  buttonDisabled
18083
18605
  },
18084
18606
  dispatch
18085
- } = useContext(store$a);
18607
+ } = useContext(store$b);
18086
18608
  const {
18087
18609
  t
18088
18610
  } = useTranslation("passwordReset");
@@ -18099,14 +18621,14 @@ const PasswordResetButton = ({
18099
18621
  };
18100
18622
 
18101
18623
  const PasswordResetEmail = props => /*#__PURE__*/React__default.createElement(Email, Object.assign({
18102
- store: store$a
18624
+ store: store$b
18103
18625
  }, props, {
18104
18626
  value: window.Pelcro.helpers.getURLParameter("email"),
18105
18627
  disabled: true
18106
18628
  }));
18107
18629
 
18108
18630
  const PasswordResetConfirmPassword = props => /*#__PURE__*/React__default.createElement(ConfirmPassword, Object.assign({
18109
- store: store$a
18631
+ store: store$b
18110
18632
  }, props));
18111
18633
 
18112
18634
  const PasswordResetView = props => {
@@ -18158,7 +18680,7 @@ const PasswordResetModal = ({
18158
18680
  };
18159
18681
  PasswordResetModal.viewId = "password-reset";
18160
18682
 
18161
- const initialState$9 = {
18683
+ const initialState$a = {
18162
18684
  email: "",
18163
18685
  emailError: null,
18164
18686
  buttonDisabled: false,
@@ -18167,10 +18689,10 @@ const initialState$9 = {
18167
18689
  content: ""
18168
18690
  }
18169
18691
  };
18170
- const store$9 = /*#__PURE__*/createContext(initialState$9);
18692
+ const store$a = /*#__PURE__*/createContext(initialState$a);
18171
18693
  const {
18172
- Provider: Provider$9
18173
- } = store$9;
18694
+ Provider: Provider$a
18695
+ } = store$a;
18174
18696
 
18175
18697
  const PasswordForgotContainer = ({
18176
18698
  style,
@@ -18248,21 +18770,21 @@ const PasswordForgotContainer = ({
18248
18770
  default:
18249
18771
  return state;
18250
18772
  }
18251
- }, initialState$9);
18773
+ }, initialState$a);
18252
18774
  return /*#__PURE__*/React__default.createElement("div", {
18253
18775
  style: { ...style
18254
18776
  },
18255
18777
  className: `pelcro-container pelcro-password-forgot-container ${className}`
18256
- }, /*#__PURE__*/React__default.createElement(Provider$9, {
18778
+ }, /*#__PURE__*/React__default.createElement(Provider$a, {
18257
18779
  value: {
18258
18780
  state,
18259
18781
  dispatch
18260
18782
  }
18261
18783
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default.cloneElement(child, {
18262
- store: store$9,
18784
+ store: store$a,
18263
18785
  key: i
18264
18786
  })) : /*#__PURE__*/React__default.cloneElement(children, {
18265
- store: store$9
18787
+ store: store$a
18266
18788
  })));
18267
18789
  };
18268
18790
 
@@ -18278,7 +18800,7 @@ const PasswordForgotButton = ({
18278
18800
  emailError
18279
18801
  },
18280
18802
  dispatch
18281
- } = useContext(store$9);
18803
+ } = useContext(store$a);
18282
18804
  const {
18283
18805
  t
18284
18806
  } = useTranslation("passwordForgot");
@@ -18299,7 +18821,7 @@ const PasswordForgotButton = ({
18299
18821
  };
18300
18822
 
18301
18823
  const PasswordForgotEmail = props => /*#__PURE__*/React__default.createElement(Email, Object.assign({
18302
- store: store$9
18824
+ store: store$a
18303
18825
  }, props));
18304
18826
 
18305
18827
  const PasswordForgotView = props => {
@@ -18349,7 +18871,7 @@ const PasswordForgotModal = ({
18349
18871
  };
18350
18872
  PasswordForgotModal.viewId = "password-forgot";
18351
18873
 
18352
- const initialState$8 = {
18874
+ const initialState$9 = {
18353
18875
  currentPassword: "",
18354
18876
  newPassword: "",
18355
18877
  confirmNewPassword: "",
@@ -18363,10 +18885,10 @@ const initialState$8 = {
18363
18885
  content: ""
18364
18886
  }
18365
18887
  };
18366
- const store$8 = /*#__PURE__*/createContext(initialState$8);
18888
+ const store$9 = /*#__PURE__*/createContext(initialState$9);
18367
18889
  const {
18368
- Provider: Provider$8
18369
- } = store$8;
18890
+ Provider: Provider$9
18891
+ } = store$9;
18370
18892
  const PasswordChangeContainer = ({
18371
18893
  style,
18372
18894
  className = "",
@@ -18518,21 +19040,21 @@ const PasswordChangeContainer = ({
18518
19040
  default:
18519
19041
  return state;
18520
19042
  }
18521
- }, initialState$8);
19043
+ }, initialState$9);
18522
19044
  return /*#__PURE__*/React__default.createElement("div", {
18523
19045
  style: { ...style
18524
19046
  },
18525
19047
  className: `pelcro-container pelcro-password-change-container ${className}`
18526
- }, /*#__PURE__*/React__default.createElement(Provider$8, {
19048
+ }, /*#__PURE__*/React__default.createElement(Provider$9, {
18527
19049
  value: {
18528
19050
  state,
18529
19051
  dispatch
18530
19052
  }
18531
19053
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default.cloneElement(child, {
18532
- store: store$8,
19054
+ store: store$9,
18533
19055
  key: i
18534
19056
  })) : /*#__PURE__*/React__default.cloneElement(children, {
18535
- store: store$8
19057
+ store: store$9
18536
19058
  })));
18537
19059
  };
18538
19060
 
@@ -18543,7 +19065,7 @@ function PasswordChangeCurrentPassword(props) {
18543
19065
  currentPassword,
18544
19066
  currentPasswordError
18545
19067
  }
18546
- } = useContext(store$8);
19068
+ } = useContext(store$9);
18547
19069
  const handleBlur = useCallback(() => {
18548
19070
  return dispatch({
18549
19071
  type: VALIDATE_PASSWORD
@@ -18577,7 +19099,7 @@ function PasswordChangeNewPassword(props) {
18577
19099
  newPassword,
18578
19100
  newPasswordError
18579
19101
  }
18580
- } = useContext(store$8);
19102
+ } = useContext(store$9);
18581
19103
  const handleBlur = useCallback(() => {
18582
19104
  return dispatch({
18583
19105
  type: VALIDATE_NEW_PASSWORD
@@ -18611,7 +19133,7 @@ function PasswordChangeConfirmNewPassword(props) {
18611
19133
  confirmNewPassword,
18612
19134
  confirmNewPasswordError
18613
19135
  }
18614
- } = useContext(store$8);
19136
+ } = useContext(store$9);
18615
19137
  const handleBlur = useCallback(() => {
18616
19138
  return dispatch({
18617
19139
  type: VALIDATE_CONFIRM_NEW_PASSWORD
@@ -18652,7 +19174,7 @@ const PasswordChangeButton = ({
18652
19174
  confirmNewPasswordError
18653
19175
  },
18654
19176
  dispatch
18655
- } = useContext(store$8);
19177
+ } = useContext(store$9);
18656
19178
  const {
18657
19179
  t
18658
19180
  } = useTranslation("passwordChange");
@@ -18718,17 +19240,17 @@ const PasswordChangeModal = ({
18718
19240
  };
18719
19241
  PasswordChangeModal.viewId = "password-change";
18720
19242
 
18721
- const initialState$7 = {
19243
+ const initialState$8 = {
18722
19244
  buttonDisabled: false,
18723
19245
  alert: {
18724
19246
  type: "error",
18725
19247
  content: ""
18726
19248
  }
18727
19249
  };
18728
- const store$7 = /*#__PURE__*/createContext(initialState$7);
19250
+ const store$8 = /*#__PURE__*/createContext(initialState$8);
18729
19251
  const {
18730
- Provider: Provider$7
18731
- } = store$7;
19252
+ Provider: Provider$8
19253
+ } = store$8;
18732
19254
 
18733
19255
  const CartContainer = ({
18734
19256
  style,
@@ -18819,21 +19341,21 @@ const CartContainer = ({
18819
19341
  default:
18820
19342
  return state;
18821
19343
  }
18822
- }, initialState$7);
19344
+ }, initialState$8);
18823
19345
  return /*#__PURE__*/React__default.createElement("div", {
18824
19346
  style: { ...style
18825
19347
  },
18826
19348
  className: `pelcro-container pelcro-cart-container ${className}`
18827
- }, /*#__PURE__*/React__default.createElement(Provider$7, {
19349
+ }, /*#__PURE__*/React__default.createElement(Provider$8, {
18828
19350
  value: {
18829
19351
  state,
18830
19352
  dispatch
18831
19353
  }
18832
19354
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default.cloneElement(child, {
18833
- store: store$7,
19355
+ store: store$8,
18834
19356
  key: i
18835
19357
  })) : /*#__PURE__*/React__default.cloneElement(children, {
18836
- store: store$7
19358
+ store: store$8
18837
19359
  })));
18838
19360
  };
18839
19361
 
@@ -18870,7 +19392,7 @@ const CartSubmit = ({
18870
19392
  buttonDisabled
18871
19393
  },
18872
19394
  dispatch
18873
- } = useContext(store$7);
19395
+ } = useContext(store$8);
18874
19396
  const {
18875
19397
  t
18876
19398
  } = useTranslation("cart");
@@ -18901,7 +19423,7 @@ const CartTotalPrice = () => {
18901
19423
  state: {
18902
19424
  alert
18903
19425
  }
18904
- } = useContext(store$7);
19426
+ } = useContext(store$8);
18905
19427
  const {
18906
19428
  cartItems
18907
19429
  } = usePelcro();
@@ -19214,7 +19736,7 @@ const OrderConfirmModal = props => {
19214
19736
  };
19215
19737
  OrderConfirmModal.viewId = "order-confirm";
19216
19738
 
19217
- const initialState$6 = {
19739
+ const initialState$7 = {
19218
19740
  email: "",
19219
19741
  firstName: "",
19220
19742
  lastName: "",
@@ -19226,10 +19748,10 @@ const initialState$6 = {
19226
19748
  content: ""
19227
19749
  }
19228
19750
  };
19229
- const store$6 = /*#__PURE__*/createContext(initialState$6);
19751
+ const store$7 = /*#__PURE__*/createContext(initialState$7);
19230
19752
  const {
19231
- Provider: Provider$6
19232
- } = store$6;
19753
+ Provider: Provider$7
19754
+ } = store$7;
19233
19755
 
19234
19756
  const GiftCreateContainer = ({
19235
19757
  style,
@@ -19333,21 +19855,21 @@ const GiftCreateContainer = ({
19333
19855
  default:
19334
19856
  return state;
19335
19857
  }
19336
- }, initialState$6);
19858
+ }, initialState$7);
19337
19859
  return /*#__PURE__*/React__default.createElement("div", {
19338
19860
  style: { ...style
19339
19861
  },
19340
19862
  className: `pelcro-container pelcro-gift-create-container ${className}`
19341
- }, /*#__PURE__*/React__default.createElement(Provider$6, {
19863
+ }, /*#__PURE__*/React__default.createElement(Provider$7, {
19342
19864
  value: {
19343
19865
  state,
19344
19866
  dispatch
19345
19867
  }
19346
19868
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default.cloneElement(child, {
19347
- store: store$6,
19869
+ store: store$7,
19348
19870
  key: i
19349
19871
  })) : /*#__PURE__*/React__default.cloneElement(children, {
19350
- store: store$6
19872
+ store: store$7
19351
19873
  })));
19352
19874
  };
19353
19875
 
@@ -19361,7 +19883,7 @@ const GiftCreateSubmitButton = ({
19361
19883
  state: {
19362
19884
  disableSubmit
19363
19885
  }
19364
- } = useContext(store$6);
19886
+ } = useContext(store$7);
19365
19887
  const {
19366
19888
  t
19367
19889
  } = useTranslation("register");
@@ -19378,15 +19900,15 @@ const GiftCreateSubmitButton = ({
19378
19900
 
19379
19901
  const GiftCreateEmail = props => /*#__PURE__*/React__default.createElement(Email, Object.assign({
19380
19902
  initWithUserEmail: false,
19381
- store: store$6
19903
+ store: store$7
19382
19904
  }, props));
19383
19905
 
19384
19906
  const GiftCreateFirstName = props => /*#__PURE__*/React__default.createElement(FirstName, Object.assign({
19385
- store: store$6
19907
+ store: store$7
19386
19908
  }, props));
19387
19909
 
19388
19910
  const GiftCreateLastName = props => /*#__PURE__*/React__default.createElement(LastName, Object.assign({
19389
- store: store$6
19911
+ store: store$7
19390
19912
  }, props));
19391
19913
 
19392
19914
  var _path$h;
@@ -19471,7 +19993,7 @@ const GiftCreateStartDate = props => {
19471
19993
  const {
19472
19994
  dispatch,
19473
19995
  state
19474
- } = useContext(store$6);
19996
+ } = useContext(store$7);
19475
19997
 
19476
19998
  const handleInputChange = value => {
19477
19999
  dispatch({
@@ -19544,7 +20066,7 @@ function GiftCreateMessage(props) {
19544
20066
  const {
19545
20067
  dispatch,
19546
20068
  state
19547
- } = useContext(store$6);
20069
+ } = useContext(store$7);
19548
20070
  const MAX_CHARS_COUNT = 200;
19549
20071
  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;
19550
20072
 
@@ -19668,7 +20190,7 @@ const GiftCreateModal = ({
19668
20190
  };
19669
20191
  GiftCreateModal.viewId = "gift-create";
19670
20192
 
19671
- const initialState$5 = {
20193
+ const initialState$6 = {
19672
20194
  giftCode: "",
19673
20195
  buttonDisabled: true,
19674
20196
  alert: {
@@ -19676,10 +20198,10 @@ const initialState$5 = {
19676
20198
  content: ""
19677
20199
  }
19678
20200
  };
19679
- const store$5 = /*#__PURE__*/createContext(initialState$5);
20201
+ const store$6 = /*#__PURE__*/createContext(initialState$6);
19680
20202
  const {
19681
- Provider: Provider$5
19682
- } = store$5;
20203
+ Provider: Provider$6
20204
+ } = store$6;
19683
20205
 
19684
20206
  const GiftRedeemContainer = ({
19685
20207
  style,
@@ -19744,21 +20266,21 @@ const GiftRedeemContainer = ({
19744
20266
  default:
19745
20267
  return state;
19746
20268
  }
19747
- }, initialState$5);
20269
+ }, initialState$6);
19748
20270
  return /*#__PURE__*/React__default.createElement("div", {
19749
20271
  style: { ...style
19750
20272
  },
19751
20273
  className: `pelcro-container pelcro-gift-redeem-container ${className}`
19752
- }, /*#__PURE__*/React__default.createElement(Provider$5, {
20274
+ }, /*#__PURE__*/React__default.createElement(Provider$6, {
19753
20275
  value: {
19754
20276
  state,
19755
20277
  dispatch
19756
20278
  }
19757
20279
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default.cloneElement(child, {
19758
- store: store$5,
20280
+ store: store$6,
19759
20281
  key: i
19760
20282
  })) : /*#__PURE__*/React__default.cloneElement(children, {
19761
- store: store$5
20283
+ store: store$6
19762
20284
  })));
19763
20285
  };
19764
20286
 
@@ -19795,7 +20317,7 @@ function GiftCode({
19795
20317
  }
19796
20318
 
19797
20319
  const GiftRedeemCode = props => /*#__PURE__*/React__default.createElement(GiftCode, Object.assign({
19798
- store: store$5
20320
+ store: store$6
19799
20321
  }, props));
19800
20322
 
19801
20323
  const GiftRedeemSubmitButton = ({
@@ -19808,7 +20330,7 @@ const GiftRedeemSubmitButton = ({
19808
20330
  state: {
19809
20331
  disableSubmit
19810
20332
  }
19811
- } = useContext(store$5);
20333
+ } = useContext(store$6);
19812
20334
  const {
19813
20335
  t
19814
20336
  } = useTranslation("register");
@@ -19901,7 +20423,7 @@ const moveDefaultAddressToStart = addresses => {
19901
20423
  return [defaultAddress, ...addressesWithoutDefault];
19902
20424
  };
19903
20425
 
19904
- const initialState$4 = {
20426
+ const initialState$5 = {
19905
20427
  addresses: [],
19906
20428
  selectedAddressId: null,
19907
20429
  isSubmitting: false,
@@ -19910,10 +20432,10 @@ const initialState$4 = {
19910
20432
  content: ""
19911
20433
  }
19912
20434
  };
19913
- const store$4 = /*#__PURE__*/createContext(initialState$4);
20435
+ const store$5 = /*#__PURE__*/createContext(initialState$5);
19914
20436
  const {
19915
- Provider: Provider$4
19916
- } = store$4;
20437
+ Provider: Provider$5
20438
+ } = store$5;
19917
20439
 
19918
20440
  const AddressSelectContainer = ({
19919
20441
  style,
@@ -20008,7 +20530,7 @@ const AddressSelectContainer = ({
20008
20530
  default:
20009
20531
  return state;
20010
20532
  }
20011
- }, initialState$4);
20533
+ }, initialState$5);
20012
20534
  useEffect(() => {
20013
20535
  var _window$Pelcro$user$r;
20014
20536
 
@@ -20021,16 +20543,16 @@ const AddressSelectContainer = ({
20021
20543
  style: { ...style
20022
20544
  },
20023
20545
  className: `pelcro-container pelcro-address-select-container ${className}`
20024
- }, /*#__PURE__*/React__default.createElement(Provider$4, {
20546
+ }, /*#__PURE__*/React__default.createElement(Provider$5, {
20025
20547
  value: {
20026
20548
  state,
20027
20549
  dispatch
20028
20550
  }
20029
20551
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default.cloneElement(child, {
20030
- store: store$4,
20552
+ store: store$5,
20031
20553
  key: i
20032
20554
  })) : /*#__PURE__*/React__default.cloneElement(children, {
20033
- store: store$4
20555
+ store: store$5
20034
20556
  })));
20035
20557
  };
20036
20558
 
@@ -20041,7 +20563,7 @@ const AddressSelectList = () => {
20041
20563
  addresses,
20042
20564
  selectedAddressId
20043
20565
  }
20044
- } = useContext(store$4);
20566
+ } = useContext(store$5);
20045
20567
 
20046
20568
  const handleAddressSelect = event => {
20047
20569
  dispatch({
@@ -20085,7 +20607,7 @@ const AddressSelectSubmit = ({
20085
20607
  selectedAddressId,
20086
20608
  isSubmitting
20087
20609
  }
20088
- } = useContext(store$4);
20610
+ } = useContext(store$5);
20089
20611
  const {
20090
20612
  t
20091
20613
  } = useTranslation("address");
@@ -20181,7 +20703,7 @@ const moveDefaultPaymentMethodToStart = paymentMethods => {
20181
20703
  return [defaultPaymentMethod, ...paymentMethodsWithoutDefault];
20182
20704
  };
20183
20705
 
20184
- const initialState$3 = {
20706
+ const initialState$4 = {
20185
20707
  paymentMethods: [],
20186
20708
  selectedPaymentMethodId: null,
20187
20709
  isSubmitting: false,
@@ -20190,10 +20712,10 @@ const initialState$3 = {
20190
20712
  content: ""
20191
20713
  }
20192
20714
  };
20193
- const store$3 = /*#__PURE__*/createContext(initialState$3);
20715
+ const store$4 = /*#__PURE__*/createContext(initialState$4);
20194
20716
  const {
20195
- Provider: Provider$3
20196
- } = store$3;
20717
+ Provider: Provider$4
20718
+ } = store$4;
20197
20719
 
20198
20720
  const PaymentMethodSelectContainer = ({
20199
20721
  style,
@@ -20252,7 +20774,7 @@ const PaymentMethodSelectContainer = ({
20252
20774
  default:
20253
20775
  return state;
20254
20776
  }
20255
- }, initialState$3);
20777
+ }, initialState$4);
20256
20778
  useEffect(() => {
20257
20779
  var _window$Pelcro$user$r3;
20258
20780
 
@@ -20265,16 +20787,16 @@ const PaymentMethodSelectContainer = ({
20265
20787
  style: { ...style
20266
20788
  },
20267
20789
  className: `pelcro-container pelcro-payment-select-container ${className}`
20268
- }, /*#__PURE__*/React__default.createElement(Provider$3, {
20790
+ }, /*#__PURE__*/React__default.createElement(Provider$4, {
20269
20791
  value: {
20270
20792
  state,
20271
20793
  dispatch
20272
20794
  }
20273
20795
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default.cloneElement(child, {
20274
- store: store$3,
20796
+ store: store$4,
20275
20797
  key: i
20276
20798
  })) : /*#__PURE__*/React__default.cloneElement(children, {
20277
- store: store$3
20799
+ store: store$4
20278
20800
  })));
20279
20801
  };
20280
20802
 
@@ -20288,7 +20810,7 @@ const PaymentMethodSelectList = () => {
20288
20810
  paymentMethods,
20289
20811
  selectedPaymentMethodId
20290
20812
  }
20291
- } = useContext(store$3);
20813
+ } = useContext(store$4);
20292
20814
 
20293
20815
  const handlePaymentMethodSelect = event => {
20294
20816
  dispatch({
@@ -20338,7 +20860,7 @@ const PaymentMethodSelectSubmit = ({
20338
20860
  selectedPaymentMethodId,
20339
20861
  isSubmitting
20340
20862
  }
20341
- } = useContext(store$3);
20863
+ } = useContext(store$4);
20342
20864
  return /*#__PURE__*/React__default.createElement(Button, Object.assign({
20343
20865
  onClick: () => {
20344
20866
  dispatch({
@@ -23130,7 +23652,7 @@ const DashboardOpenButton = () => {
23130
23652
  };
23131
23653
  DashboardOpenButton.viewId = "dashboard-open";
23132
23654
 
23133
- const initialState$2 = {
23655
+ const initialState$3 = {
23134
23656
  imageSrc: null,
23135
23657
  crop: {
23136
23658
  x: 0,
@@ -23144,10 +23666,10 @@ const initialState$2 = {
23144
23666
  content: ""
23145
23667
  }
23146
23668
  };
23147
- const store$2 = /*#__PURE__*/createContext(initialState$2);
23669
+ const store$3 = /*#__PURE__*/createContext(initialState$3);
23148
23670
  const {
23149
- Provider: Provider$2
23150
- } = store$2;
23671
+ Provider: Provider$3
23672
+ } = store$3;
23151
23673
 
23152
23674
  const ProfilePicChangeContainer = ({
23153
23675
  style,
@@ -23281,21 +23803,21 @@ const ProfilePicChangeContainer = ({
23281
23803
  default:
23282
23804
  return state;
23283
23805
  }
23284
- }, initialState$2);
23806
+ }, initialState$3);
23285
23807
  return /*#__PURE__*/React__default.createElement("div", {
23286
23808
  style: { ...style
23287
23809
  },
23288
23810
  className: `pelcro-container pelcro-profile-picture-container ${className}`
23289
- }, /*#__PURE__*/React__default.createElement(Provider$2, {
23811
+ }, /*#__PURE__*/React__default.createElement(Provider$3, {
23290
23812
  value: {
23291
23813
  state,
23292
23814
  dispatch
23293
23815
  }
23294
23816
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default.cloneElement(child, {
23295
- store: store$2,
23817
+ store: store$3,
23296
23818
  key: i
23297
23819
  })) : /*#__PURE__*/React__default.cloneElement(children, {
23298
- store: store$2
23820
+ store: store$3
23299
23821
  })));
23300
23822
  };
23301
23823
  /**
@@ -23357,7 +23879,7 @@ const ProfilePicChangeButton = ({
23357
23879
  isSubmitting
23358
23880
  },
23359
23881
  dispatch
23360
- } = useContext(store$2);
23882
+ } = useContext(store$3);
23361
23883
  const {
23362
23884
  t
23363
23885
  } = useTranslation("userEdit");
@@ -24725,7 +25247,7 @@ const ProfilePicChangeCropper = ({
24725
25247
  zoom
24726
25248
  },
24727
25249
  dispatch
24728
- } = useContext(store$2);
25250
+ } = useContext(store$3);
24729
25251
  return /*#__PURE__*/React__default.createElement("div", {
24730
25252
  className: `plc-relative plc-w-full plc-h-52 sm:plc-h-96 ${className}`
24731
25253
  }, /*#__PURE__*/React__default.createElement(Cropper, Object.assign({
@@ -24767,7 +25289,7 @@ const ProfilePicChangeZoom = ({
24767
25289
  zoom
24768
25290
  },
24769
25291
  dispatch
24770
- } = useContext(store$2);
25292
+ } = useContext(store$3);
24771
25293
  const {
24772
25294
  t
24773
25295
  } = useTranslation("userEdit");
@@ -24819,7 +25341,7 @@ const ProfilePicChangeSelectButton = ({
24819
25341
  state: {
24820
25342
  isSubmitting
24821
25343
  }
24822
- } = useContext(store$2);
25344
+ } = useContext(store$3);
24823
25345
  const {
24824
25346
  t
24825
25347
  } = useTranslation("userEdit");
@@ -24861,7 +25383,7 @@ const ProfilePicChangeRemoveButton = ({
24861
25383
  state: {
24862
25384
  isSubmitting
24863
25385
  }
24864
- } = useContext(store$2);
25386
+ } = useContext(store$3);
24865
25387
  const {
24866
25388
  t
24867
25389
  } = useTranslation("userEdit");
@@ -24884,7 +25406,7 @@ const ProfilePicChangeWrapper = () => {
24884
25406
  state: {
24885
25407
  imageSrc
24886
25408
  }
24887
- } = useContext(store$2);
25409
+ } = useContext(store$3);
24888
25410
  const {
24889
25411
  t
24890
25412
  } = useTranslation("userEdit");
@@ -24946,17 +25468,17 @@ function ProfilePicChangeModal({
24946
25468
  }
24947
25469
  ProfilePicChangeModal.viewId = "profile-picture";
24948
25470
 
24949
- const initialState$1 = {
25471
+ const initialState$2 = {
24950
25472
  isSubmitting: false,
24951
25473
  alert: {
24952
25474
  type: "error",
24953
25475
  content: ""
24954
25476
  }
24955
25477
  };
24956
- const store$1 = /*#__PURE__*/createContext(initialState$1);
25478
+ const store$2 = /*#__PURE__*/createContext(initialState$2);
24957
25479
  const {
24958
- Provider: Provider$1
24959
- } = store$1;
25480
+ Provider: Provider$2
25481
+ } = store$2;
24960
25482
 
24961
25483
  const EmailVerifyContainer = ({
24962
25484
  style,
@@ -25019,21 +25541,21 @@ const EmailVerifyContainer = ({
25019
25541
  default:
25020
25542
  return state;
25021
25543
  }
25022
- }, initialState$1);
25544
+ }, initialState$2);
25023
25545
  return /*#__PURE__*/React__default.createElement("div", {
25024
25546
  style: { ...style
25025
25547
  },
25026
25548
  className: `pelcro-container pelcro-email-verify-container ${className}`
25027
- }, /*#__PURE__*/React__default.createElement(Provider$1, {
25549
+ }, /*#__PURE__*/React__default.createElement(Provider$2, {
25028
25550
  value: {
25029
25551
  state,
25030
25552
  dispatch
25031
25553
  }
25032
25554
  }, children.length ? children.map((child, i) => /*#__PURE__*/React__default.cloneElement(child, {
25033
- store: store$1,
25555
+ store: store$2,
25034
25556
  key: i
25035
25557
  })) : /*#__PURE__*/React__default.cloneElement(children, {
25036
- store: store$1
25558
+ store: store$2
25037
25559
  })));
25038
25560
  };
25039
25561
 
@@ -25047,7 +25569,7 @@ const EmailVerifyResendButton = ({
25047
25569
  state: {
25048
25570
  isSubmitting
25049
25571
  }
25050
- } = useContext(store$1);
25572
+ } = useContext(store$2);
25051
25573
  const {
25052
25574
  t
25053
25575
  } = useTranslation("verifyEmail");
@@ -25122,6 +25644,170 @@ const EmailVerifyModal = ({
25122
25644
  };
25123
25645
  EmailVerifyModal.viewId = "email-verify";
25124
25646
 
25647
+ const initialState$1 = {
25648
+ isLoading: true,
25649
+ isTokenValid: false,
25650
+ alert: {
25651
+ type: "error",
25652
+ content: ""
25653
+ }
25654
+ };
25655
+ const store$1 = /*#__PURE__*/createContext(initialState$1);
25656
+ const {
25657
+ Provider: Provider$1
25658
+ } = store$1;
25659
+
25660
+ const VerifyLinkTokenContainer = ({
25661
+ style,
25662
+ className = "",
25663
+ onSuccess = () => {},
25664
+ onFailure = () => {},
25665
+ children
25666
+ }) => {
25667
+ const handleVerifyLinkToken = ({}, dispatch) => {
25668
+ const token = window.Pelcro.helpers.getURLParameter("token");
25669
+ window.Pelcro.user.verifyLoginToken({
25670
+ token
25671
+ }, (err, res) => {
25672
+ dispatch({
25673
+ type: LOADING,
25674
+ payload: false
25675
+ });
25676
+
25677
+ if (err) {
25678
+ dispatch({
25679
+ type: SHOW_ALERT,
25680
+ payload: {
25681
+ type: "error",
25682
+ content: getErrorMessages(err)
25683
+ }
25684
+ });
25685
+ onFailure(err);
25686
+ } else {
25687
+ onSuccess(res);
25688
+ }
25689
+ });
25690
+ };
25691
+
25692
+ const [state, dispatch] = useReducerWithSideEffects((state, action) => {
25693
+ switch (action.type) {
25694
+ case SHOW_ALERT:
25695
+ return lib_7({ ...state,
25696
+ alert: action.payload
25697
+ });
25698
+
25699
+ case LOADING:
25700
+ return lib_7({ ...state,
25701
+ isLoading: action.payload
25702
+ });
25703
+
25704
+ case LINK_TOKEN_VERIFY:
25705
+ return lib_5({ ...state,
25706
+ isLoading: true
25707
+ }, (state, dispatch) => handleVerifyLinkToken(state, dispatch));
25708
+
25709
+ default:
25710
+ return state;
25711
+ }
25712
+ }, initialState$1);
25713
+ return /*#__PURE__*/React__default.createElement("div", {
25714
+ style: { ...style
25715
+ },
25716
+ className: `pelcro-container pelcro-login-container ${className}`
25717
+ }, /*#__PURE__*/React__default.createElement(Provider$1, {
25718
+ value: {
25719
+ state,
25720
+ dispatch
25721
+ }
25722
+ }, children.length ? children.map((child, i) => {
25723
+ if (child) {
25724
+ return /*#__PURE__*/React__default.cloneElement(child, {
25725
+ store: store$1,
25726
+ key: i
25727
+ });
25728
+ }
25729
+ }) : /*#__PURE__*/React__default.cloneElement(children, {
25730
+ store: store$1
25731
+ })));
25732
+ };
25733
+
25734
+ const VerifyLinkTokenLoader = () => {
25735
+ useEffect(() => {
25736
+ dispatch({
25737
+ type: LINK_TOKEN_VERIFY
25738
+ });
25739
+ }, []);
25740
+ const {
25741
+ dispatch,
25742
+ state: {
25743
+ isLoading
25744
+ }
25745
+ } = useContext(store$1);
25746
+
25747
+ if (isLoading) {
25748
+ return /*#__PURE__*/React__default.createElement(Loader, {
25749
+ width: 60,
25750
+ height: 100
25751
+ });
25752
+ }
25753
+
25754
+ return /*#__PURE__*/React__default.createElement("div", {
25755
+ className: "plc-max-h-80 plc-overflow-y-auto pelcro-newsletters-wrapper"
25756
+ });
25757
+ };
25758
+
25759
+ /**
25760
+ *
25761
+ */
25762
+
25763
+ function VerifyLinkTokenView(props) {
25764
+ const {
25765
+ t
25766
+ } = useTranslation("verifyLinkToken");
25767
+ return /*#__PURE__*/React__default.createElement("div", {
25768
+ id: "pelcro-login-view"
25769
+ }, /*#__PURE__*/React__default.createElement("div", {
25770
+ className: "plc-mb-6 plc-text-2xl plc-font-semibold plc-text-center plc-text-gray-900 pelcro-title-wrapper"
25771
+ }, /*#__PURE__*/React__default.createElement("h4", null, t("labels.title"))), /*#__PURE__*/React__default.createElement("form", {
25772
+ action: "javascript:void(0);",
25773
+ className: "plc-mt-2 pelcro-form"
25774
+ }, /*#__PURE__*/React__default.createElement(VerifyLinkTokenContainer, props, /*#__PURE__*/React__default.createElement(VerifyLinkTokenLoader, null), /*#__PURE__*/React__default.createElement(AlertWithContext, null))));
25775
+ }
25776
+
25777
+ /**
25778
+ *
25779
+ */
25780
+
25781
+ function VerifyLinkTokenModal({
25782
+ onDisplay,
25783
+ onClose,
25784
+ ...props
25785
+ }) {
25786
+ const {
25787
+ t
25788
+ } = useTranslation("verifyLinkToken");
25789
+ const {
25790
+ resetView
25791
+ } = usePelcro();
25792
+
25793
+ const onSuccess = res => {
25794
+ var _props$onSuccess;
25795
+
25796
+ (_props$onSuccess = props.onSuccess) === null || _props$onSuccess === void 0 ? void 0 : _props$onSuccess.call(props, res);
25797
+ resetView();
25798
+ notify.success(t("messages.success"));
25799
+ };
25800
+
25801
+ return /*#__PURE__*/React__default.createElement(Modal, {
25802
+ id: "pelcro-login-modal",
25803
+ onDisplay: onDisplay,
25804
+ onClose: onClose
25805
+ }, /*#__PURE__*/React__default.createElement(ModalBody, null, /*#__PURE__*/React__default.createElement(VerifyLinkTokenView, Object.assign({}, props, {
25806
+ onSuccess: onSuccess
25807
+ }))), /*#__PURE__*/React__default.createElement(ModalFooter, null, /*#__PURE__*/React__default.createElement(Authorship, null)));
25808
+ }
25809
+ VerifyLinkTokenModal.viewId = "passwordless-login";
25810
+
25125
25811
  const InvoicePaymentContainer = props => /*#__PURE__*/React__default.createElement(PaymentMethodContainer, Object.assign({
25126
25812
  type: "invoicePayment",
25127
25813
  className: "pelcro-invoice-payment-container"
@@ -25268,6 +25954,8 @@ const InvoiceDetailsView = props => {
25268
25954
  invoice
25269
25955
  } = usePelcro();
25270
25956
  const showPayButton = canPayInvoice(invoice);
25957
+ const showDownloadButton = Boolean(invoice === null || invoice === void 0 ? void 0 : invoice.invoice_pdf);
25958
+ const hasPlanDetails = Boolean(invoice.plan);
25271
25959
  const creationDate = new Date(invoice === null || invoice === void 0 ? void 0 : invoice.created_at);
25272
25960
  const formattedCreationDate = new Intl.DateTimeFormat("en-CA").format(creationDate);
25273
25961
  return /*#__PURE__*/React__default.createElement("div", {
@@ -25285,7 +25973,7 @@ const InvoiceDetailsView = props => {
25285
25973
  className: "plc-font-bold pelcro-invoice-summary-title"
25286
25974
  }, t("labels.summary")), invoice && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("p", {
25287
25975
  className: "plc-mr-2 pelcro-invoice-creation-date"
25288
- }, `${t("labels.creationDate")} ${formattedCreationDate}`), /*#__PURE__*/React__default.createElement("div", {
25976
+ }, `${t("labels.creationDate")} ${formattedCreationDate}`), hasPlanDetails && /*#__PURE__*/React__default.createElement("div", {
25289
25977
  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"
25290
25978
  }, /*#__PURE__*/React__default.createElement("div", {
25291
25979
  className: "plc-break-words pelcro-invoice-plan-name"
@@ -25311,7 +25999,7 @@ const InvoiceDetailsView = props => {
25311
25999
  className: "plc-font-semibold pelcro-invoice-total"
25312
26000
  }, getFormattedPriceByLocal(invoice.amount_remaining, invoice.currency, getPageOrDefaultLanguage())))))), /*#__PURE__*/React__default.createElement("div", {
25313
26001
  className: "plc-flex plc-items-center plc-justify-center plc-mt-4"
25314
- }, /*#__PURE__*/React__default.createElement(InvoiceDetailsDownloadButton, {
26002
+ }, showDownloadButton && /*#__PURE__*/React__default.createElement(InvoiceDetailsDownloadButton, {
25315
26003
  url: invoice === null || invoice === void 0 ? void 0 : invoice.invoice_pdf,
25316
26004
  className: "plc-w-full plc-text-center"
25317
26005
  }), showPayButton && /*#__PURE__*/React__default.createElement(InvoiceDetailsPayButton, {
@@ -25351,4 +26039,4 @@ const InvoiceDetailsModal = ({
25351
26039
  };
25352
26040
  InvoiceDetailsModal.viewId = "invoice-details";
25353
26041
 
25354
- export { AddressCreateCity, AddressCreateContainer, AddressCreateCountrySelect, AddressCreateFirstName, AddressCreateLastName, AddressCreateLine1, AddressCreateLine2, AddressCreateModal, AddressCreatePostalCode, AddressCreateStateSelect, AddressCreateSubmit, AddressCreateTextInput, AddressCreateView, AddressSelectContainer, AddressSelectList, AddressSelectModal, AddressSelectSubmit, AddressSelectView, AddressUpdateCity, AddressUpdateContainer, AddressUpdateCountrySelect, AddressUpdateFirstName, AddressUpdateLastName, AddressUpdateLine1, AddressUpdateLine2, AddressUpdateModal, AddressUpdatePostalCode, AddressUpdateStateSelect, AddressUpdateSubmit, AddressUpdateTextInput, AddressUpdateView, AlertWithContext as Alert, Alert as AlertElement, ApplyCouponButton, Auth0LoginButton, Badge, BankRedirection, Button, CartContainer, CartModal, CartRemoveItemButton, CartSubmit, CartTotalPrice, CartView, Checkbox, CheckoutForm, ConfirmPassword, CouponCode, CouponCodeField, DashboardWithHook as Dashboard, DashboardOpenButton, DatePicker, DiscountedPrice, Email, EmailVerifyContainer, EmailVerifyModal, EmailVerifyResendButton, EmailVerifyView, FacebookLoginButton, GiftCreateContainer, GiftCreateEmail, GiftCreateFirstName, GiftCreateLastName, GiftCreateMessage, GiftCreateModal, GiftCreateStartDate, GiftCreateSubmitButton, GiftCreateView, GiftRedeemCode, GiftRedeemContainer, GiftRedeemModal, GiftRedeemSubmitButton, GiftRedeemView, GoogleLoginButton, Input, InvoiceDetailsContainer, InvoiceDetailsDownloadButton, InvoiceDetailsModal, InvoiceDetailsPayButton, InvoiceDetailsView, InvoicePaymentContainer, InvoicePaymentModal, InvoicePaymentView, Link, LoginButton, LoginContainer, LoginEmail, LoginModal, LoginPassword, LoginView, Logout, MeterModal, MeterView, Modal, ModalBody, ModalFooter, NewsletterWithHook as NewsLetter, NewsletterUpdateButton, NewsletterUpdateContainer, NewsletterUpdateList, NewsletterUpdateModal, NewsletterUpdateView, Notification, OrderConfirmModal, OrderCreateContainer, OrderCreateModal, OrderCreateSubmitButton, OrderCreateView, Password, PasswordChangeButton, PasswordChangeConfirmNewPassword, PasswordChangeContainer, PasswordChangeCurrentPassword, PasswordChangeModal, PasswordChangeNewPassword, PasswordChangeView, PasswordForgotButton, PasswordForgotContainer, PasswordForgotEmail, PasswordForgotModal, PasswordForgotView, PasswordResetButton, PasswordResetConfirmPassword, PasswordResetContainer, PasswordResetEmail, PasswordResetModal, PasswordResetPassword, PasswordResetView, PaymentCreateContainer, PaymentCreateView, PaymentMethodContainer, PaymentMethodSelectContainer, PaymentMethodSelectList, PaymentMethodSelectModal, PaymentMethodSelectSubmit, PaymentMethodSelectView, PaymentMethodUpdateContainer, PaymentMethodUpdateModal, PaymentMethodUpdateView, PaymentMethodView, PaymentSuccessModal, PaymentSuccessView, PaypalSubscribeButton, PelcroCardCVC, PelcroCardExpiry, PelcroCardNumber, PelcroModalController, PelcroPaymentRequestButton, ProfilePicChangeButton, ProfilePicChangeContainer, ProfilePicChangeCropper, ProfilePicChangeModal, ProfilePicChangeRemoveButton, ProfilePicChangeSelectButton, ProfilePicChangeView, ProfilePicChangeZoom, Radio, RegisterButton, RegisterCompany, RegisterContainer, RegisterEmail, RegisterFirstName, RegisterJobTitle, RegisterLastName, RegisterModal, RegisterPassword, RegisterView, Select, SelectModalWithHook as SelectModal, SelectedPaymentMethod, ShopPurchaseButton, ShopSelectProductButton, ShopView, SubmitPaymentMethod, SubscriptionCreateContainer, SubscriptionCreateModal, SubscriptionCreateView, SubscriptionRenewContainer, SubscriptionRenewModal, SubscriptionRenewView, TaxAmount, TextArea, Tooltip, UserUpdateButton, UserUpdateContainer, UserUpdateDisplayName, UserUpdateEmail, UserUpdateFirstName, UserUpdateLastName, UserUpdateModal, UserUpdatePhone, UserUpdateProfilePic, UserUpdateTextInput, UserUpdateView, authenticatedButtons, i18next as i18n, init$1 as initButtons, init as initContentEntitlement, invoicePaymentSubmitButton, notify, unauthenticatedButtons, usePelcro };
26042
+ export { AddressCreateCity, AddressCreateContainer, AddressCreateCountrySelect, AddressCreateFirstName, AddressCreateLastName, AddressCreateLine1, AddressCreateLine2, AddressCreateModal, AddressCreatePostalCode, AddressCreateStateSelect, AddressCreateSubmit, AddressCreateTextInput, AddressCreateView, AddressSelectContainer, AddressSelectList, AddressSelectModal, AddressSelectSubmit, AddressSelectView, AddressUpdateCity, AddressUpdateContainer, AddressUpdateCountrySelect, AddressUpdateFirstName, AddressUpdateLastName, AddressUpdateLine1, AddressUpdateLine2, AddressUpdateModal, AddressUpdatePostalCode, AddressUpdateStateSelect, AddressUpdateSubmit, AddressUpdateTextInput, AddressUpdateView, AlertWithContext as Alert, Alert as AlertElement, ApplyCouponButton, Auth0LoginButton, Badge, BankRedirection, Button, CartContainer, CartModal, CartRemoveItemButton, CartSubmit, CartTotalPrice, CartView, Checkbox, CheckoutForm, ConfirmPassword, CouponCode, CouponCodeField, DashboardWithHook as Dashboard, DashboardOpenButton, DatePicker, DiscountedPrice, Email, EmailVerifyContainer, EmailVerifyModal, EmailVerifyResendButton, EmailVerifyView, FacebookLoginButton, GiftCreateContainer, GiftCreateEmail, GiftCreateFirstName, GiftCreateLastName, GiftCreateMessage, GiftCreateModal, GiftCreateStartDate, GiftCreateSubmitButton, GiftCreateView, GiftRedeemCode, GiftRedeemContainer, GiftRedeemModal, GiftRedeemSubmitButton, GiftRedeemView, GoogleLoginButton, Input, InvoiceDetailsContainer, InvoiceDetailsDownloadButton, InvoiceDetailsModal, InvoiceDetailsPayButton, InvoiceDetailsView, InvoicePaymentContainer, InvoicePaymentModal, InvoicePaymentView, Link, LoginButton, LoginContainer, LoginEmail, LoginModal, LoginPassword, LoginView, Logout, MeterModal, MeterView, Modal, ModalBody, ModalFooter, NewsletterWithHook as NewsLetter, NewsletterUpdateButton, NewsletterUpdateContainer, NewsletterUpdateList, NewsletterUpdateModal, NewsletterUpdateView, Notification, OrderConfirmModal, OrderCreateContainer, OrderCreateModal, OrderCreateSubmitButton, OrderCreateView, Password, PasswordChangeButton, PasswordChangeConfirmNewPassword, PasswordChangeContainer, PasswordChangeCurrentPassword, PasswordChangeModal, PasswordChangeNewPassword, PasswordChangeView, PasswordForgotButton, PasswordForgotContainer, PasswordForgotEmail, PasswordForgotModal, PasswordForgotView, PasswordResetButton, PasswordResetConfirmPassword, PasswordResetContainer, PasswordResetEmail, PasswordResetModal, PasswordResetPassword, PasswordResetView, PaymentCreateContainer, PaymentCreateView, PaymentMethodContainer, PaymentMethodSelectContainer, PaymentMethodSelectList, PaymentMethodSelectModal, PaymentMethodSelectSubmit, PaymentMethodSelectView, PaymentMethodUpdateContainer, PaymentMethodUpdateModal, PaymentMethodUpdateView, PaymentMethodView, PaymentSuccessModal, PaymentSuccessView, PaypalSubscribeButton, PelcroCardCVC, PelcroCardExpiry, PelcroCardNumber, PelcroModalController, PelcroPaymentRequestButton, ProfilePicChangeButton, ProfilePicChangeContainer, ProfilePicChangeCropper, ProfilePicChangeModal, ProfilePicChangeRemoveButton, ProfilePicChangeSelectButton, ProfilePicChangeView, ProfilePicChangeZoom, Radio, RegisterButton, RegisterCompany, RegisterContainer, RegisterEmail, RegisterFirstName, RegisterJobTitle, RegisterLastName, RegisterModal, RegisterPassword, RegisterView, Select, SelectModalWithHook as SelectModal, SelectedPaymentMethod, ShopPurchaseButton, ShopSelectProductButton, ShopView, SubmitPaymentMethod, SubscriptionCreateContainer, SubscriptionCreateModal, SubscriptionCreateView, SubscriptionRenewContainer, SubscriptionRenewModal, SubscriptionRenewView, TaxAmount, TextArea, Tooltip, UserUpdateButton, UserUpdateContainer, UserUpdateDisplayName, UserUpdateEmail, UserUpdateFirstName, UserUpdateLastName, UserUpdateModal, UserUpdatePhone, UserUpdateProfilePic, UserUpdateTextInput, UserUpdateView, VerifyLinkTokenContainer, VerifyLinkTokenLoader, VerifyLinkTokenModal, VerifyLinkTokenView, authenticatedButtons, i18next as i18n, init$1 as initButtons, init as initContentEntitlement, invoicePaymentSubmitButton, notify, unauthenticatedButtons, usePelcro };