@pelcro/react-pelcro-js 3.6.0-beta.20 → 3.6.0-beta.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -7924,10 +7924,10 @@ const getEntitlementsFromElem = elem => {
7924
7924
  return elem.dataset.pelcroEntitlements.split(",").map(entitlement => entitlement.trim()).filter(entitlement => entitlement);
7925
7925
  };
7926
7926
  const getPaymentCardIcon$1 = name => {
7927
- var _icons$name;
7927
+ var _icons$name$toLowerCa;
7928
7928
 
7929
7929
  const icons = {
7930
- Visa: /*#__PURE__*/React__default['default'].createElement("svg", {
7930
+ visa: /*#__PURE__*/React__default['default'].createElement("svg", {
7931
7931
  className: "plc-w-16",
7932
7932
  xmlns: "http://www.w3.org/2000/svg",
7933
7933
  viewBox: "0 0 48 48"
@@ -7938,7 +7938,7 @@ const getPaymentCardIcon$1 = name => {
7938
7938
  fill: "#FFC107",
7939
7939
  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"
7940
7940
  })),
7941
- MasterCard: /*#__PURE__*/React__default['default'].createElement("svg", {
7941
+ mastercard: /*#__PURE__*/React__default['default'].createElement("svg", {
7942
7942
  className: "plc-w-16",
7943
7943
  xmlns: "http://www.w3.org/2000/svg",
7944
7944
  viewBox: "0 0 48 48"
@@ -7952,7 +7952,7 @@ const getPaymentCardIcon$1 = name => {
7952
7952
  fill: "#ff3d00",
7953
7953
  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"
7954
7954
  })),
7955
- "American Express": /*#__PURE__*/React__default['default'].createElement("svg", {
7955
+ "american express": /*#__PURE__*/React__default['default'].createElement("svg", {
7956
7956
  className: "plc-w-16",
7957
7957
  xmlns: "http://www.w3.org/2000/svg",
7958
7958
  viewBox: "0 0 48 48"
@@ -7964,7 +7964,7 @@ const getPaymentCardIcon$1 = name => {
7964
7964
  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"
7965
7965
  }))
7966
7966
  };
7967
- return (_icons$name = icons[name]) !== null && _icons$name !== void 0 ? _icons$name : /*#__PURE__*/React__default['default'].createElement("svg", {
7967
+ return (_icons$name$toLowerCa = icons[name.toLowerCase()]) !== null && _icons$name$toLowerCa !== void 0 ? _icons$name$toLowerCa : /*#__PURE__*/React__default['default'].createElement("svg", {
7968
7968
  xmlns: "http://www.w3.org/2000/svg",
7969
7969
  className: "plc-w-16",
7970
7970
  fill: "none",
@@ -9975,12 +9975,16 @@ const debounce = (func, waitTime) => {
9975
9975
  };
9976
9976
  };
9977
9977
  function getSiteCardProcessor() {
9978
- var _window$Pelcro$site$r;
9978
+ var _window$Pelcro$site$r, _window$Pelcro$site$r2;
9979
9979
 
9980
9980
  if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_gateway_settings) {
9981
9981
  return "vantiv";
9982
9982
  }
9983
9983
 
9984
+ if ((_window$Pelcro$site$r2 = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r2 !== void 0 && _window$Pelcro$site$r2.tap_gateway_settings) {
9985
+ return "tap";
9986
+ }
9987
+
9984
9988
  return "stripe";
9985
9989
  }
9986
9990
 
@@ -10086,6 +10090,14 @@ const loadPaymentSDKs = () => {
10086
10090
  const scriptUrlToUse = window.Pelcro.site.read().vantiv_gateway_settings.environment === "production" ? PRODUCTION_URL : PRELIVE_URL;
10087
10091
  window.Pelcro.helpers.loadSDK(scriptUrlToUse, "vantiv-eprotect-sdk");
10088
10092
  }
10093
+ } // Load Tap SDKs
10094
+
10095
+
10096
+ const supportsTap = Boolean(window.Pelcro.site.read().tap_gateway_settings);
10097
+
10098
+ if (supportsTap) {
10099
+ window.Pelcro.helpers.loadSDK("https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js", "tap-bluebird");
10100
+ window.Pelcro.helpers.loadSDK("https://secure.gosell.io/js/sdk/tap.min.js", "tap-sdk");
10089
10101
  }
10090
10102
  };
10091
10103
  const loadAuth0SDK = () => {
@@ -14198,7 +14210,7 @@ var _generateUserError = /*#__PURE__*/new WeakMap();
14198
14210
 
14199
14211
  class Payment {
14200
14212
  /**
14201
- * @param {(StripeGateway|PaypalGateway|VantivGateway)} paymentGateway
14213
+ * @param {(StripeGateway|PaypalGateway|VantivGateway|TapGateway)} paymentGateway
14202
14214
  */
14203
14215
  constructor(paymentGateway) {
14204
14216
  _defineProperty$3(this, "execute", (options, callback) => {
@@ -14219,7 +14231,7 @@ class Payment {
14219
14231
  _isPaymentGatewayInvalid.set(this, {
14220
14232
  writable: true,
14221
14233
  value: gateway => {
14222
- return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway);
14234
+ return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway || gateway instanceof TapGateway);
14223
14235
  }
14224
14236
  });
14225
14237
 
@@ -14274,7 +14286,8 @@ class Payment {
14274
14286
  const PAYMENT_GATEWAYS_ENUM = {
14275
14287
  stripe: "stripe",
14276
14288
  paypal: "braintree",
14277
- vantiv: "vantiv"
14289
+ vantiv: "vantiv",
14290
+ tap: "tap"
14278
14291
  };
14279
14292
  /**
14280
14293
  * Payment Strategies
@@ -14842,6 +14855,241 @@ class VantivGateway {
14842
14855
 
14843
14856
  }
14844
14857
 
14858
+ var _paymentGateway4 = /*#__PURE__*/new WeakMap();
14859
+
14860
+ var _createSubscription4 = /*#__PURE__*/new WeakMap();
14861
+
14862
+ var _renewSubscription3 = /*#__PURE__*/new WeakMap();
14863
+
14864
+ var _createGiftedSubscription4 = /*#__PURE__*/new WeakMap();
14865
+
14866
+ var _renewGiftedSubscription3 = /*#__PURE__*/new WeakMap();
14867
+
14868
+ var _purchaseEcommerceOrder3 = /*#__PURE__*/new WeakMap();
14869
+
14870
+ var _payInvoice4 = /*#__PURE__*/new WeakMap();
14871
+
14872
+ class TapGateway {
14873
+ constructor() {
14874
+ _paymentGateway4.set(this, {
14875
+ writable: true,
14876
+ value: PAYMENT_GATEWAYS_ENUM["tap"]
14877
+ });
14878
+
14879
+ _defineProperty$3(this, "execute", (options, callback) => {
14880
+ const types = PAYMENT_TYPES;
14881
+
14882
+ switch (options.type) {
14883
+ case types.CREATE_SUBSCRIPTION:
14884
+ return _classPrivateFieldGet(this, _createSubscription4).call(this, options, callback);
14885
+
14886
+ case types.RENEW_SUBSCRIPTION:
14887
+ return _classPrivateFieldGet(this, _renewSubscription3).call(this, options, callback);
14888
+
14889
+ case types.CREATE_GIFTED_SUBSCRIPTION:
14890
+ return _classPrivateFieldGet(this, _createGiftedSubscription4).call(this, options, callback);
14891
+
14892
+ case types.RENEW_GIFTED_SUBSCRIPTION:
14893
+ return _classPrivateFieldGet(this, _renewGiftedSubscription3).call(this, options, callback);
14894
+
14895
+ case types.PURCHASE_ECOMMERCE_ORDER:
14896
+ return _classPrivateFieldGet(this, _purchaseEcommerceOrder3).call(this, options, callback);
14897
+
14898
+ case types.PAY_INVOICE:
14899
+ return _classPrivateFieldGet(this, _payInvoice4).call(this, options, callback);
14900
+
14901
+ default:
14902
+ console.error("Unsupported payment method: tap Gateway");
14903
+ }
14904
+ });
14905
+
14906
+ _createSubscription4.set(this, {
14907
+ writable: true,
14908
+ value: (options, callback) => {
14909
+ const {
14910
+ token,
14911
+ plan,
14912
+ couponCode,
14913
+ product,
14914
+ quantity = 1,
14915
+ addressId,
14916
+ isExistingSource
14917
+ } = options;
14918
+ const params = isExistingSource ? {
14919
+ source_id: token
14920
+ } : {
14921
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway4),
14922
+ gateway_token: token
14923
+ };
14924
+ window.Pelcro.subscription.create({
14925
+ quantity,
14926
+ auth_token: window.Pelcro.user.read().auth_token,
14927
+ plan_id: plan.id,
14928
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
14929
+ coupon_code: couponCode,
14930
+ address_id: product.address_required ? addressId : null,
14931
+ ...params
14932
+ }, (err, res) => {
14933
+ callback(err, res);
14934
+ });
14935
+ }
14936
+ });
14937
+
14938
+ _renewSubscription3.set(this, {
14939
+ writable: true,
14940
+ value: (options, callback) => {
14941
+ const {
14942
+ subscriptionIdToRenew,
14943
+ token,
14944
+ plan,
14945
+ couponCode,
14946
+ product,
14947
+ addressId,
14948
+ isExistingSource
14949
+ } = options;
14950
+ const params = isExistingSource ? {
14951
+ source_id: token
14952
+ } : {
14953
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway4),
14954
+ gateway_token: token
14955
+ };
14956
+ window.Pelcro.subscription.renew({
14957
+ auth_token: window.Pelcro.user.read().auth_token,
14958
+ plan_id: plan.id,
14959
+ coupon_code: couponCode,
14960
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
14961
+ subscription_id: subscriptionIdToRenew,
14962
+ address_id: product.address_required ? addressId : null,
14963
+ ...params
14964
+ }, (err, res) => {
14965
+ callback(err, res);
14966
+ });
14967
+ }
14968
+ });
14969
+
14970
+ _createGiftedSubscription4.set(this, {
14971
+ writable: true,
14972
+ value: (options, callback) => {
14973
+ const {
14974
+ token,
14975
+ plan,
14976
+ couponCode,
14977
+ product,
14978
+ giftRecipient,
14979
+ quantity = 1,
14980
+ addressId,
14981
+ isExistingSource
14982
+ } = options;
14983
+ const params = isExistingSource ? {
14984
+ source_id: token
14985
+ } : {
14986
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway4),
14987
+ gateway_token: token
14988
+ };
14989
+ window.Pelcro.subscription.create({
14990
+ quantity,
14991
+ auth_token: window.Pelcro.user.read().auth_token,
14992
+ plan_id: plan.id,
14993
+ coupon_code: couponCode,
14994
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
14995
+ gift_recipient_email: giftRecipient.email,
14996
+ gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
14997
+ gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
14998
+ gift_start_date: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.startDate,
14999
+ gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
15000
+ address_id: product.address_required ? addressId : null,
15001
+ ...params
15002
+ }, (err, res) => {
15003
+ callback(err, res);
15004
+ });
15005
+ }
15006
+ });
15007
+
15008
+ _renewGiftedSubscription3.set(this, {
15009
+ writable: true,
15010
+ value: (options, callback) => {
15011
+ const {
15012
+ subscriptionIdToRenew,
15013
+ token,
15014
+ product,
15015
+ plan,
15016
+ couponCode,
15017
+ addressId,
15018
+ isExistingSource
15019
+ } = options;
15020
+ const params = isExistingSource ? {
15021
+ source_id: token
15022
+ } : {
15023
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway4),
15024
+ gateway_token: token
15025
+ };
15026
+ window.Pelcro.subscription.renewGift({
15027
+ auth_token: window.Pelcro.user.read().auth_token,
15028
+ plan_id: plan.id,
15029
+ coupon_code: couponCode,
15030
+ subscription_id: subscriptionIdToRenew,
15031
+ address_id: product.address_required ? addressId : null,
15032
+ ...params
15033
+ }, (err, res) => {
15034
+ callback(err, res);
15035
+ });
15036
+ }
15037
+ });
15038
+
15039
+ _purchaseEcommerceOrder3.set(this, {
15040
+ writable: true,
15041
+ value: (options, callback) => {
15042
+ const {
15043
+ token,
15044
+ items,
15045
+ couponCode,
15046
+ addressId,
15047
+ isExistingSource
15048
+ } = options;
15049
+ const params = isExistingSource ? {
15050
+ source_id: token
15051
+ } : {
15052
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway4),
15053
+ gateway_token: token
15054
+ };
15055
+ window.Pelcro.ecommerce.order.create({
15056
+ items,
15057
+ coupon_code: couponCode,
15058
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
15059
+ ...params,
15060
+ ...(addressId && {
15061
+ address_id: addressId
15062
+ })
15063
+ }, (err, res) => {
15064
+ callback(err, res);
15065
+ });
15066
+ }
15067
+ });
15068
+
15069
+ _payInvoice4.set(this, {
15070
+ writable: true,
15071
+ value: (options, callback) => {
15072
+ const {
15073
+ token,
15074
+ invoiceId
15075
+ } = options;
15076
+ const params = options.isExistingSource ? {
15077
+ source_id: token,
15078
+ invoice_id: invoiceId
15079
+ } : {
15080
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway4),
15081
+ gateway_token: token,
15082
+ invoice_id: invoiceId
15083
+ };
15084
+ window.Pelcro.invoice.pay(params, (err, res) => {
15085
+ callback(err, res);
15086
+ });
15087
+ }
15088
+ });
15089
+ }
15090
+
15091
+ }
15092
+
14845
15093
  /**
14846
15094
  * @typedef {Object} PaymentStateType
14847
15095
  * @property {boolean} disableSubmit
@@ -14935,6 +15183,257 @@ const PaymentMethodContainerWithoutStripe = ({
14935
15183
  });
14936
15184
  updateTotalAmountWithTax();
14937
15185
  }, []);
15186
+ /*====== Start Tap integration ========*/
15187
+
15188
+ const submitUsingTap = () => {
15189
+ var _ref, _ref2, _state$updatedPrice;
15190
+
15191
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
15192
+
15193
+ if (isUsingExistingPaymentMethod) {
15194
+ // no need to create a new source using tap
15195
+ return handleTapPayment(null);
15196
+ }
15197
+
15198
+ if (!tapInstanceRef.current) {
15199
+ return console.error("Tap sdk script wasn't loaded, you need to load tap sdk before rendering the tap payment flow");
15200
+ }
15201
+
15202
+ const getOrderItemsTotal = () => {
15203
+ if (!order) {
15204
+ return null;
15205
+ }
15206
+
15207
+ const isQuickPurchase = !Array.isArray(order);
15208
+
15209
+ if (isQuickPurchase) {
15210
+ return order.price * order.quantity;
15211
+ }
15212
+
15213
+ if (order.length === 0) {
15214
+ return null;
15215
+ }
15216
+
15217
+ return order.reduce((total, item) => {
15218
+ return total + item.price * item.quantity;
15219
+ }, 0);
15220
+ };
15221
+
15222
+ 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();
15223
+ tapInstanceRef.current.createToken(tapInstanceCard.current).then(function (result) {
15224
+ if (result.error) {
15225
+ // Inform the user if there was an error
15226
+ onFailure(result.error);
15227
+ return dispatch({
15228
+ type: SHOW_ALERT,
15229
+ payload: {
15230
+ type: "error",
15231
+ content: getErrorMessages(result.error)
15232
+ }
15233
+ });
15234
+ } else {
15235
+ console.log("Tap API Call result", result);
15236
+ window.Pelcro.payment.authorize({
15237
+ auth_token: window.Pelcro.user.read().auth_token,
15238
+ site_id: window.Pelcro.siteid,
15239
+ amount: totalAmount,
15240
+ 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,
15241
+ tap_token: result.id,
15242
+ redirect_url: `${window.Pelcro.environment.domain}/webhook/tap/callback/3dsecure?auth_token=${window.Pelcro.user.read().auth_token}`
15243
+ }, (err, res) => {
15244
+ toggleAuthenticationPendingView(true, res);
15245
+
15246
+ const listenFor3DSecureCompletionMessage = () => {
15247
+ const retrieveSourceInfoFromIframe = event => {
15248
+ const {
15249
+ data
15250
+ } = event;
15251
+
15252
+ if (data.message === "3DS-authentication-complete") {
15253
+ const tapID = data.tapID;
15254
+ toggleAuthenticationPendingView(false);
15255
+ window.removeEventListener("message", retrieveSourceInfoFromIframe);
15256
+ handleTapPayment(tapID);
15257
+ }
15258
+ }; // listen to injected iframe for authentication complete message
15259
+
15260
+
15261
+ window.addEventListener("message", retrieveSourceInfoFromIframe);
15262
+ };
15263
+
15264
+ listenFor3DSecureCompletionMessage(); // if (err) {
15265
+ // onFailure(err);
15266
+ // return dispatch({
15267
+ // type: SHOW_ALERT,
15268
+ // payload: {
15269
+ // type: "error",
15270
+ // content: getErrorMessages(err)
15271
+ // }
15272
+ // });
15273
+ // }
15274
+ // dispatch({
15275
+ // type: SHOW_ALERT,
15276
+ // payload: {
15277
+ // type: "success",
15278
+ // content: t("messages.sourceUpdated")
15279
+ // }
15280
+ // });
15281
+ // onSuccess(res);
15282
+ });
15283
+ }
15284
+ });
15285
+ };
15286
+
15287
+ function handleTapPayment(paymentRequest) {
15288
+ // if (paymentRequest) {
15289
+ // const SUCCESS_STATUS = "870";
15290
+ // if (paymentRequest.response !== SUCCESS_STATUS) {
15291
+ // switch (paymentRequest.response) {
15292
+ // case "871":
15293
+ // return handlePaymentError({
15294
+ // error: new Error("Invalid account number")
15295
+ // });
15296
+ // default:
15297
+ // return handlePaymentError({
15298
+ // error: new Error(paymentRequest.message)
15299
+ // });
15300
+ // }
15301
+ // }
15302
+ // }
15303
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
15304
+
15305
+ if (type === "createPayment") {
15306
+ handleTapSubscription();
15307
+ } else if (type === "orderCreate") {
15308
+ purchase(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
15309
+ } else if (type === "invoicePayment") {
15310
+ payInvoice(new TapGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, dispatch);
15311
+ } else if (type === "updatePaymentSource") {
15312
+ createNewTapCard();
15313
+ }
15314
+
15315
+ function createNewTapCard() {
15316
+ window.Pelcro.source.create({
15317
+ auth_token: window.Pelcro.user.read().auth_token,
15318
+ token: paymentRequest,
15319
+ gateway: "tap"
15320
+ }, (err, res) => {
15321
+ dispatch({
15322
+ type: DISABLE_SUBMIT,
15323
+ payload: false
15324
+ });
15325
+ dispatch({
15326
+ type: LOADING,
15327
+ payload: false
15328
+ });
15329
+
15330
+ if (err) {
15331
+ onFailure(err);
15332
+ return dispatch({
15333
+ type: SHOW_ALERT,
15334
+ payload: {
15335
+ type: "error",
15336
+ content: getErrorMessages(err)
15337
+ }
15338
+ });
15339
+ }
15340
+
15341
+ dispatch({
15342
+ type: SHOW_ALERT,
15343
+ payload: {
15344
+ type: "success",
15345
+ content: t("messages.sourceUpdated")
15346
+ }
15347
+ });
15348
+ onSuccess(res);
15349
+ });
15350
+ }
15351
+
15352
+ function handleTapSubscription() {
15353
+ const payment = new Payment(new TapGateway());
15354
+ const createSubscription = !isGift && !subscriptionIdToRenew;
15355
+ const renewSubscription = !isGift && subscriptionIdToRenew;
15356
+ const giftSubscriprition = isGift && !subscriptionIdToRenew;
15357
+ const renewGift = isRenewingGift;
15358
+ const {
15359
+ couponCode
15360
+ } = state;
15361
+
15362
+ if (renewGift) {
15363
+ return payment.execute({
15364
+ type: PAYMENT_TYPES.RENEW_GIFTED_SUBSCRIPTION,
15365
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
15366
+ plan,
15367
+ couponCode,
15368
+ product,
15369
+ isExistingSource: isUsingExistingPaymentMethod,
15370
+ subscriptionIdToRenew,
15371
+ addressId: selectedAddressId
15372
+ }, (err, res) => {
15373
+ if (err) {
15374
+ return handlePaymentError(err);
15375
+ }
15376
+
15377
+ onSuccess(res);
15378
+ });
15379
+ } else if (giftSubscriprition) {
15380
+ return payment.execute({
15381
+ type: PAYMENT_TYPES.CREATE_GIFTED_SUBSCRIPTION,
15382
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
15383
+ quantity: plan.quantity,
15384
+ plan,
15385
+ couponCode,
15386
+ product,
15387
+ isExistingSource: isUsingExistingPaymentMethod,
15388
+ giftRecipient,
15389
+ addressId: selectedAddressId
15390
+ }, (err, res) => {
15391
+ if (err) {
15392
+ return handlePaymentError(err);
15393
+ }
15394
+
15395
+ onSuccess(res);
15396
+ });
15397
+ } else if (renewSubscription) {
15398
+ return payment.execute({
15399
+ type: PAYMENT_TYPES.RENEW_SUBSCRIPTION,
15400
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
15401
+ quantity: plan.quantity,
15402
+ plan,
15403
+ couponCode,
15404
+ product,
15405
+ isExistingSource: isUsingExistingPaymentMethod,
15406
+ subscriptionIdToRenew,
15407
+ addressId: selectedAddressId
15408
+ }, (err, res) => {
15409
+ if (err) {
15410
+ return handlePaymentError(err);
15411
+ }
15412
+
15413
+ onSuccess(res);
15414
+ });
15415
+ } else if (createSubscription) {
15416
+ return payment.execute({
15417
+ type: PAYMENT_TYPES.CREATE_SUBSCRIPTION,
15418
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
15419
+ quantity: plan.quantity,
15420
+ plan,
15421
+ couponCode,
15422
+ product,
15423
+ isExistingSource: isUsingExistingPaymentMethod,
15424
+ addressId: selectedAddressId
15425
+ }, (err, res) => {
15426
+ if (err) {
15427
+ return handlePaymentError(err);
15428
+ }
15429
+
15430
+ onSuccess(res);
15431
+ });
15432
+ }
15433
+ }
15434
+ }
15435
+ /*====== End Tap integration ========*/
15436
+
14938
15437
 
14939
15438
  const submitUsingVantiv = () => {
14940
15439
  const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
@@ -15112,6 +15611,8 @@ const PaymentMethodContainerWithoutStripe = ({
15112
15611
  }
15113
15612
 
15114
15613
  const vantivInstanceRef = React__default['default'].useRef(null);
15614
+ const tapInstanceRef = React__default['default'].useRef(null);
15615
+ const tapInstanceCard = React__default['default'].useRef(null);
15115
15616
  React.useEffect(() => {
15116
15617
  const cardProcessor = getSiteCardProcessor();
15117
15618
 
@@ -15139,6 +15640,72 @@ const PaymentMethodContainerWithoutStripe = ({
15139
15640
  }
15140
15641
  });
15141
15642
  }
15643
+
15644
+ if (cardProcessor === "tap" && !selectedPaymentMethodId) {
15645
+ var _window$Pelcro$site$r3;
15646
+
15647
+ 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);
15648
+ let elements = tapKey.elements({});
15649
+ let style = {
15650
+ base: {
15651
+ color: "#535353",
15652
+ lineHeight: "18px",
15653
+ fontFamily: "sans-serif",
15654
+ fontSmoothing: "antialiased",
15655
+ fontSize: "16px",
15656
+ "::placeholder": {
15657
+ color: "rgba(0, 0, 0, 0.26)",
15658
+ fontSize: "15px"
15659
+ }
15660
+ },
15661
+ invalid: {
15662
+ color: "red"
15663
+ }
15664
+ }; // input labels/placeholders
15665
+
15666
+ let labels = {
15667
+ cardNumber: "Card Number",
15668
+ expirationDate: "MM/YY",
15669
+ cvv: "CVV",
15670
+ cardHolder: "Card Holder Name"
15671
+ }; //payment options
15672
+
15673
+ let paymentOptions = {
15674
+ labels: labels,
15675
+ TextDirection: "ltr"
15676
+ }; //create element, pass style and payment options
15677
+
15678
+ let card = elements.create("card", {
15679
+ style: style
15680
+ }, paymentOptions); //mount element
15681
+
15682
+ card.mount("#tapPaymentIframe"); //card change event listener
15683
+
15684
+ card.addEventListener("change", function (event) {// if (event.error_interactive) {
15685
+ // onFailure(event.error_interactive);
15686
+ // return dispatch({
15687
+ // type: SHOW_ALERT,
15688
+ // payload: {
15689
+ // type: "error",
15690
+ // content: getErrorMessages(event.error_interactive)
15691
+ // }
15692
+ // });
15693
+ // } else {
15694
+ // dispatch({
15695
+ // type: SHOW_ALERT,
15696
+ // payload: { type: "error", content: "" }
15697
+ // });
15698
+ // }
15699
+ // let displayError = document.getElementById("error-handler");
15700
+ // if (event.error) {
15701
+ // displayError.textContent = event.error.message;
15702
+ // } else {
15703
+ // displayError.textContent = "";
15704
+ // }
15705
+ });
15706
+ tapInstanceRef.current = tapKey;
15707
+ tapInstanceCard.current = card;
15708
+ }
15142
15709
  }, [selectedPaymentMethodId]);
15143
15710
 
15144
15711
  const initPaymentRequest = (state, dispatch) => {
@@ -15211,9 +15778,9 @@ const PaymentMethodContainerWithoutStripe = ({
15211
15778
 
15212
15779
 
15213
15780
  const updateTotalAmountWithTax = () => {
15214
- var _window$Pelcro$site$r3;
15781
+ var _window$Pelcro$site$r4;
15215
15782
 
15216
- 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;
15783
+ 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;
15217
15784
 
15218
15785
  if (taxesEnabled && type === "createPayment") {
15219
15786
  dispatch({
@@ -15806,7 +16373,7 @@ const PaymentMethodContainerWithoutStripe = ({
15806
16373
  source,
15807
16374
  error
15808
16375
  }) => {
15809
- var _ref, _ref2, _state$updatedPrice, _source$card3;
16376
+ var _ref3, _ref4, _state$updatedPrice2, _source$card3;
15810
16377
 
15811
16378
  if (error) {
15812
16379
  return handlePaymentError(error);
@@ -15832,7 +16399,7 @@ const PaymentMethodContainerWithoutStripe = ({
15832
16399
  }, 0);
15833
16400
  };
15834
16401
 
15835
- 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();
16402
+ const totalAmount = (_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();
15836
16403
 
15837
16404
  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) {
15838
16405
  return resolveTaxCalculation().then(res => {
@@ -15863,13 +16430,13 @@ const PaymentMethodContainerWithoutStripe = ({
15863
16430
 
15864
16431
 
15865
16432
  const resolveTaxCalculation = () => {
15866
- var _window$Pelcro$site$r4;
16433
+ var _window$Pelcro$site$r5;
15867
16434
 
15868
16435
  if (type === "invoicePayment") {
15869
16436
  return new Promise(resolve => resolve());
15870
16437
  }
15871
16438
 
15872
- 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;
16439
+ 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;
15873
16440
  return new Promise((resolve, reject) => {
15874
16441
  // resolve early if taxes isn't enabled
15875
16442
  if (!taxesEnabled) {
@@ -16021,10 +16588,12 @@ const PaymentMethodContainerWithoutStripe = ({
16021
16588
  };
16022
16589
 
16023
16590
  const injectCardAuthenticationIframe = source => {
16591
+ var _source$redirect;
16592
+
16024
16593
  const cardAuthContainer = document.querySelector(".card-authentication-container");
16025
16594
  const iframe = document.createElement("iframe");
16026
- iframe.src = source.redirect.url;
16027
- iframe.style = "position: absolute; width: 100%; height: 100%; left: 0; top: 40px; bottom: 0; z-index: 10;";
16595
+ 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;
16596
+ iframe.style = "position: absolute; width: 100%; height: 100%; left: 0; top: 0; bottom: 0; z-index: 10;";
16028
16597
  cardAuthContainer.appendChild(iframe);
16029
16598
  };
16030
16599
 
@@ -16070,6 +16639,10 @@ const PaymentMethodContainerWithoutStripe = ({
16070
16639
  return submitUsingVantiv();
16071
16640
  }
16072
16641
 
16642
+ if (getSiteCardProcessor() === "tap") {
16643
+ return submitUsingTap();
16644
+ }
16645
+
16073
16646
  if (selectedPaymentMethodId) {
16074
16647
  // pay with selected method (source) if exists already
16075
16648
  return handlePayment({
@@ -16283,6 +16856,12 @@ const CheckoutForm = () => {
16283
16856
  });
16284
16857
  }
16285
16858
 
16859
+ if (cardProcessor === "tap") {
16860
+ return /*#__PURE__*/React__default['default'].createElement("div", {
16861
+ id: "tapPaymentIframe"
16862
+ });
16863
+ }
16864
+
16286
16865
  if (cardProcessor === "stripe") {
16287
16866
  return /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(PelcroCardNumber, {
16288
16867
  autoFocus: true
@@ -16967,13 +17546,14 @@ function PaymentMethodView({
16967
17546
  showCoupon,
16968
17547
  showExternalPaymentMethods
16969
17548
  }) {
16970
- var _window$Pelcro$site$r;
17549
+ var _window$Pelcro$site$r, _window$Pelcro$site$r2;
16971
17550
 
16972
17551
  const {
16973
17552
  t
16974
17553
  } = useTranslation("checkoutForm");
16975
17554
  const cardProcessor = getSiteCardProcessor();
16976
17555
  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);
17556
+ 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);
16977
17557
  return /*#__PURE__*/React__default['default'].createElement("div", {
16978
17558
  className: "plc-flex plc-flex-col plc-items-center plc-mt-4 sm:plc-px-8 pelcro-payment-block"
16979
17559
  }, cardProcessor === "stripe" && /*#__PURE__*/React__default['default'].createElement("div", {
@@ -24217,10 +24797,10 @@ var GroupContext = /*#__PURE__*/React.createContext(null);
24217
24797
  GroupContext.displayName = 'GroupContext';
24218
24798
 
24219
24799
  const getPaymentCardIcon = name => {
24220
- var _icons$name;
24800
+ var _icons$name$toLowerCa;
24221
24801
 
24222
24802
  const icons = {
24223
- Visa: /*#__PURE__*/React__default['default'].createElement("svg", {
24803
+ visa: /*#__PURE__*/React__default['default'].createElement("svg", {
24224
24804
  className: "plc-w-12",
24225
24805
  fill: "#ffffff",
24226
24806
  xmlns: "http://www.w3.org/2000/svg",
@@ -24228,7 +24808,7 @@ const getPaymentCardIcon = name => {
24228
24808
  }, /*#__PURE__*/React__default['default'].createElement("path", {
24229
24809
  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"
24230
24810
  })),
24231
- MasterCard: /*#__PURE__*/React__default['default'].createElement("svg", {
24811
+ mastercard: /*#__PURE__*/React__default['default'].createElement("svg", {
24232
24812
  className: "plc-w-12",
24233
24813
  fill: "#ffffff",
24234
24814
  xmlns: "http://www.w3.org/2000/svg",
@@ -24236,7 +24816,7 @@ const getPaymentCardIcon = name => {
24236
24816
  }, /*#__PURE__*/React__default['default'].createElement("path", {
24237
24817
  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 "
24238
24818
  })),
24239
- "American Express": /*#__PURE__*/React__default['default'].createElement("svg", {
24819
+ "american express": /*#__PURE__*/React__default['default'].createElement("svg", {
24240
24820
  className: "plc-w-12",
24241
24821
  fill: "#ffffff",
24242
24822
  xmlns: "http://www.w3.org/2000/svg",
@@ -24245,7 +24825,7 @@ const getPaymentCardIcon = name => {
24245
24825
  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"
24246
24826
  }))
24247
24827
  };
24248
- return (_icons$name = icons[name]) !== null && _icons$name !== void 0 ? _icons$name : /*#__PURE__*/React__default['default'].createElement("svg", {
24828
+ return (_icons$name$toLowerCa = icons[name.toLowerCase()]) !== null && _icons$name$toLowerCa !== void 0 ? _icons$name$toLowerCa : /*#__PURE__*/React__default['default'].createElement("svg", {
24249
24829
  xmlns: "http://www.w3.org/2000/svg",
24250
24830
  className: "plc-w-12",
24251
24831
  fill: "none",