@pelcro/react-pelcro-js 3.7.1 → 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.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,10 @@ 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;
7903
+ var _icons$name$toLowerCa;
7895
7904
 
7896
7905
  const icons = {
7897
- Visa: /*#__PURE__*/React__default.createElement("svg", {
7906
+ visa: /*#__PURE__*/React__default.createElement("svg", {
7898
7907
  className: "plc-w-16",
7899
7908
  xmlns: "http://www.w3.org/2000/svg",
7900
7909
  viewBox: "0 0 48 48"
@@ -7905,7 +7914,7 @@ const getPaymentCardIcon$1 = name => {
7905
7914
  fill: "#FFC107",
7906
7915
  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
7916
  })),
7908
- MasterCard: /*#__PURE__*/React__default.createElement("svg", {
7917
+ mastercard: /*#__PURE__*/React__default.createElement("svg", {
7909
7918
  className: "plc-w-16",
7910
7919
  xmlns: "http://www.w3.org/2000/svg",
7911
7920
  viewBox: "0 0 48 48"
@@ -7919,7 +7928,7 @@ const getPaymentCardIcon$1 = name => {
7919
7928
  fill: "#ff3d00",
7920
7929
  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
7930
  })),
7922
- "American Express": /*#__PURE__*/React__default.createElement("svg", {
7931
+ "american express": /*#__PURE__*/React__default.createElement("svg", {
7923
7932
  className: "plc-w-16",
7924
7933
  xmlns: "http://www.w3.org/2000/svg",
7925
7934
  viewBox: "0 0 48 48"
@@ -7931,7 +7940,7 @@ const getPaymentCardIcon$1 = name => {
7931
7940
  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
7941
  }))
7933
7942
  };
7934
- return (_icons$name = icons[name]) !== null && _icons$name !== void 0 ? _icons$name : /*#__PURE__*/React__default.createElement("svg", {
7943
+ return (_icons$name$toLowerCa = icons[name.toLowerCase()]) !== null && _icons$name$toLowerCa !== void 0 ? _icons$name$toLowerCa : /*#__PURE__*/React__default.createElement("svg", {
7935
7944
  xmlns: "http://www.w3.org/2000/svg",
7936
7945
  className: "plc-w-16",
7937
7946
  fill: "none",
@@ -9942,12 +9951,16 @@ const debounce = (func, waitTime) => {
9942
9951
  };
9943
9952
  };
9944
9953
  function getSiteCardProcessor() {
9945
- var _window$Pelcro$site$r;
9954
+ var _window$Pelcro$site$r, _window$Pelcro$site$r2;
9946
9955
 
9947
9956
  if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_gateway_settings) {
9948
9957
  return "vantiv";
9949
9958
  }
9950
9959
 
9960
+ if ((_window$Pelcro$site$r2 = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r2 !== void 0 && _window$Pelcro$site$r2.tap_gateway_settings) {
9961
+ return "tap";
9962
+ }
9963
+
9951
9964
  return "stripe";
9952
9965
  }
9953
9966
 
@@ -10053,6 +10066,14 @@ const loadPaymentSDKs = () => {
10053
10066
  const scriptUrlToUse = window.Pelcro.site.read().vantiv_gateway_settings.environment === "production" ? PRODUCTION_URL : PRELIVE_URL;
10054
10067
  window.Pelcro.helpers.loadSDK(scriptUrlToUse, "vantiv-eprotect-sdk");
10055
10068
  }
10069
+ } // Load Tap SDKs
10070
+
10071
+
10072
+ const supportsTap = Boolean(window.Pelcro.site.read().tap_gateway_settings);
10073
+
10074
+ if (supportsTap) {
10075
+ window.Pelcro.helpers.loadSDK("https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js", "tap-bluebird");
10076
+ window.Pelcro.helpers.loadSDK("https://secure.gosell.io/js/sdk/tap.min.js", "tap-sdk");
10056
10077
  }
10057
10078
  };
10058
10079
  const loadAuth0SDK = () => {
@@ -14165,7 +14186,7 @@ var _generateUserError = /*#__PURE__*/new WeakMap();
14165
14186
 
14166
14187
  class Payment {
14167
14188
  /**
14168
- * @param {(StripeGateway|PaypalGateway|VantivGateway)} paymentGateway
14189
+ * @param {(StripeGateway|PaypalGateway|VantivGateway|TapGateway)} paymentGateway
14169
14190
  */
14170
14191
  constructor(paymentGateway) {
14171
14192
  _defineProperty$3(this, "execute", (options, callback) => {
@@ -14186,7 +14207,7 @@ class Payment {
14186
14207
  _isPaymentGatewayInvalid.set(this, {
14187
14208
  writable: true,
14188
14209
  value: gateway => {
14189
- return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway);
14210
+ return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway || gateway instanceof TapGateway);
14190
14211
  }
14191
14212
  });
14192
14213
 
@@ -14241,7 +14262,8 @@ class Payment {
14241
14262
  const PAYMENT_GATEWAYS_ENUM = {
14242
14263
  stripe: "stripe",
14243
14264
  paypal: "braintree",
14244
- vantiv: "vantiv"
14265
+ vantiv: "vantiv",
14266
+ tap: "tap"
14245
14267
  };
14246
14268
  /**
14247
14269
  * Payment Strategies
@@ -14809,6 +14831,241 @@ class VantivGateway {
14809
14831
 
14810
14832
  }
14811
14833
 
14834
+ var _paymentGateway4 = /*#__PURE__*/new WeakMap();
14835
+
14836
+ var _createSubscription4 = /*#__PURE__*/new WeakMap();
14837
+
14838
+ var _renewSubscription3 = /*#__PURE__*/new WeakMap();
14839
+
14840
+ var _createGiftedSubscription4 = /*#__PURE__*/new WeakMap();
14841
+
14842
+ var _renewGiftedSubscription3 = /*#__PURE__*/new WeakMap();
14843
+
14844
+ var _purchaseEcommerceOrder3 = /*#__PURE__*/new WeakMap();
14845
+
14846
+ var _payInvoice4 = /*#__PURE__*/new WeakMap();
14847
+
14848
+ class TapGateway {
14849
+ constructor() {
14850
+ _paymentGateway4.set(this, {
14851
+ writable: true,
14852
+ value: PAYMENT_GATEWAYS_ENUM["tap"]
14853
+ });
14854
+
14855
+ _defineProperty$3(this, "execute", (options, callback) => {
14856
+ const types = PAYMENT_TYPES;
14857
+
14858
+ switch (options.type) {
14859
+ case types.CREATE_SUBSCRIPTION:
14860
+ return _classPrivateFieldGet(this, _createSubscription4).call(this, options, callback);
14861
+
14862
+ case types.RENEW_SUBSCRIPTION:
14863
+ return _classPrivateFieldGet(this, _renewSubscription3).call(this, options, callback);
14864
+
14865
+ case types.CREATE_GIFTED_SUBSCRIPTION:
14866
+ return _classPrivateFieldGet(this, _createGiftedSubscription4).call(this, options, callback);
14867
+
14868
+ case types.RENEW_GIFTED_SUBSCRIPTION:
14869
+ return _classPrivateFieldGet(this, _renewGiftedSubscription3).call(this, options, callback);
14870
+
14871
+ case types.PURCHASE_ECOMMERCE_ORDER:
14872
+ return _classPrivateFieldGet(this, _purchaseEcommerceOrder3).call(this, options, callback);
14873
+
14874
+ case types.PAY_INVOICE:
14875
+ return _classPrivateFieldGet(this, _payInvoice4).call(this, options, callback);
14876
+
14877
+ default:
14878
+ console.error("Unsupported payment method: tap Gateway");
14879
+ }
14880
+ });
14881
+
14882
+ _createSubscription4.set(this, {
14883
+ writable: true,
14884
+ value: (options, callback) => {
14885
+ const {
14886
+ token,
14887
+ plan,
14888
+ couponCode,
14889
+ product,
14890
+ quantity = 1,
14891
+ addressId,
14892
+ isExistingSource
14893
+ } = options;
14894
+ const params = isExistingSource ? {
14895
+ source_id: token
14896
+ } : {
14897
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway4),
14898
+ gateway_token: token
14899
+ };
14900
+ window.Pelcro.subscription.create({
14901
+ quantity,
14902
+ auth_token: window.Pelcro.user.read().auth_token,
14903
+ plan_id: plan.id,
14904
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
14905
+ coupon_code: couponCode,
14906
+ address_id: product.address_required ? addressId : null,
14907
+ ...params
14908
+ }, (err, res) => {
14909
+ callback(err, res);
14910
+ });
14911
+ }
14912
+ });
14913
+
14914
+ _renewSubscription3.set(this, {
14915
+ writable: true,
14916
+ value: (options, callback) => {
14917
+ const {
14918
+ subscriptionIdToRenew,
14919
+ token,
14920
+ plan,
14921
+ couponCode,
14922
+ product,
14923
+ addressId,
14924
+ isExistingSource
14925
+ } = options;
14926
+ const params = isExistingSource ? {
14927
+ source_id: token
14928
+ } : {
14929
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway4),
14930
+ gateway_token: token
14931
+ };
14932
+ window.Pelcro.subscription.renew({
14933
+ auth_token: window.Pelcro.user.read().auth_token,
14934
+ plan_id: plan.id,
14935
+ coupon_code: couponCode,
14936
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
14937
+ subscription_id: subscriptionIdToRenew,
14938
+ address_id: product.address_required ? addressId : null,
14939
+ ...params
14940
+ }, (err, res) => {
14941
+ callback(err, res);
14942
+ });
14943
+ }
14944
+ });
14945
+
14946
+ _createGiftedSubscription4.set(this, {
14947
+ writable: true,
14948
+ value: (options, callback) => {
14949
+ const {
14950
+ token,
14951
+ plan,
14952
+ couponCode,
14953
+ product,
14954
+ giftRecipient,
14955
+ quantity = 1,
14956
+ addressId,
14957
+ isExistingSource
14958
+ } = options;
14959
+ const params = isExistingSource ? {
14960
+ source_id: token
14961
+ } : {
14962
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway4),
14963
+ gateway_token: token
14964
+ };
14965
+ window.Pelcro.subscription.create({
14966
+ quantity,
14967
+ auth_token: window.Pelcro.user.read().auth_token,
14968
+ plan_id: plan.id,
14969
+ coupon_code: couponCode,
14970
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
14971
+ gift_recipient_email: giftRecipient.email,
14972
+ gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
14973
+ gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
14974
+ gift_start_date: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.startDate,
14975
+ gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
14976
+ address_id: product.address_required ? addressId : null,
14977
+ ...params
14978
+ }, (err, res) => {
14979
+ callback(err, res);
14980
+ });
14981
+ }
14982
+ });
14983
+
14984
+ _renewGiftedSubscription3.set(this, {
14985
+ writable: true,
14986
+ value: (options, callback) => {
14987
+ const {
14988
+ subscriptionIdToRenew,
14989
+ token,
14990
+ product,
14991
+ plan,
14992
+ couponCode,
14993
+ addressId,
14994
+ isExistingSource
14995
+ } = options;
14996
+ const params = isExistingSource ? {
14997
+ source_id: token
14998
+ } : {
14999
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway4),
15000
+ gateway_token: token
15001
+ };
15002
+ window.Pelcro.subscription.renewGift({
15003
+ auth_token: window.Pelcro.user.read().auth_token,
15004
+ plan_id: plan.id,
15005
+ coupon_code: couponCode,
15006
+ subscription_id: subscriptionIdToRenew,
15007
+ address_id: product.address_required ? addressId : null,
15008
+ ...params
15009
+ }, (err, res) => {
15010
+ callback(err, res);
15011
+ });
15012
+ }
15013
+ });
15014
+
15015
+ _purchaseEcommerceOrder3.set(this, {
15016
+ writable: true,
15017
+ value: (options, callback) => {
15018
+ const {
15019
+ token,
15020
+ items,
15021
+ couponCode,
15022
+ addressId,
15023
+ isExistingSource
15024
+ } = options;
15025
+ const params = isExistingSource ? {
15026
+ source_id: token
15027
+ } : {
15028
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway4),
15029
+ gateway_token: token
15030
+ };
15031
+ window.Pelcro.ecommerce.order.create({
15032
+ items,
15033
+ coupon_code: couponCode,
15034
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
15035
+ ...params,
15036
+ ...(addressId && {
15037
+ address_id: addressId
15038
+ })
15039
+ }, (err, res) => {
15040
+ callback(err, res);
15041
+ });
15042
+ }
15043
+ });
15044
+
15045
+ _payInvoice4.set(this, {
15046
+ writable: true,
15047
+ value: (options, callback) => {
15048
+ const {
15049
+ token,
15050
+ invoiceId
15051
+ } = options;
15052
+ const params = options.isExistingSource ? {
15053
+ source_id: token,
15054
+ invoice_id: invoiceId
15055
+ } : {
15056
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway4),
15057
+ gateway_token: token,
15058
+ invoice_id: invoiceId
15059
+ };
15060
+ window.Pelcro.invoice.pay(params, (err, res) => {
15061
+ callback(err, res);
15062
+ });
15063
+ }
15064
+ });
15065
+ }
15066
+
15067
+ }
15068
+
14812
15069
  /**
14813
15070
  * @typedef {Object} PaymentStateType
14814
15071
  * @property {boolean} disableSubmit
@@ -14853,55 +15110,324 @@ const {
14853
15110
  Provider: Provider$j
14854
15111
  } = store$j;
14855
15112
 
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;
15113
+ const PaymentMethodContainerWithoutStripe = ({
15114
+ style,
15115
+ className = "",
15116
+ children,
15117
+ stripe,
15118
+ type,
15119
+ onSuccess = () => {},
15120
+ onGiftRenewalSuccess = () => {},
15121
+ onFailure = () => {},
15122
+ ...props
15123
+ }) => {
15124
+ var _props$product, _props$plan, _props$subscriptionId, _props$selectedAddres, _props$giftRecipient, _props$isGift, _props$isRenewingGift, _props$invoice;
15125
+
15126
+ const {
15127
+ t
15128
+ } = useTranslation("payment");
15129
+ const pelcroStore = usePelcro();
15130
+ const {
15131
+ set,
15132
+ order,
15133
+ selectedPaymentMethodId,
15134
+ couponCode
15135
+ } = usePelcro();
15136
+ const product = (_props$product = props.product) !== null && _props$product !== void 0 ? _props$product : pelcroStore.product;
15137
+ const plan = (_props$plan = props.plan) !== null && _props$plan !== void 0 ? _props$plan : pelcroStore.plan;
15138
+ const subscriptionIdToRenew = (_props$subscriptionId = props.subscriptionIdToRenew) !== null && _props$subscriptionId !== void 0 ? _props$subscriptionId : pelcroStore.subscriptionIdToRenew;
15139
+ const selectedAddressId = (_props$selectedAddres = props.selectedAddressId) !== null && _props$selectedAddres !== void 0 ? _props$selectedAddres : pelcroStore.selectedAddressId;
15140
+ const giftRecipient = (_props$giftRecipient = props.giftRecipient) !== null && _props$giftRecipient !== void 0 ? _props$giftRecipient : pelcroStore.giftRecipient;
15141
+ const isGift = (_props$isGift = props.isGift) !== null && _props$isGift !== void 0 ? _props$isGift : pelcroStore.isGift;
15142
+ const isRenewingGift = (_props$isRenewingGift = props.isRenewingGift) !== null && _props$isRenewingGift !== void 0 ? _props$isRenewingGift : pelcroStore.isRenewingGift;
15143
+ const invoice = (_props$invoice = props.invoice) !== null && _props$invoice !== void 0 ? _props$invoice : pelcroStore.invoice;
15144
+ useEffect(() => {
15145
+ if (window.Pelcro.coupon.getFromUrl()) {
15146
+ dispatch({
15147
+ type: UPDATE_COUPON_CODE,
15148
+ payload: window.Pelcro.coupon.getFromUrl()
15149
+ });
15150
+ } else if (couponCode) {
15151
+ dispatch({
15152
+ type: UPDATE_COUPON_CODE,
15153
+ payload: couponCode
15154
+ });
15155
+ }
15156
+
15157
+ dispatch({
15158
+ type: INIT_CONTAINER
15159
+ });
15160
+ updateTotalAmountWithTax();
15161
+ }, []);
15162
+ /*====== Start Tap integration ========*/
15163
+
15164
+ const submitUsingTap = () => {
15165
+ var _ref, _ref2, _state$updatedPrice;
15166
+
15167
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
15168
+
15169
+ if (isUsingExistingPaymentMethod) {
15170
+ // no need to create a new source using tap
15171
+ return handleTapPayment(null);
15172
+ }
15173
+
15174
+ if (!tapInstanceRef.current) {
15175
+ return console.error("Tap sdk script wasn't loaded, you need to load tap sdk before rendering the tap payment flow");
15176
+ }
15177
+
15178
+ const getOrderItemsTotal = () => {
15179
+ if (!order) {
15180
+ return null;
15181
+ }
15182
+
15183
+ const isQuickPurchase = !Array.isArray(order);
15184
+
15185
+ if (isQuickPurchase) {
15186
+ return order.price * order.quantity;
15187
+ }
15188
+
15189
+ if (order.length === 0) {
15190
+ return null;
15191
+ }
15192
+
15193
+ return order.reduce((total, item) => {
15194
+ return total + item.price * item.quantity;
15195
+ }, 0);
15196
+ };
15197
+
15198
+ 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();
15199
+ tapInstanceRef.current.createToken(tapInstanceCard.current).then(function (result) {
15200
+ if (result.error) {
15201
+ // Inform the user if there was an error
15202
+ onFailure(result.error);
15203
+ dispatch({
15204
+ type: DISABLE_SUBMIT,
15205
+ payload: false
15206
+ });
15207
+ dispatch({
15208
+ type: LOADING,
15209
+ payload: false
15210
+ });
15211
+ return dispatch({
15212
+ type: SHOW_ALERT,
15213
+ payload: {
15214
+ type: "error",
15215
+ content: getErrorMessages(result.error)
15216
+ }
15217
+ });
15218
+ } else {
15219
+ console.log("Tap API Call result", result);
15220
+ window.Pelcro.payment.authorize({
15221
+ auth_token: window.Pelcro.user.read().auth_token,
15222
+ site_id: window.Pelcro.siteid,
15223
+ amount: totalAmount,
15224
+ 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,
15225
+ tap_token: result.id,
15226
+ redirect_url: `${window.Pelcro.environment.domain}/webhook/tap/callback/3dsecure?auth_token=${window.Pelcro.user.read().auth_token}`
15227
+ }, (err, res) => {
15228
+ if (err) {
15229
+ // Inform the user if there was an error
15230
+ onFailure(err);
15231
+ dispatch({
15232
+ type: DISABLE_SUBMIT,
15233
+ payload: false
15234
+ });
15235
+ dispatch({
15236
+ type: LOADING,
15237
+ payload: false
15238
+ });
15239
+ return dispatch({
15240
+ type: SHOW_ALERT,
15241
+ payload: {
15242
+ type: "error",
15243
+ content: getErrorMessages(err)
15244
+ }
15245
+ });
15246
+ } else {
15247
+ toggleAuthenticationPendingView(true, res);
15248
+
15249
+ const listenFor3DSecureCompletionMessage = () => {
15250
+ const retrieveSourceInfoFromIframe = event => {
15251
+ const {
15252
+ data
15253
+ } = event;
15254
+
15255
+ if (data.message === "3DS-authentication-complete") {
15256
+ const tapID = data.tapID;
15257
+ toggleAuthenticationPendingView(false);
15258
+ window.removeEventListener("message", retrieveSourceInfoFromIframe);
15259
+ dispatch({
15260
+ type: SHOW_ALERT,
15261
+ payload: {
15262
+ type: "error",
15263
+ content: null
15264
+ }
15265
+ });
15266
+ handleTapPayment(tapID);
15267
+ }
15268
+ }; // listen to injected iframe for authentication complete message
15269
+
15270
+
15271
+ window.addEventListener("message", retrieveSourceInfoFromIframe);
15272
+ };
15273
+
15274
+ listenFor3DSecureCompletionMessage();
15275
+ }
15276
+ });
15277
+ }
15278
+ });
15279
+ };
15280
+
15281
+ function handleTapPayment(paymentRequest) {
15282
+ // if (paymentRequest) {
15283
+ // const SUCCESS_STATUS = "870";
15284
+ // if (paymentRequest.response !== SUCCESS_STATUS) {
15285
+ // switch (paymentRequest.response) {
15286
+ // case "871":
15287
+ // return handlePaymentError({
15288
+ // error: new Error("Invalid account number")
15289
+ // });
15290
+ // default:
15291
+ // return handlePaymentError({
15292
+ // error: new Error(paymentRequest.message)
15293
+ // });
15294
+ // }
15295
+ // }
15296
+ // }
15297
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
15298
+
15299
+ if (type === "createPayment") {
15300
+ handleTapSubscription();
15301
+ } else if (type === "orderCreate") {
15302
+ purchase(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
15303
+ } else if (type === "invoicePayment") {
15304
+ payInvoice(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
15305
+ } else if (type === "updatePaymentSource") {
15306
+ createNewTapCard();
15307
+ }
15308
+
15309
+ function createNewTapCard() {
15310
+ window.Pelcro.source.create({
15311
+ auth_token: window.Pelcro.user.read().auth_token,
15312
+ token: paymentRequest,
15313
+ gateway: "tap"
15314
+ }, (err, res) => {
15315
+ dispatch({
15316
+ type: DISABLE_SUBMIT,
15317
+ payload: false
15318
+ });
15319
+ dispatch({
15320
+ type: LOADING,
15321
+ payload: false
15322
+ });
15323
+
15324
+ if (err) {
15325
+ onFailure(err);
15326
+ return dispatch({
15327
+ type: SHOW_ALERT,
15328
+ payload: {
15329
+ type: "error",
15330
+ content: getErrorMessages(err)
15331
+ }
15332
+ });
15333
+ }
15334
+
15335
+ dispatch({
15336
+ type: SHOW_ALERT,
15337
+ payload: {
15338
+ type: "success",
15339
+ content: t("messages.sourceUpdated")
15340
+ }
15341
+ });
15342
+ onSuccess(res);
15343
+ });
15344
+ }
15345
+
15346
+ function handleTapSubscription() {
15347
+ const payment = new Payment(new TapGateway());
15348
+ const createSubscription = !isGift && !subscriptionIdToRenew;
15349
+ const renewSubscription = !isGift && subscriptionIdToRenew;
15350
+ const giftSubscriprition = isGift && !subscriptionIdToRenew;
15351
+ const renewGift = isRenewingGift;
15352
+ const {
15353
+ couponCode
15354
+ } = state;
15355
+
15356
+ if (renewGift) {
15357
+ return payment.execute({
15358
+ type: PAYMENT_TYPES.RENEW_GIFTED_SUBSCRIPTION,
15359
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
15360
+ plan,
15361
+ couponCode,
15362
+ product,
15363
+ isExistingSource: isUsingExistingPaymentMethod,
15364
+ subscriptionIdToRenew,
15365
+ addressId: selectedAddressId
15366
+ }, (err, res) => {
15367
+ if (err) {
15368
+ return handlePaymentError(err);
15369
+ }
15370
+
15371
+ onSuccess(res);
15372
+ });
15373
+ } else if (giftSubscriprition) {
15374
+ return payment.execute({
15375
+ type: PAYMENT_TYPES.CREATE_GIFTED_SUBSCRIPTION,
15376
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
15377
+ quantity: plan.quantity,
15378
+ plan,
15379
+ couponCode,
15380
+ product,
15381
+ isExistingSource: isUsingExistingPaymentMethod,
15382
+ giftRecipient,
15383
+ addressId: selectedAddressId
15384
+ }, (err, res) => {
15385
+ if (err) {
15386
+ return handlePaymentError(err);
15387
+ }
14868
15388
 
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
- });
15389
+ onSuccess(res);
15390
+ });
15391
+ } else if (renewSubscription) {
15392
+ return payment.execute({
15393
+ type: PAYMENT_TYPES.RENEW_SUBSCRIPTION,
15394
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
15395
+ quantity: plan.quantity,
15396
+ plan,
15397
+ couponCode,
15398
+ product,
15399
+ isExistingSource: isUsingExistingPaymentMethod,
15400
+ subscriptionIdToRenew,
15401
+ addressId: selectedAddressId
15402
+ }, (err, res) => {
15403
+ if (err) {
15404
+ return handlePaymentError(err);
15405
+ }
15406
+
15407
+ onSuccess(res);
15408
+ });
15409
+ } else if (createSubscription) {
15410
+ return payment.execute({
15411
+ type: PAYMENT_TYPES.CREATE_SUBSCRIPTION,
15412
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
15413
+ quantity: plan.quantity,
15414
+ plan,
15415
+ couponCode,
15416
+ product,
15417
+ isExistingSource: isUsingExistingPaymentMethod,
15418
+ addressId: selectedAddressId
15419
+ }, (err, res) => {
15420
+ if (err) {
15421
+ return handlePaymentError(err);
15422
+ }
15423
+
15424
+ onSuccess(res);
15425
+ });
15426
+ }
14898
15427
  }
15428
+ }
15429
+ /*====== End Tap integration ========*/
14899
15430
 
14900
- dispatch({
14901
- type: INIT_CONTAINER
14902
- });
14903
- updateTotalAmountWithTax();
14904
- }, []);
14905
15431
 
14906
15432
  const submitUsingVantiv = () => {
14907
15433
  const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
@@ -14952,7 +15478,7 @@ const PaymentMethodContainerWithoutStripe = ({
14952
15478
  } else if (type === "orderCreate") {
14953
15479
  purchase(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
14954
15480
  } else if (type === "invoicePayment") {
14955
- payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
15481
+ payInvoice(new VantivGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
14956
15482
  } else if (type === "updatePaymentSource") {
14957
15483
  createNewVantivCard();
14958
15484
  }
@@ -15079,6 +15605,8 @@ const PaymentMethodContainerWithoutStripe = ({
15079
15605
  }
15080
15606
 
15081
15607
  const vantivInstanceRef = React__default.useRef(null);
15608
+ const tapInstanceRef = React__default.useRef(null);
15609
+ const tapInstanceCard = React__default.useRef(null);
15082
15610
  useEffect(() => {
15083
15611
  const cardProcessor = getSiteCardProcessor();
15084
15612
 
@@ -15102,9 +15630,77 @@ const PaymentMethodContainerWithoutStripe = ({
15102
15630
  accountNumber: "1234 1234 1234 1234"
15103
15631
  },
15104
15632
  enhancedUxFeatures: {
15105
- inlineFieldValidations: true
15633
+ inlineFieldValidations: true,
15634
+ expDateValidation: true,
15635
+ numericInputsOnly: true
15636
+ }
15637
+ });
15638
+ }
15639
+
15640
+ if (cardProcessor === "tap" && !selectedPaymentMethodId) {
15641
+ var _window$Pelcro$site$r3;
15642
+
15643
+ 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);
15644
+ let elements = tapKey.elements({});
15645
+ let style = {
15646
+ base: {
15647
+ color: "#535353",
15648
+ lineHeight: "18px",
15649
+ fontFamily: "sans-serif",
15650
+ fontSmoothing: "antialiased",
15651
+ fontSize: "16px",
15652
+ "::placeholder": {
15653
+ color: "rgba(0, 0, 0, 0.26)",
15654
+ fontSize: "15px"
15655
+ }
15656
+ },
15657
+ invalid: {
15658
+ color: "red"
15106
15659
  }
15660
+ }; // input labels/placeholders
15661
+
15662
+ let labels = {
15663
+ cardNumber: "Card Number",
15664
+ expirationDate: "MM/YY",
15665
+ cvv: "CVV",
15666
+ cardHolder: "Card Holder Name"
15667
+ }; //payment options
15668
+
15669
+ let paymentOptions = {
15670
+ labels: labels,
15671
+ TextDirection: "ltr"
15672
+ }; //create element, pass style and payment options
15673
+
15674
+ let card = elements.create("card", {
15675
+ style: style
15676
+ }, paymentOptions); //mount element
15677
+
15678
+ card.mount("#tapPaymentIframe"); //card change event listener
15679
+
15680
+ card.addEventListener("change", function (event) {// if (event.error_interactive) {
15681
+ // onFailure(event.error_interactive);
15682
+ // return dispatch({
15683
+ // type: SHOW_ALERT,
15684
+ // payload: {
15685
+ // type: "error",
15686
+ // content: getErrorMessages(event.error_interactive)
15687
+ // }
15688
+ // });
15689
+ // } else {
15690
+ // dispatch({
15691
+ // type: SHOW_ALERT,
15692
+ // payload: { type: "error", content: "" }
15693
+ // });
15694
+ // }
15695
+ // let displayError = document.getElementById("error-handler");
15696
+ // if (event.error) {
15697
+ // displayError.textContent = event.error.message;
15698
+ // } else {
15699
+ // displayError.textContent = "";
15700
+ // }
15107
15701
  });
15702
+ tapInstanceRef.current = tapKey;
15703
+ tapInstanceCard.current = card;
15108
15704
  }
15109
15705
  }, [selectedPaymentMethodId]);
15110
15706
 
@@ -15178,9 +15774,9 @@ const PaymentMethodContainerWithoutStripe = ({
15178
15774
 
15179
15775
 
15180
15776
  const updateTotalAmountWithTax = () => {
15181
- var _window$Pelcro$site$r3;
15777
+ var _window$Pelcro$site$r4;
15182
15778
 
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;
15779
+ 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
15780
 
15185
15781
  if (taxesEnabled && type === "createPayment") {
15186
15782
  dispatch({
@@ -15407,6 +16003,97 @@ const PaymentMethodContainerWithoutStripe = ({
15407
16003
  updateTotalAmountWithTax();
15408
16004
  }
15409
16005
  };
16006
+ /**
16007
+ * Attempt to confirm a Stripe card payment via it's PaymentIntent.
16008
+ * Only trigger method if PaymentIntent status is `requires_action`.
16009
+ *
16010
+ * @see https://stripe.com/docs/payments/intents#intent-statuses
16011
+ *
16012
+ * @param response
16013
+ * @param error
16014
+ * @returns {*}
16015
+ */
16016
+
16017
+
16018
+ const confirmStripeCardPayment = (response, error, isSubCreate = false) => {
16019
+ if (response) {
16020
+ var _response$data;
16021
+
16022
+ const paymentIntent = (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.payment_intent;
16023
+
16024
+ if ((paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.status) === "requires_action" && paymentIntent !== null && paymentIntent !== void 0 && paymentIntent.client_secret) {
16025
+ stripe.confirmCardPayment(paymentIntent.client_secret).then(res => {
16026
+ if (!isSubCreate) {
16027
+ dispatch({
16028
+ type: DISABLE_SUBMIT,
16029
+ payload: false
16030
+ });
16031
+ }
16032
+
16033
+ dispatch({
16034
+ type: LOADING,
16035
+ payload: false
16036
+ });
16037
+
16038
+ if (res.error) {
16039
+ onFailure(res.error);
16040
+ return dispatch({
16041
+ type: SHOW_ALERT,
16042
+ payload: {
16043
+ type: "error",
16044
+ content: isSubCreate ? t("messages.tryAgainFromInvoice") : getErrorMessages(res.error)
16045
+ }
16046
+ });
16047
+ }
16048
+
16049
+ onSuccess(res);
16050
+ });
16051
+ } else if ((paymentIntent === null || paymentIntent === void 0 ? void 0 : paymentIntent.status) === "requires_payment_method" && paymentIntent !== null && paymentIntent !== void 0 && paymentIntent.client_secret) {
16052
+ if (!isSubCreate) {
16053
+ dispatch({
16054
+ type: DISABLE_SUBMIT,
16055
+ payload: false
16056
+ });
16057
+ }
16058
+
16059
+ dispatch({
16060
+ type: LOADING,
16061
+ payload: false
16062
+ });
16063
+ return dispatch({
16064
+ type: SHOW_ALERT,
16065
+ payload: {
16066
+ type: "error",
16067
+ content: isSubCreate ? t("messages.tryAgainFromInvoice") : t("messages.cardAuthFailed")
16068
+ }
16069
+ });
16070
+ } else {
16071
+ onSuccess(response);
16072
+ }
16073
+ } else {
16074
+ dispatch({
16075
+ type: DISABLE_SUBMIT,
16076
+ payload: false
16077
+ });
16078
+ dispatch({
16079
+ type: LOADING,
16080
+ payload: false
16081
+ });
16082
+
16083
+ if (error) {
16084
+ onFailure(error);
16085
+ return dispatch({
16086
+ type: SHOW_ALERT,
16087
+ payload: {
16088
+ type: "error",
16089
+ content: getErrorMessages(error)
16090
+ }
16091
+ });
16092
+ }
16093
+
16094
+ onSuccess(response);
16095
+ }
16096
+ };
15410
16097
 
15411
16098
  const subscribe = (stripeSource, state, dispatch) => {
15412
16099
  const {
@@ -15429,27 +16116,7 @@ const PaymentMethodContainerWithoutStripe = ({
15429
16116
  gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
15430
16117
  address_id: product.address_required ? selectedAddressId : null
15431
16118
  }, (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);
16119
+ confirmStripeCardPayment(res, err, true);
15453
16120
  });
15454
16121
  } else {
15455
16122
  if (isRenewingGift) {
@@ -15673,27 +16340,7 @@ const PaymentMethodContainerWithoutStripe = ({
15673
16340
  isExistingSource: Boolean(selectedPaymentMethodId),
15674
16341
  invoiceId: invoice.id
15675
16342
  }, (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);
16343
+ confirmStripeCardPayment(res, err);
15697
16344
  });
15698
16345
  };
15699
16346
 
@@ -15773,7 +16420,7 @@ const PaymentMethodContainerWithoutStripe = ({
15773
16420
  source,
15774
16421
  error
15775
16422
  }) => {
15776
- var _ref, _ref2, _state$updatedPrice, _source$card3;
16423
+ var _ref3, _ref4, _state$updatedPrice2;
15777
16424
 
15778
16425
  if (error) {
15779
16426
  return handlePaymentError(error);
@@ -15799,25 +16446,7 @@ const PaymentMethodContainerWithoutStripe = ({
15799
16446
  }, 0);
15800
16447
  };
15801
16448
 
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
-
16449
+ (_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
16450
  return handlePayment(source);
15822
16451
  }).catch(error => {
15823
16452
  return handlePaymentError(error);
@@ -15830,13 +16459,13 @@ const PaymentMethodContainerWithoutStripe = ({
15830
16459
 
15831
16460
 
15832
16461
  const resolveTaxCalculation = () => {
15833
- var _window$Pelcro$site$r4;
16462
+ var _window$Pelcro$site$r5;
15834
16463
 
15835
16464
  if (type === "invoicePayment") {
15836
16465
  return new Promise(resolve => resolve());
15837
16466
  }
15838
16467
 
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;
16468
+ 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
16469
  return new Promise((resolve, reject) => {
15841
16470
  // resolve early if taxes isn't enabled
15842
16471
  if (!taxesEnabled) {
@@ -15911,7 +16540,7 @@ const PaymentMethodContainerWithoutStripe = ({
15911
16540
  } else if (stripeSource && type === "orderCreate") {
15912
16541
  purchase(new StripeGateway(), stripeSource.id, state, dispatch);
15913
16542
  } else if (stripeSource && type === "invoicePayment") {
15914
- payInvoice(new StripeGateway(), stripeSource.id, dispatch);
16543
+ payInvoice(new StripeGateway(), stripeSource.id);
15915
16544
  }
15916
16545
  };
15917
16546
 
@@ -15988,10 +16617,12 @@ const PaymentMethodContainerWithoutStripe = ({
15988
16617
  };
15989
16618
 
15990
16619
  const injectCardAuthenticationIframe = source => {
16620
+ var _source$redirect;
16621
+
15991
16622
  const cardAuthContainer = document.querySelector(".card-authentication-container");
15992
16623
  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;";
16624
+ 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;
16625
+ iframe.style = "position: absolute; width: 100%; height: 100%; left: 0; top: 0; bottom: 0; z-index: 10;";
15995
16626
  cardAuthContainer.appendChild(iframe);
15996
16627
  };
15997
16628
 
@@ -16037,6 +16668,10 @@ const PaymentMethodContainerWithoutStripe = ({
16037
16668
  return submitUsingVantiv();
16038
16669
  }
16039
16670
 
16671
+ if (getSiteCardProcessor() === "tap") {
16672
+ return submitUsingTap();
16673
+ }
16674
+
16040
16675
  if (selectedPaymentMethodId) {
16041
16676
  // pay with selected method (source) if exists already
16042
16677
  return handlePayment({
@@ -16055,7 +16690,7 @@ const PaymentMethodContainerWithoutStripe = ({
16055
16690
  case HANDLE_PAYPAL_SUBSCRIPTION:
16056
16691
  return lib_5(state, (state, dispatch) => {
16057
16692
  if (type === "invoicePayment") {
16058
- payInvoice(new PaypalGateway(), action.payload, dispatch);
16693
+ payInvoice(new PaypalGateway(), action.payload);
16059
16694
  } else {
16060
16695
  handlePaypalSubscription(state, action.payload);
16061
16696
  }
@@ -16250,6 +16885,12 @@ const CheckoutForm = () => {
16250
16885
  });
16251
16886
  }
16252
16887
 
16888
+ if (cardProcessor === "tap") {
16889
+ return /*#__PURE__*/React__default.createElement("div", {
16890
+ id: "tapPaymentIframe"
16891
+ });
16892
+ }
16893
+
16253
16894
  if (cardProcessor === "stripe") {
16254
16895
  return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(PelcroCardNumber, {
16255
16896
  autoFocus: true
@@ -16934,13 +17575,14 @@ function PaymentMethodView({
16934
17575
  showCoupon,
16935
17576
  showExternalPaymentMethods
16936
17577
  }) {
16937
- var _window$Pelcro$site$r;
17578
+ var _window$Pelcro$site$r, _window$Pelcro$site$r2;
16938
17579
 
16939
17580
  const {
16940
17581
  t
16941
17582
  } = useTranslation("checkoutForm");
16942
17583
  const cardProcessor = getSiteCardProcessor();
16943
17584
  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);
17585
+ 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
17586
  return /*#__PURE__*/React__default.createElement("div", {
16945
17587
  className: "plc-flex plc-flex-col plc-items-center plc-mt-4 sm:plc-px-8 pelcro-payment-block"
16946
17588
  }, cardProcessor === "stripe" && /*#__PURE__*/React__default.createElement("div", {
@@ -17892,9 +18534,7 @@ class DefaultNewsLetter extends Component {
17892
18534
  });
17893
18535
 
17894
18536
  _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);
18537
+ window.Pelcro.paywall.setNewsletterExtraVisits(true);
17898
18538
  this.props.setView("meter");
17899
18539
  });
17900
18540
 
@@ -24184,10 +24824,10 @@ var GroupContext = /*#__PURE__*/createContext(null);
24184
24824
  GroupContext.displayName = 'GroupContext';
24185
24825
 
24186
24826
  const getPaymentCardIcon = name => {
24187
- var _icons$name;
24827
+ var _icons$name$toLowerCa;
24188
24828
 
24189
24829
  const icons = {
24190
- Visa: /*#__PURE__*/React__default.createElement("svg", {
24830
+ visa: /*#__PURE__*/React__default.createElement("svg", {
24191
24831
  className: "plc-w-12",
24192
24832
  fill: "#ffffff",
24193
24833
  xmlns: "http://www.w3.org/2000/svg",
@@ -24195,7 +24835,7 @@ const getPaymentCardIcon = name => {
24195
24835
  }, /*#__PURE__*/React__default.createElement("path", {
24196
24836
  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
24837
  })),
24198
- MasterCard: /*#__PURE__*/React__default.createElement("svg", {
24838
+ mastercard: /*#__PURE__*/React__default.createElement("svg", {
24199
24839
  className: "plc-w-12",
24200
24840
  fill: "#ffffff",
24201
24841
  xmlns: "http://www.w3.org/2000/svg",
@@ -24203,7 +24843,7 @@ const getPaymentCardIcon = name => {
24203
24843
  }, /*#__PURE__*/React__default.createElement("path", {
24204
24844
  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
24845
  })),
24206
- "American Express": /*#__PURE__*/React__default.createElement("svg", {
24846
+ "american express": /*#__PURE__*/React__default.createElement("svg", {
24207
24847
  className: "plc-w-12",
24208
24848
  fill: "#ffffff",
24209
24849
  xmlns: "http://www.w3.org/2000/svg",
@@ -24212,7 +24852,7 @@ const getPaymentCardIcon = name => {
24212
24852
  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
24853
  }))
24214
24854
  };
24215
- return (_icons$name = icons[name]) !== null && _icons$name !== void 0 ? _icons$name : /*#__PURE__*/React__default.createElement("svg", {
24855
+ return (_icons$name$toLowerCa = icons[name.toLowerCase()]) !== null && _icons$name$toLowerCa !== void 0 ? _icons$name$toLowerCa : /*#__PURE__*/React__default.createElement("svg", {
24216
24856
  xmlns: "http://www.w3.org/2000/svg",
24217
24857
  className: "plc-w-12",
24218
24858
  fill: "none",
@@ -24710,7 +25350,7 @@ const SubscriptionsItems = ({
24710
25350
  onClick: onReactivateClick,
24711
25351
  disabled: disableSubmit,
24712
25352
  "data-key": sub.id
24713
- }, t("labels.reactivate")), sub.cancel_at_period_end === 1 && /*#__PURE__*/React__default.createElement(Button, {
25353
+ }, t("labels.reactivate")), sub.cancel_at_period_end === 1 && sub.status !== "incomplete" && /*#__PURE__*/React__default.createElement(Button, {
24714
25354
  variant: "ghost",
24715
25355
  className: "plc-text-blue-400 pelcro-dashboard-sub-renew-button",
24716
25356
  icon: /*#__PURE__*/React__default.createElement(SvgRefresh, null),
@@ -25541,6 +26181,10 @@ class Dashboard extends Component {
25541
26181
  return `${this.locale("labels.canceledOn")} ${formattedCancelDate}`;
25542
26182
  }
25543
26183
 
26184
+ if (subscription.status === "incomplete") {
26185
+ return `${this.locale("labels.status.incomplete")}`;
26186
+ }
26187
+
25544
26188
  if (subscription.cancel_at_period_end) {
25545
26189
  // DateTime from BE is missing 3 zeros so we add them before instancing a date
25546
26190
  const expiryDate = new Date(Number(`${subscription.expires_at}000`));
@@ -25606,6 +26250,16 @@ class Dashboard extends Component {
25606
26250
  };
25607
26251
  }
25608
26252
 
26253
+ if (sub.status === "incomplete") {
26254
+ return {
26255
+ title: this.locale("labels.status.incomplete"),
26256
+ content: this.getSubscriptionStatusText(sub),
26257
+ textColor: "plc-text-orange-700",
26258
+ bgColor: "plc-bg-orange-100",
26259
+ icon: /*#__PURE__*/React__default.createElement(SvgExclamation, null)
26260
+ };
26261
+ }
26262
+
25609
26263
  return {
25610
26264
  title: this.locale("labels.status.active"),
25611
26265
  content: this.getSubscriptionStatusText(sub),