@pelcro/react-pelcro-js 3.7.0 → 3.8.0

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
@@ -4935,7 +4935,8 @@ var messages$h = {
4935
4935
  successfully: "avec succès.",
4936
4936
  sourceUpdated: "Vos informations de paiement ont été mises à jour",
4937
4937
  cardAuthFailed: "Nous ne parvenons pas à authentifier votre mode de paiement. Veuillez choisir un autre mode de paiement et essayer à nouveau.",
4938
- cardAuthNotSupported: "Votre carte ne peut être mise à jour puisqu'elle nécessite une authentification. Veuillez utiliser un autre mode de paiement ou contacter le service client."
4938
+ cardAuthNotSupported: "Votre carte ne peut être mise à jour puisqu'elle nécessite une authentification. Veuillez utiliser un autre mode de paiement ou contacter le service client.",
4939
+ tryAgainFromInvoice: "Nous n'avons pas pu authentifier votre paiement, mais votre abonnement a été créé. Veuillez essayer de payer la facture en utilisant un autre mode de paiement depuis le tableau de bord."
4939
4940
  };
4940
4941
  var errors$2 = {
4941
4942
  "": ""
@@ -4975,7 +4976,8 @@ var messages$g = {
4975
4976
  successfully: "successfully",
4976
4977
  sourceUpdated: "Your payment information has been updated",
4977
4978
  cardAuthFailed: "We are unable to authenticate your payment method. Please choose a different payment method and try again.",
4978
- cardAuthNotSupported: "Updating your payment method to one that requires authentication is currently not possible. Please use a different payment method or contact customer service."
4979
+ cardAuthNotSupported: "Updating your payment method to one that requires authentication is currently not possible. Please use a different payment method or contact customer service.",
4980
+ tryAgainFromInvoice: "We were unable to authenticate your payment, however your subscription was created. Please attempt to pay for the invoice using another payment method from the dashboard."
4979
4981
  };
4980
4982
  var errors$1 = {
4981
4983
  "": ""
@@ -5015,7 +5017,8 @@ var messages$f = {
5015
5017
  successfully: "님께 성공적으로 전송되었습니다.",
5016
5018
  sourceUpdated: "귀하의 결제 정보가 업데이트되었습니다.",
5017
5019
  cardAuthFailed: "해당 결제 수단은 인증할 수 없습니다. 다른 결제 수단을 선택하여 다시 시도해보시기 바랍니다.",
5018
- cardAuthNotSupported: "인증이 요구되는 결제 수단으로의 업데이트는 현재 지원되지 않습니다. 다른 결제 수단을 이용하거나 고객센터로 문의하시기 바랍니다."
5020
+ cardAuthNotSupported: "인증이 요구되는 결제 수단으로의 업데이트는 현재 지원되지 않습니다. 다른 결제 수단을 이용하거나 고객센터로 문의하시기 바랍니다.",
5021
+ tryAgainFromInvoice: "결제를 인증할 수 없지만 구독이 생성되었습니다. 대시보드에서 다른 결제 수단을 사용하여 인보이스 결제를 시도하세요."
5019
5022
  };
5020
5023
  var errors = {
5021
5024
  "": ""
@@ -5038,7 +5041,8 @@ var labels$h = {
5038
5041
  active: "Active",
5039
5042
  inTrial: "In trial",
5040
5043
  endingSoon: "Ending soon",
5041
- scheduled: "Scheduled"
5044
+ scheduled: "Scheduled",
5045
+ incomplete: "Incomplete"
5042
5046
  },
5043
5047
  shipments: "Shipments remaining",
5044
5048
  logout: "Logout",
@@ -5138,9 +5142,10 @@ var labels$g = {
5138
5142
  status: {
5139
5143
  title: "Statut",
5140
5144
  active: "Active",
5141
- inTrial: "Dans l'essai",
5142
- endingSoon: "Fin bientôt",
5143
- scheduled: "Programmé"
5145
+ inTrial: "En essai",
5146
+ endingSoon: "Expire bientôt",
5147
+ scheduled: "Programmé",
5148
+ incomplete: "Incomplet"
5144
5149
  },
5145
5150
  shipments: "Expéditions restantes",
5146
5151
  logout: "Déconnexion",
@@ -5242,7 +5247,8 @@ var labels$f = {
5242
5247
  active: "활성화",
5243
5248
  inTrial: "체험판 사용",
5244
5249
  endingSoon: "만료 예정",
5245
- scheduled: "예약"
5250
+ scheduled: "예약",
5251
+ incomplete: "불완전한"
5246
5252
  },
5247
5253
  shipments: "남은 배송 일정",
5248
5254
  logout: "로그아웃",
@@ -7399,7 +7405,7 @@ class PelcroActions {
7399
7405
  });
7400
7406
  });
7401
7407
 
7402
- _defineProperty$3(this, "logout", () => {
7408
+ _defineProperty$3(this, "logout", (displayLogin = true) => {
7403
7409
  var _ReactGA$event;
7404
7410
 
7405
7411
  const {
@@ -7419,7 +7425,10 @@ class PelcroActions {
7419
7425
  nonInteraction: true
7420
7426
  });
7421
7427
  resetView();
7422
- switchView("login");
7428
+
7429
+ if (displayLogin) {
7430
+ switchView("login");
7431
+ }
7423
7432
  });
7424
7433
 
7425
7434
  _defineProperty$3(this, "addToCart", itemSkuId => {
@@ -7921,10 +7930,10 @@ const getEntitlementsFromElem = elem => {
7921
7930
  return elem.dataset.pelcroEntitlements.split(",").map(entitlement => entitlement.trim()).filter(entitlement => entitlement);
7922
7931
  };
7923
7932
  const getPaymentCardIcon$1 = name => {
7924
- var _icons$name;
7933
+ var _icons$name$toLowerCa;
7925
7934
 
7926
7935
  const icons = {
7927
- Visa: /*#__PURE__*/React__default['default'].createElement("svg", {
7936
+ visa: /*#__PURE__*/React__default['default'].createElement("svg", {
7928
7937
  className: "plc-w-16",
7929
7938
  xmlns: "http://www.w3.org/2000/svg",
7930
7939
  viewBox: "0 0 48 48"
@@ -7935,7 +7944,7 @@ const getPaymentCardIcon$1 = name => {
7935
7944
  fill: "#FFC107",
7936
7945
  d: "M12.212,24.945l-0.966-4.748c0,0-0.437-1.029-1.573-1.029c-1.136,0-4.44,0-4.44,0S10.894,20.84,12.212,24.945z"
7937
7946
  })),
7938
- MasterCard: /*#__PURE__*/React__default['default'].createElement("svg", {
7947
+ mastercard: /*#__PURE__*/React__default['default'].createElement("svg", {
7939
7948
  className: "plc-w-16",
7940
7949
  xmlns: "http://www.w3.org/2000/svg",
7941
7950
  viewBox: "0 0 48 48"
@@ -7949,7 +7958,7 @@ const getPaymentCardIcon$1 = name => {
7949
7958
  fill: "#ff3d00",
7950
7959
  d: "M18,24c0,4.755,2.376,8.95,6,11.48c3.624-2.53,6-6.725,6-11.48s-2.376-8.95-6-11.48 C20.376,15.05,18,19.245,18,24z"
7951
7960
  })),
7952
- "American Express": /*#__PURE__*/React__default['default'].createElement("svg", {
7961
+ "american express": /*#__PURE__*/React__default['default'].createElement("svg", {
7953
7962
  className: "plc-w-16",
7954
7963
  xmlns: "http://www.w3.org/2000/svg",
7955
7964
  viewBox: "0 0 48 48"
@@ -7961,7 +7970,7 @@ const getPaymentCardIcon$1 = name => {
7961
7970
  d: "M22.255 20l-2.113 4.683L18.039 20h-2.695v6.726L12.341 20h-2.274L7 26.981h1.815l.671-1.558h3.432l.682 1.558h3.465v-5.185l2.299 5.185h1.563l2.351-5.095v5.095H25V20H22.255zM10.135 23.915l1.026-2.44 1.066 2.44H10.135zM37.883 23.413L41 20.018h-2.217l-1.994 2.164L34.86 20H28v6.982h6.635l2.092-2.311L38.767 27h2.21L37.883 23.413zM33.728 25.516h-4.011v-1.381h3.838v-1.323h-3.838v-1.308l4.234.012 1.693 1.897L33.728 25.516z"
7962
7971
  }))
7963
7972
  };
7964
- return (_icons$name = icons[name]) !== null && _icons$name !== void 0 ? _icons$name : /*#__PURE__*/React__default['default'].createElement("svg", {
7973
+ return (_icons$name$toLowerCa = icons[name.toLowerCase()]) !== null && _icons$name$toLowerCa !== void 0 ? _icons$name$toLowerCa : /*#__PURE__*/React__default['default'].createElement("svg", {
7965
7974
  xmlns: "http://www.w3.org/2000/svg",
7966
7975
  className: "plc-w-16",
7967
7976
  fill: "none",
@@ -9972,12 +9981,16 @@ const debounce = (func, waitTime) => {
9972
9981
  };
9973
9982
  };
9974
9983
  function getSiteCardProcessor() {
9975
- var _window$Pelcro$site$r;
9984
+ var _window$Pelcro$site$r, _window$Pelcro$site$r2;
9976
9985
 
9977
9986
  if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_gateway_settings) {
9978
9987
  return "vantiv";
9979
9988
  }
9980
9989
 
9990
+ if ((_window$Pelcro$site$r2 = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r2 !== void 0 && _window$Pelcro$site$r2.tap_gateway_settings) {
9991
+ return "tap";
9992
+ }
9993
+
9981
9994
  return "stripe";
9982
9995
  }
9983
9996
 
@@ -10083,6 +10096,14 @@ const loadPaymentSDKs = () => {
10083
10096
  const scriptUrlToUse = window.Pelcro.site.read().vantiv_gateway_settings.environment === "production" ? PRODUCTION_URL : PRELIVE_URL;
10084
10097
  window.Pelcro.helpers.loadSDK(scriptUrlToUse, "vantiv-eprotect-sdk");
10085
10098
  }
10099
+ } // Load Tap SDKs
10100
+
10101
+
10102
+ const supportsTap = Boolean(window.Pelcro.site.read().tap_gateway_settings);
10103
+
10104
+ if (supportsTap) {
10105
+ window.Pelcro.helpers.loadSDK("https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js", "tap-bluebird");
10106
+ window.Pelcro.helpers.loadSDK("https://secure.gosell.io/js/sdk/tap.min.js", "tap-sdk");
10086
10107
  }
10087
10108
  };
10088
10109
  const loadAuth0SDK = () => {
@@ -14195,7 +14216,7 @@ var _generateUserError = /*#__PURE__*/new WeakMap();
14195
14216
 
14196
14217
  class Payment {
14197
14218
  /**
14198
- * @param {(StripeGateway|PaypalGateway|VantivGateway)} paymentGateway
14219
+ * @param {(StripeGateway|PaypalGateway|VantivGateway|TapGateway)} paymentGateway
14199
14220
  */
14200
14221
  constructor(paymentGateway) {
14201
14222
  _defineProperty$3(this, "execute", (options, callback) => {
@@ -14216,7 +14237,7 @@ class Payment {
14216
14237
  _isPaymentGatewayInvalid.set(this, {
14217
14238
  writable: true,
14218
14239
  value: gateway => {
14219
- return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway);
14240
+ return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway || gateway instanceof TapGateway);
14220
14241
  }
14221
14242
  });
14222
14243
 
@@ -14271,7 +14292,8 @@ class Payment {
14271
14292
  const PAYMENT_GATEWAYS_ENUM = {
14272
14293
  stripe: "stripe",
14273
14294
  paypal: "braintree",
14274
- vantiv: "vantiv"
14295
+ vantiv: "vantiv",
14296
+ tap: "tap"
14275
14297
  };
14276
14298
  /**
14277
14299
  * Payment Strategies
@@ -14839,6 +14861,241 @@ class VantivGateway {
14839
14861
 
14840
14862
  }
14841
14863
 
14864
+ var _paymentGateway4 = /*#__PURE__*/new WeakMap();
14865
+
14866
+ var _createSubscription4 = /*#__PURE__*/new WeakMap();
14867
+
14868
+ var _renewSubscription3 = /*#__PURE__*/new WeakMap();
14869
+
14870
+ var _createGiftedSubscription4 = /*#__PURE__*/new WeakMap();
14871
+
14872
+ var _renewGiftedSubscription3 = /*#__PURE__*/new WeakMap();
14873
+
14874
+ var _purchaseEcommerceOrder3 = /*#__PURE__*/new WeakMap();
14875
+
14876
+ var _payInvoice4 = /*#__PURE__*/new WeakMap();
14877
+
14878
+ class TapGateway {
14879
+ constructor() {
14880
+ _paymentGateway4.set(this, {
14881
+ writable: true,
14882
+ value: PAYMENT_GATEWAYS_ENUM["tap"]
14883
+ });
14884
+
14885
+ _defineProperty$3(this, "execute", (options, callback) => {
14886
+ const types = PAYMENT_TYPES;
14887
+
14888
+ switch (options.type) {
14889
+ case types.CREATE_SUBSCRIPTION:
14890
+ return _classPrivateFieldGet(this, _createSubscription4).call(this, options, callback);
14891
+
14892
+ case types.RENEW_SUBSCRIPTION:
14893
+ return _classPrivateFieldGet(this, _renewSubscription3).call(this, options, callback);
14894
+
14895
+ case types.CREATE_GIFTED_SUBSCRIPTION:
14896
+ return _classPrivateFieldGet(this, _createGiftedSubscription4).call(this, options, callback);
14897
+
14898
+ case types.RENEW_GIFTED_SUBSCRIPTION:
14899
+ return _classPrivateFieldGet(this, _renewGiftedSubscription3).call(this, options, callback);
14900
+
14901
+ case types.PURCHASE_ECOMMERCE_ORDER:
14902
+ return _classPrivateFieldGet(this, _purchaseEcommerceOrder3).call(this, options, callback);
14903
+
14904
+ case types.PAY_INVOICE:
14905
+ return _classPrivateFieldGet(this, _payInvoice4).call(this, options, callback);
14906
+
14907
+ default:
14908
+ console.error("Unsupported payment method: tap Gateway");
14909
+ }
14910
+ });
14911
+
14912
+ _createSubscription4.set(this, {
14913
+ writable: true,
14914
+ value: (options, callback) => {
14915
+ const {
14916
+ token,
14917
+ plan,
14918
+ couponCode,
14919
+ product,
14920
+ quantity = 1,
14921
+ addressId,
14922
+ isExistingSource
14923
+ } = options;
14924
+ const params = isExistingSource ? {
14925
+ source_id: token
14926
+ } : {
14927
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway4),
14928
+ gateway_token: token
14929
+ };
14930
+ window.Pelcro.subscription.create({
14931
+ quantity,
14932
+ auth_token: window.Pelcro.user.read().auth_token,
14933
+ plan_id: plan.id,
14934
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
14935
+ coupon_code: couponCode,
14936
+ address_id: product.address_required ? addressId : null,
14937
+ ...params
14938
+ }, (err, res) => {
14939
+ callback(err, res);
14940
+ });
14941
+ }
14942
+ });
14943
+
14944
+ _renewSubscription3.set(this, {
14945
+ writable: true,
14946
+ value: (options, callback) => {
14947
+ const {
14948
+ subscriptionIdToRenew,
14949
+ token,
14950
+ plan,
14951
+ couponCode,
14952
+ product,
14953
+ addressId,
14954
+ isExistingSource
14955
+ } = options;
14956
+ const params = isExistingSource ? {
14957
+ source_id: token
14958
+ } : {
14959
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway4),
14960
+ gateway_token: token
14961
+ };
14962
+ window.Pelcro.subscription.renew({
14963
+ auth_token: window.Pelcro.user.read().auth_token,
14964
+ plan_id: plan.id,
14965
+ coupon_code: couponCode,
14966
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
14967
+ subscription_id: subscriptionIdToRenew,
14968
+ address_id: product.address_required ? addressId : null,
14969
+ ...params
14970
+ }, (err, res) => {
14971
+ callback(err, res);
14972
+ });
14973
+ }
14974
+ });
14975
+
14976
+ _createGiftedSubscription4.set(this, {
14977
+ writable: true,
14978
+ value: (options, callback) => {
14979
+ const {
14980
+ token,
14981
+ plan,
14982
+ couponCode,
14983
+ product,
14984
+ giftRecipient,
14985
+ quantity = 1,
14986
+ addressId,
14987
+ isExistingSource
14988
+ } = options;
14989
+ const params = isExistingSource ? {
14990
+ source_id: token
14991
+ } : {
14992
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway4),
14993
+ gateway_token: token
14994
+ };
14995
+ window.Pelcro.subscription.create({
14996
+ quantity,
14997
+ auth_token: window.Pelcro.user.read().auth_token,
14998
+ plan_id: plan.id,
14999
+ coupon_code: couponCode,
15000
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
15001
+ gift_recipient_email: giftRecipient.email,
15002
+ gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
15003
+ gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
15004
+ gift_start_date: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.startDate,
15005
+ gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
15006
+ address_id: product.address_required ? addressId : null,
15007
+ ...params
15008
+ }, (err, res) => {
15009
+ callback(err, res);
15010
+ });
15011
+ }
15012
+ });
15013
+
15014
+ _renewGiftedSubscription3.set(this, {
15015
+ writable: true,
15016
+ value: (options, callback) => {
15017
+ const {
15018
+ subscriptionIdToRenew,
15019
+ token,
15020
+ product,
15021
+ plan,
15022
+ couponCode,
15023
+ addressId,
15024
+ isExistingSource
15025
+ } = options;
15026
+ const params = isExistingSource ? {
15027
+ source_id: token
15028
+ } : {
15029
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway4),
15030
+ gateway_token: token
15031
+ };
15032
+ window.Pelcro.subscription.renewGift({
15033
+ auth_token: window.Pelcro.user.read().auth_token,
15034
+ plan_id: plan.id,
15035
+ coupon_code: couponCode,
15036
+ subscription_id: subscriptionIdToRenew,
15037
+ address_id: product.address_required ? addressId : null,
15038
+ ...params
15039
+ }, (err, res) => {
15040
+ callback(err, res);
15041
+ });
15042
+ }
15043
+ });
15044
+
15045
+ _purchaseEcommerceOrder3.set(this, {
15046
+ writable: true,
15047
+ value: (options, callback) => {
15048
+ const {
15049
+ token,
15050
+ items,
15051
+ couponCode,
15052
+ addressId,
15053
+ isExistingSource
15054
+ } = options;
15055
+ const params = isExistingSource ? {
15056
+ source_id: token
15057
+ } : {
15058
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway4),
15059
+ gateway_token: token
15060
+ };
15061
+ window.Pelcro.ecommerce.order.create({
15062
+ items,
15063
+ coupon_code: couponCode,
15064
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
15065
+ ...params,
15066
+ ...(addressId && {
15067
+ address_id: addressId
15068
+ })
15069
+ }, (err, res) => {
15070
+ callback(err, res);
15071
+ });
15072
+ }
15073
+ });
15074
+
15075
+ _payInvoice4.set(this, {
15076
+ writable: true,
15077
+ value: (options, callback) => {
15078
+ const {
15079
+ token,
15080
+ invoiceId
15081
+ } = options;
15082
+ const params = options.isExistingSource ? {
15083
+ source_id: token,
15084
+ invoice_id: invoiceId
15085
+ } : {
15086
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway4),
15087
+ gateway_token: token,
15088
+ invoice_id: invoiceId
15089
+ };
15090
+ window.Pelcro.invoice.pay(params, (err, res) => {
15091
+ callback(err, res);
15092
+ });
15093
+ }
15094
+ });
15095
+ }
15096
+
15097
+ }
15098
+
14842
15099
  /**
14843
15100
  * @typedef {Object} PaymentStateType
14844
15101
  * @property {boolean} disableSubmit
@@ -14883,55 +15140,324 @@ const {
14883
15140
  Provider: Provider$j
14884
15141
  } = store$j;
14885
15142
 
14886
- const PaymentMethodContainerWithoutStripe = ({
14887
- style,
14888
- className = "",
14889
- children,
14890
- stripe,
14891
- type,
14892
- onSuccess = () => {},
14893
- onGiftRenewalSuccess = () => {},
14894
- onFailure = () => {},
14895
- ...props
14896
- }) => {
14897
- var _props$product, _props$plan, _props$subscriptionId, _props$selectedAddres, _props$giftRecipient, _props$isGift, _props$isRenewingGift, _props$invoice;
15143
+ const PaymentMethodContainerWithoutStripe = ({
15144
+ style,
15145
+ className = "",
15146
+ children,
15147
+ stripe,
15148
+ type,
15149
+ onSuccess = () => {},
15150
+ onGiftRenewalSuccess = () => {},
15151
+ onFailure = () => {},
15152
+ ...props
15153
+ }) => {
15154
+ var _props$product, _props$plan, _props$subscriptionId, _props$selectedAddres, _props$giftRecipient, _props$isGift, _props$isRenewingGift, _props$invoice;
15155
+
15156
+ const {
15157
+ t
15158
+ } = useTranslation("payment");
15159
+ const pelcroStore = usePelcro();
15160
+ const {
15161
+ set,
15162
+ order,
15163
+ selectedPaymentMethodId,
15164
+ couponCode
15165
+ } = usePelcro();
15166
+ const product = (_props$product = props.product) !== null && _props$product !== void 0 ? _props$product : pelcroStore.product;
15167
+ const plan = (_props$plan = props.plan) !== null && _props$plan !== void 0 ? _props$plan : pelcroStore.plan;
15168
+ const subscriptionIdToRenew = (_props$subscriptionId = props.subscriptionIdToRenew) !== null && _props$subscriptionId !== void 0 ? _props$subscriptionId : pelcroStore.subscriptionIdToRenew;
15169
+ const selectedAddressId = (_props$selectedAddres = props.selectedAddressId) !== null && _props$selectedAddres !== void 0 ? _props$selectedAddres : pelcroStore.selectedAddressId;
15170
+ const giftRecipient = (_props$giftRecipient = props.giftRecipient) !== null && _props$giftRecipient !== void 0 ? _props$giftRecipient : pelcroStore.giftRecipient;
15171
+ const isGift = (_props$isGift = props.isGift) !== null && _props$isGift !== void 0 ? _props$isGift : pelcroStore.isGift;
15172
+ const isRenewingGift = (_props$isRenewingGift = props.isRenewingGift) !== null && _props$isRenewingGift !== void 0 ? _props$isRenewingGift : pelcroStore.isRenewingGift;
15173
+ const invoice = (_props$invoice = props.invoice) !== null && _props$invoice !== void 0 ? _props$invoice : pelcroStore.invoice;
15174
+ React.useEffect(() => {
15175
+ if (window.Pelcro.coupon.getFromUrl()) {
15176
+ dispatch({
15177
+ type: UPDATE_COUPON_CODE,
15178
+ payload: window.Pelcro.coupon.getFromUrl()
15179
+ });
15180
+ } else if (couponCode) {
15181
+ dispatch({
15182
+ type: UPDATE_COUPON_CODE,
15183
+ payload: couponCode
15184
+ });
15185
+ }
15186
+
15187
+ dispatch({
15188
+ type: INIT_CONTAINER
15189
+ });
15190
+ updateTotalAmountWithTax();
15191
+ }, []);
15192
+ /*====== Start Tap integration ========*/
15193
+
15194
+ const submitUsingTap = () => {
15195
+ var _ref, _ref2, _state$updatedPrice;
15196
+
15197
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
15198
+
15199
+ if (isUsingExistingPaymentMethod) {
15200
+ // no need to create a new source using tap
15201
+ return handleTapPayment(null);
15202
+ }
15203
+
15204
+ if (!tapInstanceRef.current) {
15205
+ return console.error("Tap sdk script wasn't loaded, you need to load tap sdk before rendering the tap payment flow");
15206
+ }
15207
+
15208
+ const getOrderItemsTotal = () => {
15209
+ if (!order) {
15210
+ return null;
15211
+ }
15212
+
15213
+ const isQuickPurchase = !Array.isArray(order);
15214
+
15215
+ if (isQuickPurchase) {
15216
+ return order.price * order.quantity;
15217
+ }
15218
+
15219
+ if (order.length === 0) {
15220
+ return null;
15221
+ }
15222
+
15223
+ return order.reduce((total, item) => {
15224
+ return total + item.price * item.quantity;
15225
+ }, 0);
15226
+ };
15227
+
15228
+ const totalAmount = (_ref = (_ref2 = (_state$updatedPrice = state === null || state === void 0 ? void 0 : state.updatedPrice) !== null && _state$updatedPrice !== void 0 ? _state$updatedPrice : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref2 !== void 0 ? _ref2 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref !== void 0 ? _ref : getOrderItemsTotal();
15229
+ tapInstanceRef.current.createToken(tapInstanceCard.current).then(function (result) {
15230
+ if (result.error) {
15231
+ // Inform the user if there was an error
15232
+ onFailure(result.error);
15233
+ dispatch({
15234
+ type: DISABLE_SUBMIT,
15235
+ payload: false
15236
+ });
15237
+ dispatch({
15238
+ type: LOADING,
15239
+ payload: false
15240
+ });
15241
+ return dispatch({
15242
+ type: SHOW_ALERT,
15243
+ payload: {
15244
+ type: "error",
15245
+ content: getErrorMessages(result.error)
15246
+ }
15247
+ });
15248
+ } else {
15249
+ console.log("Tap API Call result", result);
15250
+ window.Pelcro.payment.authorize({
15251
+ auth_token: window.Pelcro.user.read().auth_token,
15252
+ site_id: window.Pelcro.siteid,
15253
+ amount: totalAmount,
15254
+ currency: (plan === null || plan === void 0 ? void 0 : plan.currency) || (invoice === null || invoice === void 0 ? void 0 : invoice.currency) || window.Pelcro.site.read().default_currency,
15255
+ tap_token: result.id,
15256
+ redirect_url: `${window.Pelcro.environment.domain}/webhook/tap/callback/3dsecure?auth_token=${window.Pelcro.user.read().auth_token}`
15257
+ }, (err, res) => {
15258
+ if (err) {
15259
+ // Inform the user if there was an error
15260
+ onFailure(err);
15261
+ dispatch({
15262
+ type: DISABLE_SUBMIT,
15263
+ payload: false
15264
+ });
15265
+ dispatch({
15266
+ type: LOADING,
15267
+ payload: false
15268
+ });
15269
+ return dispatch({
15270
+ type: SHOW_ALERT,
15271
+ payload: {
15272
+ type: "error",
15273
+ content: getErrorMessages(err)
15274
+ }
15275
+ });
15276
+ } else {
15277
+ toggleAuthenticationPendingView(true, res);
15278
+
15279
+ const listenFor3DSecureCompletionMessage = () => {
15280
+ const retrieveSourceInfoFromIframe = event => {
15281
+ const {
15282
+ data
15283
+ } = event;
15284
+
15285
+ if (data.message === "3DS-authentication-complete") {
15286
+ const tapID = data.tapID;
15287
+ toggleAuthenticationPendingView(false);
15288
+ window.removeEventListener("message", retrieveSourceInfoFromIframe);
15289
+ dispatch({
15290
+ type: SHOW_ALERT,
15291
+ payload: {
15292
+ type: "error",
15293
+ content: null
15294
+ }
15295
+ });
15296
+ handleTapPayment(tapID);
15297
+ }
15298
+ }; // listen to injected iframe for authentication complete message
15299
+
15300
+
15301
+ window.addEventListener("message", retrieveSourceInfoFromIframe);
15302
+ };
15303
+
15304
+ listenFor3DSecureCompletionMessage();
15305
+ }
15306
+ });
15307
+ }
15308
+ });
15309
+ };
15310
+
15311
+ function handleTapPayment(paymentRequest) {
15312
+ // if (paymentRequest) {
15313
+ // const SUCCESS_STATUS = "870";
15314
+ // if (paymentRequest.response !== SUCCESS_STATUS) {
15315
+ // switch (paymentRequest.response) {
15316
+ // case "871":
15317
+ // return handlePaymentError({
15318
+ // error: new Error("Invalid account number")
15319
+ // });
15320
+ // default:
15321
+ // return handlePaymentError({
15322
+ // error: new Error(paymentRequest.message)
15323
+ // });
15324
+ // }
15325
+ // }
15326
+ // }
15327
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
15328
+
15329
+ if (type === "createPayment") {
15330
+ handleTapSubscription();
15331
+ } else if (type === "orderCreate") {
15332
+ purchase(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
15333
+ } else if (type === "invoicePayment") {
15334
+ payInvoice(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
15335
+ } else if (type === "updatePaymentSource") {
15336
+ createNewTapCard();
15337
+ }
15338
+
15339
+ function createNewTapCard() {
15340
+ window.Pelcro.source.create({
15341
+ auth_token: window.Pelcro.user.read().auth_token,
15342
+ token: paymentRequest,
15343
+ gateway: "tap"
15344
+ }, (err, res) => {
15345
+ dispatch({
15346
+ type: DISABLE_SUBMIT,
15347
+ payload: false
15348
+ });
15349
+ dispatch({
15350
+ type: LOADING,
15351
+ payload: false
15352
+ });
15353
+
15354
+ if (err) {
15355
+ onFailure(err);
15356
+ return dispatch({
15357
+ type: SHOW_ALERT,
15358
+ payload: {
15359
+ type: "error",
15360
+ content: getErrorMessages(err)
15361
+ }
15362
+ });
15363
+ }
15364
+
15365
+ dispatch({
15366
+ type: SHOW_ALERT,
15367
+ payload: {
15368
+ type: "success",
15369
+ content: t("messages.sourceUpdated")
15370
+ }
15371
+ });
15372
+ onSuccess(res);
15373
+ });
15374
+ }
15375
+
15376
+ function handleTapSubscription() {
15377
+ const payment = new Payment(new TapGateway());
15378
+ const createSubscription = !isGift && !subscriptionIdToRenew;
15379
+ const renewSubscription = !isGift && subscriptionIdToRenew;
15380
+ const giftSubscriprition = isGift && !subscriptionIdToRenew;
15381
+ const renewGift = isRenewingGift;
15382
+ const {
15383
+ couponCode
15384
+ } = state;
15385
+
15386
+ if (renewGift) {
15387
+ return payment.execute({
15388
+ type: PAYMENT_TYPES.RENEW_GIFTED_SUBSCRIPTION,
15389
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
15390
+ plan,
15391
+ couponCode,
15392
+ product,
15393
+ isExistingSource: isUsingExistingPaymentMethod,
15394
+ subscriptionIdToRenew,
15395
+ addressId: selectedAddressId
15396
+ }, (err, res) => {
15397
+ if (err) {
15398
+ return handlePaymentError(err);
15399
+ }
15400
+
15401
+ onSuccess(res);
15402
+ });
15403
+ } else if (giftSubscriprition) {
15404
+ return payment.execute({
15405
+ type: PAYMENT_TYPES.CREATE_GIFTED_SUBSCRIPTION,
15406
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
15407
+ quantity: plan.quantity,
15408
+ plan,
15409
+ couponCode,
15410
+ product,
15411
+ isExistingSource: isUsingExistingPaymentMethod,
15412
+ giftRecipient,
15413
+ addressId: selectedAddressId
15414
+ }, (err, res) => {
15415
+ if (err) {
15416
+ return handlePaymentError(err);
15417
+ }
15418
+
15419
+ onSuccess(res);
15420
+ });
15421
+ } else if (renewSubscription) {
15422
+ return payment.execute({
15423
+ type: PAYMENT_TYPES.RENEW_SUBSCRIPTION,
15424
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
15425
+ quantity: plan.quantity,
15426
+ plan,
15427
+ couponCode,
15428
+ product,
15429
+ isExistingSource: isUsingExistingPaymentMethod,
15430
+ subscriptionIdToRenew,
15431
+ addressId: selectedAddressId
15432
+ }, (err, res) => {
15433
+ if (err) {
15434
+ return handlePaymentError(err);
15435
+ }
14898
15436
 
14899
- const {
14900
- t
14901
- } = useTranslation("payment");
14902
- const pelcroStore = usePelcro();
14903
- const {
14904
- set,
14905
- order,
14906
- selectedPaymentMethodId,
14907
- couponCode
14908
- } = usePelcro();
14909
- const product = (_props$product = props.product) !== null && _props$product !== void 0 ? _props$product : pelcroStore.product;
14910
- const plan = (_props$plan = props.plan) !== null && _props$plan !== void 0 ? _props$plan : pelcroStore.plan;
14911
- const subscriptionIdToRenew = (_props$subscriptionId = props.subscriptionIdToRenew) !== null && _props$subscriptionId !== void 0 ? _props$subscriptionId : pelcroStore.subscriptionIdToRenew;
14912
- const selectedAddressId = (_props$selectedAddres = props.selectedAddressId) !== null && _props$selectedAddres !== void 0 ? _props$selectedAddres : pelcroStore.selectedAddressId;
14913
- const giftRecipient = (_props$giftRecipient = props.giftRecipient) !== null && _props$giftRecipient !== void 0 ? _props$giftRecipient : pelcroStore.giftRecipient;
14914
- const isGift = (_props$isGift = props.isGift) !== null && _props$isGift !== void 0 ? _props$isGift : pelcroStore.isGift;
14915
- const isRenewingGift = (_props$isRenewingGift = props.isRenewingGift) !== null && _props$isRenewingGift !== void 0 ? _props$isRenewingGift : pelcroStore.isRenewingGift;
14916
- const invoice = (_props$invoice = props.invoice) !== null && _props$invoice !== void 0 ? _props$invoice : pelcroStore.invoice;
14917
- React.useEffect(() => {
14918
- if (window.Pelcro.coupon.getFromUrl()) {
14919
- dispatch({
14920
- type: UPDATE_COUPON_CODE,
14921
- payload: window.Pelcro.coupon.getFromUrl()
14922
- });
14923
- } else if (couponCode) {
14924
- dispatch({
14925
- type: UPDATE_COUPON_CODE,
14926
- payload: couponCode
14927
- });
15437
+ onSuccess(res);
15438
+ });
15439
+ } else if (createSubscription) {
15440
+ return payment.execute({
15441
+ type: PAYMENT_TYPES.CREATE_SUBSCRIPTION,
15442
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
15443
+ quantity: plan.quantity,
15444
+ plan,
15445
+ couponCode,
15446
+ product,
15447
+ isExistingSource: isUsingExistingPaymentMethod,
15448
+ addressId: selectedAddressId
15449
+ }, (err, res) => {
15450
+ if (err) {
15451
+ return handlePaymentError(err);
15452
+ }
15453
+
15454
+ onSuccess(res);
15455
+ });
15456
+ }
14928
15457
  }
15458
+ }
15459
+ /*====== End Tap integration ========*/
14929
15460
 
14930
- dispatch({
14931
- type: INIT_CONTAINER
14932
- });
14933
- updateTotalAmountWithTax();
14934
- }, []);
14935
15461
 
14936
15462
  const submitUsingVantiv = () => {
14937
15463
  const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
@@ -14982,7 +15508,7 @@ const PaymentMethodContainerWithoutStripe = ({
14982
15508
  } else if (type === "orderCreate") {
14983
15509
  purchase(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
14984
15510
  } else if (type === "invoicePayment") {
14985
- payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
15511
+ payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
14986
15512
  } else if (type === "updatePaymentSource") {
14987
15513
  createNewVantivCard();
14988
15514
  }
@@ -15109,6 +15635,8 @@ const PaymentMethodContainerWithoutStripe = ({
15109
15635
  }
15110
15636
 
15111
15637
  const vantivInstanceRef = React__default['default'].useRef(null);
15638
+ const tapInstanceRef = React__default['default'].useRef(null);
15639
+ const tapInstanceCard = React__default['default'].useRef(null);
15112
15640
  React.useEffect(() => {
15113
15641
  const cardProcessor = getSiteCardProcessor();
15114
15642
 
@@ -15132,9 +15660,77 @@ const PaymentMethodContainerWithoutStripe = ({
15132
15660
  accountNumber: "1234 1234 1234 1234"
15133
15661
  },
15134
15662
  enhancedUxFeatures: {
15135
- inlineFieldValidations: true
15663
+ inlineFieldValidations: true,
15664
+ expDateValidation: true,
15665
+ numericInputsOnly: true
15666
+ }
15667
+ });
15668
+ }
15669
+
15670
+ if (cardProcessor === "tap" && !selectedPaymentMethodId) {
15671
+ var _window$Pelcro$site$r3;
15672
+
15673
+ const tapKey = Tapjsli((_window$Pelcro$site$r3 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : _window$Pelcro$site$r3.tap_gateway_settings.publishable_key);
15674
+ let elements = tapKey.elements({});
15675
+ let style = {
15676
+ base: {
15677
+ color: "#535353",
15678
+ lineHeight: "18px",
15679
+ fontFamily: "sans-serif",
15680
+ fontSmoothing: "antialiased",
15681
+ fontSize: "16px",
15682
+ "::placeholder": {
15683
+ color: "rgba(0, 0, 0, 0.26)",
15684
+ fontSize: "15px"
15685
+ }
15686
+ },
15687
+ invalid: {
15688
+ color: "red"
15136
15689
  }
15690
+ }; // input labels/placeholders
15691
+
15692
+ let labels = {
15693
+ cardNumber: "Card Number",
15694
+ expirationDate: "MM/YY",
15695
+ cvv: "CVV",
15696
+ cardHolder: "Card Holder Name"
15697
+ }; //payment options
15698
+
15699
+ let paymentOptions = {
15700
+ labels: labels,
15701
+ TextDirection: "ltr"
15702
+ }; //create element, pass style and payment options
15703
+
15704
+ let card = elements.create("card", {
15705
+ style: style
15706
+ }, paymentOptions); //mount element
15707
+
15708
+ card.mount("#tapPaymentIframe"); //card change event listener
15709
+
15710
+ card.addEventListener("change", function (event) {// if (event.error_interactive) {
15711
+ // onFailure(event.error_interactive);
15712
+ // return dispatch({
15713
+ // type: SHOW_ALERT,
15714
+ // payload: {
15715
+ // type: "error",
15716
+ // content: getErrorMessages(event.error_interactive)
15717
+ // }
15718
+ // });
15719
+ // } else {
15720
+ // dispatch({
15721
+ // type: SHOW_ALERT,
15722
+ // payload: { type: "error", content: "" }
15723
+ // });
15724
+ // }
15725
+ // let displayError = document.getElementById("error-handler");
15726
+ // if (event.error) {
15727
+ // displayError.textContent = event.error.message;
15728
+ // } else {
15729
+ // displayError.textContent = "";
15730
+ // }
15137
15731
  });
15732
+ tapInstanceRef.current = tapKey;
15733
+ tapInstanceCard.current = card;
15138
15734
  }
15139
15735
  }, [selectedPaymentMethodId]);
15140
15736
 
@@ -15208,9 +15804,9 @@ const PaymentMethodContainerWithoutStripe = ({
15208
15804
 
15209
15805
 
15210
15806
  const updateTotalAmountWithTax = () => {
15211
- var _window$Pelcro$site$r3;
15807
+ var _window$Pelcro$site$r4;
15212
15808
 
15213
- 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;
15809
+ 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;
15214
15810
 
15215
15811
  if (taxesEnabled && type === "createPayment") {
15216
15812
  dispatch({
@@ -15437,6 +16033,97 @@ const PaymentMethodContainerWithoutStripe = ({
15437
16033
  updateTotalAmountWithTax();
15438
16034
  }
15439
16035
  };
16036
+ /**
16037
+ * Attempt to confirm a Stripe card payment via it's PaymentIntent.
16038
+ * Only trigger method if PaymentIntent status is `requires_action`.
16039
+ *
16040
+ * @see https://stripe.com/docs/payments/intents#intent-statuses
16041
+ *
16042
+ * @param response
16043
+ * @param error
16044
+ * @returns {*}
16045
+ */
16046
+
16047
+
16048
+ const confirmStripeCardPayment = (response, error, isSubCreate = false) => {
16049
+ if (response) {
16050
+ var _response$data;
16051
+
16052
+ const paymentIntent = (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.payment_intent;
16053
+
16054
+ if ((paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.status) === "requires_action" && paymentIntent !== null && paymentIntent !== void 0 && paymentIntent.client_secret) {
16055
+ stripe.confirmCardPayment(paymentIntent.client_secret).then(res => {
16056
+ if (!isSubCreate) {
16057
+ dispatch({
16058
+ type: DISABLE_SUBMIT,
16059
+ payload: false
16060
+ });
16061
+ }
16062
+
16063
+ dispatch({
16064
+ type: LOADING,
16065
+ payload: false
16066
+ });
16067
+
16068
+ if (res.error) {
16069
+ onFailure(res.error);
16070
+ return dispatch({
16071
+ type: SHOW_ALERT,
16072
+ payload: {
16073
+ type: "error",
16074
+ content: isSubCreate ? t("messages.tryAgainFromInvoice") : getErrorMessages(res.error)
16075
+ }
16076
+ });
16077
+ }
16078
+
16079
+ onSuccess(res);
16080
+ });
16081
+ } else if ((paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.status) === "requires_payment_method" && paymentIntent !== null && paymentIntent !== void 0 && paymentIntent.client_secret) {
16082
+ if (!isSubCreate) {
16083
+ dispatch({
16084
+ type: DISABLE_SUBMIT,
16085
+ payload: false
16086
+ });
16087
+ }
16088
+
16089
+ dispatch({
16090
+ type: LOADING,
16091
+ payload: false
16092
+ });
16093
+ return dispatch({
16094
+ type: SHOW_ALERT,
16095
+ payload: {
16096
+ type: "error",
16097
+ content: isSubCreate ? t("messages.tryAgainFromInvoice") : t("messages.cardAuthFailed")
16098
+ }
16099
+ });
16100
+ } else {
16101
+ onSuccess(response);
16102
+ }
16103
+ } else {
16104
+ dispatch({
16105
+ type: DISABLE_SUBMIT,
16106
+ payload: false
16107
+ });
16108
+ dispatch({
16109
+ type: LOADING,
16110
+ payload: false
16111
+ });
16112
+
16113
+ if (error) {
16114
+ onFailure(error);
16115
+ return dispatch({
16116
+ type: SHOW_ALERT,
16117
+ payload: {
16118
+ type: "error",
16119
+ content: getErrorMessages(error)
16120
+ }
16121
+ });
16122
+ }
16123
+
16124
+ onSuccess(response);
16125
+ }
16126
+ };
15440
16127
 
15441
16128
  const subscribe = (stripeSource, state, dispatch) => {
15442
16129
  const {
@@ -15459,27 +16146,7 @@ const PaymentMethodContainerWithoutStripe = ({
15459
16146
  gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
15460
16147
  address_id: product.address_required ? selectedAddressId : null
15461
16148
  }, (err, res) => {
15462
- dispatch({
15463
- type: DISABLE_SUBMIT,
15464
- payload: false
15465
- });
15466
- dispatch({
15467
- type: LOADING,
15468
- payload: false
15469
- });
15470
-
15471
- if (err) {
15472
- onFailure(err);
15473
- return dispatch({
15474
- type: SHOW_ALERT,
15475
- payload: {
15476
- type: "error",
15477
- content: getErrorMessages(err)
15478
- }
15479
- });
15480
- }
15481
-
15482
- onSuccess(res);
16149
+ confirmStripeCardPayment(res, err, true);
15483
16150
  });
15484
16151
  } else {
15485
16152
  if (isRenewingGift) {
@@ -15703,27 +16370,7 @@ const PaymentMethodContainerWithoutStripe = ({
15703
16370
  isExistingSource: Boolean(selectedPaymentMethodId),
15704
16371
  invoiceId: invoice.id
15705
16372
  }, (err, res) => {
15706
- dispatch({
15707
- type: DISABLE_SUBMIT,
15708
- payload: false
15709
- });
15710
- dispatch({
15711
- type: LOADING,
15712
- payload: false
15713
- });
15714
-
15715
- if (err) {
15716
- onFailure(err);
15717
- return dispatch({
15718
- type: SHOW_ALERT,
15719
- payload: {
15720
- type: "error",
15721
- content: getErrorMessages(err)
15722
- }
15723
- });
15724
- }
15725
-
15726
- onSuccess(res);
16373
+ confirmStripeCardPayment(res, err);
15727
16374
  });
15728
16375
  };
15729
16376
 
@@ -15803,7 +16450,7 @@ const PaymentMethodContainerWithoutStripe = ({
15803
16450
  source,
15804
16451
  error
15805
16452
  }) => {
15806
- var _ref, _ref2, _state$updatedPrice, _source$card3;
16453
+ var _ref3, _ref4, _state$updatedPrice2;
15807
16454
 
15808
16455
  if (error) {
15809
16456
  return handlePaymentError(error);
@@ -15829,25 +16476,7 @@ const PaymentMethodContainerWithoutStripe = ({
15829
16476
  }, 0);
15830
16477
  };
15831
16478
 
15832
- const totalAmount = (_ref = (_ref2 = (_state$updatedPrice = state === null || state === void 0 ? void 0 : state.updatedPrice) !== null && _state$updatedPrice !== void 0 ? _state$updatedPrice : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref2 !== void 0 ? _ref2 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref !== void 0 ? _ref : getOrderItemsTotal();
15833
-
15834
- if ((source === null || source === void 0 ? void 0 : (_source$card3 = source.card) === null || _source$card3 === void 0 ? void 0 : _source$card3.three_d_secure) === "required" && totalAmount > 0) {
15835
- return resolveTaxCalculation().then(res => {
15836
- var _res$totalAmountWithT;
15837
-
15838
- return generate3DSecureSource(source, (_res$totalAmountWithT = res === null || res === void 0 ? void 0 : res.totalAmountWithTax) !== null && _res$totalAmountWithT !== void 0 ? _res$totalAmountWithT : totalAmount).then(({
15839
- source,
15840
- error
15841
- }) => {
15842
- if (error) {
15843
- return handlePaymentError(error);
15844
- }
15845
-
15846
- toggleAuthenticationPendingView(true, source);
15847
- });
15848
- });
15849
- }
15850
-
16479
+ (_ref3 = (_ref4 = (_state$updatedPrice2 = state === null || state === void 0 ? void 0 : state.updatedPrice) !== null && _state$updatedPrice2 !== void 0 ? _state$updatedPrice2 : plan === null || plan === void 0 ? void 0 : plan.amount) !== null && _ref4 !== void 0 ? _ref4 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref3 !== void 0 ? _ref3 : getOrderItemsTotal();
15851
16480
  return handlePayment(source);
15852
16481
  }).catch(error => {
15853
16482
  return handlePaymentError(error);
@@ -15860,13 +16489,13 @@ const PaymentMethodContainerWithoutStripe = ({
15860
16489
 
15861
16490
 
15862
16491
  const resolveTaxCalculation = () => {
15863
- var _window$Pelcro$site$r4;
16492
+ var _window$Pelcro$site$r5;
15864
16493
 
15865
16494
  if (type === "invoicePayment") {
15866
16495
  return new Promise(resolve => resolve());
15867
16496
  }
15868
16497
 
15869
- 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;
16498
+ const taxesEnabled = (_window$Pelcro$site$r5 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r5 === void 0 ? void 0 : _window$Pelcro$site$r5.taxes_enabled;
15870
16499
  return new Promise((resolve, reject) => {
15871
16500
  // resolve early if taxes isn't enabled
15872
16501
  if (!taxesEnabled) {
@@ -15941,7 +16570,7 @@ const PaymentMethodContainerWithoutStripe = ({
15941
16570
  } else if (stripeSource && type === "orderCreate") {
15942
16571
  purchase(new StripeGateway(), stripeSource.id, state, dispatch);
15943
16572
  } else if (stripeSource && type === "invoicePayment") {
15944
- payInvoice(new StripeGateway(), stripeSource.id, dispatch);
16573
+ payInvoice(new StripeGateway(), stripeSource.id);
15945
16574
  }
15946
16575
  };
15947
16576
 
@@ -16018,10 +16647,12 @@ const PaymentMethodContainerWithoutStripe = ({
16018
16647
  };
16019
16648
 
16020
16649
  const injectCardAuthenticationIframe = source => {
16650
+ var _source$redirect;
16651
+
16021
16652
  const cardAuthContainer = document.querySelector(".card-authentication-container");
16022
16653
  const iframe = document.createElement("iframe");
16023
- iframe.src = source.redirect.url;
16024
- iframe.style = "position: absolute; width: 100%; height: 100%; left: 0; top: 40px; bottom: 0; z-index: 10;";
16654
+ iframe.src = source !== null && source !== void 0 && (_source$redirect = source.redirect) !== null && _source$redirect !== void 0 && _source$redirect.url ? source.redirect.url : source.threeDSecure_url;
16655
+ iframe.style = "position: absolute; width: 100%; height: 100%; left: 0; top: 0; bottom: 0; z-index: 10;";
16025
16656
  cardAuthContainer.appendChild(iframe);
16026
16657
  };
16027
16658
 
@@ -16067,6 +16698,10 @@ const PaymentMethodContainerWithoutStripe = ({
16067
16698
  return submitUsingVantiv();
16068
16699
  }
16069
16700
 
16701
+ if (getSiteCardProcessor() === "tap") {
16702
+ return submitUsingTap();
16703
+ }
16704
+
16070
16705
  if (selectedPaymentMethodId) {
16071
16706
  // pay with selected method (source) if exists already
16072
16707
  return handlePayment({
@@ -16085,7 +16720,7 @@ const PaymentMethodContainerWithoutStripe = ({
16085
16720
  case HANDLE_PAYPAL_SUBSCRIPTION:
16086
16721
  return lib_5(state, (state, dispatch) => {
16087
16722
  if (type === "invoicePayment") {
16088
- payInvoice(new PaypalGateway(), action.payload, dispatch);
16723
+ payInvoice(new PaypalGateway(), action.payload);
16089
16724
  } else {
16090
16725
  handlePaypalSubscription(state, action.payload);
16091
16726
  }
@@ -16280,6 +16915,12 @@ const CheckoutForm = () => {
16280
16915
  });
16281
16916
  }
16282
16917
 
16918
+ if (cardProcessor === "tap") {
16919
+ return /*#__PURE__*/React__default['default'].createElement("div", {
16920
+ id: "tapPaymentIframe"
16921
+ });
16922
+ }
16923
+
16283
16924
  if (cardProcessor === "stripe") {
16284
16925
  return /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(PelcroCardNumber, {
16285
16926
  autoFocus: true
@@ -16964,13 +17605,14 @@ function PaymentMethodView({
16964
17605
  showCoupon,
16965
17606
  showExternalPaymentMethods
16966
17607
  }) {
16967
- var _window$Pelcro$site$r;
17608
+ var _window$Pelcro$site$r, _window$Pelcro$site$r2;
16968
17609
 
16969
17610
  const {
16970
17611
  t
16971
17612
  } = useTranslation("checkoutForm");
16972
17613
  const cardProcessor = getSiteCardProcessor();
16973
17614
  const supportsVantiv = Boolean((_window$Pelcro$site$r = window.Pelcro.site.read()) === null || _window$Pelcro$site$r === void 0 ? void 0 : _window$Pelcro$site$r.vantiv_gateway_settings);
17615
+ Boolean((_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.tap_gateway_settings);
16974
17616
  return /*#__PURE__*/React__default['default'].createElement("div", {
16975
17617
  className: "plc-flex plc-flex-col plc-items-center plc-mt-4 sm:plc-px-8 pelcro-payment-block"
16976
17618
  }, cardProcessor === "stripe" && /*#__PURE__*/React__default['default'].createElement("div", {
@@ -17673,17 +18315,17 @@ const SubscriptionSuspendView = props => {
17673
18315
  }))));
17674
18316
  };
17675
18317
 
17676
- const SubscriptionSuspendModal = ({
18318
+ function SubscriptionSuspendModal({
17677
18319
  onDisplay,
17678
18320
  onClose,
17679
18321
  ...otherProps
17680
- }) => {
18322
+ }) {
17681
18323
  return /*#__PURE__*/React__default['default'].createElement(Modal, {
17682
18324
  onDisplay: onDisplay,
17683
18325
  onClose: onClose,
17684
18326
  id: "pelcro-subscription-suspend-modal"
17685
18327
  }, /*#__PURE__*/React__default['default'].createElement(ModalBody, null, /*#__PURE__*/React__default['default'].createElement(SubscriptionSuspendView, otherProps)), /*#__PURE__*/React__default['default'].createElement(ModalFooter, null, /*#__PURE__*/React__default['default'].createElement(Authorship, null)));
17686
- };
18328
+ }
17687
18329
  SubscriptionSuspendModal.viewId = "subscription-suspend";
17688
18330
 
17689
18331
  var _path$j;
@@ -17922,9 +18564,7 @@ class DefaultNewsLetter extends React.Component {
17922
18564
  });
17923
18565
 
17924
18566
  _defineProperty$3(this, "postSubmit", () => {
17925
- var _this$product, _this$product$paywall, _this$product2, _this$product2$paywal;
17926
-
17927
- window.Pelcro.paywall.decrementPageViewFrequency((_this$product = this.product) === null || _this$product === void 0 ? void 0 : (_this$product$paywall = _this$product.paywall) === null || _this$product$paywall === void 0 ? void 0 : _this$product$paywall.newsletter_extra_visits, (_this$product2 = this.product) === null || _this$product2 === void 0 ? void 0 : (_this$product2$paywal = _this$product2.paywall) === null || _this$product2$paywal === void 0 ? void 0 : _this$product2$paywal.frequency_limit);
18567
+ window.Pelcro.paywall.setNewsletterExtraVisits(true);
17928
18568
  this.props.setView("meter");
17929
18569
  });
17930
18570
 
@@ -24214,10 +24854,10 @@ var GroupContext = /*#__PURE__*/React.createContext(null);
24214
24854
  GroupContext.displayName = 'GroupContext';
24215
24855
 
24216
24856
  const getPaymentCardIcon = name => {
24217
- var _icons$name;
24857
+ var _icons$name$toLowerCa;
24218
24858
 
24219
24859
  const icons = {
24220
- Visa: /*#__PURE__*/React__default['default'].createElement("svg", {
24860
+ visa: /*#__PURE__*/React__default['default'].createElement("svg", {
24221
24861
  className: "plc-w-12",
24222
24862
  fill: "#ffffff",
24223
24863
  xmlns: "http://www.w3.org/2000/svg",
@@ -24225,7 +24865,7 @@ const getPaymentCardIcon = name => {
24225
24865
  }, /*#__PURE__*/React__default['default'].createElement("path", {
24226
24866
  d: "M 5 7 C 2.25 7 0 9.25 0 12 L 0 38 C 0 40.75 2.25 43 5 43 L 45 43 C 47.75 43 50 40.75 50 38 L 50 12 C 50 9.25 47.75 7 45 7 Z M 5 9 L 45 9 C 46.667969 9 48 10.332031 48 12 L 48 38 C 48 39.667969 46.667969 41 45 41 L 5 41 C 3.332031 41 2 39.667969 2 38 L 2 12 C 2 10.332031 3.332031 9 5 9 Z M 29.6875 19.40625 C 26.585938 19.40625 25 20.933594 25 22.875 C 25 26.386719 29.0625 25.914063 29.0625 27.71875 C 29.0625 28.023438 28.828125 28.75 27.125 28.75 C 25.417969 28.75 24.3125 28.09375 24.3125 28.09375 L 23.78125 30.46875 C 23.78125 30.46875 24.886719 31.09375 27 31.09375 C 29.113281 31.09375 32.03125 29.476563 32.03125 27.125 C 32.03125 24.296875 27.96875 24.074219 27.96875 22.8125 C 27.96875 22.167969 28.46875 21.6875 29.9375 21.6875 C 30.890625 21.6875 31.96875 22.40625 31.96875 22.40625 L 32.46875 19.96875 C 32.46875 19.96875 31.050781 19.40625 29.6875 19.40625 Z M 16.46875 19.625 L 13.78125 27.5625 C 13.78125 27.5625 13.597656 26.886719 13.53125 26.46875 C 11.996094 23.023438 9.5 21.75 9.5 21.75 L 11.875 30.75 L 15.125 30.75 L 19.625 19.625 Z M 20.78125 19.625 L 19.03125 30.75 L 22 30.75 L 23.78125 19.625 Z M 36.8125 19.625 L 31.96875 30.75 L 34.90625 30.75 L 35.5 29.15625 L 39.1875 29.15625 L 39.5 30.75 L 42.1875 30.75 L 39.90625 19.625 Z M 6.25 19.65625 C 6.25 19.65625 12.054688 21.453125 13.40625 25.8125 L 12.40625 20.75 C 12.40625 20.75 11.976563 19.65625 10.8125 19.65625 Z M 37.9375 22.84375 L 38.75 27.03125 L 36.3125 27.03125 Z"
24227
24867
  })),
24228
- MasterCard: /*#__PURE__*/React__default['default'].createElement("svg", {
24868
+ mastercard: /*#__PURE__*/React__default['default'].createElement("svg", {
24229
24869
  className: "plc-w-12",
24230
24870
  fill: "#ffffff",
24231
24871
  xmlns: "http://www.w3.org/2000/svg",
@@ -24233,7 +24873,7 @@ const getPaymentCardIcon = name => {
24233
24873
  }, /*#__PURE__*/React__default['default'].createElement("path", {
24234
24874
  d: "M 5 7 C 2.25 7 0 9.25 0 12 L 0 38 C 0 40.75 2.25 43 5 43 L 45 43 C 47.75 43 50 40.75 50 38 L 50 12 C 50 9.25 47.75 7 45 7 Z M 5 9 L 45 9 C 46.667969 9 48 10.332031 48 12 L 48 38 C 48 39.667969 46.667969 41 45 41 L 5 41 C 3.332031 41 2 39.667969 2 38 L 2 12 C 2 10.332031 3.332031 9 5 9 Z M 17 13 C 10.382812 13 5 18.382812 5 25 C 5 31.617188 10.382812 37 17 37 C 20.078125 37 22.875 35.816406 25 33.90625 C 27.125 35.816406 29.925781 37 33 37 C 39.617188 37 45 31.617188 45 25 C 45 18.382812 39.617188 13 33 13 C 29.925781 13 27.125 14.183594 25 16.09375 C 22.875 14.183594 20.078125 13 17 13 Z M 33 15 C 38.535156 15 43 19.464844 43 25 C 43 30.535156 38.535156 35 33 35 C 30.449219 35 28.109375 34.066406 26.34375 32.5 C 27.996094 30.441406 29 27.839844 29 25 C 29 22.160156 27.996094 19.558594 26.34375 17.5 C 28.109375 15.933594 30.449219 15 33 15 Z M 33 15 "
24235
24875
  })),
24236
- "American Express": /*#__PURE__*/React__default['default'].createElement("svg", {
24876
+ "american express": /*#__PURE__*/React__default['default'].createElement("svg", {
24237
24877
  className: "plc-w-12",
24238
24878
  fill: "#ffffff",
24239
24879
  xmlns: "http://www.w3.org/2000/svg",
@@ -24242,7 +24882,7 @@ const getPaymentCardIcon = name => {
24242
24882
  d: "M 5 7 C 2.25 7 0 9.25 0 12 L 0 38 C 0 40.75 2.25 43 5 43 L 45 43 C 47.75 43 50 40.75 50 38 L 50 12 C 50 9.25 47.75 7 45 7 Z M 5 9 L 45 9 C 46.667969 9 48 10.332031 48 12 L 48 38 C 48 39.667969 46.667969 41 45 41 L 5 41 C 3.332031 41 2 39.667969 2 38 L 2 12 C 2 10.332031 3.332031 9 5 9 Z M 8.5625 19.90625 L 4.84375 28.40625 L 7.0625 28.40625 L 7.875 26.5 L 12.0625 26.5 L 12.875 28.40625 L 17.09375 28.40625 L 17.09375 22.09375 L 19.90625 28.40625 L 21.8125 28.40625 L 24.65625 22.1875 L 24.65625 28.40625 L 26.75 28.40625 L 26.75 19.90625 L 23.40625 19.90625 L 20.84375 25.625 L 18.28125 19.90625 L 15 19.90625 L 15 28.09375 L 11.34375 19.90625 Z M 29.5 19.90625 L 29.5 28.4375 L 37.5 28.4375 L 40 25.59375 L 42.46875 28.4375 L 45.125 28.4375 L 41.375 24.0625 L 45.125 19.90625 L 42.46875 19.90625 L 40.0625 22.5625 L 37.75 19.90625 Z M 9.90625 21.6875 L 11.21875 24.6875 L 8.65625 24.6875 Z M 31.5625 21.71875 L 36.65625 21.75 L 38.6875 24.0625 L 36.40625 26.625 L 31.5625 26.625 L 31.5625 24.9375 L 36.1875 24.9375 L 36.1875 23.3125 L 31.5625 23.3125 Z"
24243
24883
  }))
24244
24884
  };
24245
- return (_icons$name = icons[name]) !== null && _icons$name !== void 0 ? _icons$name : /*#__PURE__*/React__default['default'].createElement("svg", {
24885
+ return (_icons$name$toLowerCa = icons[name.toLowerCase()]) !== null && _icons$name$toLowerCa !== void 0 ? _icons$name$toLowerCa : /*#__PURE__*/React__default['default'].createElement("svg", {
24246
24886
  xmlns: "http://www.w3.org/2000/svg",
24247
24887
  className: "plc-w-12",
24248
24888
  fill: "none",
@@ -24740,7 +25380,7 @@ const SubscriptionsItems = ({
24740
25380
  onClick: onReactivateClick,
24741
25381
  disabled: disableSubmit,
24742
25382
  "data-key": sub.id
24743
- }, t("labels.reactivate")), sub.cancel_at_period_end === 1 && /*#__PURE__*/React__default['default'].createElement(Button, {
25383
+ }, t("labels.reactivate")), sub.cancel_at_period_end === 1 && sub.status !== "incomplete" && /*#__PURE__*/React__default['default'].createElement(Button, {
24744
25384
  variant: "ghost",
24745
25385
  className: "plc-text-blue-400 pelcro-dashboard-sub-renew-button",
24746
25386
  icon: /*#__PURE__*/React__default['default'].createElement(SvgRefresh, null),
@@ -25571,6 +26211,10 @@ class Dashboard extends React.Component {
25571
26211
  return `${this.locale("labels.canceledOn")} ${formattedCancelDate}`;
25572
26212
  }
25573
26213
 
26214
+ if (subscription.status === "incomplete") {
26215
+ return `${this.locale("labels.status.incomplete")}`;
26216
+ }
26217
+
25574
26218
  if (subscription.cancel_at_period_end) {
25575
26219
  // DateTime from BE is missing 3 zeros so we add them before instancing a date
25576
26220
  const expiryDate = new Date(Number(`${subscription.expires_at}000`));
@@ -25636,6 +26280,16 @@ class Dashboard extends React.Component {
25636
26280
  };
25637
26281
  }
25638
26282
 
26283
+ if (sub.status === "incomplete") {
26284
+ return {
26285
+ title: this.locale("labels.status.incomplete"),
26286
+ content: this.getSubscriptionStatusText(sub),
26287
+ textColor: "plc-text-orange-700",
26288
+ bgColor: "plc-bg-orange-100",
26289
+ icon: /*#__PURE__*/React__default['default'].createElement(SvgExclamation, null)
26290
+ };
26291
+ }
26292
+
25639
26293
  return {
25640
26294
  title: this.locale("labels.status.active"),
25641
26295
  content: this.getSubscriptionStatusText(sub),
@@ -28370,9 +29024,9 @@ const InvoiceDetailsView = props => {
28370
29024
  className: "pelcro-invoice-total"
28371
29025
  }, getFormattedPriceByLocal(invoice.total, invoice.currency, getPageOrDefaultLanguage())), /*#__PURE__*/React__default['default'].createElement("p", {
28372
29026
  className: "pelcro-invoice-total"
28373
- }, getFormattedPriceByLocal(invoice.amount_paid, invoice.currency, getPageOrDefaultLanguage())), /*#__PURE__*/React__default['default'].createElement("p", {
29027
+ }, invoice.paid && invoice.amount_paid === 0 ? getFormattedPriceByLocal(invoice.total, invoice.currency, getPageOrDefaultLanguage()) : getFormattedPriceByLocal(invoice.amount_paid, invoice.currency, getPageOrDefaultLanguage())), /*#__PURE__*/React__default['default'].createElement("p", {
28374
29028
  className: "plc-font-semibold pelcro-invoice-total"
28375
- }, getFormattedPriceByLocal(invoice.amount_remaining, invoice.currency, getPageOrDefaultLanguage())))))), /*#__PURE__*/React__default['default'].createElement("div", {
29029
+ }, invoice.paid ? getFormattedPriceByLocal(0, invoice.currency, getPageOrDefaultLanguage()) : getFormattedPriceByLocal(invoice.amount_remaining, invoice.currency, getPageOrDefaultLanguage())))))), /*#__PURE__*/React__default['default'].createElement("div", {
28376
29030
  className: "plc-flex plc-items-center plc-justify-center plc-mt-4"
28377
29031
  }, showDownloadButton && /*#__PURE__*/React__default['default'].createElement(InvoiceDetailsDownloadButton, {
28378
29032
  url: invoice === null || invoice === void 0 ? void 0 : invoice.invoice_pdf,
@@ -30023,6 +30677,7 @@ exports.SubscriptionCreateView = SubscriptionCreateView;
30023
30677
  exports.SubscriptionRenewContainer = SubscriptionRenewContainer;
30024
30678
  exports.SubscriptionRenewModal = SubscriptionRenewModal;
30025
30679
  exports.SubscriptionRenewView = SubscriptionRenewView;
30680
+ exports.SubscriptionSuspendContainer = SubscriptionSuspendContainer;
30026
30681
  exports.SubscriptionSuspendModal = SubscriptionSuspendModal;
30027
30682
  exports.SubscriptionSuspendView = SubscriptionSuspendView;
30028
30683
  exports.TaxAmount = TaxAmount;