@pelcro/react-pelcro-js 3.2.0-beta.6 → 3.2.0-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -4684,17 +4684,17 @@ var invoiceDetails_en = {
4684
4684
  buttons: buttons$1
4685
4685
  };
4686
4686
 
4687
- var title$2 = "Invoice details";
4687
+ var title$2 = "Détails de la facture";
4688
4688
  var labels = {
4689
- summary: "Summary",
4689
+ summary: "Résumé",
4690
4690
  total: "Total",
4691
- amountPaid: "Amount paid",
4692
- amountDue: "Amount due",
4693
- creationDate: "Created on:"
4691
+ amountPaid: "Montant payé",
4692
+ amountDue: "Montant ",
4693
+ creationDate: "Créé le:"
4694
4694
  };
4695
4695
  var buttons = {
4696
- download: "Download",
4697
- pay: "Pay now"
4696
+ download: "Télécharger",
4697
+ pay: "Payer"
4698
4698
  };
4699
4699
  var invoiceDetails_fr = {
4700
4700
  title: title$2,
@@ -8775,7 +8775,7 @@ const debounce = (func, waitTime) => {
8775
8775
  function getSiteCardProcessor() {
8776
8776
  var _window$Pelcro$site$r;
8777
8777
 
8778
- if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_pay_page_id) {
8778
+ if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_gateway_settings) {
8779
8779
  return "vantiv";
8780
8780
  }
8781
8781
 
@@ -13020,6 +13020,7 @@ class StripeGateway {
13020
13020
  auth_token: window.Pelcro.user.read().auth_token,
13021
13021
  plan_id: plan.id,
13022
13022
  coupon_code: couponCode,
13023
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13023
13024
  address_id: product.address_required ? addressId : null
13024
13025
  }, (err, res) => {
13025
13026
  callback(err, res);
@@ -13046,6 +13047,7 @@ class StripeGateway {
13046
13047
  auth_token: window.Pelcro.user.read().auth_token,
13047
13048
  plan_id: plan.id,
13048
13049
  coupon_code: couponCode,
13050
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13049
13051
  gift_recipient_email: giftRecipient.email,
13050
13052
  gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
13051
13053
  gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
@@ -13073,6 +13075,7 @@ class StripeGateway {
13073
13075
  stripe_token: token,
13074
13076
  auth_token: window.Pelcro.user.read().auth_token,
13075
13077
  plan_id: plan.id,
13078
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13076
13079
  coupon_code: couponCode,
13077
13080
  subscription_id: subscriptionIdToRenew,
13078
13081
  address_id: product.address_required ? addressId : null
@@ -13125,6 +13128,7 @@ class StripeGateway {
13125
13128
  window.Pelcro.ecommerce.order.create({
13126
13129
  items,
13127
13130
  coupon_code: couponCode,
13131
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13128
13132
  ...params,
13129
13133
  ...(addressId && {
13130
13134
  address_id: addressId
@@ -13212,6 +13216,7 @@ class PaypalGateway {
13212
13216
  payment_gateway: _classPrivateFieldGet(this, _paymentGateway2),
13213
13217
  auth_token: window.Pelcro.user.read().auth_token,
13214
13218
  plan_id: plan.id,
13219
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13215
13220
  coupon_code: couponCode,
13216
13221
  address_id: product.address_required ? addressId : null
13217
13222
  }, (err, res) => {
@@ -13239,6 +13244,7 @@ class PaypalGateway {
13239
13244
  auth_token: window.Pelcro.user.read().auth_token,
13240
13245
  plan_id: plan.id,
13241
13246
  coupon_code: couponCode,
13247
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13242
13248
  gift_recipient_email: giftRecipient.email,
13243
13249
  gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
13244
13250
  gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
@@ -13341,6 +13347,7 @@ class VantivGateway {
13341
13347
  quantity,
13342
13348
  auth_token: window.Pelcro.user.read().auth_token,
13343
13349
  plan_id: plan.id,
13350
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13344
13351
  coupon_code: couponCode,
13345
13352
  address_id: product.address_required ? addressId : null,
13346
13353
  ...params
@@ -13372,6 +13379,7 @@ class VantivGateway {
13372
13379
  auth_token: window.Pelcro.user.read().auth_token,
13373
13380
  plan_id: plan.id,
13374
13381
  coupon_code: couponCode,
13382
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13375
13383
  subscription_id: subscriptionIdToRenew,
13376
13384
  address_id: product.address_required ? addressId : null,
13377
13385
  ...params
@@ -13405,6 +13413,7 @@ class VantivGateway {
13405
13413
  auth_token: window.Pelcro.user.read().auth_token,
13406
13414
  plan_id: plan.id,
13407
13415
  coupon_code: couponCode,
13416
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13408
13417
  gift_recipient_email: giftRecipient.email,
13409
13418
  gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
13410
13419
  gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
@@ -13468,6 +13477,7 @@ class VantivGateway {
13468
13477
  window.Pelcro.ecommerce.order.create({
13469
13478
  items,
13470
13479
  coupon_code: couponCode,
13480
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13471
13481
  ...params,
13472
13482
  ...(addressId && {
13473
13483
  address_id: addressId
@@ -13590,8 +13600,11 @@ const PaymentMethodContainerWithoutStripe = ({
13590
13600
  updateTotalAmountWithTax();
13591
13601
  }, []);
13592
13602
 
13593
- const submitVantivPayment = () => {
13594
- if (selectedPaymentMethodId) {
13603
+ const submitUsingVantiv = () => {
13604
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
13605
+
13606
+ if (isUsingExistingPaymentMethod) {
13607
+ // no need to create a new source using vantiv
13595
13608
  return handleVantivPayment(null);
13596
13609
  }
13597
13610
 
@@ -13599,7 +13612,10 @@ const PaymentMethodContainerWithoutStripe = ({
13599
13612
  return console.error("Vantiv sdk script wasn't loaded, you need to load vantiv sdk before rendering the vantiv payment flow");
13600
13613
  }
13601
13614
 
13602
- const orderId = `pelcro-${new Date().getTime()}`; // calls handleVantivPayment
13615
+ const orderId = `pelcro-${new Date().getTime()}`;
13616
+ /*
13617
+ calls handleVantivPayment to either handle a payment or update a source by simply creating a new source
13618
+ */
13603
13619
 
13604
13620
  vantivInstanceRef.current.getPaypageRegistrationId({
13605
13621
  id: orderId,
@@ -13626,6 +13642,45 @@ const PaymentMethodContainerWithoutStripe = ({
13626
13642
  purchase(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
13627
13643
  } else if (type === "invoicePayment") {
13628
13644
  payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
13645
+ } else if (type === "updatePaymentSource") {
13646
+ createNewVantivCard();
13647
+ }
13648
+
13649
+ function createNewVantivCard() {
13650
+ window.Pelcro.source.create({
13651
+ auth_token: window.Pelcro.user.read().auth_token,
13652
+ token: paymentRequest,
13653
+ gateway: "vantiv"
13654
+ }, (err, res) => {
13655
+ dispatch({
13656
+ type: DISABLE_SUBMIT,
13657
+ payload: false
13658
+ });
13659
+ dispatch({
13660
+ type: LOADING,
13661
+ payload: false
13662
+ });
13663
+
13664
+ if (err) {
13665
+ onFailure(err);
13666
+ return dispatch({
13667
+ type: SHOW_ALERT,
13668
+ payload: {
13669
+ type: "error",
13670
+ content: getErrorMessages(err)
13671
+ }
13672
+ });
13673
+ }
13674
+
13675
+ dispatch({
13676
+ type: SHOW_ALERT,
13677
+ payload: {
13678
+ type: "success",
13679
+ content: t("messages.sourceUpdated")
13680
+ }
13681
+ });
13682
+ onSuccess(res);
13683
+ });
13629
13684
  }
13630
13685
 
13631
13686
  function handleVantivSubscription() {
@@ -13971,6 +14026,7 @@ const PaymentMethodContainerWithoutStripe = ({
13971
14026
  window.Pelcro.order.create({
13972
14027
  auth_token: window.Pelcro.user.read().auth_token,
13973
14028
  plan_id: plan.id,
14029
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13974
14030
  coupon_code: couponCode,
13975
14031
  address_id: selectedAddressId
13976
14032
  }, handleCouponResponse);
@@ -14052,6 +14108,7 @@ const PaymentMethodContainerWithoutStripe = ({
14052
14108
  stripe_token: !stripeSource.isExistingSource ? stripeSource.id : undefined,
14053
14109
  auth_token: window.Pelcro.user.read().auth_token,
14054
14110
  plan_id: plan.id,
14111
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
14055
14112
  quantity: plan.quantity,
14056
14113
  coupon_code: couponCode,
14057
14114
  gift_recipient_email: giftRecipient ? giftRecipient.email : null,
@@ -14123,6 +14180,7 @@ const PaymentMethodContainerWithoutStripe = ({
14123
14180
  stripe_token: !stripeSource.isExistingSource ? stripeSource.id : undefined,
14124
14181
  auth_token: window.Pelcro.user.read().auth_token,
14125
14182
  plan_id: plan.id,
14183
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
14126
14184
  coupon_code: couponCode,
14127
14185
  subscription_id: subscriptionIdToRenew,
14128
14186
  address_id: product.address_required ? selectedAddressId : null
@@ -14344,7 +14402,9 @@ const PaymentMethodContainerWithoutStripe = ({
14344
14402
 
14345
14403
  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") {
14346
14404
  return handlePaymentError({
14347
- message: t("messages.cardAuthNotSupported")
14405
+ error: {
14406
+ message: t("messages.cardAuthNotSupported")
14407
+ }
14348
14408
  });
14349
14409
  }
14350
14410
 
@@ -14475,6 +14535,7 @@ const PaymentMethodContainerWithoutStripe = ({
14475
14535
  window.Pelcro.order.create({
14476
14536
  auth_token: window.Pelcro.user.read().auth_token,
14477
14537
  plan_id: plan.id,
14538
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
14478
14539
  coupon_code: state === null || state === void 0 ? void 0 : state.couponCode,
14479
14540
  address_id: selectedAddressId
14480
14541
  }, (error, res) => {
@@ -14588,7 +14649,9 @@ const PaymentMethodContainerWithoutStripe = ({
14588
14649
 
14589
14650
  if ((source === null || source === void 0 ? void 0 : source.status) === "failed") {
14590
14651
  return handlePaymentError({
14591
- message: t("messages.cardAuthFailed")
14652
+ error: {
14653
+ message: t("messages.cardAuthFailed")
14654
+ }
14592
14655
  });
14593
14656
  }
14594
14657
 
@@ -14660,7 +14723,7 @@ const PaymentMethodContainerWithoutStripe = ({
14660
14723
  isLoading: true
14661
14724
  }, (state, dispatch) => {
14662
14725
  if (getSiteCardProcessor() === "vantiv") {
14663
- return submitVantivPayment();
14726
+ return submitUsingVantiv();
14664
14727
  }
14665
14728
 
14666
14729
  if (selectedPaymentMethodId) {
@@ -25702,6 +25765,8 @@ const InvoiceDetailsView = props => {
25702
25765
  invoice
25703
25766
  } = usePelcro();
25704
25767
  const showPayButton = canPayInvoice(invoice);
25768
+ const showDownloadButton = Boolean(invoice === null || invoice === void 0 ? void 0 : invoice.invoice_pdf);
25769
+ const hasPlanDetails = Boolean(invoice.plan);
25705
25770
  const creationDate = new Date(invoice === null || invoice === void 0 ? void 0 : invoice.created_at);
25706
25771
  const formattedCreationDate = new Intl.DateTimeFormat("en-CA").format(creationDate);
25707
25772
  return /*#__PURE__*/React__default['default'].createElement("div", {
@@ -25719,7 +25784,7 @@ const InvoiceDetailsView = props => {
25719
25784
  className: "plc-font-bold pelcro-invoice-summary-title"
25720
25785
  }, t("labels.summary")), invoice && /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement("p", {
25721
25786
  className: "plc-mr-2 pelcro-invoice-creation-date"
25722
- }, `${t("labels.creationDate")} ${formattedCreationDate}`), /*#__PURE__*/React__default['default'].createElement("div", {
25787
+ }, `${t("labels.creationDate")} ${formattedCreationDate}`), hasPlanDetails && /*#__PURE__*/React__default['default'].createElement("div", {
25723
25788
  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"
25724
25789
  }, /*#__PURE__*/React__default['default'].createElement("div", {
25725
25790
  className: "plc-break-words pelcro-invoice-plan-name"
@@ -25745,7 +25810,7 @@ const InvoiceDetailsView = props => {
25745
25810
  className: "plc-font-semibold pelcro-invoice-total"
25746
25811
  }, getFormattedPriceByLocal(invoice.amount_remaining, invoice.currency, getPageOrDefaultLanguage())))))), /*#__PURE__*/React__default['default'].createElement("div", {
25747
25812
  className: "plc-flex plc-items-center plc-justify-center plc-mt-4"
25748
- }, /*#__PURE__*/React__default['default'].createElement(InvoiceDetailsDownloadButton, {
25813
+ }, showDownloadButton && /*#__PURE__*/React__default['default'].createElement(InvoiceDetailsDownloadButton, {
25749
25814
  url: invoice === null || invoice === void 0 ? void 0 : invoice.invoice_pdf,
25750
25815
  className: "plc-w-full plc-text-center"
25751
25816
  }), showPayButton && /*#__PURE__*/React__default['default'].createElement(InvoiceDetailsPayButton, {
package/dist/index.esm.js CHANGED
@@ -4654,17 +4654,17 @@ var invoiceDetails_en = {
4654
4654
  buttons: buttons$1
4655
4655
  };
4656
4656
 
4657
- var title$2 = "Invoice details";
4657
+ var title$2 = "Détails de la facture";
4658
4658
  var labels = {
4659
- summary: "Summary",
4659
+ summary: "Résumé",
4660
4660
  total: "Total",
4661
- amountPaid: "Amount paid",
4662
- amountDue: "Amount due",
4663
- creationDate: "Created on:"
4661
+ amountPaid: "Montant payé",
4662
+ amountDue: "Montant ",
4663
+ creationDate: "Créé le:"
4664
4664
  };
4665
4665
  var buttons = {
4666
- download: "Download",
4667
- pay: "Pay now"
4666
+ download: "Télécharger",
4667
+ pay: "Payer"
4668
4668
  };
4669
4669
  var invoiceDetails_fr = {
4670
4670
  title: title$2,
@@ -8745,7 +8745,7 @@ const debounce = (func, waitTime) => {
8745
8745
  function getSiteCardProcessor() {
8746
8746
  var _window$Pelcro$site$r;
8747
8747
 
8748
- if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_pay_page_id) {
8748
+ if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_gateway_settings) {
8749
8749
  return "vantiv";
8750
8750
  }
8751
8751
 
@@ -12990,6 +12990,7 @@ class StripeGateway {
12990
12990
  auth_token: window.Pelcro.user.read().auth_token,
12991
12991
  plan_id: plan.id,
12992
12992
  coupon_code: couponCode,
12993
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
12993
12994
  address_id: product.address_required ? addressId : null
12994
12995
  }, (err, res) => {
12995
12996
  callback(err, res);
@@ -13016,6 +13017,7 @@ class StripeGateway {
13016
13017
  auth_token: window.Pelcro.user.read().auth_token,
13017
13018
  plan_id: plan.id,
13018
13019
  coupon_code: couponCode,
13020
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13019
13021
  gift_recipient_email: giftRecipient.email,
13020
13022
  gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
13021
13023
  gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
@@ -13043,6 +13045,7 @@ class StripeGateway {
13043
13045
  stripe_token: token,
13044
13046
  auth_token: window.Pelcro.user.read().auth_token,
13045
13047
  plan_id: plan.id,
13048
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13046
13049
  coupon_code: couponCode,
13047
13050
  subscription_id: subscriptionIdToRenew,
13048
13051
  address_id: product.address_required ? addressId : null
@@ -13095,6 +13098,7 @@ class StripeGateway {
13095
13098
  window.Pelcro.ecommerce.order.create({
13096
13099
  items,
13097
13100
  coupon_code: couponCode,
13101
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13098
13102
  ...params,
13099
13103
  ...(addressId && {
13100
13104
  address_id: addressId
@@ -13182,6 +13186,7 @@ class PaypalGateway {
13182
13186
  payment_gateway: _classPrivateFieldGet(this, _paymentGateway2),
13183
13187
  auth_token: window.Pelcro.user.read().auth_token,
13184
13188
  plan_id: plan.id,
13189
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13185
13190
  coupon_code: couponCode,
13186
13191
  address_id: product.address_required ? addressId : null
13187
13192
  }, (err, res) => {
@@ -13209,6 +13214,7 @@ class PaypalGateway {
13209
13214
  auth_token: window.Pelcro.user.read().auth_token,
13210
13215
  plan_id: plan.id,
13211
13216
  coupon_code: couponCode,
13217
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13212
13218
  gift_recipient_email: giftRecipient.email,
13213
13219
  gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
13214
13220
  gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
@@ -13311,6 +13317,7 @@ class VantivGateway {
13311
13317
  quantity,
13312
13318
  auth_token: window.Pelcro.user.read().auth_token,
13313
13319
  plan_id: plan.id,
13320
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13314
13321
  coupon_code: couponCode,
13315
13322
  address_id: product.address_required ? addressId : null,
13316
13323
  ...params
@@ -13342,6 +13349,7 @@ class VantivGateway {
13342
13349
  auth_token: window.Pelcro.user.read().auth_token,
13343
13350
  plan_id: plan.id,
13344
13351
  coupon_code: couponCode,
13352
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13345
13353
  subscription_id: subscriptionIdToRenew,
13346
13354
  address_id: product.address_required ? addressId : null,
13347
13355
  ...params
@@ -13375,6 +13383,7 @@ class VantivGateway {
13375
13383
  auth_token: window.Pelcro.user.read().auth_token,
13376
13384
  plan_id: plan.id,
13377
13385
  coupon_code: couponCode,
13386
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13378
13387
  gift_recipient_email: giftRecipient.email,
13379
13388
  gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
13380
13389
  gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
@@ -13438,6 +13447,7 @@ class VantivGateway {
13438
13447
  window.Pelcro.ecommerce.order.create({
13439
13448
  items,
13440
13449
  coupon_code: couponCode,
13450
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13441
13451
  ...params,
13442
13452
  ...(addressId && {
13443
13453
  address_id: addressId
@@ -13560,8 +13570,11 @@ const PaymentMethodContainerWithoutStripe = ({
13560
13570
  updateTotalAmountWithTax();
13561
13571
  }, []);
13562
13572
 
13563
- const submitVantivPayment = () => {
13564
- if (selectedPaymentMethodId) {
13573
+ const submitUsingVantiv = () => {
13574
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
13575
+
13576
+ if (isUsingExistingPaymentMethod) {
13577
+ // no need to create a new source using vantiv
13565
13578
  return handleVantivPayment(null);
13566
13579
  }
13567
13580
 
@@ -13569,7 +13582,10 @@ const PaymentMethodContainerWithoutStripe = ({
13569
13582
  return console.error("Vantiv sdk script wasn't loaded, you need to load vantiv sdk before rendering the vantiv payment flow");
13570
13583
  }
13571
13584
 
13572
- const orderId = `pelcro-${new Date().getTime()}`; // calls handleVantivPayment
13585
+ const orderId = `pelcro-${new Date().getTime()}`;
13586
+ /*
13587
+ calls handleVantivPayment to either handle a payment or update a source by simply creating a new source
13588
+ */
13573
13589
 
13574
13590
  vantivInstanceRef.current.getPaypageRegistrationId({
13575
13591
  id: orderId,
@@ -13596,6 +13612,45 @@ const PaymentMethodContainerWithoutStripe = ({
13596
13612
  purchase(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
13597
13613
  } else if (type === "invoicePayment") {
13598
13614
  payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
13615
+ } else if (type === "updatePaymentSource") {
13616
+ createNewVantivCard();
13617
+ }
13618
+
13619
+ function createNewVantivCard() {
13620
+ window.Pelcro.source.create({
13621
+ auth_token: window.Pelcro.user.read().auth_token,
13622
+ token: paymentRequest,
13623
+ gateway: "vantiv"
13624
+ }, (err, res) => {
13625
+ dispatch({
13626
+ type: DISABLE_SUBMIT,
13627
+ payload: false
13628
+ });
13629
+ dispatch({
13630
+ type: LOADING,
13631
+ payload: false
13632
+ });
13633
+
13634
+ if (err) {
13635
+ onFailure(err);
13636
+ return dispatch({
13637
+ type: SHOW_ALERT,
13638
+ payload: {
13639
+ type: "error",
13640
+ content: getErrorMessages(err)
13641
+ }
13642
+ });
13643
+ }
13644
+
13645
+ dispatch({
13646
+ type: SHOW_ALERT,
13647
+ payload: {
13648
+ type: "success",
13649
+ content: t("messages.sourceUpdated")
13650
+ }
13651
+ });
13652
+ onSuccess(res);
13653
+ });
13599
13654
  }
13600
13655
 
13601
13656
  function handleVantivSubscription() {
@@ -13941,6 +13996,7 @@ const PaymentMethodContainerWithoutStripe = ({
13941
13996
  window.Pelcro.order.create({
13942
13997
  auth_token: window.Pelcro.user.read().auth_token,
13943
13998
  plan_id: plan.id,
13999
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
13944
14000
  coupon_code: couponCode,
13945
14001
  address_id: selectedAddressId
13946
14002
  }, handleCouponResponse);
@@ -14022,6 +14078,7 @@ const PaymentMethodContainerWithoutStripe = ({
14022
14078
  stripe_token: !stripeSource.isExistingSource ? stripeSource.id : undefined,
14023
14079
  auth_token: window.Pelcro.user.read().auth_token,
14024
14080
  plan_id: plan.id,
14081
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
14025
14082
  quantity: plan.quantity,
14026
14083
  coupon_code: couponCode,
14027
14084
  gift_recipient_email: giftRecipient ? giftRecipient.email : null,
@@ -14093,6 +14150,7 @@ const PaymentMethodContainerWithoutStripe = ({
14093
14150
  stripe_token: !stripeSource.isExistingSource ? stripeSource.id : undefined,
14094
14151
  auth_token: window.Pelcro.user.read().auth_token,
14095
14152
  plan_id: plan.id,
14153
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
14096
14154
  coupon_code: couponCode,
14097
14155
  subscription_id: subscriptionIdToRenew,
14098
14156
  address_id: product.address_required ? selectedAddressId : null
@@ -14314,7 +14372,9 @@ const PaymentMethodContainerWithoutStripe = ({
14314
14372
 
14315
14373
  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") {
14316
14374
  return handlePaymentError({
14317
- message: t("messages.cardAuthNotSupported")
14375
+ error: {
14376
+ message: t("messages.cardAuthNotSupported")
14377
+ }
14318
14378
  });
14319
14379
  }
14320
14380
 
@@ -14445,6 +14505,7 @@ const PaymentMethodContainerWithoutStripe = ({
14445
14505
  window.Pelcro.order.create({
14446
14506
  auth_token: window.Pelcro.user.read().auth_token,
14447
14507
  plan_id: plan.id,
14508
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
14448
14509
  coupon_code: state === null || state === void 0 ? void 0 : state.couponCode,
14449
14510
  address_id: selectedAddressId
14450
14511
  }, (error, res) => {
@@ -14558,7 +14619,9 @@ const PaymentMethodContainerWithoutStripe = ({
14558
14619
 
14559
14620
  if ((source === null || source === void 0 ? void 0 : source.status) === "failed") {
14560
14621
  return handlePaymentError({
14561
- message: t("messages.cardAuthFailed")
14622
+ error: {
14623
+ message: t("messages.cardAuthFailed")
14624
+ }
14562
14625
  });
14563
14626
  }
14564
14627
 
@@ -14630,7 +14693,7 @@ const PaymentMethodContainerWithoutStripe = ({
14630
14693
  isLoading: true
14631
14694
  }, (state, dispatch) => {
14632
14695
  if (getSiteCardProcessor() === "vantiv") {
14633
- return submitVantivPayment();
14696
+ return submitUsingVantiv();
14634
14697
  }
14635
14698
 
14636
14699
  if (selectedPaymentMethodId) {
@@ -25672,6 +25735,8 @@ const InvoiceDetailsView = props => {
25672
25735
  invoice
25673
25736
  } = usePelcro();
25674
25737
  const showPayButton = canPayInvoice(invoice);
25738
+ const showDownloadButton = Boolean(invoice === null || invoice === void 0 ? void 0 : invoice.invoice_pdf);
25739
+ const hasPlanDetails = Boolean(invoice.plan);
25675
25740
  const creationDate = new Date(invoice === null || invoice === void 0 ? void 0 : invoice.created_at);
25676
25741
  const formattedCreationDate = new Intl.DateTimeFormat("en-CA").format(creationDate);
25677
25742
  return /*#__PURE__*/React__default.createElement("div", {
@@ -25689,7 +25754,7 @@ const InvoiceDetailsView = props => {
25689
25754
  className: "plc-font-bold pelcro-invoice-summary-title"
25690
25755
  }, t("labels.summary")), invoice && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("p", {
25691
25756
  className: "plc-mr-2 pelcro-invoice-creation-date"
25692
- }, `${t("labels.creationDate")} ${formattedCreationDate}`), /*#__PURE__*/React__default.createElement("div", {
25757
+ }, `${t("labels.creationDate")} ${formattedCreationDate}`), hasPlanDetails && /*#__PURE__*/React__default.createElement("div", {
25693
25758
  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"
25694
25759
  }, /*#__PURE__*/React__default.createElement("div", {
25695
25760
  className: "plc-break-words pelcro-invoice-plan-name"
@@ -25715,7 +25780,7 @@ const InvoiceDetailsView = props => {
25715
25780
  className: "plc-font-semibold pelcro-invoice-total"
25716
25781
  }, getFormattedPriceByLocal(invoice.amount_remaining, invoice.currency, getPageOrDefaultLanguage())))))), /*#__PURE__*/React__default.createElement("div", {
25717
25782
  className: "plc-flex plc-items-center plc-justify-center plc-mt-4"
25718
- }, /*#__PURE__*/React__default.createElement(InvoiceDetailsDownloadButton, {
25783
+ }, showDownloadButton && /*#__PURE__*/React__default.createElement(InvoiceDetailsDownloadButton, {
25719
25784
  url: invoice === null || invoice === void 0 ? void 0 : invoice.invoice_pdf,
25720
25785
  className: "plc-w-full plc-text-center"
25721
25786
  }), showPayButton && /*#__PURE__*/React__default.createElement(InvoiceDetailsPayButton, {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pelcro/react-pelcro-js",
3
3
  "description": "Pelcro's React UI Elements",
4
- "version": "3.2.0-beta.6",
4
+ "version": "3.2.0-beta.9",
5
5
  "license": "MIT",
6
6
  "private": false,
7
7
  "main": "dist/index.cjs.js",