@pelcro/react-pelcro-js 3.21.7 → 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.esm.js CHANGED
@@ -10847,13 +10847,16 @@ const debounce = (func, waitTime) => {
10847
10847
  };
10848
10848
  };
10849
10849
  function getSiteCardProcessor() {
10850
- var _window$Pelcro$site$r, _window$Pelcro$site$r2;
10850
+ var _window$Pelcro$site$r, _window$Pelcro$site$r2, _window$Pelcro$site$r3;
10851
10851
  if ((_window$Pelcro$site$r = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r !== void 0 && _window$Pelcro$site$r.vantiv_gateway_settings) {
10852
10852
  return "vantiv";
10853
10853
  }
10854
10854
  if ((_window$Pelcro$site$r2 = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r2 !== void 0 && _window$Pelcro$site$r2.tap_gateway_settings) {
10855
10855
  return "tap";
10856
10856
  }
10857
+ if ((_window$Pelcro$site$r3 = window.Pelcro.site.read()) !== null && _window$Pelcro$site$r3 !== void 0 && _window$Pelcro$site$r3.cybersource_gateway_settings) {
10858
+ return "cybersource";
10859
+ }
10857
10860
  return "stripe";
10858
10861
  }
10859
10862
 
@@ -11714,6 +11717,8 @@ const SET_FIRST_NAME_ERROR = "SET_FIRST_NAME_ERROR";
11714
11717
  const SET_LAST_NAME_ERROR = "SET_LAST_NAME_ERROR";
11715
11718
  const SET_PHONE_ERROR = "SET_PHONE_ERROR";
11716
11719
  const SET_TEXT_FIELD = "SET_TEXT_FIELD";
11720
+ const SET_MONTH = "SET_MONTH";
11721
+ const SET_YEAR = "SET_YEAR";
11717
11722
  const SET_TOKEN = "SET_TOKEN";
11718
11723
  const SET_GIFT_CODE = "SET_GIFT_CODE";
11719
11724
  const RESET_LOGIN_FORM = "RESET_LOGIN_FORM";
@@ -15473,7 +15478,7 @@ var _isPaymentGatewayInvalid = /*#__PURE__*/new WeakMap();
15473
15478
  var _generateUserError = /*#__PURE__*/new WeakMap();
15474
15479
  class Payment {
15475
15480
  /**
15476
- * @param {(StripeGateway|PaypalGateway|VantivGateway|TapGateway)} paymentGateway
15481
+ * @param {(StripeGateway|PaypalGateway|VantivGateway|TapGateway|CybersourceGateway)} paymentGateway
15477
15482
  */
15478
15483
  constructor(paymentGateway) {
15479
15484
  _defineProperty$3(this, "execute", (options, callback) => {
@@ -15492,7 +15497,7 @@ class Payment {
15492
15497
  _classPrivateFieldInitSpec$1(this, _isPaymentGatewayInvalid, {
15493
15498
  writable: true,
15494
15499
  value: gateway => {
15495
- return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway || gateway instanceof TapGateway);
15500
+ return gateway && !(gateway instanceof StripeGateway || gateway instanceof PaypalGateway || gateway instanceof VantivGateway || gateway instanceof TapGateway || gateway instanceof CybersourceGateway);
15496
15501
  }
15497
15502
  });
15498
15503
  _classPrivateFieldInitSpec$1(this, _generateUserError, {
@@ -15546,7 +15551,8 @@ const PAYMENT_GATEWAYS_ENUM = {
15546
15551
  stripe: "stripe",
15547
15552
  paypal: "braintree",
15548
15553
  vantiv: "vantiv",
15549
- tap: "tap"
15554
+ tap: "tap",
15555
+ cybersource: "cybersource"
15550
15556
  };
15551
15557
 
15552
15558
  /**
@@ -16268,6 +16274,222 @@ class TapGateway {
16268
16274
  }
16269
16275
  }
16270
16276
 
16277
+ /**
16278
+ * Cybersource gateway strategy
16279
+ */
16280
+ var _paymentGateway5 = /*#__PURE__*/new WeakMap();
16281
+ var _createSubscription5 = /*#__PURE__*/new WeakMap();
16282
+ var _renewSubscription4 = /*#__PURE__*/new WeakMap();
16283
+ var _createGiftedSubscription5 = /*#__PURE__*/new WeakMap();
16284
+ var _renewGiftedSubscription4 = /*#__PURE__*/new WeakMap();
16285
+ var _purchaseEcommerceOrder4 = /*#__PURE__*/new WeakMap();
16286
+ var _payInvoice5 = /*#__PURE__*/new WeakMap();
16287
+ class CybersourceGateway {
16288
+ constructor() {
16289
+ _classPrivateFieldInitSpec$1(this, _paymentGateway5, {
16290
+ writable: true,
16291
+ value: PAYMENT_GATEWAYS_ENUM["cybersource"]
16292
+ });
16293
+ _defineProperty$3(this, "execute", (options, callback) => {
16294
+ const types = PAYMENT_TYPES;
16295
+ switch (options.type) {
16296
+ case types.CREATE_SUBSCRIPTION:
16297
+ return _classPrivateFieldGet(this, _createSubscription5).call(this, options, callback);
16298
+ case types.RENEW_SUBSCRIPTION:
16299
+ return _classPrivateFieldGet(this, _renewSubscription4).call(this, options, callback);
16300
+ case types.CREATE_GIFTED_SUBSCRIPTION:
16301
+ return _classPrivateFieldGet(this, _createGiftedSubscription5).call(this, options, callback);
16302
+ case types.RENEW_GIFTED_SUBSCRIPTION:
16303
+ return _classPrivateFieldGet(this, _renewGiftedSubscription4).call(this, options, callback);
16304
+ case types.PURCHASE_ECOMMERCE_ORDER:
16305
+ return _classPrivateFieldGet(this, _purchaseEcommerceOrder4).call(this, options, callback);
16306
+ case types.PAY_INVOICE:
16307
+ return _classPrivateFieldGet(this, _payInvoice5).call(this, options, callback);
16308
+ default:
16309
+ console.error("Unsupported payment method: cybersource Gateway");
16310
+ }
16311
+ });
16312
+ _classPrivateFieldInitSpec$1(this, _createSubscription5, {
16313
+ writable: true,
16314
+ value: (options, callback) => {
16315
+ const {
16316
+ token,
16317
+ plan,
16318
+ couponCode,
16319
+ product,
16320
+ quantity = 1,
16321
+ addressId,
16322
+ isExistingSource
16323
+ } = options;
16324
+ const params = isExistingSource ? {
16325
+ source_id: token
16326
+ } : {
16327
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
16328
+ gateway_token: token
16329
+ };
16330
+ window.Pelcro.subscription.create({
16331
+ quantity,
16332
+ auth_token: window.Pelcro.user.read().auth_token,
16333
+ plan_id: plan.id,
16334
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
16335
+ coupon_code: couponCode,
16336
+ address_id: product.address_required ? addressId : null,
16337
+ ...params
16338
+ }, (err, res) => {
16339
+ callback(err, res);
16340
+ });
16341
+ }
16342
+ });
16343
+ _classPrivateFieldInitSpec$1(this, _renewSubscription4, {
16344
+ writable: true,
16345
+ value: (options, callback) => {
16346
+ const {
16347
+ subscriptionIdToRenew,
16348
+ token,
16349
+ plan,
16350
+ couponCode,
16351
+ product,
16352
+ addressId,
16353
+ isExistingSource
16354
+ } = options;
16355
+ const params = isExistingSource ? {
16356
+ source_id: token
16357
+ } : {
16358
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
16359
+ gateway_token: token
16360
+ };
16361
+ window.Pelcro.subscription.renew({
16362
+ auth_token: window.Pelcro.user.read().auth_token,
16363
+ plan_id: plan.id,
16364
+ coupon_code: couponCode,
16365
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
16366
+ subscription_id: subscriptionIdToRenew,
16367
+ address_id: product.address_required ? addressId : null,
16368
+ ...params
16369
+ }, (err, res) => {
16370
+ callback(err, res);
16371
+ });
16372
+ }
16373
+ });
16374
+ _classPrivateFieldInitSpec$1(this, _createGiftedSubscription5, {
16375
+ writable: true,
16376
+ value: (options, callback) => {
16377
+ const {
16378
+ token,
16379
+ plan,
16380
+ couponCode,
16381
+ product,
16382
+ giftRecipient,
16383
+ quantity = 1,
16384
+ addressId,
16385
+ isExistingSource
16386
+ } = options;
16387
+ const params = isExistingSource ? {
16388
+ source_id: token
16389
+ } : {
16390
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
16391
+ gateway_token: token
16392
+ };
16393
+ window.Pelcro.subscription.create({
16394
+ quantity,
16395
+ auth_token: window.Pelcro.user.read().auth_token,
16396
+ plan_id: plan.id,
16397
+ coupon_code: couponCode,
16398
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
16399
+ gift_recipient_email: giftRecipient.email,
16400
+ gift_recipient_first_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.firstName,
16401
+ gift_recipient_last_name: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.lastName,
16402
+ gift_start_date: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.startDate,
16403
+ gift_message: giftRecipient === null || giftRecipient === void 0 ? void 0 : giftRecipient.giftMessage,
16404
+ address_id: product.address_required ? addressId : null,
16405
+ ...params
16406
+ }, (err, res) => {
16407
+ callback(err, res);
16408
+ });
16409
+ }
16410
+ });
16411
+ _classPrivateFieldInitSpec$1(this, _renewGiftedSubscription4, {
16412
+ writable: true,
16413
+ value: (options, callback) => {
16414
+ const {
16415
+ subscriptionIdToRenew,
16416
+ token,
16417
+ product,
16418
+ plan,
16419
+ couponCode,
16420
+ addressId,
16421
+ isExistingSource
16422
+ } = options;
16423
+ const params = isExistingSource ? {
16424
+ source_id: token
16425
+ } : {
16426
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
16427
+ gateway_token: token
16428
+ };
16429
+ window.Pelcro.subscription.renewGift({
16430
+ auth_token: window.Pelcro.user.read().auth_token,
16431
+ plan_id: plan.id,
16432
+ coupon_code: couponCode,
16433
+ subscription_id: subscriptionIdToRenew,
16434
+ address_id: product.address_required ? addressId : null,
16435
+ ...params
16436
+ }, (err, res) => {
16437
+ callback(err, res);
16438
+ });
16439
+ }
16440
+ });
16441
+ _classPrivateFieldInitSpec$1(this, _purchaseEcommerceOrder4, {
16442
+ writable: true,
16443
+ value: (options, callback) => {
16444
+ const {
16445
+ token,
16446
+ items,
16447
+ couponCode,
16448
+ addressId,
16449
+ isExistingSource
16450
+ } = options;
16451
+ const params = isExistingSource ? {
16452
+ source_id: token
16453
+ } : {
16454
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
16455
+ gateway_token: token
16456
+ };
16457
+ window.Pelcro.ecommerce.order.create({
16458
+ items,
16459
+ coupon_code: couponCode,
16460
+ campaign_key: window.Pelcro.helpers.getURLParameter("campaign_key"),
16461
+ ...params,
16462
+ ...(addressId && {
16463
+ address_id: addressId
16464
+ })
16465
+ }, (err, res) => {
16466
+ callback(err, res);
16467
+ });
16468
+ }
16469
+ });
16470
+ _classPrivateFieldInitSpec$1(this, _payInvoice5, {
16471
+ writable: true,
16472
+ value: (options, callback) => {
16473
+ const {
16474
+ token,
16475
+ invoiceId
16476
+ } = options;
16477
+ const params = options.isExistingSource ? {
16478
+ source_id: token,
16479
+ invoice_id: invoiceId
16480
+ } : {
16481
+ payment_gateway: _classPrivateFieldGet(this, _paymentGateway5),
16482
+ gateway_token: token,
16483
+ invoice_id: invoiceId
16484
+ };
16485
+ window.Pelcro.invoice.pay(params, (err, res) => {
16486
+ callback(err, res);
16487
+ });
16488
+ }
16489
+ });
16490
+ }
16491
+ }
16492
+
16271
16493
  /**
16272
16494
  * @typedef {Object} PaymentStateType
16273
16495
  * @property {boolean} disableSubmit
@@ -16307,6 +16529,8 @@ const initialState$k = {
16307
16529
  firstNameError: null,
16308
16530
  lastNameError: null,
16309
16531
  phoneError: null,
16532
+ month: "",
16533
+ year: "",
16310
16534
  alert: {
16311
16535
  type: "error",
16312
16536
  content: ""
@@ -16372,9 +16596,250 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16372
16596
  updateTotalAmountWithTax();
16373
16597
  }, []);
16374
16598
 
16599
+ /*====== Start Cybersource integration ========*/
16600
+ const cybersourceErrorHandle = err => {
16601
+ var _err$details, _err$details$response;
16602
+ const errorMessages = [];
16603
+
16604
+ // enumerable error (ex: validation errors)
16605
+ 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 => {
16606
+ let {
16607
+ message
16608
+ } = _ref2;
16609
+ errorMessages.push(message);
16610
+ });
16611
+
16612
+ // convert to multiline string
16613
+ return errorMessages.join("\n");
16614
+ };
16615
+ const submitUsingCybersource = (state, dispatch) => {
16616
+ var _cybersourceInstanceR;
16617
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
16618
+ if (isUsingExistingPaymentMethod) {
16619
+ // no need to create a new source using cybersrce
16620
+ return handleCybersourcePayment(null, state);
16621
+ }
16622
+ if (!cybersourceInstanceRef.current) {
16623
+ return console.error("Cybersource sdk script wasn't loaded, you need to load Cybersource sdk before rendering the Cybersource payment flow");
16624
+ }
16625
+ let options = {
16626
+ cardExpirationMonth: state.month,
16627
+ cardExpirationYear: state.year
16628
+ };
16629
+ (_cybersourceInstanceR = cybersourceInstanceRef.current) === null || _cybersourceInstanceR === void 0 ? void 0 : _cybersourceInstanceR.createToken(options, function (err, response) {
16630
+ if (err) {
16631
+ dispatch({
16632
+ type: DISABLE_SUBMIT,
16633
+ payload: false
16634
+ });
16635
+ dispatch({
16636
+ type: LOADING,
16637
+ payload: false
16638
+ });
16639
+ return dispatch({
16640
+ type: SHOW_ALERT,
16641
+ payload: {
16642
+ type: "error",
16643
+ content: cybersourceErrorHandle(err)
16644
+ }
16645
+ });
16646
+ }
16647
+ handleCybersourcePayment(response.token, state);
16648
+ });
16649
+ };
16650
+ function handleCybersourcePayment(paymentRequest, state) {
16651
+ const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
16652
+ if (type === "createPayment") {
16653
+ handleCybersourceSubscription();
16654
+ } else if (type === "orderCreate") {
16655
+ purchase(new CybersourceGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest, state, dispatch);
16656
+ } else if (type === "invoicePayment") {
16657
+ payInvoice(new CybersourceGateway(), isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest);
16658
+ } else if (type === "updatePaymentSource") {
16659
+ createNewCybersourceCard();
16660
+ }
16661
+ function createNewCybersourceCard() {
16662
+ window.Pelcro.source.create({
16663
+ auth_token: window.Pelcro.user.read().auth_token,
16664
+ token: paymentRequest,
16665
+ gateway: "cybersource"
16666
+ }, (err, res) => {
16667
+ dispatch({
16668
+ type: DISABLE_SUBMIT,
16669
+ payload: false
16670
+ });
16671
+ dispatch({
16672
+ type: LOADING,
16673
+ payload: false
16674
+ });
16675
+ toggleAuthenticationSuccessPendingView(false);
16676
+ if (err) {
16677
+ onFailure(err);
16678
+ return dispatch({
16679
+ type: SHOW_ALERT,
16680
+ payload: {
16681
+ type: "error",
16682
+ content: getErrorMessages(err)
16683
+ }
16684
+ });
16685
+ }
16686
+ dispatch({
16687
+ type: SHOW_ALERT,
16688
+ payload: {
16689
+ type: "success",
16690
+ content: t("messages.sourceUpdated")
16691
+ }
16692
+ });
16693
+ onSuccess(res);
16694
+ } //
16695
+ );
16696
+ }
16697
+
16698
+ function handleCybersourceSubscription() {
16699
+ const payment = new Payment(new CybersourceGateway());
16700
+ const createSubscription = !isGift && !subscriptionIdToRenew;
16701
+ const renewSubscription = !isGift && subscriptionIdToRenew;
16702
+ const giftSubscriprition = isGift && !subscriptionIdToRenew;
16703
+ const renewGift = isRenewingGift;
16704
+ const {
16705
+ couponCode
16706
+ } = state;
16707
+ if (renewGift) {
16708
+ return payment.execute({
16709
+ type: PAYMENT_TYPES.RENEW_GIFTED_SUBSCRIPTION,
16710
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
16711
+ plan,
16712
+ couponCode,
16713
+ product,
16714
+ isExistingSource: isUsingExistingPaymentMethod,
16715
+ subscriptionIdToRenew,
16716
+ addressId: selectedAddressId
16717
+ }, (err, res) => {
16718
+ if (err) {
16719
+ return handlePaymentError(err);
16720
+ }
16721
+ onSuccess(res);
16722
+ });
16723
+ } else if (giftSubscriprition) {
16724
+ return payment.execute({
16725
+ type: PAYMENT_TYPES.CREATE_GIFTED_SUBSCRIPTION,
16726
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
16727
+ quantity: plan.quantity,
16728
+ plan,
16729
+ couponCode,
16730
+ product,
16731
+ isExistingSource: isUsingExistingPaymentMethod,
16732
+ giftRecipient,
16733
+ addressId: selectedAddressId
16734
+ }, (err, res) => {
16735
+ if (err) {
16736
+ return handlePaymentError(err);
16737
+ }
16738
+ onSuccess(res);
16739
+ });
16740
+ } else if (renewSubscription) {
16741
+ return payment.execute({
16742
+ type: PAYMENT_TYPES.RENEW_SUBSCRIPTION,
16743
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
16744
+ quantity: plan.quantity,
16745
+ plan,
16746
+ couponCode,
16747
+ product,
16748
+ isExistingSource: isUsingExistingPaymentMethod,
16749
+ subscriptionIdToRenew,
16750
+ addressId: selectedAddressId
16751
+ }, (err, res) => {
16752
+ if (err) {
16753
+ return handlePaymentError(err);
16754
+ }
16755
+ onSuccess(res);
16756
+ });
16757
+ } else if (createSubscription) {
16758
+ return payment.execute({
16759
+ type: PAYMENT_TYPES.CREATE_SUBSCRIPTION,
16760
+ token: isUsingExistingPaymentMethod ? selectedPaymentMethodId : paymentRequest,
16761
+ quantity: plan.quantity,
16762
+ plan,
16763
+ couponCode,
16764
+ product,
16765
+ isExistingSource: isUsingExistingPaymentMethod,
16766
+ addressId: selectedAddressId
16767
+ }, (err, res) => {
16768
+ if (err) {
16769
+ return handlePaymentError(err);
16770
+ }
16771
+ onSuccess(res);
16772
+ });
16773
+ }
16774
+ }
16775
+ }
16776
+ const tokenizeCard = (error, microformInstance) => {
16777
+ if (error) {
16778
+ return;
16779
+ }
16780
+ cybersourceInstanceRef.current = microformInstance;
16781
+ };
16782
+ const initCybersourceScript = () => {
16783
+ // jwk api call
16784
+ window.Pelcro.payment.getJWK({
16785
+ auth_token: window.Pelcro.user.read().auth_token,
16786
+ site_id: window.Pelcro.siteid
16787
+ }, (err, res) => {
16788
+ if (err) {
16789
+ onFailure(err);
16790
+ dispatch({
16791
+ type: DISABLE_SUBMIT,
16792
+ payload: false
16793
+ });
16794
+ dispatch({
16795
+ type: LOADING,
16796
+ payload: false
16797
+ });
16798
+ return dispatch({
16799
+ type: SHOW_ALERT,
16800
+ payload: {
16801
+ type: "error",
16802
+ content: getErrorMessages(err)
16803
+ }
16804
+ });
16805
+ }
16806
+ const {
16807
+ key: jwk
16808
+ } = res;
16809
+ // SETUP MICROFORM
16810
+ FLEX.microform({
16811
+ keyId: jwk.kid,
16812
+ keystore: jwk,
16813
+ container: "#cybersourceCardNumber",
16814
+ placeholder: "Card Number",
16815
+ styles: {
16816
+ input: {
16817
+ "font-size": "14px",
16818
+ "font-family": "helvetica, tahoma, calibri, sans-serif",
16819
+ color: "#555"
16820
+ },
16821
+ ":focus": {
16822
+ color: "blue"
16823
+ },
16824
+ ":disabled": {
16825
+ cursor: "not-allowed"
16826
+ },
16827
+ valid: {
16828
+ color: "#3c763d"
16829
+ },
16830
+ invalid: {
16831
+ color: "#a94442"
16832
+ }
16833
+ }
16834
+ }, tokenizeCard);
16835
+ });
16836
+ };
16837
+
16838
+ /*====== End Cybersource integration ========*/
16839
+
16375
16840
  /*====== Start Tap integration ========*/
16376
16841
  const submitUsingTap = state => {
16377
- var _ref2, _ref3, _ref4, _state$updatedPrice;
16842
+ var _ref3, _ref4, _ref5, _state$updatedPrice;
16378
16843
  const isUsingExistingPaymentMethod = Boolean(selectedPaymentMethodId);
16379
16844
  if (isUsingExistingPaymentMethod) {
16380
16845
  // no need to create a new source using tap
@@ -16398,7 +16863,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16398
16863
  return total + item.price * item.quantity;
16399
16864
  }, 0);
16400
16865
  };
16401
- 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;
16866
+ 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;
16402
16867
  tapInstanceRef.current.createToken(tapInstanceCard.current).then(function (result) {
16403
16868
  if (result.error) {
16404
16869
  // Inform the user if there was an error
@@ -16815,6 +17280,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16815
17280
  const vantivInstanceRef = React__default.useRef(null);
16816
17281
  const tapInstanceRef = React__default.useRef(null);
16817
17282
  const tapInstanceCard = React__default.useRef(null);
17283
+ const cybersourceInstanceRef = React__default.useRef(null);
16818
17284
  useEffect(() => {
16819
17285
  if (skipPayment && ((plan === null || plan === void 0 ? void 0 : plan.amount) === 0 || props !== null && props !== void 0 && props.freeOrders)) return;
16820
17286
  if (cardProcessor === "vantiv" && !selectedPaymentMethodId) {
@@ -16863,6 +17329,15 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16863
17329
  if (cardProcessor === "tap" && !selectedPaymentMethodId && window.Tapjsli) {
16864
17330
  initTapScript();
16865
17331
  }
17332
+ if (cardProcessor === "cybersource" && !selectedPaymentMethodId && !window.FLEX) {
17333
+ window.Pelcro.helpers.loadSDK("https://flex.cybersource.com/cybersource/assets/microform/0.4/flex-microform.min.js", "cybersource-cdn");
17334
+ document.querySelector('script[src="https://flex.cybersource.com/cybersource/assets/microform/0.4/flex-microform.min.js"]').addEventListener("load", () => {
17335
+ initCybersourceScript();
17336
+ });
17337
+ }
17338
+ if (cardProcessor === "cybersource" && !selectedPaymentMethodId && window.FLEX) {
17339
+ initCybersourceScript();
17340
+ }
16866
17341
  });
16867
17342
  }, [selectedPaymentMethodId]);
16868
17343
  const initPaymentRequest = (state, dispatch) => {
@@ -16878,13 +17353,13 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16878
17353
  });
16879
17354
 
16880
17355
  // When Google pay / Apple pay source created
16881
- paymentRequest.on("source", _ref5 => {
17356
+ paymentRequest.on("source", _ref6 => {
16882
17357
  var _source$card;
16883
17358
  let {
16884
17359
  complete,
16885
17360
  source,
16886
17361
  ...data
16887
- } = _ref5;
17362
+ } = _ref6;
16888
17363
  dispatch({
16889
17364
  type: DISABLE_COUPON_BUTTON,
16890
17365
  payload: true
@@ -16899,11 +17374,11 @@ const PaymentMethodContainerWithoutStripe = _ref => {
16899
17374
  });
16900
17375
  complete("success");
16901
17376
  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") {
16902
- return generate3DSecureSource(source).then(_ref6 => {
17377
+ return generate3DSecureSource(source).then(_ref7 => {
16903
17378
  let {
16904
17379
  source,
16905
17380
  error
16906
- } = _ref6;
17381
+ } = _ref7;
16907
17382
  if (error) {
16908
17383
  return handlePaymentError(error);
16909
17384
  }
@@ -17503,12 +17978,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17503
17978
  const updatePaymentSource = (state, dispatch) => {
17504
17979
  return stripe.createSource({
17505
17980
  type: "card"
17506
- }).then(_ref7 => {
17981
+ }).then(_ref8 => {
17507
17982
  var _source$card2;
17508
17983
  let {
17509
17984
  source,
17510
17985
  error
17511
- } = _ref7;
17986
+ } = _ref8;
17512
17987
  if (error) {
17513
17988
  return handlePaymentError(error);
17514
17989
  }
@@ -17589,12 +18064,12 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17589
18064
  }
17590
18065
  stripe.createSource({
17591
18066
  type: "card"
17592
- }).then(_ref8 => {
17593
- var _ref9, _ref10, _state$updatedPrice2;
18067
+ }).then(_ref9 => {
18068
+ var _ref10, _ref11, _state$updatedPrice2;
17594
18069
  let {
17595
18070
  source,
17596
18071
  error
17597
- } = _ref8;
18072
+ } = _ref9;
17598
18073
  if (error) {
17599
18074
  return handlePaymentError(error);
17600
18075
  }
@@ -17613,7 +18088,7 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17613
18088
  return total + item.price * item.quantity;
17614
18089
  }, 0);
17615
18090
  };
17616
- (_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();
18091
+ (_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();
17617
18092
  return handlePayment(source);
17618
18093
  }).catch(error => {
17619
18094
  return handlePaymentError(error);
@@ -17829,6 +18304,9 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17829
18304
  if (getSiteCardProcessor() === "tap") {
17830
18305
  return submitUsingTap(state);
17831
18306
  }
18307
+ if (getSiteCardProcessor() === "cybersource") {
18308
+ return submitUsingCybersource(state, dispatch);
18309
+ }
17832
18310
  if (selectedPaymentMethodId) {
17833
18311
  // pay with selected method (source) if exists already
17834
18312
  return handlePayment({
@@ -17896,6 +18374,16 @@ const PaymentMethodContainerWithoutStripe = _ref => {
17896
18374
  ...state,
17897
18375
  percentOff: action.payload
17898
18376
  });
18377
+ case SET_MONTH:
18378
+ return lib_7({
18379
+ ...state,
18380
+ month: action.payload
18381
+ });
18382
+ case SET_YEAR:
18383
+ return lib_7({
18384
+ ...state,
18385
+ year: action.payload
18386
+ });
17899
18387
  case SET_FIRST_NAME:
17900
18388
  return lib_7({
17901
18389
  ...state,
@@ -17994,6 +18482,114 @@ const PaymentMethodContainer = props => {
17994
18482
  return null;
17995
18483
  };
17996
18484
 
18485
+ function Select(_ref) {
18486
+ let {
18487
+ label = "",
18488
+ required,
18489
+ id,
18490
+ errorId,
18491
+ error = "",
18492
+ className = "",
18493
+ labelClassName = "",
18494
+ errorClassName = "",
18495
+ wrapperClassName = "",
18496
+ children,
18497
+ ...otherProps
18498
+ } = _ref;
18499
+ return /*#__PURE__*/React__default.createElement("div", {
18500
+ className: `pelcro-input-wrapper ${wrapperClassName}`
18501
+ }, /*#__PURE__*/React__default.createElement("label", {
18502
+ htmlFor: id,
18503
+ className: `pelcro-input-label ${labelClassName}`
18504
+ }, `${label}${required ? "*" : ""}`), /*#__PURE__*/React__default.createElement("select", Object.assign({
18505
+ id: id,
18506
+ className: `pelcro-input-field ${className} ${error ? "pelcro-input-invalid" : ""}`,
18507
+ "aria-describedby": errorId,
18508
+ "aria-invalid": Boolean(error)
18509
+ }, otherProps), children), error && /*#__PURE__*/React__default.createElement("p", {
18510
+ id: errorId,
18511
+ "aria-live": "assertive",
18512
+ className: `pelcro-input-error ${errorClassName}`
18513
+ }, error));
18514
+ }
18515
+
18516
+ function MonthSelect(_ref) {
18517
+ let {
18518
+ placeholder,
18519
+ store,
18520
+ ...otherProps
18521
+ } = _ref;
18522
+ const {
18523
+ dispatch,
18524
+ state: {
18525
+ month
18526
+ }
18527
+ } = useContext(store);
18528
+ const get2digits = num => num < 10 ? "0" + num.toString() : num.toString();
18529
+ const createMonthsItems = useMemo(() => {
18530
+ return [...Array.from({
18531
+ length: 12
18532
+ }, (_, i) => i + 1)].map(i => {
18533
+ return /*#__PURE__*/React__default.createElement("option", {
18534
+ key: i,
18535
+ value: get2digits(i)
18536
+ }, get2digits(i));
18537
+ });
18538
+ }, []);
18539
+ const handleInputChange = value => {
18540
+ dispatch({
18541
+ type: SET_MONTH,
18542
+ payload: value
18543
+ });
18544
+ };
18545
+ return /*#__PURE__*/React__default.createElement(Select, Object.assign({
18546
+ value: month,
18547
+ onChange: e => handleInputChange(e.target.value)
18548
+ }, otherProps), /*#__PURE__*/React__default.createElement("option", {
18549
+ value: "",
18550
+ disabled: true,
18551
+ selected: true
18552
+ }, placeholder), createMonthsItems);
18553
+ }
18554
+
18555
+ function YearSelect(_ref) {
18556
+ let {
18557
+ placeholder,
18558
+ store,
18559
+ ...otherProps
18560
+ } = _ref;
18561
+ const {
18562
+ dispatch,
18563
+ state: {
18564
+ year
18565
+ }
18566
+ } = useContext(store);
18567
+ const createYearsItems = useMemo(() => {
18568
+ return Array.from({
18569
+ length: 10
18570
+ }, (_, i) => i + new Date().getFullYear()).map(i => {
18571
+ return /*#__PURE__*/React__default.createElement("option", {
18572
+ key: i,
18573
+ value: i
18574
+ }, i);
18575
+ });
18576
+ }, []);
18577
+ const handleInputChange = value => {
18578
+ dispatch({
18579
+ type: SET_YEAR,
18580
+ payload: value
18581
+ });
18582
+ };
18583
+ return /*#__PURE__*/React__default.createElement(Select, Object.assign({
18584
+ value: year,
18585
+ onChange: e => handleInputChange(e.target.value)
18586
+ }, otherProps), /*#__PURE__*/React__default.createElement("option", {
18587
+ value: "",
18588
+ disabled: true,
18589
+ selected: true
18590
+ }, placeholder), createYearsItems);
18591
+ }
18592
+
17997
18593
  const StripeInputStyle = {
17998
18594
  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",
17999
18595
  focus: "plc-ring-2 plc-ring-primary-400",
@@ -18083,6 +18679,24 @@ const CheckoutForm = () => {
18083
18679
  id: "tapPaymentIframe"
18084
18680
  });
18085
18681
  }
18682
+ if (cardProcessor === "cybersource") {
18683
+ return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("div", {
18684
+ id: "cybersourceCardNumber",
18685
+ className: "pelcro-input-field plc-h-12"
18686
+ }), /*#__PURE__*/React__default.createElement("div", {
18687
+ className: "plc-flex plc-items-end plc-justify-between plc-my-2"
18688
+ }, /*#__PURE__*/React__default.createElement("div", {
18689
+ className: "plc-w-6/12 plc-pr-4"
18690
+ }, /*#__PURE__*/React__default.createElement(MonthSelect, {
18691
+ store: store$k,
18692
+ placeholder: "Exp Month"
18693
+ })), /*#__PURE__*/React__default.createElement("div", {
18694
+ className: "plc-w-6/12"
18695
+ }, /*#__PURE__*/React__default.createElement(YearSelect, {
18696
+ store: store$k,
18697
+ placeholder: "Exp Year"
18698
+ }))));
18699
+ }
18086
18700
  if (cardProcessor === "stripe") {
18087
18701
  return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(PelcroCardNumber, {
18088
18702
  autoFocus: true
@@ -18821,7 +19435,7 @@ const OrderCreateFreeButton = _ref => {
18821
19435
  *
18822
19436
  */
18823
19437
  function PaymentMethodView(_ref) {
18824
- var _window$Pelcro$site$r, _window$Pelcro$site$r2, _calcAndFormatItemsTo, _order$;
19438
+ var _window$Pelcro$site$r, _window$Pelcro$site$r2, _window$Pelcro$site$r3, _calcAndFormatItemsTo, _order$;
18825
19439
  let {
18826
19440
  onSuccess,
18827
19441
  onGiftRenewalSuccess,
@@ -18839,6 +19453,7 @@ function PaymentMethodView(_ref) {
18839
19453
  const cardProcessor = getSiteCardProcessor();
18840
19454
  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);
18841
19455
  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);
19456
+ 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);
18842
19457
  const isUserFirstName = Boolean(window.Pelcro.user.read().first_name);
18843
19458
  const isUserLastName = Boolean(window.Pelcro.user.read().last_name);
18844
19459
  const isUserPhone = Boolean(window.Pelcro.user.read().phone);
@@ -18896,7 +19511,7 @@ function PaymentMethodView(_ref) {
18896
19511
  className: "plc-mb-2"
18897
19512
  }, /*#__PURE__*/React__default.createElement(CouponCode, null), /*#__PURE__*/React__default.createElement(DiscountedPrice, null)), /*#__PURE__*/React__default.createElement(TaxAmount, null), /*#__PURE__*/React__default.createElement("div", {
18898
19513
  className: "plc-grid plc-mt-4 plc-gap-y-2"
18899
- }, /*#__PURE__*/React__default.createElement(SubmitPaymentMethod, null), showExternalPaymentMethods && !supportsVantiv && !supportsTap ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(PelcroPaymentRequestButton, null), /*#__PURE__*/React__default.createElement(PaypalSubscribeButton, null)) : showExternalPaymentMethods && supportsVantiv ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(PaypalSubscribeButton, null)) : null)))));
19514
+ }, /*#__PURE__*/React__default.createElement(SubmitPaymentMethod, null), showExternalPaymentMethods && !supportsVantiv && !supportsCybersource && !supportsTap ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(PelcroPaymentRequestButton, null), /*#__PURE__*/React__default.createElement(PaypalSubscribeButton, null)) : showExternalPaymentMethods && supportsVantiv ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(PaypalSubscribeButton, null)) : null)))));
18900
19515
  }
18901
19516
 
18902
19517
  const SubscriptionRenewView = _ref => {
@@ -21918,37 +22533,6 @@ const AddressCreateSubmit = _ref => {
21918
22533
  }, otherProps), name !== null && name !== void 0 ? name : t("buttons.submit"));
21919
22534
  };
21920
22535
 
21921
- function Select(_ref) {
21922
- let {
21923
- label = "",
21924
- required,
21925
- id,
21926
- errorId,
21927
- error = "",
21928
- className = "",
21929
- labelClassName = "",
21930
- errorClassName = "",
21931
- wrapperClassName = "",
21932
- children,
21933
- ...otherProps
21934
- } = _ref;
21935
- return /*#__PURE__*/React__default.createElement("div", {
21936
- className: `pelcro-input-wrapper ${wrapperClassName}`
21937
- }, /*#__PURE__*/React__default.createElement("label", {
21938
- htmlFor: id,
21939
- className: `pelcro-input-label ${labelClassName}`
21940
- }, `${label}${required ? "*" : ""}`), /*#__PURE__*/React__default.createElement("select", Object.assign({
21941
- id: id,
21942
- className: `pelcro-input-field ${className} ${error ? "pelcro-input-invalid" : ""}`,
21943
- "aria-describedby": errorId,
21944
- "aria-invalid": Boolean(error)
21945
- }, otherProps), children), error && /*#__PURE__*/React__default.createElement("p", {
21946
- id: errorId,
21947
- "aria-live": "assertive",
21948
- className: `pelcro-input-error ${errorClassName}`
21949
- }, error));
21950
- }
21951
-
21952
22536
  function CountrySelect(_ref) {
21953
22537
  let {
21954
22538
  placeholder,