@pelcro/react-pelcro-js 3.21.6 → 3.21.8

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
@@ -3457,7 +3457,8 @@ var labels$10 = {
3457
3457
  removeCoupon: "REMOVE",
3458
3458
  firstName: "First name",
3459
3459
  lastName: "Last name",
3460
- phone: "Phone"
3460
+ phone: "Phone",
3461
+ freeItems: "Free Items"
3461
3462
  };
3462
3463
  var checkoutForm_en = {
3463
3464
  messages: messages$14,
@@ -4398,7 +4399,8 @@ var labels$H = {
4398
4399
  removeCoupon: "RETIRER",
4399
4400
  firstName: "Prénom",
4400
4401
  lastName: "Nom de famille",
4401
- phone: "Téléphoner"
4402
+ phone: "Téléphoner",
4403
+ freeItems: "Articles gratuits"
4402
4404
  };
4403
4405
  var checkoutForm_fr = {
4404
4406
  messages: messages$M,
@@ -5225,7 +5227,8 @@ var labels$s = {
5225
5227
  removeCoupon: "제거",
5226
5228
  firstName: "이름",
5227
5229
  lastName: "성",
5228
- phone: "핸드폰"
5230
+ phone: "핸드폰",
5231
+ freeItems: "무료 아이템"
5229
5232
  };
5230
5233
  var checkoutForm_ko = {
5231
5234
  messages: messages$v,
@@ -6156,7 +6159,8 @@ var labels$d = {
6156
6159
  removeCoupon: "ELIMINAR",
6157
6160
  firstName: "Nombre",
6158
6161
  lastName: "Apellido",
6159
- phone: "Teléfono"
6162
+ phone: "Teléfono",
6163
+ freeItems: "Artículos gratis"
6160
6164
  };
6161
6165
  var checkoutForm_es = {
6162
6166
  messages: messages$e,
@@ -8707,7 +8711,7 @@ const calcAndFormatItemsTotal = (items, currency) => {
8707
8711
  if (!Array.isArray(items)) return;
8708
8712
  let totalWithoutDividingBy100 = 0;
8709
8713
  for (const item of items) {
8710
- totalWithoutDividingBy100 += parseFloat(item.price ? isCurrencyZeroDecimal(currency) ? item.price * item.quantity : (item.price * item.quantity).toFixed(2) : isCurrencyZeroDecimal(currency) ? item.amount : item.amount.toFixed(2));
8714
+ totalWithoutDividingBy100 += parseFloat(item !== null && item !== void 0 && item.price || (item === null || item === void 0 ? void 0 : item.price) === 0 ? isCurrencyZeroDecimal(currency) ? item.price * item.quantity : (item.price * item.quantity).toFixed(2) : isCurrencyZeroDecimal(currency) ? item.amount : item.amount.toFixed(2));
8711
8715
  }
8712
8716
  return getFormattedPriceByLocal(totalWithoutDividingBy100, currency, getPageOrDefaultLanguage());
8713
8717
  };
@@ -10873,13 +10877,16 @@ const debounce = (func, waitTime) => {
10873
10877
  };
10874
10878
  };
10875
10879
  function getSiteCardProcessor() {
10876
- var _window$Pelcro$site$r, _window$Pelcro$site$r2;
10880
+ var _window$Pelcro$site$r, _window$Pelcro$site$r2, _window$Pelcro$site$r3;
10877
10881
  if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_gateway_settings) {
10878
10882
  return "vantiv";
10879
10883
  }
10880
10884
  if ((_window$Pelcro$site$r2 = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r2 !== void 0 && _window$Pelcro$site$r2.tap_gateway_settings) {
10881
10885
  return "tap";
10882
10886
  }
10887
+ if ((_window$Pelcro$site$r3 = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r3 !== void 0 && _window$Pelcro$site$r3.cybersource_gateway_settings) {
10888
+ return "cybersource";
10889
+ }
10883
10890
  return "stripe";
10884
10891
  }
10885
10892
 
@@ -11740,6 +11747,8 @@ const SET_FIRST_NAME_ERROR = "SET_FIRST_NAME_ERROR";
11740
11747
  const SET_LAST_NAME_ERROR = "SET_LAST_NAME_ERROR";
11741
11748
  const SET_PHONE_ERROR = "SET_PHONE_ERROR";
11742
11749
  const SET_TEXT_FIELD = "SET_TEXT_FIELD";
11750
+ const SET_MONTH = "SET_MONTH";
11751
+ const SET_YEAR = "SET_YEAR";
11743
11752
  const SET_TOKEN = "SET_TOKEN";
11744
11753
  const SET_GIFT_CODE = "SET_GIFT_CODE";
11745
11754
  const RESET_LOGIN_FORM = "RESET_LOGIN_FORM";
@@ -15499,7 +15508,7 @@ var _isPaymentGatewayInvalid = /*#__PURE__*/new WeakMap();
15499
15508
  var _generateUserError = /*#__PURE__*/new WeakMap();
15500
15509
  class Payment {
15501
15510
  /**
15502
- * @param {(StripeGateway|PaypalGateway|VantivGateway|TapGateway)} paymentGateway
15511
+ * @param {(StripeGateway|PaypalGateway|VantivGateway|TapGateway|CybersourceGateway)} paymentGateway
15503
15512
  */
15504
15513
  constructor(paymentGateway) {
15505
15514
  _defineProperty$3(this, "execute", (options, callback) => {
@@ -15518,7 +15527,7 @@ class Payment {
15518
15527
  _classPrivateFieldInitSpec$1(this, _isPaymentGatewayInvalid, {
15519
15528
  writable: true,
15520
15529
  value: gateway => {
15521
- return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway || gateway instanceof TapGateway);
15530
+ return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway || gateway instanceof TapGateway || gateway instanceof CybersourceGateway);
15522
15531
  }
15523
15532
  });
15524
15533
  _classPrivateFieldInitSpec$1(this, _generateUserError, {
@@ -15572,7 +15581,8 @@ const PAYMENT_GATEWAYS_ENUM = {
15572
15581
  stripe: "stripe",
15573
15582
  paypal: "braintree",
15574
15583
  vantiv: "vantiv",
15575
- tap: "tap"
15584
+ tap: "tap",
15585
+ cybersource: "cybersource"
15576
15586
  };
15577
15587
 
15578
15588
  /**
@@ -16294,6 +16304,222 @@ class TapGateway {
16294
16304
  }
16295
16305
  }
16296
16306
 
16307
+ /**
16308
+ * Cybersource gateway strategy
16309
+ */
16310
+ var _paymentGateway5 = /*#__PURE__*/new WeakMap();
16311
+ var _createSubscription5 = /*#__PURE__*/new WeakMap();
16312
+ var _renewSubscription4 = /*#__PURE__*/new WeakMap();
16313
+ var _createGiftedSubscription5 = /*#__PURE__*/new WeakMap();
16314
+ var _renewGiftedSubscription4 = /*#__PURE__*/new WeakMap();
16315
+ var _purchaseEcommerceOrder4 = /*#__PURE__*/new WeakMap();
16316
+ var _payInvoice5 = /*#__PURE__*/new WeakMap();
16317
+ class CybersourceGateway {
16318
+ constructor() {
16319
+ _classPrivateFieldInitSpec$1(this, _paymentGateway5, {
16320
+ writable: true,
16321
+ value: PAYMENT_GATEWAYS_ENUM["cybersource"]
16322
+ });
16323
+ _defineProperty$3(this, "execute", (options, callback) => {
16324
+ const types = PAYMENT_TYPES;
16325
+ switch (options.type) {
16326
+ case types.CREATE_SUBSCRIPTION:
16327
+ return _classPrivateFieldGet(this, _createSubscription5).call(this, options, callback);
16328
+ case types.RENEW_SUBSCRIPTION:
16329
+ return _classPrivateFieldGet(this, _renewSubscription4).call(this, options, callback);
16330
+ case types.CREATE_GIFTED_SUBSCRIPTION:
16331
+ return _classPrivateFieldGet(this, _createGiftedSubscription5).call(this, options, callback);
16332
+ case types.RENEW_GIFTED_SUBSCRIPTION:
16333
+ return _classPrivateFieldGet(this, _renewGiftedSubscription4).call(this, options, callback);
16334
+ case types.PURCHASE_ECOMMERCE_ORDER:
16335
+ return _classPrivateFieldGet(this, _purchaseEcommerceOrder4).call(this, options, callback);
16336
+ case types.PAY_INVOICE:
16337
+ return _classPrivateFieldGet(this, _payInvoice5).call(this, options, callback);
16338
+ default:
16339
+ console.error("Unsupported payment method: cybersource Gateway");
16340
+ }
16341
+ });
16342
+ _classPrivateFieldInitSpec$1(this, _createSubscription5, {
16343
+ writable: true,
16344
+ value: (options, callback) => {
16345
+ const {
16346
+ token,
16347
+ plan,
16348
+ couponCode,
16349
+ product,
16350
+ quantity = 1,
16351
+ addressId,
16352
+ isExistingSource
16353
+ } = options;
16354
+ const params = isExistingSource ? {
16355
+ source_id: token
16356
+ } : {
16357
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
16358
+ gateway_token: token
16359
+ };
16360
+ window.Pelcro.subscription.create({
16361
+ quantity,
16362
+ auth_token: window.Pelcro.user.read().auth_token,
16363
+ plan_id: plan.id,
16364
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
16365
+ coupon_code: couponCode,
16366
+ address_id: product.address_required ? addressId : null,
16367
+ ...params
16368
+ }, (err, res) => {
16369
+ callback(err, res);
16370
+ });
16371
+ }
16372
+ });
16373
+ _classPrivateFieldInitSpec$1(this, _renewSubscription4, {
16374
+ writable: true,
16375
+ value: (options, callback) => {
16376
+ const {
16377
+ subscriptionIdToRenew,
16378
+ token,
16379
+ plan,
16380
+ couponCode,
16381
+ product,
16382
+ addressId,
16383
+ isExistingSource
16384
+ } = options;
16385
+ const params = isExistingSource ? {
16386
+ source_id: token
16387
+ } : {
16388
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
16389
+ gateway_token: token
16390
+ };
16391
+ window.Pelcro.subscription.renew({
16392
+ auth_token: window.Pelcro.user.read().auth_token,
16393
+ plan_id: plan.id,
16394
+ coupon_code: couponCode,
16395
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
16396
+ subscription_id: subscriptionIdToRenew,
16397
+ address_id: product.address_required ? addressId : null,
16398
+ ...params
16399
+ }, (err, res) => {
16400
+ callback(err, res);
16401
+ });
16402
+ }
16403
+ });
16404
+ _classPrivateFieldInitSpec$1(this, _createGiftedSubscription5, {
16405
+ writable: true,
16406
+ value: (options, callback) => {
16407
+ const {
16408
+ token,
16409
+ plan,
16410
+ couponCode,
16411
+ product,
16412
+ giftRecipient,
16413
+ quantity = 1,
16414
+ addressId,
16415
+ isExistingSource
16416
+ } = options;
16417
+ const params = isExistingSource ? {
16418
+ source_id: token
16419
+ } : {
16420
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
16421
+ gateway_token: token
16422
+ };
16423
+ window.Pelcro.subscription.create({
16424
+ quantity,
16425
+ auth_token: window.Pelcro.user.read().auth_token,
16426
+ plan_id: plan.id,
16427
+ coupon_code: couponCode,
16428
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
16429
+ gift_recipient_email: giftRecipient.email,
16430
+ gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
16431
+ gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
16432
+ gift_start_date: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.startDate,
16433
+ gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
16434
+ address_id: product.address_required ? addressId : null,
16435
+ ...params
16436
+ }, (err, res) => {
16437
+ callback(err, res);
16438
+ });
16439
+ }
16440
+ });
16441
+ _classPrivateFieldInitSpec$1(this, _renewGiftedSubscription4, {
16442
+ writable: true,
16443
+ value: (options, callback) => {
16444
+ const {
16445
+ subscriptionIdToRenew,
16446
+ token,
16447
+ product,
16448
+ plan,
16449
+ couponCode,
16450
+ addressId,
16451
+ isExistingSource
16452
+ } = options;
16453
+ const params = isExistingSource ? {
16454
+ source_id: token
16455
+ } : {
16456
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
16457
+ gateway_token: token
16458
+ };
16459
+ window.Pelcro.subscription.renewGift({
16460
+ auth_token: window.Pelcro.user.read().auth_token,
16461
+ plan_id: plan.id,
16462
+ coupon_code: couponCode,
16463
+ subscription_id: subscriptionIdToRenew,
16464
+ address_id: product.address_required ? addressId : null,
16465
+ ...params
16466
+ }, (err, res) => {
16467
+ callback(err, res);
16468
+ });
16469
+ }
16470
+ });
16471
+ _classPrivateFieldInitSpec$1(this, _purchaseEcommerceOrder4, {
16472
+ writable: true,
16473
+ value: (options, callback) => {
16474
+ const {
16475
+ token,
16476
+ items,
16477
+ couponCode,
16478
+ addressId,
16479
+ isExistingSource
16480
+ } = options;
16481
+ const params = isExistingSource ? {
16482
+ source_id: token
16483
+ } : {
16484
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
16485
+ gateway_token: token
16486
+ };
16487
+ window.Pelcro.ecommerce.order.create({
16488
+ items,
16489
+ coupon_code: couponCode,
16490
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
16491
+ ...params,
16492
+ ...(addressId && {
16493
+ address_id: addressId
16494
+ })
16495
+ }, (err, res) => {
16496
+ callback(err, res);
16497
+ });
16498
+ }
16499
+ });
16500
+ _classPrivateFieldInitSpec$1(this, _payInvoice5, {
16501
+ writable: true,
16502
+ value: (options, callback) => {
16503
+ const {
16504
+ token,
16505
+ invoiceId
16506
+ } = options;
16507
+ const params = options.isExistingSource ? {
16508
+ source_id: token,
16509
+ invoice_id: invoiceId
16510
+ } : {
16511
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
16512
+ gateway_token: token,
16513
+ invoice_id: invoiceId
16514
+ };
16515
+ window.Pelcro.invoice.pay(params, (err, res) => {
16516
+ callback(err, res);
16517
+ });
16518
+ }
16519
+ });
16520
+ }
16521
+ }
16522
+
16297
16523
  /**
16298
16524
  * @typedef {Object} PaymentStateType
16299
16525
  * @property {boolean} disableSubmit
@@ -16333,6 +16559,8 @@ const initialState$k = {
16333
16559
  firstNameError: null,
16334
16560
  lastNameError: null,
16335
16561
  phoneError: null,
16562
+ month: "",
16563
+ year: "",
16336
16564
  alert: {
16337
16565
  type: "error",
16338
16566
  content: ""
@@ -16398,37 +16626,38 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16398
16626
  updateTotalAmountWithTax();
16399
16627
  }, []);
16400
16628
 
16401
- /*====== Start Tap integration ========*/
16402
- const submitUsingTap = state => {
16403
- var _ref2, _ref3, _ref4, _state$updatedPrice;
16629
+ /*====== Start Cybersource integration ========*/
16630
+ const cybersourceErrorHandle = err => {
16631
+ var _err$details, _err$details$response;
16632
+ const errorMessages = [];
16633
+
16634
+ // enumerable error (ex: validation errors)
16635
+ Object.values(err === null || err === void 0 ? void 0 : (_err$details = err.details) === null || _err$details === void 0 ? void 0 : (_err$details$response = _err$details.responseStatus) === null || _err$details$response === void 0 ? void 0 : _err$details$response.details).forEach(_ref2 => {
16636
+ let {
16637
+ message
16638
+ } = _ref2;
16639
+ errorMessages.push(message);
16640
+ });
16641
+
16642
+ // convert to multiline string
16643
+ return errorMessages.join("\n");
16644
+ };
16645
+ const submitUsingCybersource = (state, dispatch) => {
16646
+ var _cybersourceInstanceR;
16404
16647
  const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
16405
16648
  if (isUsingExistingPaymentMethod) {
16406
- // no need to create a new source using tap
16407
- return handleTapPayment(null, state);
16649
+ // no need to create a new source using cybersrce
16650
+ return handleCybersourcePayment(null, state);
16408
16651
  }
16409
- if (!tapInstanceRef.current) {
16410
- return console.error("Tap sdk script wasn't loaded, you need to load tap sdk before rendering the tap payment flow");
16652
+ if (!cybersourceInstanceRef.current) {
16653
+ return console.error("Cybersource sdk script wasn't loaded, you need to load Cybersource sdk before rendering the Cybersource payment flow");
16411
16654
  }
16412
- const getOrderItemsTotal = () => {
16413
- if (!order) {
16414
- return null;
16415
- }
16416
- const isQuickPurchase = !Array.isArray(order);
16417
- if (isQuickPurchase) {
16418
- return order.price * order.quantity;
16419
- }
16420
- if (order.length === 0) {
16421
- return null;
16422
- }
16423
- return order.reduce((total, item) => {
16424
- return total + item.price * item.quantity;
16425
- }, 0);
16655
+ let options = {
16656
+ cardExpirationMonth: state.month,
16657
+ cardExpirationYear: state.year
16426
16658
  };
16427
- const totalAmount = (_ref2 = (_ref3 = (_ref4 = (_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 && _ref4 !== void 0 ? _ref4 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref3 !== void 0 ? _ref3 : getOrderItemsTotal()) !== null && _ref2 !== void 0 ? _ref2 : 10;
16428
- tapInstanceRef.current.createToken(tapInstanceCard.current).then(function (result) {
16429
- if (result.error) {
16430
- // Inform the user if there was an error
16431
- onFailure(result.error);
16659
+ (_cybersourceInstanceR = cybersourceInstanceRef.current) === null || _cybersourceInstanceR === void 0 ? void 0 : _cybersourceInstanceR.createToken(options, function (err, response) {
16660
+ if (err) {
16432
16661
  dispatch({
16433
16662
  type: DISABLE_SUBMIT,
16434
16663
  payload: false
@@ -16441,36 +16670,276 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16441
16670
  type: SHOW_ALERT,
16442
16671
  payload: {
16443
16672
  type: "error",
16444
- content: getErrorMessages(result.error)
16673
+ content: cybersourceErrorHandle(err)
16445
16674
  }
16446
16675
  });
16447
- } else {
16448
- window.Pelcro.payment.verify({
16449
- auth_token: window.Pelcro.user.read().auth_token,
16450
- first_name: window.Pelcro.user.read().first_name || state.firstName,
16451
- last_name: window.Pelcro.user.read().last_name || state.lastName,
16452
- phone: window.Pelcro.user.read().phone || state.phone,
16453
- site_id: window.Pelcro.siteid,
16454
- amount: totalAmount,
16455
- 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,
16456
- tap_token: result.id,
16457
- funding: result.card.funding,
16458
- redirect_url: `${window.Pelcro.environment.domain}/webhook/tap/callback/3dsecure?auth_token=${window.Pelcro.user.read().auth_token}&type=verify_card&site_id=${window.Pelcro.siteid}`
16459
- }, (err, res) => {
16460
- if (err) {
16461
- // Inform the user if there was an error
16462
- onFailure(err);
16463
- dispatch({
16464
- type: DISABLE_SUBMIT,
16465
- payload: false
16466
- });
16467
- dispatch({
16468
- type: LOADING,
16469
- payload: false
16470
- });
16471
- return dispatch({
16472
- type: SHOW_ALERT,
16473
- payload: {
16676
+ }
16677
+ handleCybersourcePayment(response.token, state);
16678
+ });
16679
+ };
16680
+ function handleCybersourcePayment(paymentRequest, state) {
16681
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
16682
+ if (type === "createPayment") {
16683
+ handleCybersourceSubscription();
16684
+ } else if (type === "orderCreate") {
16685
+ purchase(new CybersourceGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
16686
+ } else if (type === "invoicePayment") {
16687
+ payInvoice(new CybersourceGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
16688
+ } else if (type === "updatePaymentSource") {
16689
+ createNewCybersourceCard();
16690
+ }
16691
+ function createNewCybersourceCard() {
16692
+ window.Pelcro.source.create({
16693
+ auth_token: window.Pelcro.user.read().auth_token,
16694
+ token: paymentRequest,
16695
+ gateway: "cybersource"
16696
+ }, (err, res) => {
16697
+ dispatch({
16698
+ type: DISABLE_SUBMIT,
16699
+ payload: false
16700
+ });
16701
+ dispatch({
16702
+ type: LOADING,
16703
+ payload: false
16704
+ });
16705
+ toggleAuthenticationSuccessPendingView(false);
16706
+ if (err) {
16707
+ onFailure(err);
16708
+ return dispatch({
16709
+ type: SHOW_ALERT,
16710
+ payload: {
16711
+ type: "error",
16712
+ content: getErrorMessages(err)
16713
+ }
16714
+ });
16715
+ }
16716
+ dispatch({
16717
+ type: SHOW_ALERT,
16718
+ payload: {
16719
+ type: "success",
16720
+ content: t("messages.sourceUpdated")
16721
+ }
16722
+ });
16723
+ onSuccess(res);
16724
+ } //
16725
+ );
16726
+ }
16727
+
16728
+ function handleCybersourceSubscription() {
16729
+ const payment = new Payment(new CybersourceGateway());
16730
+ const createSubscription = !isGift && !subscriptionIdToRenew;
16731
+ const renewSubscription = !isGift && subscriptionIdToRenew;
16732
+ const giftSubscriprition = isGift && !subscriptionIdToRenew;
16733
+ const renewGift = isRenewingGift;
16734
+ const {
16735
+ couponCode
16736
+ } = state;
16737
+ if (renewGift) {
16738
+ return payment.execute({
16739
+ type: PAYMENT_TYPES.RENEW_GIFTED_SUBSCRIPTION,
16740
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
16741
+ plan,
16742
+ couponCode,
16743
+ product,
16744
+ isExistingSource: isUsingExistingPaymentMethod,
16745
+ subscriptionIdToRenew,
16746
+ addressId: selectedAddressId
16747
+ }, (err, res) => {
16748
+ if (err) {
16749
+ return handlePaymentError(err);
16750
+ }
16751
+ onSuccess(res);
16752
+ });
16753
+ } else if (giftSubscriprition) {
16754
+ return payment.execute({
16755
+ type: PAYMENT_TYPES.CREATE_GIFTED_SUBSCRIPTION,
16756
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
16757
+ quantity: plan.quantity,
16758
+ plan,
16759
+ couponCode,
16760
+ product,
16761
+ isExistingSource: isUsingExistingPaymentMethod,
16762
+ giftRecipient,
16763
+ addressId: selectedAddressId
16764
+ }, (err, res) => {
16765
+ if (err) {
16766
+ return handlePaymentError(err);
16767
+ }
16768
+ onSuccess(res);
16769
+ });
16770
+ } else if (renewSubscription) {
16771
+ return payment.execute({
16772
+ type: PAYMENT_TYPES.RENEW_SUBSCRIPTION,
16773
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
16774
+ quantity: plan.quantity,
16775
+ plan,
16776
+ couponCode,
16777
+ product,
16778
+ isExistingSource: isUsingExistingPaymentMethod,
16779
+ subscriptionIdToRenew,
16780
+ addressId: selectedAddressId
16781
+ }, (err, res) => {
16782
+ if (err) {
16783
+ return handlePaymentError(err);
16784
+ }
16785
+ onSuccess(res);
16786
+ });
16787
+ } else if (createSubscription) {
16788
+ return payment.execute({
16789
+ type: PAYMENT_TYPES.CREATE_SUBSCRIPTION,
16790
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
16791
+ quantity: plan.quantity,
16792
+ plan,
16793
+ couponCode,
16794
+ product,
16795
+ isExistingSource: isUsingExistingPaymentMethod,
16796
+ addressId: selectedAddressId
16797
+ }, (err, res) => {
16798
+ if (err) {
16799
+ return handlePaymentError(err);
16800
+ }
16801
+ onSuccess(res);
16802
+ });
16803
+ }
16804
+ }
16805
+ }
16806
+ const tokenizeCard = (error, microformInstance) => {
16807
+ if (error) {
16808
+ return;
16809
+ }
16810
+ cybersourceInstanceRef.current = microformInstance;
16811
+ };
16812
+ const initCybersourceScript = () => {
16813
+ // jwk api call
16814
+ window.Pelcro.payment.getJWK({
16815
+ auth_token: window.Pelcro.user.read().auth_token,
16816
+ site_id: window.Pelcro.siteid
16817
+ }, (err, res) => {
16818
+ if (err) {
16819
+ onFailure(err);
16820
+ dispatch({
16821
+ type: DISABLE_SUBMIT,
16822
+ payload: false
16823
+ });
16824
+ dispatch({
16825
+ type: LOADING,
16826
+ payload: false
16827
+ });
16828
+ return dispatch({
16829
+ type: SHOW_ALERT,
16830
+ payload: {
16831
+ type: "error",
16832
+ content: getErrorMessages(err)
16833
+ }
16834
+ });
16835
+ }
16836
+ const {
16837
+ key: jwk
16838
+ } = res;
16839
+ // SETUP MICROFORM
16840
+ FLEX.microform({
16841
+ keyId: jwk.kid,
16842
+ keystore: jwk,
16843
+ container: "#cybersourceCardNumber",
16844
+ placeholder: "Card Number",
16845
+ styles: {
16846
+ input: {
16847
+ "font-size": "14px",
16848
+ "font-family": "helvetica, tahoma, calibri, sans-serif",
16849
+ color: "#555"
16850
+ },
16851
+ ":focus": {
16852
+ color: "blue"
16853
+ },
16854
+ ":disabled": {
16855
+ cursor: "not-allowed"
16856
+ },
16857
+ valid: {
16858
+ color: "#3c763d"
16859
+ },
16860
+ invalid: {
16861
+ color: "#a94442"
16862
+ }
16863
+ }
16864
+ }, tokenizeCard);
16865
+ });
16866
+ };
16867
+
16868
+ /*====== End Cybersource integration ========*/
16869
+
16870
+ /*====== Start Tap integration ========*/
16871
+ const submitUsingTap = state => {
16872
+ var _ref3, _ref4, _ref5, _state$updatedPrice;
16873
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
16874
+ if (isUsingExistingPaymentMethod) {
16875
+ // no need to create a new source using tap
16876
+ return handleTapPayment(null, state);
16877
+ }
16878
+ if (!tapInstanceRef.current) {
16879
+ return console.error("Tap sdk script wasn't loaded, you need to load tap sdk before rendering the tap payment flow");
16880
+ }
16881
+ const getOrderItemsTotal = () => {
16882
+ if (!order) {
16883
+ return null;
16884
+ }
16885
+ const isQuickPurchase = !Array.isArray(order);
16886
+ if (isQuickPurchase) {
16887
+ return order.price * order.quantity;
16888
+ }
16889
+ if (order.length === 0) {
16890
+ return null;
16891
+ }
16892
+ return order.reduce((total, item) => {
16893
+ return total + item.price * item.quantity;
16894
+ }, 0);
16895
+ };
16896
+ const totalAmount = (_ref3 = (_ref4 = (_ref5 = (_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 && _ref5 !== void 0 ? _ref5 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref4 !== void 0 ? _ref4 : getOrderItemsTotal()) !== null && _ref3 !== void 0 ? _ref3 : 10;
16897
+ tapInstanceRef.current.createToken(tapInstanceCard.current).then(function (result) {
16898
+ if (result.error) {
16899
+ // Inform the user if there was an error
16900
+ onFailure(result.error);
16901
+ dispatch({
16902
+ type: DISABLE_SUBMIT,
16903
+ payload: false
16904
+ });
16905
+ dispatch({
16906
+ type: LOADING,
16907
+ payload: false
16908
+ });
16909
+ return dispatch({
16910
+ type: SHOW_ALERT,
16911
+ payload: {
16912
+ type: "error",
16913
+ content: getErrorMessages(result.error)
16914
+ }
16915
+ });
16916
+ } else {
16917
+ window.Pelcro.payment.verify({
16918
+ auth_token: window.Pelcro.user.read().auth_token,
16919
+ first_name: window.Pelcro.user.read().first_name || state.firstName,
16920
+ last_name: window.Pelcro.user.read().last_name || state.lastName,
16921
+ phone: window.Pelcro.user.read().phone || state.phone,
16922
+ site_id: window.Pelcro.siteid,
16923
+ amount: totalAmount,
16924
+ 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,
16925
+ tap_token: result.id,
16926
+ funding: result.card.funding,
16927
+ redirect_url: `${window.Pelcro.environment.domain}/webhook/tap/callback/3dsecure?auth_token=${window.Pelcro.user.read().auth_token}&type=verify_card&site_id=${window.Pelcro.siteid}`
16928
+ }, (err, res) => {
16929
+ if (err) {
16930
+ // Inform the user if there was an error
16931
+ onFailure(err);
16932
+ dispatch({
16933
+ type: DISABLE_SUBMIT,
16934
+ payload: false
16935
+ });
16936
+ dispatch({
16937
+ type: LOADING,
16938
+ payload: false
16939
+ });
16940
+ return dispatch({
16941
+ type: SHOW_ALERT,
16942
+ payload: {
16474
16943
  type: "error",
16475
16944
  content: getErrorMessages(err)
16476
16945
  }
@@ -16841,8 +17310,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16841
17310
  const vantivInstanceRef = React__default['default'].useRef(null);
16842
17311
  const tapInstanceRef = React__default['default'].useRef(null);
16843
17312
  const tapInstanceCard = React__default['default'].useRef(null);
17313
+ const cybersourceInstanceRef = React__default['default'].useRef(null);
16844
17314
  React.useEffect(() => {
16845
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
17315
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
16846
17316
  if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
16847
17317
  var _window$Pelcro$site$r2, _window$Pelcro$site$r3;
16848
17318
  const payPageId = (_window$Pelcro$site$r2 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r2 === void 0 ? void 0 : _window$Pelcro$site$r2.vantiv_gateway_settings.pay_page_id;
@@ -16878,7 +17348,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16878
17348
  }, [vantivPaymentRequest]);
16879
17349
  React.useEffect(() => {
16880
17350
  whenUserReady(() => {
16881
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
17351
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
16882
17352
  if (cardProcessor === "tap" && !window.Tapjsli) {
16883
17353
  window.Pelcro.helpers.loadSDK("https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.4/bluebird.min.js", "tap-bluebird");
16884
17354
  window.Pelcro.helpers.loadSDK("https://secure.gosell.io/js/sdk/tap.min.js", "tap-sdk");
@@ -16889,10 +17359,19 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16889
17359
  if (cardProcessor === "tap" && !selectedPaymentMethodId && window.Tapjsli) {
16890
17360
  initTapScript();
16891
17361
  }
17362
+ if (cardProcessor === "cybersource" && !selectedPaymentMethodId && !window.FLEX) {
17363
+ window.Pelcro.helpers.loadSDK("https://flex.cybersource.com/cybersource/assets/microform/0.4/flex-microform.min.js", "cybersource-cdn");
17364
+ document.querySelector('script[src="https://flex.cybersource.com/cybersource/assets/microform/0.4/flex-microform.min.js"]').addEventListener("load", () => {
17365
+ initCybersourceScript();
17366
+ });
17367
+ }
17368
+ if (cardProcessor === "cybersource" && !selectedPaymentMethodId && window.FLEX) {
17369
+ initCybersourceScript();
17370
+ }
16892
17371
  });
16893
17372
  }, [selectedPaymentMethodId]);
16894
17373
  const initPaymentRequest = (state, dispatch) => {
16895
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
17374
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
16896
17375
  try {
16897
17376
  const paymentRequest = stripe.paymentRequest({
16898
17377
  country: window.Pelcro.user.location.countryCode || "US",
@@ -16904,13 +17383,13 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16904
17383
  });
16905
17384
 
16906
17385
  // When Google pay / Apple pay source created
16907
- paymentRequest.on("source", _ref5 => {
17386
+ paymentRequest.on("source", _ref6 => {
16908
17387
  var _source$card;
16909
17388
  let {
16910
17389
  complete,
16911
17390
  source,
16912
17391
  ...data
16913
- } = _ref5;
17392
+ } = _ref6;
16914
17393
  dispatch({
16915
17394
  type: DISABLE_COUPON_BUTTON,
16916
17395
  payload: true
@@ -16925,11 +17404,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16925
17404
  });
16926
17405
  complete("success");
16927
17406
  if ((source === null || source === void 0 ? void 0 : (_source$card = source.card) === null || _source$card === void 0 ? void 0 : _source$card.three_d_secure) === "required") {
16928
- return generate3DSecureSource(source).then(_ref6 => {
17407
+ return generate3DSecureSource(source).then(_ref7 => {
16929
17408
  let {
16930
17409
  source,
16931
17410
  error
16932
- } = _ref6;
17411
+ } = _ref7;
16933
17412
  if (error) {
16934
17413
  return handlePaymentError(error);
16935
17414
  }
@@ -16961,7 +17440,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16961
17440
  */
16962
17441
  const updateTotalAmountWithTax = () => {
16963
17442
  var _window$Pelcro$site$r4;
16964
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) return;
17443
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
16965
17444
  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;
16966
17445
  if (taxesEnabled && type === "createPayment") {
16967
17446
  dispatch({
@@ -17458,16 +17937,18 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17458
17937
  items: mappedOrderItems,
17459
17938
  addressId: selectedAddressId,
17460
17939
  couponCode
17461
- }, (err, res) => {
17462
- dispatch({
17463
- type: DISABLE_SUBMIT,
17464
- payload: false
17465
- });
17466
- dispatch({
17467
- type: LOADING,
17468
- payload: false
17469
- });
17940
+ }, (err, orderResponse) => {
17941
+ var _window$Pelcro2, _window$Pelcro2$user, _window$Pelcro2$user$;
17470
17942
  if (err) {
17943
+ toggleAuthenticationSuccessPendingView(false);
17944
+ dispatch({
17945
+ type: DISABLE_SUBMIT,
17946
+ payload: false
17947
+ });
17948
+ dispatch({
17949
+ type: LOADING,
17950
+ payload: false
17951
+ });
17471
17952
  onFailure(err);
17472
17953
  return dispatch({
17473
17954
  type: SHOW_ALERT,
@@ -17487,7 +17968,30 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17487
17968
  cartItems: []
17488
17969
  });
17489
17970
  }
17490
- onSuccess(res);
17971
+ window.Pelcro.user.refresh({
17972
+ auth_token: (_window$Pelcro2 = window.Pelcro) === null || _window$Pelcro2 === void 0 ? void 0 : (_window$Pelcro2$user = _window$Pelcro2.user) === null || _window$Pelcro2$user === void 0 ? void 0 : (_window$Pelcro2$user$ = _window$Pelcro2$user.read()) === null || _window$Pelcro2$user$ === void 0 ? void 0 : _window$Pelcro2$user$.auth_token
17973
+ }, (err, res) => {
17974
+ dispatch({
17975
+ type: DISABLE_SUBMIT,
17976
+ payload: false
17977
+ });
17978
+ dispatch({
17979
+ type: LOADING,
17980
+ payload: false
17981
+ });
17982
+ toggleAuthenticationSuccessPendingView(false);
17983
+ if (err) {
17984
+ onFailure(err);
17985
+ return dispatch({
17986
+ type: SHOW_ALERT,
17987
+ payload: {
17988
+ type: "error",
17989
+ content: getErrorMessages(err)
17990
+ }
17991
+ });
17992
+ }
17993
+ onSuccess(orderResponse);
17994
+ });
17491
17995
  });
17492
17996
  };
17493
17997
  const payInvoice = (gatewayService, gatewayToken, dispatch) => {
@@ -17504,12 +18008,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17504
18008
  const updatePaymentSource = (state, dispatch) => {
17505
18009
  return stripe.createSource({
17506
18010
  type: "card"
17507
- }).then(_ref7 => {
18011
+ }).then(_ref8 => {
17508
18012
  var _source$card2;
17509
18013
  let {
17510
18014
  source,
17511
18015
  error
17512
- } = _ref7;
18016
+ } = _ref8;
17513
18017
  if (error) {
17514
18018
  return handlePaymentError(error);
17515
18019
  }
@@ -17565,14 +18069,37 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17565
18069
  });
17566
18070
  };
17567
18071
  const submitPayment = (state, dispatch) => {
18072
+ if (skipPayment && props !== null && props !== void 0 && props.freeOrders) {
18073
+ const isQuickPurchase = !Array.isArray(order);
18074
+ const mappedOrderItems = isQuickPurchase ? [{
18075
+ sku_id: order.id,
18076
+ quantity: order.quantity
18077
+ }] : order.map(item => ({
18078
+ sku_id: item.id,
18079
+ quantity: item.quantity
18080
+ }));
18081
+ window.Pelcro.ecommerce.order.create({
18082
+ items: mappedOrderItems,
18083
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
18084
+ ...(selectedAddressId && {
18085
+ address_id: selectedAddressId
18086
+ })
18087
+ }, (err, res) => {
18088
+ if (err) {
18089
+ return handlePaymentError(err);
18090
+ }
18091
+ return onSuccess(res);
18092
+ });
18093
+ return;
18094
+ }
17568
18095
  stripe.createSource({
17569
18096
  type: "card"
17570
- }).then(_ref8 => {
17571
- var _ref9, _ref10, _state$updatedPrice2;
18097
+ }).then(_ref9 => {
18098
+ var _ref10, _ref11, _state$updatedPrice2;
17572
18099
  let {
17573
18100
  source,
17574
18101
  error
17575
- } = _ref8;
18102
+ } = _ref9;
17576
18103
  if (error) {
17577
18104
  return handlePaymentError(error);
17578
18105
  }
@@ -17591,7 +18118,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17591
18118
  return total + item.price * item.quantity;
17592
18119
  }, 0);
17593
18120
  };
17594
- (_ref9 = (_ref10 = (_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 && _ref10 !== void 0 ? _ref10 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref9 !== void 0 ? _ref9 : getOrderItemsTotal();
18121
+ (_ref10 = (_ref11 = (_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 && _ref11 !== void 0 ? _ref11 : invoice === null || invoice === void 0 ? void 0 : invoice.amount_remaining) !== null && _ref10 !== void 0 ? _ref10 : getOrderItemsTotal();
17595
18122
  return handlePayment(source);
17596
18123
  }).catch(error => {
17597
18124
  return handlePaymentError(error);
@@ -17798,12 +18325,18 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17798
18325
  disableSubmit: true,
17799
18326
  isLoading: true
17800
18327
  }, (state, dispatch) => {
18328
+ if (skipPayment && props !== null && props !== void 0 && props.freeOrders) {
18329
+ return submitPayment(state);
18330
+ }
17801
18331
  if (getSiteCardProcessor() === "vantiv") {
17802
18332
  return submitUsingVantiv(state);
17803
18333
  }
17804
18334
  if (getSiteCardProcessor() === "tap") {
17805
18335
  return submitUsingTap(state);
17806
18336
  }
18337
+ if (getSiteCardProcessor() === "cybersource") {
18338
+ return submitUsingCybersource(state, dispatch);
18339
+ }
17807
18340
  if (selectedPaymentMethodId) {
17808
18341
  // pay with selected method (source) if exists already
17809
18342
  return handlePayment({
@@ -17871,6 +18404,16 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17871
18404
  ...state,
17872
18405
  percentOff: action.payload
17873
18406
  });
18407
+ case SET_MONTH:
18408
+ return lib_7({
18409
+ ...state,
18410
+ month: action.payload
18411
+ });
18412
+ case SET_YEAR:
18413
+ return lib_7({
18414
+ ...state,
18415
+ year: action.payload
18416
+ });
17874
18417
  case SET_FIRST_NAME:
17875
18418
  return lib_7({
17876
18419
  ...state,
@@ -17926,10 +18469,14 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17926
18469
  state,
17927
18470
  dispatch
17928
18471
  }
17929
- }, children.length ? children.map((child, i) => /*#__PURE__*/React__default['default'].cloneElement(child, {
17930
- store: store$k,
17931
- key: i
17932
- })) : /*#__PURE__*/React__default['default'].cloneElement(children, {
18472
+ }, children.length ? children.map((child, i) => {
18473
+ if (child) {
18474
+ return /*#__PURE__*/React__default['default'].cloneElement(child, {
18475
+ store: store$k,
18476
+ key: i
18477
+ });
18478
+ }
18479
+ }) : /*#__PURE__*/React__default['default'].cloneElement(children, {
17933
18480
  store: store$k
17934
18481
  })));
17935
18482
  };
@@ -17965,6 +18512,114 @@ const PaymentMethodContainer = props => {
17965
18512
  return null;
17966
18513
  };
17967
18514
 
18515
+ function Select(_ref) {
18516
+ let {
18517
+ label = "",
18518
+ required,
18519
+ id,
18520
+ errorId,
18521
+ error = "",
18522
+ className = "",
18523
+ labelClassName = "",
18524
+ errorClassName = "",
18525
+ wrapperClassName = "",
18526
+ children,
18527
+ ...otherProps
18528
+ } = _ref;
18529
+ return /*#__PURE__*/React__default['default'].createElement("div", {
18530
+ className: `pelcro-input-wrapper ${wrapperClassName}`
18531
+ }, /*#__PURE__*/React__default['default'].createElement("label", {
18532
+ htmlFor: id,
18533
+ className: `pelcro-input-label ${labelClassName}`
18534
+ }, `${label}${required ? "*" : ""}`), /*#__PURE__*/React__default['default'].createElement("select", Object.assign({
18535
+ id: id,
18536
+ className: `pelcro-input-field ${className} ${error ? "pelcro-input-invalid" : ""}`,
18537
+ "aria-describedby": errorId,
18538
+ "aria-invalid": Boolean(error)
18539
+ }, otherProps), children), error && /*#__PURE__*/React__default['default'].createElement("p", {
18540
+ id: errorId,
18541
+ "aria-live": "assertive",
18542
+ className: `pelcro-input-error ${errorClassName}`
18543
+ }, error));
18544
+ }
18545
+
18546
+ function MonthSelect(_ref) {
18547
+ let {
18548
+ placeholder,
18549
+ store,
18550
+ ...otherProps
18551
+ } = _ref;
18552
+ const {
18553
+ dispatch,
18554
+ state: {
18555
+ month
18556
+ }
18557
+ } = React.useContext(store);
18558
+ const get2digits = num => num < 10 ? "0" + num.toString() : num.toString();
18559
+ const createMonthsItems = React.useMemo(() => {
18560
+ return [...Array.from({
18561
+ length: 12
18562
+ }, (_, i) => i + 1)].map(i => {
18563
+ return /*#__PURE__*/React__default['default'].createElement("option", {
18564
+ key: i,
18565
+ value: get2digits(i)
18566
+ }, get2digits(i));
18567
+ });
18568
+ }, []);
18569
+ const handleInputChange = value => {
18570
+ dispatch({
18571
+ type: SET_MONTH,
18572
+ payload: value
18573
+ });
18574
+ };
18575
+ return /*#__PURE__*/React__default['default'].createElement(Select, Object.assign({
18576
+ value: month,
18577
+ onChange: e => handleInputChange(e.target.value)
18578
+ }, otherProps), /*#__PURE__*/React__default['default'].createElement("option", {
18579
+ value: "",
18580
+ disabled: true,
18581
+ selected: true
18582
+ }, placeholder), createMonthsItems);
18583
+ }
18584
+
18585
+ function YearSelect(_ref) {
18586
+ let {
18587
+ placeholder,
18588
+ store,
18589
+ ...otherProps
18590
+ } = _ref;
18591
+ const {
18592
+ dispatch,
18593
+ state: {
18594
+ year
18595
+ }
18596
+ } = React.useContext(store);
18597
+ const createYearsItems = React.useMemo(() => {
18598
+ return Array.from({
18599
+ length: 10
18600
+ }, (_, i) => i + new Date().getFullYear()).map(i => {
18601
+ return /*#__PURE__*/React__default['default'].createElement("option", {
18602
+ key: i,
18603
+ value: i
18604
+ }, i);
18605
+ });
18606
+ }, []);
18607
+ const handleInputChange = value => {
18608
+ dispatch({
18609
+ type: SET_YEAR,
18610
+ payload: value
18611
+ });
18612
+ };
18613
+ return /*#__PURE__*/React__default['default'].createElement(Select, Object.assign({
18614
+ value: year,
18615
+ onChange: e => handleInputChange(e.target.value)
18616
+ }, otherProps), /*#__PURE__*/React__default['default'].createElement("option", {
18617
+ value: "",
18618
+ disabled: true,
18619
+ selected: true
18620
+ }, placeholder), createYearsItems);
18621
+ }
18622
+
17968
18623
  const StripeInputStyle = {
17969
18624
  base: "plc-w-full plc-p-3 plc-border plc-border-gray-300 plc-appearance-none plc-outline-none plc-rounded-sm plc-bg-gray-50 pelcro-input-input",
17970
18625
  focus: "plc-ring-2 plc-ring-primary-400",
@@ -18054,6 +18709,24 @@ const CheckoutForm = () => {
18054
18709
  id: "tapPaymentIframe"
18055
18710
  });
18056
18711
  }
18712
+ if (cardProcessor === "cybersource") {
18713
+ return /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement("div", {
18714
+ id: "cybersourceCardNumber",
18715
+ className: "pelcro-input-field plc-h-12"
18716
+ }), /*#__PURE__*/React__default['default'].createElement("div", {
18717
+ className: "plc-flex plc-items-end plc-justify-between plc-my-2"
18718
+ }, /*#__PURE__*/React__default['default'].createElement("div", {
18719
+ className: "plc-w-6/12 plc-pr-4"
18720
+ }, /*#__PURE__*/React__default['default'].createElement(MonthSelect, {
18721
+ store: store$k,
18722
+ placeholder: "Exp Month"
18723
+ })), /*#__PURE__*/React__default['default'].createElement("div", {
18724
+ className: "plc-w-6/12"
18725
+ }, /*#__PURE__*/React__default['default'].createElement(YearSelect, {
18726
+ store: store$k,
18727
+ placeholder: "Exp Year"
18728
+ }))));
18729
+ }
18057
18730
  if (cardProcessor === "stripe") {
18058
18731
  return /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(PelcroCardNumber, {
18059
18732
  autoFocus: true
@@ -18752,11 +19425,47 @@ const SubscriptionCreateFreePlanButton = _ref => {
18752
19425
  }, otherProps), t("buttons.subscribe"));
18753
19426
  };
18754
19427
 
19428
+ const OrderCreateFreeButton = _ref => {
19429
+ let {
19430
+ name,
19431
+ onClick,
19432
+ ...otherProps
19433
+ } = _ref;
19434
+ const {
19435
+ state: {
19436
+ disableSubmit
19437
+ },
19438
+ dispatch
19439
+ } = React.useContext(store$k);
19440
+ const {
19441
+ t
19442
+ } = useTranslation("checkoutForm");
19443
+ const [isDisabled, setDisabled] = React.useState(true);
19444
+ React.useEffect(() => {
19445
+ setDisabled(disableSubmit);
19446
+ }, [disableSubmit]);
19447
+ return /*#__PURE__*/React__default['default'].createElement(Button, Object.assign({
19448
+ className: "plc-w-full",
19449
+ onClick: () => {
19450
+ dispatch({
19451
+ type: DISABLE_SUBMIT,
19452
+ payload: true
19453
+ });
19454
+ dispatch({
19455
+ type: SUBMIT_PAYMENT
19456
+ });
19457
+ onClick === null || onClick === void 0 ? void 0 : onClick();
19458
+ },
19459
+ disabled: isDisabled,
19460
+ isLoading: disableSubmit
19461
+ }, otherProps), t("labels.submit"));
19462
+ };
19463
+
18755
19464
  /**
18756
19465
  *
18757
19466
  */
18758
19467
  function PaymentMethodView(_ref) {
18759
- var _window$Pelcro$site$r, _window$Pelcro$site$r2;
19468
+ var _window$Pelcro$site$r, _window$Pelcro$site$r2, _window$Pelcro$site$r3, _calcAndFormatItemsTo, _order$;
18760
19469
  let {
18761
19470
  onSuccess,
18762
19471
  onGiftRenewalSuccess,
@@ -18764,7 +19473,9 @@ function PaymentMethodView(_ref) {
18764
19473
  type,
18765
19474
  showCoupon,
18766
19475
  showExternalPaymentMethods,
18767
- showSubscriptionButton
19476
+ showSubscriptionButton,
19477
+ showOrderButton,
19478
+ order
18768
19479
  } = _ref;
18769
19480
  const {
18770
19481
  t
@@ -18772,12 +19483,23 @@ function PaymentMethodView(_ref) {
18772
19483
  const cardProcessor = getSiteCardProcessor();
18773
19484
  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);
18774
19485
  const supportsTap = 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);
19486
+ const supportsCybersource = Boolean((_window$Pelcro$site$r3 = window.Pelcro.site.read()) === null || _window$Pelcro$site$r3 === void 0 ? void 0 : _window$Pelcro$site$r3.cybersource_gateway_settings);
18775
19487
  const isUserFirstName = Boolean(window.Pelcro.user.read().first_name);
18776
19488
  const isUserLastName = Boolean(window.Pelcro.user.read().last_name);
18777
19489
  const isUserPhone = Boolean(window.Pelcro.user.read().phone);
18778
19490
  return /*#__PURE__*/React__default['default'].createElement("div", {
18779
19491
  className: "plc-flex plc-flex-col plc-items-center plc-mt-4 sm:plc-px-8 pelcro-payment-block"
18780
- }, cardProcessor === "stripe" && !showSubscriptionButton && /*#__PURE__*/React__default['default'].createElement("div", {
19492
+ }, order && /*#__PURE__*/React__default['default'].createElement("div", {
19493
+ className: "plc-w-full plc-p-2 plc-mb-4 plc-font-semibold plc-text-center plc-text-gray-900 plc-bg-gray-100 plc-border plc-border-gray-200"
19494
+ }, /*#__PURE__*/React__default['default'].createElement("p", {
19495
+ className: "plc-text-gray-600"
19496
+ }, !Array.isArray(order) ? /*#__PURE__*/React__default['default'].createElement("span", {
19497
+ className: "plc-tracking-wider plc-uppercase"
19498
+ }, order === null || order === void 0 ? void 0 : order.name) : /*#__PURE__*/React__default['default'].createElement("span", {
19499
+ className: "plc-tracking-wider plc-uppercase"
19500
+ }, t("labels.freeItems")), /*#__PURE__*/React__default['default'].createElement("br", null), /*#__PURE__*/React__default['default'].createElement("span", {
19501
+ className: "plc-text-xl plc-font-semibold plc-text-primary-600"
19502
+ }, (_calcAndFormatItemsTo = calcAndFormatItemsTotal(order, (_order$ = order[0]) === null || _order$ === void 0 ? void 0 : _order$.currency)) !== null && _calcAndFormatItemsTo !== void 0 ? _calcAndFormatItemsTo : getFormattedPriceByLocal(order === null || order === void 0 ? void 0 : order.price, order === null || order === void 0 ? void 0 : order.currency, getPageOrDefaultLanguage())))), cardProcessor === "stripe" && !showSubscriptionButton && !showOrderButton && /*#__PURE__*/React__default['default'].createElement("div", {
18781
19503
  className: "plc-flex plc-items-center plc-w-full plc-px-4 plc-py-2 plc-text-center plc-text-green-600 plc-border plc-border-green-400 plc-rounded plc-bg-green-50"
18782
19504
  }, /*#__PURE__*/React__default['default'].createElement(SvgLock, {
18783
19505
  className: "plc-w-5 plc-h-5 plc-mr-1"
@@ -18793,10 +19515,11 @@ function PaymentMethodView(_ref) {
18793
19515
  type: type,
18794
19516
  onSuccess: onSuccess,
18795
19517
  onGiftRenewalSuccess: onGiftRenewalSuccess,
18796
- onFailure: onFailure
19518
+ onFailure: onFailure,
19519
+ freeOrders: showOrderButton
18797
19520
  }, /*#__PURE__*/React__default['default'].createElement(AlertWithContext, {
18798
19521
  className: "plc-mb-2"
18799
- }), showSubscriptionButton ? /*#__PURE__*/React__default['default'].createElement(SubscriptionCreateFreePlanButton, null) : /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(BankRedirection, null), /*#__PURE__*/React__default['default'].createElement(BankAuthenticationSuccess, null), /*#__PURE__*/React__default['default'].createElement(SelectedPaymentMethod, null), supportsTap && (!isUserFirstName || !isUserLastName || !isUserPhone) && /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement("div", {
19522
+ }), showSubscriptionButton && /*#__PURE__*/React__default['default'].createElement(SubscriptionCreateFreePlanButton, null), showOrderButton && /*#__PURE__*/React__default['default'].createElement(OrderCreateFreeButton, null), !showSubscriptionButton && !showOrderButton && /*#__PURE__*/React__default['default'].createElement("div", null, /*#__PURE__*/React__default['default'].createElement(BankRedirection, null), /*#__PURE__*/React__default['default'].createElement(BankAuthenticationSuccess, null), /*#__PURE__*/React__default['default'].createElement(SelectedPaymentMethod, null), supportsTap && (!isUserFirstName || !isUserLastName || !isUserPhone) && /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement("div", {
18800
19523
  className: "plc-flex plc-items-start"
18801
19524
  }, /*#__PURE__*/React__default['default'].createElement(IncludeFirstName, {
18802
19525
  id: "pelcro-input-first-name",
@@ -18818,7 +19541,7 @@ function PaymentMethodView(_ref) {
18818
19541
  className: "plc-mb-2"
18819
19542
  }, /*#__PURE__*/React__default['default'].createElement(CouponCode, null), /*#__PURE__*/React__default['default'].createElement(DiscountedPrice, null)), /*#__PURE__*/React__default['default'].createElement(TaxAmount, null), /*#__PURE__*/React__default['default'].createElement("div", {
18820
19543
  className: "plc-grid plc-mt-4 plc-gap-y-2"
18821
- }, /*#__PURE__*/React__default['default'].createElement(SubmitPaymentMethod, null), showExternalPaymentMethods && !supportsVantiv && !supportsTap ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(PelcroPaymentRequestButton, null), /*#__PURE__*/React__default['default'].createElement(PaypalSubscribeButton, null)) : showExternalPaymentMethods && supportsVantiv ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(PaypalSubscribeButton, null)) : null)))));
19544
+ }, /*#__PURE__*/React__default['default'].createElement(SubmitPaymentMethod, null), showExternalPaymentMethods && !supportsVantiv && !supportsCybersource && !supportsTap ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(PelcroPaymentRequestButton, null), /*#__PURE__*/React__default['default'].createElement(PaypalSubscribeButton, null)) : showExternalPaymentMethods && supportsVantiv ? /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(PaypalSubscribeButton, null)) : null)))));
18822
19545
  }
18823
19546
 
18824
19547
  const SubscriptionRenewView = _ref => {
@@ -20551,6 +21274,16 @@ function SubscriptionManageMembersList(props) {
20551
21274
  icon: /*#__PURE__*/React__default['default'].createElement(SvgCheckMark, null)
20552
21275
  };
20553
21276
  }, []);
21277
+ const showMemberData = React.useCallback(member => {
21278
+ var _member$customer, _member$customer2, _member$customer3, _member$customer4;
21279
+ let data;
21280
+ if ((member === null || member === void 0 ? void 0 : member.status) !== "active") {
21281
+ data = member === null || member === void 0 ? void 0 : member.invitation_email;
21282
+ return data;
21283
+ }
21284
+ data = (member === null || member === void 0 ? void 0 : (_member$customer = member.customer) === null || _member$customer === void 0 ? void 0 : _member$customer.email) || (member === null || member === void 0 ? void 0 : (_member$customer2 = member.customer) === null || _member$customer2 === void 0 ? void 0 : _member$customer2.first_name) + " " + (member === null || member === void 0 ? void 0 : (_member$customer3 = member.customer) === null || _member$customer3 === void 0 ? void 0 : _member$customer3.last_name) || (member === null || member === void 0 ? void 0 : (_member$customer4 = member.customer) === null || _member$customer4 === void 0 ? void 0 : _member$customer4.username) || "-----";
21285
+ return data;
21286
+ }, []);
20554
21287
  if (loading) {
20555
21288
  return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement("tr", null, /*#__PURE__*/React__default['default'].createElement("td", null, /*#__PURE__*/React__default['default'].createElement("div", {
20556
21289
  className: "plc-animate-pulse"
@@ -20592,10 +21325,10 @@ function SubscriptionManageMembersList(props) {
20592
21325
  className: `plc-w-full plc-align-middle plc-cursor-pointer accordion-header hover:plc-bg-gray-50 plc-text-center`
20593
21326
  }, /*#__PURE__*/React__default['default'].createElement("td", {
20594
21327
  className: "plc-truncate plc-text-left",
20595
- title: member === null || member === void 0 ? void 0 : member.invitation_email
21328
+ title: showMemberData(member)
20596
21329
  }, /*#__PURE__*/React__default['default'].createElement("span", {
20597
21330
  className: "plc-font-semibold plc-text-gray-500"
20598
- }, member === null || member === void 0 ? void 0 : member.invitation_email)), /*#__PURE__*/React__default['default'].createElement("td", {
21331
+ }, showMemberData(member))), /*#__PURE__*/React__default['default'].createElement("td", {
20599
21332
  className: "plc-py-2"
20600
21333
  }, /*#__PURE__*/React__default['default'].createElement("span", {
20601
21334
  className: `plc-inline-flex plc-p-1 plc-text-xs plc-font-semibold ${getMemberStatus(member).bgColor} plc-uppercase ${getMemberStatus(member).textColor} plc-rounded-lg`
@@ -21830,37 +22563,6 @@ const AddressCreateSubmit = _ref => {
21830
22563
  }, otherProps), name !== null && name !== void 0 ? name : t("buttons.submit"));
21831
22564
  };
21832
22565
 
21833
- function Select(_ref) {
21834
- let {
21835
- label = "",
21836
- required,
21837
- id,
21838
- errorId,
21839
- error = "",
21840
- className = "",
21841
- labelClassName = "",
21842
- errorClassName = "",
21843
- wrapperClassName = "",
21844
- children,
21845
- ...otherProps
21846
- } = _ref;
21847
- return /*#__PURE__*/React__default['default'].createElement("div", {
21848
- className: `pelcro-input-wrapper ${wrapperClassName}`
21849
- }, /*#__PURE__*/React__default['default'].createElement("label", {
21850
- htmlFor: id,
21851
- className: `pelcro-input-label ${labelClassName}`
21852
- }, `${label}${required ? "*" : ""}`), /*#__PURE__*/React__default['default'].createElement("select", Object.assign({
21853
- id: id,
21854
- className: `pelcro-input-field ${className} ${error ? "pelcro-input-invalid" : ""}`,
21855
- "aria-describedby": errorId,
21856
- "aria-invalid": Boolean(error)
21857
- }, otherProps), children), error && /*#__PURE__*/React__default['default'].createElement("p", {
21858
- id: errorId,
21859
- "aria-live": "assertive",
21860
- className: `pelcro-input-error ${errorClassName}`
21861
- }, error));
21862
- }
21863
-
21864
22566
  function CountrySelect(_ref) {
21865
22567
  let {
21866
22568
  placeholder,
@@ -24203,9 +24905,15 @@ const OrderCreateContainer = props => /*#__PURE__*/React__default['default'].cre
24203
24905
  }, props));
24204
24906
 
24205
24907
  const OrderCreateView = props => {
24908
+ var _window$Pelcro, _window$Pelcro$uiSett;
24206
24909
  const {
24207
24910
  t
24208
24911
  } = useTranslation("payment");
24912
+ const {
24913
+ order
24914
+ } = usePelcro();
24915
+ const skipPayment = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.skipPaymentForFreePlans;
24916
+ const showOrderButton = skipPayment && ((order === null || order === void 0 ? void 0 : order.price) === 0 || (order === null || order === void 0 ? void 0 : order.length) > 0 && order.every(item => (item === null || item === void 0 ? void 0 : item.price) === 0));
24209
24917
  return /*#__PURE__*/React__default['default'].createElement("div", {
24210
24918
  id: "pelcro-order-create-view"
24211
24919
  }, /*#__PURE__*/React__default['default'].createElement("div", {
@@ -24216,7 +24924,9 @@ const OrderCreateView = props => {
24216
24924
  }, /*#__PURE__*/React__default['default'].createElement(PaymentMethodView, Object.assign({
24217
24925
  type: "orderCreate",
24218
24926
  showCoupon: true,
24219
- showExternalPaymentMethods: false
24927
+ showExternalPaymentMethods: false,
24928
+ showOrderButton: showOrderButton,
24929
+ order: order
24220
24930
  }, props))));
24221
24931
  };
24222
24932
 
@@ -25424,11 +26134,12 @@ const PaymentMethodSelectModal = _ref => {
25424
26134
  const {
25425
26135
  switchToCheckoutForm,
25426
26136
  set,
25427
- plan
26137
+ plan,
26138
+ order
25428
26139
  } = usePelcro();
25429
26140
  const skipPayment = (_window$Pelcro = window.Pelcro) === null || _window$Pelcro === void 0 ? void 0 : (_window$Pelcro$uiSett = _window$Pelcro.uiSettings) === null || _window$Pelcro$uiSett === void 0 ? void 0 : _window$Pelcro$uiSett.skipPaymentForFreePlans;
25430
26141
  React.useEffect(() => {
25431
- if (skipPayment && (plan === null || plan === void 0 ? void 0 : plan.amount) === 0) {
26142
+ if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || (order === null || order === void 0 ? void 0 : order.price) === 0)) {
25432
26143
  switchToCheckoutForm();
25433
26144
  }
25434
26145
  }, []);
@@ -27536,7 +28247,7 @@ const InvoicesItems = () => {
27536
28247
  setInvoice,
27537
28248
  switchView
27538
28249
  } = usePelcro();
27539
- const invoices = (_window$Pelcro$invoic = (_window$Pelcro$invoic2 = window.Pelcro.invoice.list()) === null || _window$Pelcro$invoic2 === void 0 ? void 0 : _window$Pelcro$invoic2.filter(invoice => invoice.total > 0)) !== null && _window$Pelcro$invoic !== void 0 ? _window$Pelcro$invoic : [];
28250
+ const invoices = (_window$Pelcro$invoic = (_window$Pelcro$invoic2 = window.Pelcro.invoice.list()) === null || _window$Pelcro$invoic2 === void 0 ? void 0 : _window$Pelcro$invoic2.filter(invoice => invoice.order_id || invoice.total > 0)) !== null && _window$Pelcro$invoic !== void 0 ? _window$Pelcro$invoic : [];
27540
28251
  const showInvoiceDetails = event => {
27541
28252
  if (setInvoice(event.target.dataset.id)) {
27542
28253
  switchView("invoice-details");
@@ -28304,7 +29015,7 @@ class Dashboard extends React.Component {
28304
29015
  }
28305
29016
  function hasInvoices() {
28306
29017
  var _window$Pelcro$invoic, _window$Pelcro$invoic2;
28307
- const invoices = (_window$Pelcro$invoic = (_window$Pelcro$invoic2 = window.Pelcro.invoice.list()) === null || _window$Pelcro$invoic2 === void 0 ? void 0 : _window$Pelcro$invoic2.filter(invoice => invoice.total > 0)) !== null && _window$Pelcro$invoic !== void 0 ? _window$Pelcro$invoic : [];
29018
+ const invoices = (_window$Pelcro$invoic = (_window$Pelcro$invoic2 = window.Pelcro.invoice.list()) === null || _window$Pelcro$invoic2 === void 0 ? void 0 : _window$Pelcro$invoic2.filter(invoice => invoice.order_id || invoice.total > 0)) !== null && _window$Pelcro$invoic !== void 0 ? _window$Pelcro$invoic : [];
28308
29019
  return invoices.length > 0;
28309
29020
  }
28310
29021
  function hasDonationSubs() {
@@ -32246,6 +32957,7 @@ exports.NewsletterUpdateView = NewsletterUpdateView;
32246
32957
  exports.Notification = Notification;
32247
32958
  exports.OrderConfirmModal = OrderConfirmModal;
32248
32959
  exports.OrderCreateContainer = OrderCreateContainer;
32960
+ exports.OrderCreateFreeButton = OrderCreateFreeButton;
32249
32961
  exports.OrderCreateModal = OrderCreateModal;
32250
32962
  exports.OrderCreateSubmitButton = OrderCreateSubmitButton;
32251
32963
  exports.OrderCreateView = OrderCreateView;