@pelcro/react-pelcro-js 3.7.1 → 3.8.1-beta.1

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
@@ -4905,7 +4905,8 @@ var messages$h = {
4905
4905
  successfully: "avec succès.",
4906
4906
  sourceUpdated: "Vos informations de paiement ont été mises à jour",
4907
4907
  cardAuthFailed: "Nous ne parvenons pas à authentifier votre mode de paiement. Veuillez choisir un autre mode de paiement et essayer à nouveau.",
4908
- 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."
4908
+ 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.",
4909
+ 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."
4909
4910
  };
4910
4911
  var errors$2 = {
4911
4912
  "": ""
@@ -4945,7 +4946,8 @@ var messages$g = {
4945
4946
  successfully: "successfully",
4946
4947
  sourceUpdated: "Your payment information has been updated",
4947
4948
  cardAuthFailed: "We are unable to authenticate your payment method. Please choose a different payment method and try again.",
4948
- cardAuthNotSupported: "Updating your payment method to one that requires authentication is currently not possible. Please use a different payment method or contact customer service."
4949
+ cardAuthNotSupported: "Updating your payment method to one that requires authentication is currently not possible. Please use a different payment method or contact customer service.",
4950
+ 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."
4949
4951
  };
4950
4952
  var errors$1 = {
4951
4953
  "": ""
@@ -4985,7 +4987,8 @@ var messages$f = {
4985
4987
  successfully: "님께 성공적으로 전송되었습니다.",
4986
4988
  sourceUpdated: "귀하의 결제 정보가 업데이트되었습니다.",
4987
4989
  cardAuthFailed: "해당 결제 수단은 인증할 수 없습니다. 다른 결제 수단을 선택하여 다시 시도해보시기 바랍니다.",
4988
- cardAuthNotSupported: "인증이 요구되는 결제 수단으로의 업데이트는 현재 지원되지 않습니다. 다른 결제 수단을 이용하거나 고객센터로 문의하시기 바랍니다."
4990
+ cardAuthNotSupported: "인증이 요구되는 결제 수단으로의 업데이트는 현재 지원되지 않습니다. 다른 결제 수단을 이용하거나 고객센터로 문의하시기 바랍니다.",
4991
+ tryAgainFromInvoice: "결제를 인증할 수 없지만 구독이 생성되었습니다. 대시보드에서 다른 결제 수단을 사용하여 인보이스 결제를 시도하세요."
4989
4992
  };
4990
4993
  var errors = {
4991
4994
  "": ""
@@ -5008,7 +5011,8 @@ var labels$h = {
5008
5011
  active: "Active",
5009
5012
  inTrial: "In trial",
5010
5013
  endingSoon: "Ending soon",
5011
- scheduled: "Scheduled"
5014
+ scheduled: "Scheduled",
5015
+ incomplete: "Incomplete"
5012
5016
  },
5013
5017
  shipments: "Shipments remaining",
5014
5018
  logout: "Logout",
@@ -5108,9 +5112,10 @@ var labels$g = {
5108
5112
  status: {
5109
5113
  title: "Statut",
5110
5114
  active: "Active",
5111
- inTrial: "Dans l'essai",
5112
- endingSoon: "Fin bientôt",
5113
- scheduled: "Programmé"
5115
+ inTrial: "En essai",
5116
+ endingSoon: "Expire bientôt",
5117
+ scheduled: "Programmé",
5118
+ incomplete: "Incomplet"
5114
5119
  },
5115
5120
  shipments: "Expéditions restantes",
5116
5121
  logout: "Déconnexion",
@@ -5212,7 +5217,8 @@ var labels$f = {
5212
5217
  active: "활성화",
5213
5218
  inTrial: "체험판 사용",
5214
5219
  endingSoon: "만료 예정",
5215
- scheduled: "예약"
5220
+ scheduled: "예약",
5221
+ incomplete: "불완전한"
5216
5222
  },
5217
5223
  shipments: "남은 배송 일정",
5218
5224
  logout: "로그아웃",
@@ -7369,7 +7375,7 @@ class PelcroActions {
7369
7375
  });
7370
7376
  });
7371
7377
 
7372
- _defineProperty$3(this, "logout", () => {
7378
+ _defineProperty$3(this, "logout", (displayLogin = true) => {
7373
7379
  var _ReactGA$event;
7374
7380
 
7375
7381
  const {
@@ -7389,7 +7395,10 @@ class PelcroActions {
7389
7395
  nonInteraction: true
7390
7396
  });
7391
7397
  resetView();
7392
- switchView("login");
7398
+
7399
+ if (displayLogin) {
7400
+ switchView("login");
7401
+ }
7393
7402
  });
7394
7403
 
7395
7404
  _defineProperty$3(this, "addToCart", itemSkuId => {
@@ -7891,10 +7900,8 @@ const getEntitlementsFromElem = elem => {
7891
7900
  return elem.dataset.pelcroEntitlements.split(",").map(entitlement => entitlement.trim()).filter(entitlement => entitlement);
7892
7901
  };
7893
7902
  const getPaymentCardIcon$1 = name => {
7894
- var _icons$name;
7895
-
7896
7903
  const icons = {
7897
- Visa: /*#__PURE__*/React__default.createElement("svg", {
7904
+ visa: /*#__PURE__*/React__default.createElement("svg", {
7898
7905
  className: "plc-w-16",
7899
7906
  xmlns: "http://www.w3.org/2000/svg",
7900
7907
  viewBox: "0 0 48 48"
@@ -7905,7 +7912,7 @@ const getPaymentCardIcon$1 = name => {
7905
7912
  fill: "#FFC107",
7906
7913
  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"
7907
7914
  })),
7908
- MasterCard: /*#__PURE__*/React__default.createElement("svg", {
7915
+ mastercard: /*#__PURE__*/React__default.createElement("svg", {
7909
7916
  className: "plc-w-16",
7910
7917
  xmlns: "http://www.w3.org/2000/svg",
7911
7918
  viewBox: "0 0 48 48"
@@ -7919,7 +7926,7 @@ const getPaymentCardIcon$1 = name => {
7919
7926
  fill: "#ff3d00",
7920
7927
  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"
7921
7928
  })),
7922
- "American Express": /*#__PURE__*/React__default.createElement("svg", {
7929
+ "american express": /*#__PURE__*/React__default.createElement("svg", {
7923
7930
  className: "plc-w-16",
7924
7931
  xmlns: "http://www.w3.org/2000/svg",
7925
7932
  viewBox: "0 0 48 48"
@@ -7931,7 +7938,7 @@ const getPaymentCardIcon$1 = name => {
7931
7938
  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"
7932
7939
  }))
7933
7940
  };
7934
- return (_icons$name = icons[name]) !== null && _icons$name !== void 0 ? _icons$name : /*#__PURE__*/React__default.createElement("svg", {
7941
+ return name ? icons[name.toLowerCase()] : /*#__PURE__*/React__default.createElement("svg", {
7935
7942
  xmlns: "http://www.w3.org/2000/svg",
7936
7943
  className: "plc-w-16",
7937
7944
  fill: "none",
@@ -9942,12 +9949,16 @@ const debounce = (func, waitTime) => {
9942
9949
  };
9943
9950
  };
9944
9951
  function getSiteCardProcessor() {
9945
- var _window$Pelcro$site$r;
9952
+ var _window$Pelcro$site$r, _window$Pelcro$site$r2;
9946
9953
 
9947
9954
  if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_gateway_settings) {
9948
9955
  return "vantiv";
9949
9956
  }
9950
9957
 
9958
+ if ((_window$Pelcro$site$r2 = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r2 !== void 0 && _window$Pelcro$site$r2.tap_gateway_settings) {
9959
+ return "tap";
9960
+ }
9961
+
9951
9962
  return "stripe";
9952
9963
  }
9953
9964
 
@@ -10053,6 +10064,14 @@ const loadPaymentSDKs = () => {
10053
10064
  const scriptUrlToUse = window.Pelcro.site.read().vantiv_gateway_settings.environment === "production" ? PRODUCTION_URL : PRELIVE_URL;
10054
10065
  window.Pelcro.helpers.loadSDK(scriptUrlToUse, "vantiv-eprotect-sdk");
10055
10066
  }
10067
+ } // Load Tap SDKs
10068
+
10069
+
10070
+ const supportsTap = Boolean(window.Pelcro.site.read().tap_gateway_settings);
10071
+
10072
+ if (supportsTap) {
10073
+ window.Pelcro.helpers.loadSDK("https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js", "tap-bluebird");
10074
+ window.Pelcro.helpers.loadSDK("https://secure.gosell.io/js/sdk/tap.min.js", "tap-sdk");
10056
10075
  }
10057
10076
  };
10058
10077
  const loadAuth0SDK = () => {
@@ -14165,7 +14184,7 @@ var _generateUserError = /*#__PURE__*/new WeakMap();
14165
14184
 
14166
14185
  class Payment {
14167
14186
  /**
14168
- * @param {(StripeGateway|PaypalGateway|VantivGateway)} paymentGateway
14187
+ * @param {(StripeGateway|PaypalGateway|VantivGateway|TapGateway)} paymentGateway
14169
14188
  */
14170
14189
  constructor(paymentGateway) {
14171
14190
  _defineProperty$3(this, "execute", (options, callback) => {
@@ -14186,7 +14205,7 @@ class Payment {
14186
14205
  _isPaymentGatewayInvalid.set(this, {
14187
14206
  writable: true,
14188
14207
  value: gateway => {
14189
- return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway);
14208
+ return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway || gateway instanceof TapGateway);
14190
14209
  }
14191
14210
  });
14192
14211
 
@@ -14241,7 +14260,8 @@ class Payment {
14241
14260
  const PAYMENT_GATEWAYS_ENUM = {
14242
14261
  stripe: "stripe",
14243
14262
  paypal: "braintree",
14244
- vantiv: "vantiv"
14263
+ vantiv: "vantiv",
14264
+ tap: "tap"
14245
14265
  };
14246
14266
  /**
14247
14267
  * Payment Strategies
@@ -14809,6 +14829,241 @@ class VantivGateway {
14809
14829
 
14810
14830
  }
14811
14831
 
14832
+ var _paymentGateway4 = /*#__PURE__*/new WeakMap();
14833
+
14834
+ var _createSubscription4 = /*#__PURE__*/new WeakMap();
14835
+
14836
+ var _renewSubscription3 = /*#__PURE__*/new WeakMap();
14837
+
14838
+ var _createGiftedSubscription4 = /*#__PURE__*/new WeakMap();
14839
+
14840
+ var _renewGiftedSubscription3 = /*#__PURE__*/new WeakMap();
14841
+
14842
+ var _purchaseEcommerceOrder3 = /*#__PURE__*/new WeakMap();
14843
+
14844
+ var _payInvoice4 = /*#__PURE__*/new WeakMap();
14845
+
14846
+ class TapGateway {
14847
+ constructor() {
14848
+ _paymentGateway4.set(this, {
14849
+ writable: true,
14850
+ value: PAYMENT_GATEWAYS_ENUM["tap"]
14851
+ });
14852
+
14853
+ _defineProperty$3(this, "execute", (options, callback) => {
14854
+ const types = PAYMENT_TYPES;
14855
+
14856
+ switch (options.type) {
14857
+ case types.CREATE_SUBSCRIPTION:
14858
+ return _classPrivateFieldGet(this, _createSubscription4).call(this, options, callback);
14859
+
14860
+ case types.RENEW_SUBSCRIPTION:
14861
+ return _classPrivateFieldGet(this, _renewSubscription3).call(this, options, callback);
14862
+
14863
+ case types.CREATE_GIFTED_SUBSCRIPTION:
14864
+ return _classPrivateFieldGet(this, _createGiftedSubscription4).call(this, options, callback);
14865
+
14866
+ case types.RENEW_GIFTED_SUBSCRIPTION:
14867
+ return _classPrivateFieldGet(this, _renewGiftedSubscription3).call(this, options, callback);
14868
+
14869
+ case types.PURCHASE_ECOMMERCE_ORDER:
14870
+ return _classPrivateFieldGet(this, _purchaseEcommerceOrder3).call(this, options, callback);
14871
+
14872
+ case types.PAY_INVOICE:
14873
+ return _classPrivateFieldGet(this, _payInvoice4).call(this, options, callback);
14874
+
14875
+ default:
14876
+ console.error("Unsupported payment method: tap Gateway");
14877
+ }
14878
+ });
14879
+
14880
+ _createSubscription4.set(this, {
14881
+ writable: true,
14882
+ value: (options, callback) => {
14883
+ const {
14884
+ token,
14885
+ plan,
14886
+ couponCode,
14887
+ product,
14888
+ quantity = 1,
14889
+ addressId,
14890
+ isExistingSource
14891
+ } = options;
14892
+ const params = isExistingSource ? {
14893
+ source_id: token
14894
+ } : {
14895
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway4),
14896
+ gateway_token: token
14897
+ };
14898
+ window.Pelcro.subscription.create({
14899
+ quantity,
14900
+ auth_token: window.Pelcro.user.read().auth_token,
14901
+ plan_id: plan.id,
14902
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
14903
+ coupon_code: couponCode,
14904
+ address_id: product.address_required ? addressId : null,
14905
+ ...params
14906
+ }, (err, res) => {
14907
+ callback(err, res);
14908
+ });
14909
+ }
14910
+ });
14911
+
14912
+ _renewSubscription3.set(this, {
14913
+ writable: true,
14914
+ value: (options, callback) => {
14915
+ const {
14916
+ subscriptionIdToRenew,
14917
+ token,
14918
+ plan,
14919
+ couponCode,
14920
+ product,
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.renew({
14931
+ auth_token: window.Pelcro.user.read().auth_token,
14932
+ plan_id: plan.id,
14933
+ coupon_code: couponCode,
14934
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
14935
+ subscription_id: subscriptionIdToRenew,
14936
+ address_id: product.address_required ? addressId : null,
14937
+ ...params
14938
+ }, (err, res) => {
14939
+ callback(err, res);
14940
+ });
14941
+ }
14942
+ });
14943
+
14944
+ _createGiftedSubscription4.set(this, {
14945
+ writable: true,
14946
+ value: (options, callback) => {
14947
+ const {
14948
+ token,
14949
+ plan,
14950
+ couponCode,
14951
+ product,
14952
+ giftRecipient,
14953
+ quantity = 1,
14954
+ addressId,
14955
+ isExistingSource
14956
+ } = options;
14957
+ const params = isExistingSource ? {
14958
+ source_id: token
14959
+ } : {
14960
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway4),
14961
+ gateway_token: token
14962
+ };
14963
+ window.Pelcro.subscription.create({
14964
+ quantity,
14965
+ auth_token: window.Pelcro.user.read().auth_token,
14966
+ plan_id: plan.id,
14967
+ coupon_code: couponCode,
14968
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
14969
+ gift_recipient_email: giftRecipient.email,
14970
+ gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
14971
+ gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
14972
+ gift_start_date: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.startDate,
14973
+ gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
14974
+ address_id: product.address_required ? addressId : null,
14975
+ ...params
14976
+ }, (err, res) => {
14977
+ callback(err, res);
14978
+ });
14979
+ }
14980
+ });
14981
+
14982
+ _renewGiftedSubscription3.set(this, {
14983
+ writable: true,
14984
+ value: (options, callback) => {
14985
+ const {
14986
+ subscriptionIdToRenew,
14987
+ token,
14988
+ product,
14989
+ plan,
14990
+ couponCode,
14991
+ addressId,
14992
+ isExistingSource
14993
+ } = options;
14994
+ const params = isExistingSource ? {
14995
+ source_id: token
14996
+ } : {
14997
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway4),
14998
+ gateway_token: token
14999
+ };
15000
+ window.Pelcro.subscription.renewGift({
15001
+ auth_token: window.Pelcro.user.read().auth_token,
15002
+ plan_id: plan.id,
15003
+ coupon_code: couponCode,
15004
+ subscription_id: subscriptionIdToRenew,
15005
+ address_id: product.address_required ? addressId : null,
15006
+ ...params
15007
+ }, (err, res) => {
15008
+ callback(err, res);
15009
+ });
15010
+ }
15011
+ });
15012
+
15013
+ _purchaseEcommerceOrder3.set(this, {
15014
+ writable: true,
15015
+ value: (options, callback) => {
15016
+ const {
15017
+ token,
15018
+ items,
15019
+ couponCode,
15020
+ addressId,
15021
+ isExistingSource
15022
+ } = options;
15023
+ const params = isExistingSource ? {
15024
+ source_id: token
15025
+ } : {
15026
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway4),
15027
+ gateway_token: token
15028
+ };
15029
+ window.Pelcro.ecommerce.order.create({
15030
+ items,
15031
+ coupon_code: couponCode,
15032
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
15033
+ ...params,
15034
+ ...(addressId && {
15035
+ address_id: addressId
15036
+ })
15037
+ }, (err, res) => {
15038
+ callback(err, res);
15039
+ });
15040
+ }
15041
+ });
15042
+
15043
+ _payInvoice4.set(this, {
15044
+ writable: true,
15045
+ value: (options, callback) => {
15046
+ const {
15047
+ token,
15048
+ invoiceId
15049
+ } = options;
15050
+ const params = options.isExistingSource ? {
15051
+ source_id: token,
15052
+ invoice_id: invoiceId
15053
+ } : {
15054
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway4),
15055
+ gateway_token: token,
15056
+ invoice_id: invoiceId
15057
+ };
15058
+ window.Pelcro.invoice.pay(params, (err, res) => {
15059
+ callback(err, res);
15060
+ });
15061
+ }
15062
+ });
15063
+ }
15064
+
15065
+ }
15066
+
14812
15067
  /**
14813
15068
  * @typedef {Object} PaymentStateType
14814
15069
  * @property {boolean} disableSubmit
@@ -14853,55 +15108,324 @@ const {
14853
15108
  Provider: Provider$j
14854
15109
  } = store$j;
14855
15110
 
14856
- const PaymentMethodContainerWithoutStripe = ({
14857
- style,
14858
- className = "",
14859
- children,
14860
- stripe,
14861
- type,
14862
- onSuccess = () => {},
14863
- onGiftRenewalSuccess = () => {},
14864
- onFailure = () => {},
14865
- ...props
14866
- }) => {
14867
- var _props$product, _props$plan, _props$subscriptionId, _props$selectedAddres, _props$giftRecipient, _props$isGift, _props$isRenewingGift, _props$invoice;
15111
+ const PaymentMethodContainerWithoutStripe = ({
15112
+ style,
15113
+ className = "",
15114
+ children,
15115
+ stripe,
15116
+ type,
15117
+ onSuccess = () => {},
15118
+ onGiftRenewalSuccess = () => {},
15119
+ onFailure = () => {},
15120
+ ...props
15121
+ }) => {
15122
+ var _props$product, _props$plan, _props$subscriptionId, _props$selectedAddres, _props$giftRecipient, _props$isGift, _props$isRenewingGift, _props$invoice;
15123
+
15124
+ const {
15125
+ t
15126
+ } = useTranslation("payment");
15127
+ const pelcroStore = usePelcro();
15128
+ const {
15129
+ set,
15130
+ order,
15131
+ selectedPaymentMethodId,
15132
+ couponCode
15133
+ } = usePelcro();
15134
+ const product = (_props$product = props.product) !== null && _props$product !== void 0 ? _props$product : pelcroStore.product;
15135
+ const plan = (_props$plan = props.plan) !== null && _props$plan !== void 0 ? _props$plan : pelcroStore.plan;
15136
+ const subscriptionIdToRenew = (_props$subscriptionId = props.subscriptionIdToRenew) !== null && _props$subscriptionId !== void 0 ? _props$subscriptionId : pelcroStore.subscriptionIdToRenew;
15137
+ const selectedAddressId = (_props$selectedAddres = props.selectedAddressId) !== null && _props$selectedAddres !== void 0 ? _props$selectedAddres : pelcroStore.selectedAddressId;
15138
+ const giftRecipient = (_props$giftRecipient = props.giftRecipient) !== null && _props$giftRecipient !== void 0 ? _props$giftRecipient : pelcroStore.giftRecipient;
15139
+ const isGift = (_props$isGift = props.isGift) !== null && _props$isGift !== void 0 ? _props$isGift : pelcroStore.isGift;
15140
+ const isRenewingGift = (_props$isRenewingGift = props.isRenewingGift) !== null && _props$isRenewingGift !== void 0 ? _props$isRenewingGift : pelcroStore.isRenewingGift;
15141
+ const invoice = (_props$invoice = props.invoice) !== null && _props$invoice !== void 0 ? _props$invoice : pelcroStore.invoice;
15142
+ useEffect(() => {
15143
+ if (window.Pelcro.coupon.getFromUrl()) {
15144
+ dispatch({
15145
+ type: UPDATE_COUPON_CODE,
15146
+ payload: window.Pelcro.coupon.getFromUrl()
15147
+ });
15148
+ } else if (couponCode) {
15149
+ dispatch({
15150
+ type: UPDATE_COUPON_CODE,
15151
+ payload: couponCode
15152
+ });
15153
+ }
15154
+
15155
+ dispatch({
15156
+ type: INIT_CONTAINER
15157
+ });
15158
+ updateTotalAmountWithTax();
15159
+ }, []);
15160
+ /*====== Start Tap integration ========*/
15161
+
15162
+ const submitUsingTap = () => {
15163
+ var _ref, _ref2, _state$updatedPrice;
15164
+
15165
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
15166
+
15167
+ if (isUsingExistingPaymentMethod) {
15168
+ // no need to create a new source using tap
15169
+ return handleTapPayment(null);
15170
+ }
15171
+
15172
+ if (!tapInstanceRef.current) {
15173
+ return console.error("Tap sdk script wasn't loaded, you need to load tap sdk before rendering the tap payment flow");
15174
+ }
15175
+
15176
+ const getOrderItemsTotal = () => {
15177
+ if (!order) {
15178
+ return null;
15179
+ }
15180
+
15181
+ const isQuickPurchase = !Array.isArray(order);
15182
+
15183
+ if (isQuickPurchase) {
15184
+ return order.price * order.quantity;
15185
+ }
15186
+
15187
+ if (order.length === 0) {
15188
+ return null;
15189
+ }
15190
+
15191
+ return order.reduce((total, item) => {
15192
+ return total + item.price * item.quantity;
15193
+ }, 0);
15194
+ };
15195
+
15196
+ 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();
15197
+ tapInstanceRef.current.createToken(tapInstanceCard.current).then(function (result) {
15198
+ if (result.error) {
15199
+ // Inform the user if there was an error
15200
+ onFailure(result.error);
15201
+ dispatch({
15202
+ type: DISABLE_SUBMIT,
15203
+ payload: false
15204
+ });
15205
+ dispatch({
15206
+ type: LOADING,
15207
+ payload: false
15208
+ });
15209
+ return dispatch({
15210
+ type: SHOW_ALERT,
15211
+ payload: {
15212
+ type: "error",
15213
+ content: getErrorMessages(result.error)
15214
+ }
15215
+ });
15216
+ } else {
15217
+ console.log("Tap API Call result", result);
15218
+ window.Pelcro.payment.authorize({
15219
+ auth_token: window.Pelcro.user.read().auth_token,
15220
+ site_id: window.Pelcro.siteid,
15221
+ amount: totalAmount,
15222
+ 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,
15223
+ tap_token: result.id,
15224
+ redirect_url: `${window.Pelcro.environment.domain}/webhook/tap/callback/3dsecure?auth_token=${window.Pelcro.user.read().auth_token}`
15225
+ }, (err, res) => {
15226
+ if (err) {
15227
+ // Inform the user if there was an error
15228
+ onFailure(err);
15229
+ dispatch({
15230
+ type: DISABLE_SUBMIT,
15231
+ payload: false
15232
+ });
15233
+ dispatch({
15234
+ type: LOADING,
15235
+ payload: false
15236
+ });
15237
+ return dispatch({
15238
+ type: SHOW_ALERT,
15239
+ payload: {
15240
+ type: "error",
15241
+ content: getErrorMessages(err)
15242
+ }
15243
+ });
15244
+ } else {
15245
+ toggleAuthenticationPendingView(true, res);
15246
+
15247
+ const listenFor3DSecureCompletionMessage = () => {
15248
+ const retrieveSourceInfoFromIframe = event => {
15249
+ const {
15250
+ data
15251
+ } = event;
15252
+
15253
+ if (data.message === "3DS-authentication-complete") {
15254
+ const tapID = data.tapID;
15255
+ toggleAuthenticationPendingView(false);
15256
+ window.removeEventListener("message", retrieveSourceInfoFromIframe);
15257
+ dispatch({
15258
+ type: SHOW_ALERT,
15259
+ payload: {
15260
+ type: "error",
15261
+ content: null
15262
+ }
15263
+ });
15264
+ handleTapPayment(tapID);
15265
+ }
15266
+ }; // listen to injected iframe for authentication complete message
15267
+
15268
+
15269
+ window.addEventListener("message", retrieveSourceInfoFromIframe);
15270
+ };
15271
+
15272
+ listenFor3DSecureCompletionMessage();
15273
+ }
15274
+ });
15275
+ }
15276
+ });
15277
+ };
15278
+
15279
+ function handleTapPayment(paymentRequest) {
15280
+ // if (paymentRequest) {
15281
+ // const SUCCESS_STATUS = "870";
15282
+ // if (paymentRequest.response !== SUCCESS_STATUS) {
15283
+ // switch (paymentRequest.response) {
15284
+ // case "871":
15285
+ // return handlePaymentError({
15286
+ // error: new Error("Invalid account number")
15287
+ // });
15288
+ // default:
15289
+ // return handlePaymentError({
15290
+ // error: new Error(paymentRequest.message)
15291
+ // });
15292
+ // }
15293
+ // }
15294
+ // }
15295
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
15296
+
15297
+ if (type === "createPayment") {
15298
+ handleTapSubscription();
15299
+ } else if (type === "orderCreate") {
15300
+ purchase(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
15301
+ } else if (type === "invoicePayment") {
15302
+ payInvoice(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
15303
+ } else if (type === "updatePaymentSource") {
15304
+ createNewTapCard();
15305
+ }
15306
+
15307
+ function createNewTapCard() {
15308
+ window.Pelcro.source.create({
15309
+ auth_token: window.Pelcro.user.read().auth_token,
15310
+ token: paymentRequest,
15311
+ gateway: "tap"
15312
+ }, (err, res) => {
15313
+ dispatch({
15314
+ type: DISABLE_SUBMIT,
15315
+ payload: false
15316
+ });
15317
+ dispatch({
15318
+ type: LOADING,
15319
+ payload: false
15320
+ });
15321
+
15322
+ if (err) {
15323
+ onFailure(err);
15324
+ return dispatch({
15325
+ type: SHOW_ALERT,
15326
+ payload: {
15327
+ type: "error",
15328
+ content: getErrorMessages(err)
15329
+ }
15330
+ });
15331
+ }
15332
+
15333
+ dispatch({
15334
+ type: SHOW_ALERT,
15335
+ payload: {
15336
+ type: "success",
15337
+ content: t("messages.sourceUpdated")
15338
+ }
15339
+ });
15340
+ onSuccess(res);
15341
+ });
15342
+ }
15343
+
15344
+ function handleTapSubscription() {
15345
+ const payment = new Payment(new TapGateway());
15346
+ const createSubscription = !isGift && !subscriptionIdToRenew;
15347
+ const renewSubscription = !isGift && subscriptionIdToRenew;
15348
+ const giftSubscriprition = isGift && !subscriptionIdToRenew;
15349
+ const renewGift = isRenewingGift;
15350
+ const {
15351
+ couponCode
15352
+ } = state;
15353
+
15354
+ if (renewGift) {
15355
+ return payment.execute({
15356
+ type: PAYMENT_TYPES.RENEW_GIFTED_SUBSCRIPTION,
15357
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
15358
+ plan,
15359
+ couponCode,
15360
+ product,
15361
+ isExistingSource: isUsingExistingPaymentMethod,
15362
+ subscriptionIdToRenew,
15363
+ addressId: selectedAddressId
15364
+ }, (err, res) => {
15365
+ if (err) {
15366
+ return handlePaymentError(err);
15367
+ }
15368
+
15369
+ onSuccess(res);
15370
+ });
15371
+ } else if (giftSubscriprition) {
15372
+ return payment.execute({
15373
+ type: PAYMENT_TYPES.CREATE_GIFTED_SUBSCRIPTION,
15374
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
15375
+ quantity: plan.quantity,
15376
+ plan,
15377
+ couponCode,
15378
+ product,
15379
+ isExistingSource: isUsingExistingPaymentMethod,
15380
+ giftRecipient,
15381
+ addressId: selectedAddressId
15382
+ }, (err, res) => {
15383
+ if (err) {
15384
+ return handlePaymentError(err);
15385
+ }
14868
15386
 
14869
- const {
14870
- t
14871
- } = useTranslation("payment");
14872
- const pelcroStore = usePelcro();
14873
- const {
14874
- set,
14875
- order,
14876
- selectedPaymentMethodId,
14877
- couponCode
14878
- } = usePelcro();
14879
- const product = (_props$product = props.product) !== null && _props$product !== void 0 ? _props$product : pelcroStore.product;
14880
- const plan = (_props$plan = props.plan) !== null && _props$plan !== void 0 ? _props$plan : pelcroStore.plan;
14881
- const subscriptionIdToRenew = (_props$subscriptionId = props.subscriptionIdToRenew) !== null && _props$subscriptionId !== void 0 ? _props$subscriptionId : pelcroStore.subscriptionIdToRenew;
14882
- const selectedAddressId = (_props$selectedAddres = props.selectedAddressId) !== null && _props$selectedAddres !== void 0 ? _props$selectedAddres : pelcroStore.selectedAddressId;
14883
- const giftRecipient = (_props$giftRecipient = props.giftRecipient) !== null && _props$giftRecipient !== void 0 ? _props$giftRecipient : pelcroStore.giftRecipient;
14884
- const isGift = (_props$isGift = props.isGift) !== null && _props$isGift !== void 0 ? _props$isGift : pelcroStore.isGift;
14885
- const isRenewingGift = (_props$isRenewingGift = props.isRenewingGift) !== null && _props$isRenewingGift !== void 0 ? _props$isRenewingGift : pelcroStore.isRenewingGift;
14886
- const invoice = (_props$invoice = props.invoice) !== null && _props$invoice !== void 0 ? _props$invoice : pelcroStore.invoice;
14887
- useEffect(() => {
14888
- if (window.Pelcro.coupon.getFromUrl()) {
14889
- dispatch({
14890
- type: UPDATE_COUPON_CODE,
14891
- payload: window.Pelcro.coupon.getFromUrl()
14892
- });
14893
- } else if (couponCode) {
14894
- dispatch({
14895
- type: UPDATE_COUPON_CODE,
14896
- payload: couponCode
14897
- });
15387
+ onSuccess(res);
15388
+ });
15389
+ } else if (renewSubscription) {
15390
+ return payment.execute({
15391
+ type: PAYMENT_TYPES.RENEW_SUBSCRIPTION,
15392
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
15393
+ quantity: plan.quantity,
15394
+ plan,
15395
+ couponCode,
15396
+ product,
15397
+ isExistingSource: isUsingExistingPaymentMethod,
15398
+ subscriptionIdToRenew,
15399
+ addressId: selectedAddressId
15400
+ }, (err, res) => {
15401
+ if (err) {
15402
+ return handlePaymentError(err);
15403
+ }
15404
+
15405
+ onSuccess(res);
15406
+ });
15407
+ } else if (createSubscription) {
15408
+ return payment.execute({
15409
+ type: PAYMENT_TYPES.CREATE_SUBSCRIPTION,
15410
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
15411
+ quantity: plan.quantity,
15412
+ plan,
15413
+ couponCode,
15414
+ product,
15415
+ isExistingSource: isUsingExistingPaymentMethod,
15416
+ addressId: selectedAddressId
15417
+ }, (err, res) => {
15418
+ if (err) {
15419
+ return handlePaymentError(err);
15420
+ }
15421
+
15422
+ onSuccess(res);
15423
+ });
15424
+ }
14898
15425
  }
15426
+ }
15427
+ /*====== End Tap integration ========*/
14899
15428
 
14900
- dispatch({
14901
- type: INIT_CONTAINER
14902
- });
14903
- updateTotalAmountWithTax();
14904
- }, []);
14905
15429
 
14906
15430
  const submitUsingVantiv = () => {
14907
15431
  const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
@@ -14952,7 +15476,7 @@ const PaymentMethodContainerWithoutStripe = ({
14952
15476
  } else if (type === "orderCreate") {
14953
15477
  purchase(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
14954
15478
  } else if (type === "invoicePayment") {
14955
- payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
15479
+ payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
14956
15480
  } else if (type === "updatePaymentSource") {
14957
15481
  createNewVantivCard();
14958
15482
  }
@@ -15079,6 +15603,8 @@ const PaymentMethodContainerWithoutStripe = ({
15079
15603
  }
15080
15604
 
15081
15605
  const vantivInstanceRef = React__default.useRef(null);
15606
+ const tapInstanceRef = React__default.useRef(null);
15607
+ const tapInstanceCard = React__default.useRef(null);
15082
15608
  useEffect(() => {
15083
15609
  const cardProcessor = getSiteCardProcessor();
15084
15610
 
@@ -15102,10 +15628,78 @@ const PaymentMethodContainerWithoutStripe = ({
15102
15628
  accountNumber: "1234 1234 1234 1234"
15103
15629
  },
15104
15630
  enhancedUxFeatures: {
15105
- inlineFieldValidations: true
15631
+ inlineFieldValidations: true,
15632
+ expDateValidation: true,
15633
+ numericInputsOnly: true
15106
15634
  }
15107
15635
  });
15108
15636
  }
15637
+
15638
+ if (cardProcessor === "tap" && !selectedPaymentMethodId) {
15639
+ var _window$Pelcro$site$r3;
15640
+
15641
+ 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);
15642
+ let elements = tapKey.elements({});
15643
+ let style = {
15644
+ base: {
15645
+ color: "#535353",
15646
+ lineHeight: "18px",
15647
+ fontFamily: "sans-serif",
15648
+ fontSmoothing: "antialiased",
15649
+ fontSize: "16px",
15650
+ "::placeholder": {
15651
+ color: "rgba(0, 0, 0, 0.26)",
15652
+ fontSize: "15px"
15653
+ }
15654
+ },
15655
+ invalid: {
15656
+ color: "red"
15657
+ }
15658
+ }; // input labels/placeholders
15659
+
15660
+ let labels = {
15661
+ cardNumber: "Card Number",
15662
+ expirationDate: "MM/YY",
15663
+ cvv: "CVV",
15664
+ cardHolder: "Card Holder Name"
15665
+ }; //payment options
15666
+
15667
+ let paymentOptions = {
15668
+ labels: labels,
15669
+ TextDirection: "ltr"
15670
+ }; //create element, pass style and payment options
15671
+
15672
+ let card = elements.create("card", {
15673
+ style: style
15674
+ }, paymentOptions); //mount element
15675
+
15676
+ card.mount("#tapPaymentIframe"); //card change event listener
15677
+
15678
+ card.addEventListener("change", function (event) {// if (event.error_interactive) {
15679
+ // onFailure(event.error_interactive);
15680
+ // return dispatch({
15681
+ // type: SHOW_ALERT,
15682
+ // payload: {
15683
+ // type: "error",
15684
+ // content: getErrorMessages(event.error_interactive)
15685
+ // }
15686
+ // });
15687
+ // } else {
15688
+ // dispatch({
15689
+ // type: SHOW_ALERT,
15690
+ // payload: { type: "error", content: "" }
15691
+ // });
15692
+ // }
15693
+ // let displayError = document.getElementById("error-handler");
15694
+ // if (event.error) {
15695
+ // displayError.textContent = event.error.message;
15696
+ // } else {
15697
+ // displayError.textContent = "";
15698
+ // }
15699
+ });
15700
+ tapInstanceRef.current = tapKey;
15701
+ tapInstanceCard.current = card;
15702
+ }
15109
15703
  }, [selectedPaymentMethodId]);
15110
15704
 
15111
15705
  const initPaymentRequest = (state, dispatch) => {
@@ -15178,9 +15772,9 @@ const PaymentMethodContainerWithoutStripe = ({
15178
15772
 
15179
15773
 
15180
15774
  const updateTotalAmountWithTax = () => {
15181
- var _window$Pelcro$site$r3;
15775
+ var _window$Pelcro$site$r4;
15182
15776
 
15183
- 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;
15777
+ 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;
15184
15778
 
15185
15779
  if (taxesEnabled && type === "createPayment") {
15186
15780
  dispatch({
@@ -15407,6 +16001,97 @@ const PaymentMethodContainerWithoutStripe = ({
15407
16001
  updateTotalAmountWithTax();
15408
16002
  }
15409
16003
  };
16004
+ /**
16005
+ * Attempt to confirm a Stripe card payment via it's PaymentIntent.
16006
+ * Only trigger method if PaymentIntent status is `requires_action`.
16007
+ *
16008
+ * @see https://stripe.com/docs/payments/intents#intent-statuses
16009
+ *
16010
+ * @param response
16011
+ * @param error
16012
+ * @returns {*}
16013
+ */
16014
+
16015
+
16016
+ const confirmStripeCardPayment = (response, error, isSubCreate = false) => {
16017
+ if (response) {
16018
+ var _response$data;
16019
+
16020
+ const paymentIntent = (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.payment_intent;
16021
+
16022
+ if ((paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.status) === "requires_action" && paymentIntent !== null && paymentIntent !== void 0 && paymentIntent.client_secret) {
16023
+ stripe.confirmCardPayment(paymentIntent.client_secret).then(res => {
16024
+ if (!isSubCreate) {
16025
+ dispatch({
16026
+ type: DISABLE_SUBMIT,
16027
+ payload: false
16028
+ });
16029
+ }
16030
+
16031
+ dispatch({
16032
+ type: LOADING,
16033
+ payload: false
16034
+ });
16035
+
16036
+ if (res.error) {
16037
+ onFailure(res.error);
16038
+ return dispatch({
16039
+ type: SHOW_ALERT,
16040
+ payload: {
16041
+ type: "error",
16042
+ content: isSubCreate ? t("messages.tryAgainFromInvoice") : getErrorMessages(res.error)
16043
+ }
16044
+ });
16045
+ }
16046
+
16047
+ onSuccess(res);
16048
+ });
16049
+ } else if ((paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.status) === "requires_payment_method" && paymentIntent !== null && paymentIntent !== void 0 && paymentIntent.client_secret) {
16050
+ if (!isSubCreate) {
16051
+ dispatch({
16052
+ type: DISABLE_SUBMIT,
16053
+ payload: false
16054
+ });
16055
+ }
16056
+
16057
+ dispatch({
16058
+ type: LOADING,
16059
+ payload: false
16060
+ });
16061
+ return dispatch({
16062
+ type: SHOW_ALERT,
16063
+ payload: {
16064
+ type: "error",
16065
+ content: isSubCreate ? t("messages.tryAgainFromInvoice") : t("messages.cardAuthFailed")
16066
+ }
16067
+ });
16068
+ } else {
16069
+ onSuccess(response);
16070
+ }
16071
+ } else {
16072
+ dispatch({
16073
+ type: DISABLE_SUBMIT,
16074
+ payload: false
16075
+ });
16076
+ dispatch({
16077
+ type: LOADING,
16078
+ payload: false
16079
+ });
16080
+
16081
+ if (error) {
16082
+ onFailure(error);
16083
+ return dispatch({
16084
+ type: SHOW_ALERT,
16085
+ payload: {
16086
+ type: "error",
16087
+ content: getErrorMessages(error)
16088
+ }
16089
+ });
16090
+ }
16091
+
16092
+ onSuccess(response);
16093
+ }
16094
+ };
15410
16095
 
15411
16096
  const subscribe = (stripeSource, state, dispatch) => {
15412
16097
  const {
@@ -15429,27 +16114,7 @@ const PaymentMethodContainerWithoutStripe = ({
15429
16114
  gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
15430
16115
  address_id: product.address_required ? selectedAddressId : null
15431
16116
  }, (err, res) => {
15432
- dispatch({
15433
- type: DISABLE_SUBMIT,
15434
- payload: false
15435
- });
15436
- dispatch({
15437
- type: LOADING,
15438
- payload: false
15439
- });
15440
-
15441
- if (err) {
15442
- onFailure(err);
15443
- return dispatch({
15444
- type: SHOW_ALERT,
15445
- payload: {
15446
- type: "error",
15447
- content: getErrorMessages(err)
15448
- }
15449
- });
15450
- }
15451
-
15452
- onSuccess(res);
16117
+ confirmStripeCardPayment(res, err, true);
15453
16118
  });
15454
16119
  } else {
15455
16120
  if (isRenewingGift) {
@@ -15673,27 +16338,7 @@ const PaymentMethodContainerWithoutStripe = ({
15673
16338
  isExistingSource: Boolean(selectedPaymentMethodId),
15674
16339
  invoiceId: invoice.id
15675
16340
  }, (err, res) => {
15676
- dispatch({
15677
- type: DISABLE_SUBMIT,
15678
- payload: false
15679
- });
15680
- dispatch({
15681
- type: LOADING,
15682
- payload: false
15683
- });
15684
-
15685
- if (err) {
15686
- onFailure(err);
15687
- return dispatch({
15688
- type: SHOW_ALERT,
15689
- payload: {
15690
- type: "error",
15691
- content: getErrorMessages(err)
15692
- }
15693
- });
15694
- }
15695
-
15696
- onSuccess(res);
16341
+ confirmStripeCardPayment(res, err);
15697
16342
  });
15698
16343
  };
15699
16344
 
@@ -15773,7 +16418,7 @@ const PaymentMethodContainerWithoutStripe = ({
15773
16418
  source,
15774
16419
  error
15775
16420
  }) => {
15776
- var _ref, _ref2, _state$updatedPrice, _source$card3;
16421
+ var _ref3, _ref4, _state$updatedPrice2;
15777
16422
 
15778
16423
  if (error) {
15779
16424
  return handlePaymentError(error);
@@ -15799,25 +16444,7 @@ const PaymentMethodContainerWithoutStripe = ({
15799
16444
  }, 0);
15800
16445
  };
15801
16446
 
15802
- 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();
15803
-
15804
- 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) {
15805
- return resolveTaxCalculation().then(res => {
15806
- var _res$totalAmountWithT;
15807
-
15808
- return generate3DSecureSource(source, (_res$totalAmountWithT = res === null || res === void 0 ? void 0 : res.totalAmountWithTax) !== null && _res$totalAmountWithT !== void 0 ? _res$totalAmountWithT : totalAmount).then(({
15809
- source,
15810
- error
15811
- }) => {
15812
- if (error) {
15813
- return handlePaymentError(error);
15814
- }
15815
-
15816
- toggleAuthenticationPendingView(true, source);
15817
- });
15818
- });
15819
- }
15820
-
16447
+ (_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();
15821
16448
  return handlePayment(source);
15822
16449
  }).catch(error => {
15823
16450
  return handlePaymentError(error);
@@ -15830,13 +16457,13 @@ const PaymentMethodContainerWithoutStripe = ({
15830
16457
 
15831
16458
 
15832
16459
  const resolveTaxCalculation = () => {
15833
- var _window$Pelcro$site$r4;
16460
+ var _window$Pelcro$site$r5;
15834
16461
 
15835
16462
  if (type === "invoicePayment") {
15836
16463
  return new Promise(resolve => resolve());
15837
16464
  }
15838
16465
 
15839
- 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;
16466
+ 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;
15840
16467
  return new Promise((resolve, reject) => {
15841
16468
  // resolve early if taxes isn't enabled
15842
16469
  if (!taxesEnabled) {
@@ -15911,7 +16538,7 @@ const PaymentMethodContainerWithoutStripe = ({
15911
16538
  } else if (stripeSource && type === "orderCreate") {
15912
16539
  purchase(new StripeGateway(), stripeSource.id, state, dispatch);
15913
16540
  } else if (stripeSource && type === "invoicePayment") {
15914
- payInvoice(new StripeGateway(), stripeSource.id, dispatch);
16541
+ payInvoice(new StripeGateway(), stripeSource.id);
15915
16542
  }
15916
16543
  };
15917
16544
 
@@ -15988,10 +16615,12 @@ const PaymentMethodContainerWithoutStripe = ({
15988
16615
  };
15989
16616
 
15990
16617
  const injectCardAuthenticationIframe = source => {
16618
+ var _source$redirect;
16619
+
15991
16620
  const cardAuthContainer = document.querySelector(".card-authentication-container");
15992
16621
  const iframe = document.createElement("iframe");
15993
- iframe.src = source.redirect.url;
15994
- iframe.style = "position: absolute; width: 100%; height: 100%; left: 0; top: 40px; bottom: 0; z-index: 10;";
16622
+ 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;
16623
+ iframe.style = "position: absolute; width: 100%; height: 100%; left: 0; top: 0; bottom: 0; z-index: 10;";
15995
16624
  cardAuthContainer.appendChild(iframe);
15996
16625
  };
15997
16626
 
@@ -16037,6 +16666,10 @@ const PaymentMethodContainerWithoutStripe = ({
16037
16666
  return submitUsingVantiv();
16038
16667
  }
16039
16668
 
16669
+ if (getSiteCardProcessor() === "tap") {
16670
+ return submitUsingTap();
16671
+ }
16672
+
16040
16673
  if (selectedPaymentMethodId) {
16041
16674
  // pay with selected method (source) if exists already
16042
16675
  return handlePayment({
@@ -16055,7 +16688,7 @@ const PaymentMethodContainerWithoutStripe = ({
16055
16688
  case HANDLE_PAYPAL_SUBSCRIPTION:
16056
16689
  return lib_5(state, (state, dispatch) => {
16057
16690
  if (type === "invoicePayment") {
16058
- payInvoice(new PaypalGateway(), action.payload, dispatch);
16691
+ payInvoice(new PaypalGateway(), action.payload);
16059
16692
  } else {
16060
16693
  handlePaypalSubscription(state, action.payload);
16061
16694
  }
@@ -16250,6 +16883,12 @@ const CheckoutForm = () => {
16250
16883
  });
16251
16884
  }
16252
16885
 
16886
+ if (cardProcessor === "tap") {
16887
+ return /*#__PURE__*/React__default.createElement("div", {
16888
+ id: "tapPaymentIframe"
16889
+ });
16890
+ }
16891
+
16253
16892
  if (cardProcessor === "stripe") {
16254
16893
  return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(PelcroCardNumber, {
16255
16894
  autoFocus: true
@@ -16934,13 +17573,14 @@ function PaymentMethodView({
16934
17573
  showCoupon,
16935
17574
  showExternalPaymentMethods
16936
17575
  }) {
16937
- var _window$Pelcro$site$r;
17576
+ var _window$Pelcro$site$r, _window$Pelcro$site$r2;
16938
17577
 
16939
17578
  const {
16940
17579
  t
16941
17580
  } = useTranslation("checkoutForm");
16942
17581
  const cardProcessor = getSiteCardProcessor();
16943
17582
  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);
17583
+ 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);
16944
17584
  return /*#__PURE__*/React__default.createElement("div", {
16945
17585
  className: "plc-flex plc-flex-col plc-items-center plc-mt-4 sm:plc-px-8 pelcro-payment-block"
16946
17586
  }, cardProcessor === "stripe" && /*#__PURE__*/React__default.createElement("div", {
@@ -17892,9 +18532,7 @@ class DefaultNewsLetter extends Component {
17892
18532
  });
17893
18533
 
17894
18534
  _defineProperty$3(this, "postSubmit", () => {
17895
- var _this$product, _this$product$paywall, _this$product2, _this$product2$paywal;
17896
-
17897
- 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);
18535
+ window.Pelcro.paywall.setNewsletterExtraVisits(true);
17898
18536
  this.props.setView("meter");
17899
18537
  });
17900
18538
 
@@ -24184,10 +24822,8 @@ var GroupContext = /*#__PURE__*/createContext(null);
24184
24822
  GroupContext.displayName = 'GroupContext';
24185
24823
 
24186
24824
  const getPaymentCardIcon = name => {
24187
- var _icons$name;
24188
-
24189
24825
  const icons = {
24190
- Visa: /*#__PURE__*/React__default.createElement("svg", {
24826
+ visa: /*#__PURE__*/React__default.createElement("svg", {
24191
24827
  className: "plc-w-12",
24192
24828
  fill: "#ffffff",
24193
24829
  xmlns: "http://www.w3.org/2000/svg",
@@ -24195,7 +24831,7 @@ const getPaymentCardIcon = name => {
24195
24831
  }, /*#__PURE__*/React__default.createElement("path", {
24196
24832
  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"
24197
24833
  })),
24198
- MasterCard: /*#__PURE__*/React__default.createElement("svg", {
24834
+ mastercard: /*#__PURE__*/React__default.createElement("svg", {
24199
24835
  className: "plc-w-12",
24200
24836
  fill: "#ffffff",
24201
24837
  xmlns: "http://www.w3.org/2000/svg",
@@ -24203,7 +24839,7 @@ const getPaymentCardIcon = name => {
24203
24839
  }, /*#__PURE__*/React__default.createElement("path", {
24204
24840
  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 "
24205
24841
  })),
24206
- "American Express": /*#__PURE__*/React__default.createElement("svg", {
24842
+ "american express": /*#__PURE__*/React__default.createElement("svg", {
24207
24843
  className: "plc-w-12",
24208
24844
  fill: "#ffffff",
24209
24845
  xmlns: "http://www.w3.org/2000/svg",
@@ -24212,7 +24848,7 @@ const getPaymentCardIcon = name => {
24212
24848
  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"
24213
24849
  }))
24214
24850
  };
24215
- return (_icons$name = icons[name]) !== null && _icons$name !== void 0 ? _icons$name : /*#__PURE__*/React__default.createElement("svg", {
24851
+ return name ? icons[name.toLowerCase()] : /*#__PURE__*/React__default.createElement("svg", {
24216
24852
  xmlns: "http://www.w3.org/2000/svg",
24217
24853
  className: "plc-w-12",
24218
24854
  fill: "none",
@@ -24710,7 +25346,7 @@ const SubscriptionsItems = ({
24710
25346
  onClick: onReactivateClick,
24711
25347
  disabled: disableSubmit,
24712
25348
  "data-key": sub.id
24713
- }, t("labels.reactivate")), sub.cancel_at_period_end === 1 && /*#__PURE__*/React__default.createElement(Button, {
25349
+ }, t("labels.reactivate")), sub.cancel_at_period_end === 1 && sub.status !== "incomplete" && /*#__PURE__*/React__default.createElement(Button, {
24714
25350
  variant: "ghost",
24715
25351
  className: "plc-text-blue-400 pelcro-dashboard-sub-renew-button",
24716
25352
  icon: /*#__PURE__*/React__default.createElement(SvgRefresh, null),
@@ -25541,6 +26177,10 @@ class Dashboard extends Component {
25541
26177
  return `${this.locale("labels.canceledOn")} ${formattedCancelDate}`;
25542
26178
  }
25543
26179
 
26180
+ if (subscription.status === "incomplete") {
26181
+ return `${this.locale("labels.status.incomplete")}`;
26182
+ }
26183
+
25544
26184
  if (subscription.cancel_at_period_end) {
25545
26185
  // DateTime from BE is missing 3 zeros so we add them before instancing a date
25546
26186
  const expiryDate = new Date(Number(`${subscription.expires_at}000`));
@@ -25606,6 +26246,16 @@ class Dashboard extends Component {
25606
26246
  };
25607
26247
  }
25608
26248
 
26249
+ if (sub.status === "incomplete") {
26250
+ return {
26251
+ title: this.locale("labels.status.incomplete"),
26252
+ content: this.getSubscriptionStatusText(sub),
26253
+ textColor: "plc-text-orange-700",
26254
+ bgColor: "plc-bg-orange-100",
26255
+ icon: /*#__PURE__*/React__default.createElement(SvgExclamation, null)
26256
+ };
26257
+ }
26258
+
25609
26259
  return {
25610
26260
  title: this.locale("labels.status.active"),
25611
26261
  content: this.getSubscriptionStatusText(sub),