tf-checkout-react 1.4.18 → 1.4.20

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.
@@ -68,7 +68,6 @@ import TableRow from '@mui/material/TableRow';
68
68
  import _has from 'lodash-es/has';
69
69
  import _isNull from 'lodash-es/isNull';
70
70
  import _reverse from 'lodash-es/reverse';
71
- import { identity } from 'lodash-es';
72
71
  import _keys from 'lodash-es/keys';
73
72
  import _values from 'lodash-es/values';
74
73
  import moment$1 from 'moment';
@@ -920,6 +919,18 @@ var handlePaymentSuccess = function handlePaymentSuccess(orderHash) {
920
919
  });
921
920
  return res;
922
921
  };
922
+ var createPaymentPlan = function createPaymentPlan(orderHash, stripePaymentMethodId) {
923
+ var res = publicRequest.post("v1/order/" + orderHash + "/payment_plan/create", {
924
+ stripe_payment_method_id: stripePaymentMethodId
925
+ }, {
926
+ headers: {
927
+ 'Referer-Url': isDocumentDefined ? document.referrer : ''
928
+ }
929
+ })["catch"](function (error) {
930
+ throw error;
931
+ });
932
+ return res;
933
+ };
923
934
  var handleFreeSuccess = function handleFreeSuccess(orderHash) {
924
935
  var res = publicRequest.post("v1/order/" + orderHash + "/complete_free_registration", undefined, {
925
936
  headers: {
@@ -3857,11 +3868,13 @@ var CheckoutForm = function CheckoutForm(_ref) {
3857
3868
  _ref$isLoading = _ref.isLoading,
3858
3869
  isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
3859
3870
  _ref$handleSetLoading = _ref.handleSetLoading,
3860
- handleSetLoading = _ref$handleSetLoading === void 0 ? function () {} : _ref$handleSetLoading,
3871
+ handleSetLoading = _ref$handleSetLoading === void 0 ? _identity : _ref$handleSetLoading,
3861
3872
  _ref$conditions = _ref.conditions,
3862
3873
  conditions = _ref$conditions === void 0 ? [] : _ref$conditions,
3863
3874
  disableZipSection = _ref.disableZipSection,
3864
- paymentButtonText = _ref.paymentButtonText;
3875
+ paymentButtonText = _ref.paymentButtonText,
3876
+ _ref$forPaymentPlan = _ref.forPaymentPlan,
3877
+ forPaymentPlan = _ref$forPaymentPlan === void 0 ? false : _ref$forPaymentPlan;
3865
3878
  var stripe = useStripe();
3866
3879
  var elements = useElements();
3867
3880
  var _useState = useState(''),
@@ -3878,7 +3891,7 @@ var CheckoutForm = function CheckoutForm(_ref) {
3878
3891
  setAllowSubmit = _useState4[1];
3879
3892
  var handleSubmit = /*#__PURE__*/function () {
3880
3893
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(event) {
3881
- var card, address, paymentMethodReq, _yield$stripe$confirm, _error;
3894
+ var card, address, _setupResponse$setupI, setupResponse, paymentMethodReq, _yield$stripe$confirm, _error;
3882
3895
  return _regeneratorRuntime().wrap(function _callee$(_context) {
3883
3896
  while (1) switch (_context.prev = _context.next) {
3884
3897
  case 0:
@@ -3911,7 +3924,26 @@ var CheckoutForm = function CheckoutForm(_ref) {
3911
3924
  if (!disableZipSection) {
3912
3925
  address.postal_code = postalCode;
3913
3926
  }
3914
- _context.next = 15;
3927
+ if (!forPaymentPlan) {
3928
+ _context.next = 19;
3929
+ break;
3930
+ }
3931
+ _context.next = 16;
3932
+ return stripe.confirmCardSetup(stripe_client_secret, {
3933
+ payment_method: {
3934
+ card: card || {
3935
+ token: ''
3936
+ }
3937
+ }
3938
+ });
3939
+ case 16:
3940
+ setupResponse = _context.sent;
3941
+ onSubmit(null, {
3942
+ paymentMethodId: (_setupResponse$setupI = setupResponse.setupIntent) == null ? void 0 : _setupResponse$setupI.payment_method
3943
+ });
3944
+ return _context.abrupt("return");
3945
+ case 19:
3946
+ _context.next = 21;
3915
3947
  return stripe.createPaymentMethod({
3916
3948
  type: 'card',
3917
3949
  card: card || {
@@ -3921,44 +3953,44 @@ var CheckoutForm = function CheckoutForm(_ref) {
3921
3953
  address: address
3922
3954
  }
3923
3955
  });
3924
- case 15:
3956
+ case 21:
3925
3957
  paymentMethodReq = _context.sent;
3926
3958
  if (!paymentMethodReq.error) {
3927
- _context.next = 20;
3959
+ _context.next = 26;
3928
3960
  break;
3929
3961
  }
3930
3962
  setStripeError(paymentMethodReq.error.message || null);
3931
3963
  handleSetLoading(false);
3932
3964
  return _context.abrupt("return");
3933
- case 20:
3965
+ case 26:
3934
3966
  handleSetLoading(true);
3935
- _context.next = 23;
3967
+ _context.next = 29;
3936
3968
  return stripe.confirmCardPayment(stripe_client_secret, {
3937
3969
  payment_method: paymentMethodReq.paymentMethod.id
3938
3970
  });
3939
- case 23:
3971
+ case 29:
3940
3972
  _yield$stripe$confirm = _context.sent;
3941
3973
  _error = _yield$stripe$confirm.error;
3942
3974
  if (!_error) {
3943
- _context.next = 29;
3975
+ _context.next = 35;
3944
3976
  break;
3945
3977
  }
3946
3978
  setStripeError(_error.message);
3947
3979
  handleSetLoading(false);
3948
3980
  return _context.abrupt("return");
3949
- case 29:
3981
+ case 35:
3950
3982
  onSubmit(null);
3951
- _context.next = 35;
3983
+ _context.next = 41;
3952
3984
  break;
3953
- case 32:
3954
- _context.prev = 32;
3985
+ case 38:
3986
+ _context.prev = 38;
3955
3987
  _context.t0 = _context["catch"](1);
3956
3988
  onSubmit(_context.t0);
3957
- case 35:
3989
+ case 41:
3958
3990
  case "end":
3959
3991
  return _context.stop();
3960
3992
  }
3961
- }, _callee, null, [[1, 32]]);
3993
+ }, _callee, null, [[1, 38]]);
3962
3994
  }));
3963
3995
  return function handleSubmit(_x) {
3964
3996
  return _ref2.apply(this, arguments);
@@ -4061,7 +4093,63 @@ var CheckoutForm = function CheckoutForm(_ref) {
4061
4093
  type: "submit"
4062
4094
  }, isLoading ? React.createElement(CircularProgress$1, {
4063
4095
  size: 26
4064
- }) : (paymentButtonText ? paymentButtonText : 'Pay') + " " + getCurrencySymbolByCurrency(currency) + total))));
4096
+ }) : forPaymentPlan ? 'Confirm Payment Plan' : (paymentButtonText ? paymentButtonText : 'Pay') + " " + getCurrencySymbolByCurrency(currency) + total))));
4097
+ };
4098
+
4099
+ var PaymentPlanSection = function PaymentPlanSection(props) {
4100
+ var _paymentPlanConfig$sa;
4101
+ var paymentPlanConfig = props.paymentPlanConfig,
4102
+ currency = props.currency,
4103
+ paymentPlanUseSavedCard = props.paymentPlanUseSavedCard,
4104
+ setPaymentPlanUseSavedCard = props.setPaymentPlanUseSavedCard;
4105
+ return React.createElement("div", {
4106
+ className: "payment_plan"
4107
+ }, React.createElement("h2", {
4108
+ className: "payment_plan_title"
4109
+ }, "Payment Plan Terms"), React.createElement("div", {
4110
+ className: "payment_plan_block"
4111
+ }, React.createElement("div", {
4112
+ className: "payment_plan_text"
4113
+ }, "By clicking on the \u201CConfirm Payment Plan\u201D button, you are starting your payment plan of", ' ', React.createElement("span", {
4114
+ className: "payment_plan_highlight"
4115
+ }, paymentPlanConfig.total_installments), ' ', "payments of", ' ', React.createElement("span", {
4116
+ className: "payment_plan_highlight"
4117
+ }, currencyNormalizerCreator(createFixedFloatNormalizer(2)(paymentPlanConfig.price_per_installment), currency)), ", which will be drawn from your account every ", paymentPlanConfig.interval, " days, with the first payment taken later today."), paymentPlanConfig.has_admin_fee && React.createElement("div", {
4118
+ className: "payment_plan_text"
4119
+ }, "This includes a non-refundable admin fee of", ' ', React.createElement("span", {
4120
+ className: "payment_plan_highlight"
4121
+ }, currencyNormalizerCreator(createFixedFloatNormalizer(2)(paymentPlanConfig.admin_fee), currency)), ' ', "per payment."), paymentPlanConfig.requires_deposit && React.createElement("div", {
4122
+ className: "payment_plan_text"
4123
+ }, "You will also be charged a single, non-refundable deposit of", ' ', React.createElement("span", {
4124
+ className: "payment_plan_highlight"
4125
+ }, currencyNormalizerCreator(createFixedFloatNormalizer(2)(paymentPlanConfig.deposit), currency)), "."), React.createElement("div", {
4126
+ className: "payment_plan_text payment_plan_note payment_plan_highlight"
4127
+ }, "NOTE: If today\u2019s payment fails, your plan will not activate. Your tickets will not be issued until you complete your final payment."), !paymentPlanConfig.non_refundable_type && React.createElement("div", {
4128
+ className: "payment_plan_text"
4129
+ }, "If you do not complete your payments, your order will be canceled. Your", ' ', React.createElement("span", {
4130
+ className: "payment_plan_highlight"
4131
+ }, "first payment of", ' ', currencyNormalizerCreator(createFixedFloatNormalizer(2)(paymentPlanConfig.price_per_installment), currency)), paymentPlanConfig.has_admin_fee && React.createElement(React.Fragment, null, ", plus the", ' ', React.createElement("span", {
4132
+ className: "payment_plan_highlight"
4133
+ }, "non-refundable admin-fee of", ' ', currencyNormalizerCreator(createFixedFloatNormalizer(2)(paymentPlanConfig.admin_fee), currency))), ' ', "will not be refunded."), paymentPlanConfig.non_refundable_type === 'percent' && React.createElement("div", {
4134
+ className: "payment_plan_text"
4135
+ }, "If you do not complete your payments, you will receive", ' ', React.createElement("span", {
4136
+ className: "payment_plan_highlight"
4137
+ }, createFixedFloatNormalizer(0)(100 - paymentPlanConfig.non_refundable_amount), "%"), ' ', "of your money back", paymentPlanConfig.requires_deposit && React.createElement(React.Fragment, null, ", excluding your", ' ', currencyNormalizerCreator(createFixedFloatNormalizer(2)(paymentPlanConfig.deposit), currency), ' ', "deposit"), "."), paymentPlanConfig.non_refundable_type === 'fixed' && React.createElement("div", {
4138
+ className: "payment_plan_text"
4139
+ }, "If you do not complete your payments, you will receive all your money back", paymentPlanConfig.non_refundable_amount && React.createElement(React.Fragment, null, "except for the non-refundable amount of", ' ', currencyNormalizerCreator(createFixedFloatNormalizer(2)(paymentPlanConfig.non_refundable_amount), currency), paymentPlanConfig.requires_deposit && React.createElement(React.Fragment, null, ", excluding your", ' ', currencyNormalizerCreator(createFixedFloatNormalizer(2)(paymentPlanConfig.deposit), currency), ' ', "deposit")), "."), !!((_paymentPlanConfig$sa = paymentPlanConfig.saved_card) != null && _paymentPlanConfig$sa.stripe_payment_method_id) && React.createElement(React.Fragment, null, paymentPlanUseSavedCard && React.createElement("div", {
4140
+ className: "payment_plan_text"
4141
+ }, ' ', "Your payment will proceed with the card ending in ****", ' ', React.createElement("span", {
4142
+ className: "payment_plan_highlight"
4143
+ }, '' + paymentPlanConfig.saved_card.last_4_digits)), React.createElement("div", null, React.createElement(CheckboxField, {
4144
+ label: React.createElement("span", {
4145
+ className: 'payment_plan_toggle_label'
4146
+ }, "Use this card"),
4147
+ required: true,
4148
+ onChange: function onChange() {
4149
+ setPaymentPlanUseSavedCard(!paymentPlanUseSavedCard);
4150
+ },
4151
+ checked: paymentPlanUseSavedCard
4152
+ })))));
4065
4153
  };
4066
4154
 
4067
4155
  var publishableKey = CONFIGS.STRIPE_PUBLISHABLE_KEY || '';
@@ -4074,6 +4162,23 @@ var getStripePromise = function getStripePromise(reviewData) {
4074
4162
  }
4075
4163
  return loadStripe(stripePublishableKey, options);
4076
4164
  };
4165
+ var initialPaymentPlanConfiguration = {
4166
+ requires_deposit: false,
4167
+ deposit: 0,
4168
+ interval: 0,
4169
+ non_refundable_amount: 0,
4170
+ non_refundable_type: null,
4171
+ has_admin_fee: false,
4172
+ admin_fee: 0,
4173
+ total_installments: 0,
4174
+ price_per_installment: 0,
4175
+ stripe_setup_intent_secret: '',
4176
+ total: 0,
4177
+ saved_card: {
4178
+ last_4_digits: null,
4179
+ stripe_payment_method_id: null
4180
+ }
4181
+ };
4077
4182
  var initialOrderValues = {
4078
4183
  id: '',
4079
4184
  product_name: '',
@@ -4088,10 +4193,13 @@ var initialOrderValues = {
4088
4193
  };
4089
4194
  var initialReviewValues = {
4090
4195
  order_details: {
4196
+ id: '',
4091
4197
  order_hash: ''
4092
4198
  },
4093
4199
  payment_method: {
4094
- stripe_client_secret: ''
4200
+ stripe_client_secret: '',
4201
+ stripe_payment_plan_enabled: false,
4202
+ stripe_payment_plan_configuration: null
4095
4203
  },
4096
4204
  billing_info: {}
4097
4205
  };
@@ -4122,7 +4230,7 @@ var PaymentContainer = function PaymentContainer(_ref) {
4122
4230
  _ref$enableTimer = _ref.enableTimer,
4123
4231
  enableTimer = _ref$enableTimer === void 0 ? false : _ref$enableTimer,
4124
4232
  _ref$enablePaymentPla = _ref.enablePaymentPlan,
4125
- enablePaymentPlan = _ref$enablePaymentPla === void 0 ? false : _ref$enablePaymentPla,
4233
+ enablePaymentPlan = _ref$enablePaymentPla === void 0 ? true : _ref$enablePaymentPla,
4126
4234
  paymentButtonText = _ref.paymentButtonText,
4127
4235
  _ref$orderInfoLabel = _ref.orderInfoLabel,
4128
4236
  orderInfoLabel = _ref$orderInfoLabel === void 0 ? 'Order Review' : _ref$orderInfoLabel,
@@ -4149,6 +4257,18 @@ var PaymentContainer = function PaymentContainer(_ref) {
4149
4257
  var _useState7 = useState([]),
4150
4258
  conditions = _useState7[0],
4151
4259
  setConditions = _useState7[1];
4260
+ var _useState8 = useState(false),
4261
+ paymentPlanIsAvailable = _useState8[0],
4262
+ setPaymentPlanIsAvailable = _useState8[1];
4263
+ var _useState9 = useState(initialPaymentPlanConfiguration),
4264
+ paymentPlanConfig = _useState9[0],
4265
+ setPaymentPlanConfig = _useState9[1];
4266
+ var _useState10 = useState(true),
4267
+ paymentPlanUseSavedCard = _useState10[0],
4268
+ setPaymentPlanUseSavedCard = _useState10[1];
4269
+ var _useState11 = useState(''),
4270
+ currency = _useState11[0],
4271
+ setCurrency = _useState11[1];
4152
4272
  var showFormTitle = Boolean(formTitle);
4153
4273
  var showErrorText = Boolean(errorText);
4154
4274
  var eventId = getQueryVariable('event_id') || _get(reviewData, 'cart[0].product_id') || '';
@@ -4160,6 +4280,30 @@ var PaymentContainer = function PaymentContainer(_ref) {
4160
4280
  page: 'review',
4161
4281
  pageUrl: pageUrl
4162
4282
  });
4283
+ useEffect(function () {
4284
+ var paymentMethod = reviewData.payment_method || {};
4285
+ var paymentPlanAvailable = paymentMethod.stripe_payment_plan_enabled && enablePaymentPlan;
4286
+ setPaymentPlanIsAvailable(paymentPlanAvailable);
4287
+ if (paymentPlanAvailable) {
4288
+ var _paymentPlanConfig$sa;
4289
+ var _paymentPlanConfig = paymentMethod.stripe_payment_plan_configuration || initialPaymentPlanConfiguration;
4290
+ setPaymentPlanConfig(_paymentPlanConfig);
4291
+ setPaymentPlanUseSavedCard(!!((_paymentPlanConfig$sa = _paymentPlanConfig.saved_card) != null && _paymentPlanConfig$sa.stripe_payment_method_id));
4292
+ if (typeof window !== 'undefined') {
4293
+ var _reviewData$order_det;
4294
+ var sessionData = window.localStorage.getItem('paymentConfiguration');
4295
+ var session = sessionData ? JSON.parse(sessionData) : {};
4296
+ if (!!session && (session == null ? void 0 : session.orderId) == ((_reviewData$order_det = reviewData.order_details) == null ? void 0 : _reviewData$order_det.id)) {
4297
+ var _session$paymentPlanU, _session$showPaymentP;
4298
+ setPaymentPlanUseSavedCard((_session$paymentPlanU = session.paymentPlanUseSavedCard) != null ? _session$paymentPlanU : false);
4299
+ setShowPaymentPlanSection((_session$showPaymentP = session.showPaymentPlanSection) != null ? _session$showPaymentP : false);
4300
+ }
4301
+ }
4302
+ }
4303
+ }, [enablePaymentPlan, reviewData]);
4304
+ useEffect(function () {
4305
+ updateSessionInformation();
4306
+ }, [showPaymentPlanSection, paymentPlanUseSavedCard]);
4163
4307
  useEffect(function () {
4164
4308
  _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
4165
4309
  var response, _cart$2, attributes, cart, order_details, _order_details$ticket, ticket, orderDataArray, _orderData;
@@ -4202,6 +4346,7 @@ var PaymentContainer = function PaymentContainer(_ref) {
4202
4346
  tableTypes: orderDataArray
4203
4347
  };
4204
4348
  setOrderData(_orderData);
4349
+ setCurrency(order_details == null ? void 0 : order_details.currency);
4205
4350
  onGetPaymentDataSuccess(response.data);
4206
4351
  }
4207
4352
  _context.next = 11;
@@ -4263,7 +4408,7 @@ var PaymentContainer = function PaymentContainer(_ref) {
4263
4408
  // 2. handle payment ---> v1/order/${orderHash}/pay/
4264
4409
  // 3. redirect to confirmation page
4265
4410
  var handlePaymentMiddleWare = /*#__PURE__*/function () {
4266
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(error) {
4411
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(error, data) {
4267
4412
  var order_hash, paymentSuccessResponse, isWindowDefined, _window;
4268
4413
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
4269
4414
  while (1) switch (_context3.prev = _context3.next) {
@@ -4283,16 +4428,26 @@ var PaymentContainer = function PaymentContainer(_ref) {
4283
4428
  _context3.next = 7;
4284
4429
  return handleFreeSuccess(order_hash);
4285
4430
  case 7:
4286
- _context3.t0 = _context3.sent;
4287
- _context3.next = 13;
4431
+ paymentSuccessResponse = _context3.sent;
4432
+ _context3.next = 19;
4288
4433
  break;
4289
4434
  case 10:
4290
- _context3.next = 12;
4291
- return handlePaymentSuccess(order_hash);
4292
- case 12:
4293
- _context3.t0 = _context3.sent;
4435
+ if (!(paymentPlanIsAvailable && showPaymentPlanSection)) {
4436
+ _context3.next = 16;
4437
+ break;
4438
+ }
4439
+ _context3.next = 13;
4440
+ return createPaymentPlan(order_hash, _get(data, 'paymentMethodId', ''));
4294
4441
  case 13:
4295
- paymentSuccessResponse = _context3.t0;
4442
+ paymentSuccessResponse = _context3.sent;
4443
+ _context3.next = 19;
4444
+ break;
4445
+ case 16:
4446
+ _context3.next = 18;
4447
+ return handlePaymentSuccess(order_hash);
4448
+ case 18:
4449
+ paymentSuccessResponse = _context3.sent;
4450
+ case 19:
4296
4451
  if (paymentSuccessResponse.status === 200) {
4297
4452
  handlePayment(paymentSuccessResponse);
4298
4453
  setPaymentIsLoading(false);
@@ -4301,34 +4456,51 @@ var PaymentContainer = function PaymentContainer(_ref) {
4301
4456
  localStorage.removeItem("reservationStart-" + eventId);
4302
4457
  localStorage.removeItem('ownReservations');
4303
4458
  localStorage.removeItem('tierId');
4304
- isWindowDefined = typeof window !== "undefined";
4459
+ isWindowDefined = typeof window !== 'undefined';
4305
4460
  if (isWindowDefined) {
4306
4461
  (_window = window) == null ? void 0 : _window.dataLayer.push({
4307
- 'event': 'Purchase',
4308
- 'orderValue': orderData.total,
4309
- 'orderCurrency': orderData.currency,
4310
- 'orderId': orderData.id
4462
+ event: 'Purchase',
4463
+ orderValue: orderData.total,
4464
+ orderCurrency: orderData.currency,
4465
+ orderId: orderData.id
4311
4466
  });
4312
4467
  }
4313
4468
  }
4314
- _context3.next = 22;
4469
+ _context3.next = 27;
4315
4470
  break;
4316
- case 17:
4317
- _context3.prev = 17;
4318
- _context3.t1 = _context3["catch"](0);
4319
- setError(_get(_context3.t1, 'response.data.message'));
4320
- setPaymentIsLoading(false);
4321
- onPaymentError(_context3.t1.response);
4322
4471
  case 22:
4472
+ _context3.prev = 22;
4473
+ _context3.t0 = _context3["catch"](0);
4474
+ setError(_get(_context3.t0, 'response.data.message'));
4475
+ setPaymentIsLoading(false);
4476
+ onPaymentError(_context3.t0.response);
4477
+ case 27:
4323
4478
  case "end":
4324
4479
  return _context3.stop();
4325
4480
  }
4326
- }, _callee3, null, [[0, 17]]);
4481
+ }, _callee3, null, [[0, 22]]);
4327
4482
  }));
4328
- return function handlePaymentMiddleWare(_x) {
4483
+ return function handlePaymentMiddleWare(_x, _x2) {
4329
4484
  return _ref4.apply(this, arguments);
4330
4485
  };
4331
4486
  }();
4487
+ var showPaymentForm = function showPaymentForm() {
4488
+ var _paymentPlanConfig$sa2;
4489
+ var showPaymentForm = !isFreeTickets;
4490
+ if (paymentPlanIsAvailable && showPaymentPlanSection && !!((_paymentPlanConfig$sa2 = paymentPlanConfig.saved_card) != null && _paymentPlanConfig$sa2.stripe_payment_method_id)) {
4491
+ showPaymentForm = !paymentPlanUseSavedCard;
4492
+ }
4493
+ return showPaymentForm;
4494
+ };
4495
+ var updateSessionInformation = function updateSessionInformation() {
4496
+ if (typeof window !== 'undefined' && !!(orderData != null && orderData.id)) {
4497
+ window.localStorage.setItem('paymentConfiguration', JSON.stringify({
4498
+ paymentPlanUseSavedCard: paymentPlanUseSavedCard,
4499
+ showPaymentPlanSection: showPaymentPlanSection,
4500
+ orderId: orderData == null ? void 0 : orderData.id
4501
+ }));
4502
+ }
4503
+ };
4332
4504
  var themeMui = createTheme(themeOptions);
4333
4505
  var hasTableTypes = Boolean(Number(orderData.guest_count));
4334
4506
  var paymentFieldsData = hasTableTypes ? [{
@@ -4385,12 +4557,14 @@ var PaymentContainer = function PaymentContainer(_ref) {
4385
4557
  className = _field$className === void 0 ? '' : _field$className,
4386
4558
  _field$normalizer = field.normalizer,
4387
4559
  normalizer = _field$normalizer === void 0 ? _identity : _field$normalizer;
4388
- var currency = orderData.currency;
4389
4560
  var value = orderData[id];
4390
4561
  var component = null;
4391
4562
  if (field.id === 'add_ons' && _isEmpty(value)) {
4392
4563
  return false;
4393
4564
  }
4565
+ if (field.id === 'total' && paymentPlanIsAvailable && showPaymentPlanSection) {
4566
+ value = '' + paymentPlanConfig.total;
4567
+ }
4394
4568
  if (field.id === 'tableTypes') {
4395
4569
  var valueArray = value;
4396
4570
  component = React.createElement("div", {
@@ -4446,29 +4620,23 @@ var PaymentContainer = function PaymentContainer(_ref) {
4446
4620
  className: "add-on-each"
4447
4621
  }, ' each'));
4448
4622
  })));
4449
- })), enablePaymentPlan && React.createElement("div", {
4623
+ })), !isFreeTickets && paymentPlanIsAvailable && React.createElement("div", {
4450
4624
  className: "payment_toggle"
4451
- }, React.createElement("label", {
4452
- htmlFor: "togBtn",
4453
- className: "switch"
4454
- }, React.createElement("input", {
4455
- type: "checkbox",
4456
- id: "togBtn",
4457
- disabled: true,
4458
- onChange: function onChange() {
4459
- return setShowPaymentPlanSection(!showPaymentPlanSection);
4460
- }
4461
- }), React.createElement("div", {
4462
- className: "slider round"
4463
- }), React.createElement("span", {
4464
- className: "tog_text"
4465
- }, "Click to checkout using Payment Plan"))), showPaymentPlanSection && React.createElement("div", {
4466
- className: "payment_plan"
4467
- }, React.createElement("h2", null, "PAYMENT PLAN"), React.createElement("div", {
4468
- className: "plan_block"
4469
- }, React.createElement("h3", null, "Mbrand Payment Plan Terms"), React.createElement("p", null, "By clicking on the \u201CConfirm Payment Plan\u201D button, you are starting your payment plan of 2 payments of $115.00, which will be drawn from your account every 2 weeks, with the first payment taken later today."), React.createElement("p", null, "This includes a non-refundable admin fee of $3.00 per payment."), React.createElement("p", {
4470
- className: "payment_note"
4471
- }, "NOTE: If today\u2019s payment fails, your payment plan will not activate, and your tickets will not be issued until you complete your final payment."), React.createElement("p", null, "If you do not complete your payements, your order will be canceled. Your first payment of $115.00, plus the non-refundable admin fee of $3.00 will not be refunded."), React.createElement("p", null, "Your payment will proceed with the card ending in **** 4242."))), !isFreeTickets ? React.createElement("div", {
4625
+ }, React.createElement(CheckboxField, {
4626
+ label: React.createElement("span", {
4627
+ className: 'payment_plan_toggle_label'
4628
+ }, "Click to checkout using Payment Plan"),
4629
+ required: true,
4630
+ onChange: function onChange(_) {
4631
+ setShowPaymentPlanSection(!showPaymentPlanSection);
4632
+ },
4633
+ checked: showPaymentPlanSection
4634
+ })), showPaymentPlanSection && React.createElement(PaymentPlanSection, {
4635
+ paymentPlanConfig: paymentPlanConfig,
4636
+ currency: currency,
4637
+ paymentPlanUseSavedCard: paymentPlanUseSavedCard,
4638
+ setPaymentPlanUseSavedCard: setPaymentPlanUseSavedCard
4639
+ }), showPaymentForm() ? React.createElement("div", {
4472
4640
  className: "payment_info"
4473
4641
  }, React.createElement("div", {
4474
4642
  className: "payment_info_label"
@@ -4478,7 +4646,7 @@ var PaymentContainer = function PaymentContainer(_ref) {
4478
4646
  stripe: getStripePromise(reviewData),
4479
4647
  options: elementsOptions
4480
4648
  }, React.createElement(CheckoutForm, {
4481
- stripe_client_secret: _get(reviewData, 'payment_method.stripe_client_secret'),
4649
+ stripe_client_secret: paymentPlanIsAvailable && showPaymentPlanSection ? paymentPlanConfig.stripe_setup_intent_secret : _get(reviewData, 'payment_method.stripe_client_secret'),
4482
4650
  total: orderData.guest_count ? orderData.pay_now : orderData.total,
4483
4651
  onSubmit: handlePaymentMiddleWare,
4484
4652
  error: error,
@@ -4491,7 +4659,8 @@ var PaymentContainer = function PaymentContainer(_ref) {
4491
4659
  conditions: conditions,
4492
4660
  stripeCardOptions: stripeCardOptions,
4493
4661
  disableZipSection: disableZipSection,
4494
- paymentButtonText: paymentButtonText
4662
+ paymentButtonText: paymentButtonText,
4663
+ forPaymentPlan: paymentPlanIsAvailable && showPaymentPlanSection
4495
4664
  })))) : React.createElement("div", {
4496
4665
  className: "payment_button " + (paymentIsLoading ? 'disabled-payment-button' : '')
4497
4666
  }, React.createElement("button", {
@@ -4499,11 +4668,18 @@ var PaymentContainer = function PaymentContainer(_ref) {
4499
4668
  type: "button",
4500
4669
  onClick: function onClick() {
4501
4670
  setPaymentIsLoading(true);
4502
- handlePaymentMiddleWare(null);
4671
+ var data;
4672
+ if (paymentPlanIsAvailable && showPaymentPlanSection && paymentPlanUseSavedCard) {
4673
+ var _paymentPlanConfig$sa3;
4674
+ data = {
4675
+ paymentMethodId: (_paymentPlanConfig$sa3 = paymentPlanConfig.saved_card) == null ? void 0 : _paymentPlanConfig$sa3.stripe_payment_method_id
4676
+ };
4677
+ }
4678
+ handlePaymentMiddleWare(null, data);
4503
4679
  }
4504
4680
  }, paymentIsLoading ? React.createElement(CircularProgress$1, {
4505
4681
  size: 26
4506
- }) : 'Complete Registration')))));
4682
+ }) : isFreeTickets ? 'Complete Registration' : 'Confirm Payment Plan')))));
4507
4683
  };
4508
4684
 
4509
4685
  var config = {
@@ -4769,7 +4945,13 @@ var ConfirmationContainer = function ConfirmationContainer(_ref) {
4769
4945
  _confirmationLabels$c2 = confirmationLabels.confirmationMain,
4770
4946
  confirmationMain = _confirmationLabels$c2 === void 0 ? 'Your tickets are available in My Tickets section' : _confirmationLabels$c2,
4771
4947
  _confirmationLabels$c3 = confirmationLabels.confirmationHelper,
4772
- confirmationHelper = _confirmationLabels$c3 === void 0 ? 'Please bring them with you to the event' : _confirmationLabels$c3;
4948
+ confirmationHelper = _confirmationLabels$c3 === void 0 ? 'Please bring them with you to the event' : _confirmationLabels$c3,
4949
+ _confirmationLabels$p = confirmationLabels.paymentPlanConfirmationTitle,
4950
+ paymentPlanConfirmationTitle = _confirmationLabels$p === void 0 ? 'Your Tickets are Confirmed!' : _confirmationLabels$p,
4951
+ _confirmationLabels$p2 = confirmationLabels.paymentPlanConfirmationMain,
4952
+ paymentPlanConfirmationMain = _confirmationLabels$p2 === void 0 ? 'Your payment plan is pending and we are trying to take your initial payment. If your initial payment does not complete, your payment plan will be cancelled.' : _confirmationLabels$p2,
4953
+ _confirmationLabels$p3 = confirmationLabels.paymentPlanConfirmationHelper,
4954
+ paymentPlanConfirmationHelper = _confirmationLabels$p3 === void 0 ? 'You will receive a confirmation with your tickets once your final payment has been made.' : _confirmationLabels$p3;
4773
4955
  var pageUrl = isBrowser ? window.location.href.split('?')[0] : '';
4774
4956
  usePixel(eventId, {
4775
4957
  page: 'complete',
@@ -4806,16 +4988,20 @@ var ConfirmationContainer = function ConfirmationContainer(_ref) {
4806
4988
  className: "header-product-text"
4807
4989
  }, React.createElement("p", {
4808
4990
  className: "title"
4809
- }, confirmationTitle), React.createElement("div", {
4991
+ }, data.is_payment_plan ? paymentPlanConfirmationTitle : confirmationTitle), React.createElement("div", {
4810
4992
  className: "share-message-section",
4811
4993
  dangerouslySetInnerHTML: data.custom_confirmation_page_text && data.custom_confirmation_page_text_full_replacement ? createMarkup(data.custom_confirmation_page_text) : undefined
4812
- }, data.custom_confirmation_page_text && data.custom_confirmation_page_text_full_replacement ? undefined : React.createElement(React.Fragment, null, data.attach_tickets ? React.createElement("span", {
4994
+ }, data.custom_confirmation_page_text && data.custom_confirmation_page_text_full_replacement ? undefined : React.createElement(React.Fragment, null, Boolean(data.is_payment_plan) && React.createElement(React.Fragment, null, React.createElement("span", {
4995
+ className: "main"
4996
+ }, paymentPlanConfirmationMain), React.createElement("span", {
4997
+ className: "helper"
4998
+ }, paymentPlanConfirmationHelper)), !data.is_payment_plan && React.createElement(React.Fragment, null, data.attach_tickets ? React.createElement("span", {
4813
4999
  className: "main"
4814
5000
  }, "Your tickets have been emailed to you") : React.createElement("span", {
4815
5001
  className: "main"
4816
5002
  }, confirmationMain), React.createElement("span", {
4817
5003
  className: "helper"
4818
- }, data.attach_tickets ? 'Please bring them with you to the event' : confirmationHelper))))), data.custom_confirmation_page_text && !data.custom_confirmation_page_text_full_replacement ? React.createElement("div", {
5004
+ }, data.attach_tickets ? 'Please bring them with you to the event' : confirmationHelper)))))), data.custom_confirmation_page_text && !data.custom_confirmation_page_text_full_replacement ? React.createElement("div", {
4819
5005
  className: "custom-confirmation-page-text",
4820
5006
  dangerouslySetInnerHTML: createMarkup(data.custom_confirmation_page_text)
4821
5007
  }) : null, data.disable_referral === false && isReferralEnabled && React.createElement(React.Fragment, null, React.createElement("div", {
@@ -4894,7 +5080,7 @@ var ConfirmationContainer = function ConfirmationContainer(_ref) {
4894
5080
  className: "pricing-section_sublabel"
4895
5081
  }, pricing.subLabel)), React.createElement("div", {
4896
5082
  className: "pricing-section_price"
4897
- }, ' ', pricing.price));
5083
+ }, " ", pricing.price));
4898
5084
  }), showPricingNoteSection && React.createElement("div", {
4899
5085
  className: "note-pricing-section"
4900
5086
  }, "^ This is based on the most expensive ticket in your order."))))));
@@ -8228,26 +8414,32 @@ var SeatMapComponent = function SeatMapComponent(props) {
8228
8414
  ticketTypeTierRelations = _seatMapProps$ticketT === void 0 ? {} : _seatMapProps$ticketT,
8229
8415
  tierPrices = seatMapProps.tierPrices,
8230
8416
  isReserving = seatMapProps.isReserving,
8231
- predefinedSeats = seatMapProps.predefinedSeats;
8417
+ predefinedSeats = seatMapProps.predefinedSeats,
8418
+ isLoadingSeatMapData = seatMapProps.isLoadingSeatMapData;
8232
8419
  useEffect(function () {
8233
8420
  var parentElement = document.getElementById(mapContainerId || CONTAINER_DEFAULT_ID);
8234
8421
  // Temp solution
8235
8422
  window.tierPrices = tierPrices;
8236
- if (Boolean(parentElement)) {
8237
- var mapComponent = React.createElement(SeatMapView, {
8238
- disabled: isReserving,
8239
- loading: isReserving,
8240
- events: seatMapEvents,
8241
- isSelectionOn: false,
8242
- seatData: seatData,
8243
- statuses: statuses,
8244
- ticketTypeTireRelationsArray: getTierRelationsArray(ticketTypeTierRelations),
8245
- width: Math.min((parentElement == null ? void 0 : parentElement.clientWidth) || 800, 800),
8246
- height: Math.min((parentElement == null ? void 0 : parentElement.clientWidth) || 800, 800),
8247
- isBlockMap: seatMapType === 'block',
8248
- isTableMap: seatMapType === 'table',
8249
- predefinedSeats: predefinedSeats
8250
- });
8423
+ if (parentElement) {
8424
+ var mapComponent = null;
8425
+ if (!(seatData && statuses) || isLoadingSeatMapData) {
8426
+ mapComponent = React.createElement(Loader, null);
8427
+ } else {
8428
+ mapComponent = React.createElement(SeatMapView, {
8429
+ disabled: isReserving,
8430
+ loading: isReserving,
8431
+ events: seatMapEvents,
8432
+ isSelectionOn: false,
8433
+ seatData: seatData,
8434
+ statuses: statuses,
8435
+ ticketTypeTireRelationsArray: getTierRelationsArray(ticketTypeTierRelations),
8436
+ width: Math.min((parentElement == null ? void 0 : parentElement.clientWidth) || 800, 800),
8437
+ height: Math.min((parentElement == null ? void 0 : parentElement.clientWidth) || 800, 800),
8438
+ isBlockMap: seatMapType === 'block',
8439
+ isTableMap: seatMapType === 'table',
8440
+ predefinedSeats: predefinedSeats
8441
+ });
8442
+ }
8251
8443
  ReactDom.render(mapComponent, parentElement);
8252
8444
  }
8253
8445
  }, [isReserving, mapContainerId, seatData, seatMapEvents, seatMapType, tierPrices, statuses, ticketTypeTierRelations]);
@@ -8395,7 +8587,7 @@ var TicketsSection$1 = function TicketsSection(props) {
8395
8587
  }
8396
8588
  }, showDescription && React.createElement(Tooltip, {
8397
8589
  title: "View Ticket Info",
8398
- placement: 'left',
8590
+ placement: "left",
8399
8591
  arrow: true,
8400
8592
  componentsProps: {
8401
8593
  tooltip: {
@@ -8459,7 +8651,7 @@ var TicketsSection$1 = function TicketsSection(props) {
8459
8651
  }, option);
8460
8652
  }))))), selectedTicketsInfo[dropdownData.seatId] && React.createElement("div", {
8461
8653
  className: "ticket-description-content",
8462
- dangerouslySetInnerHTML: createMarkup(selectedTicketData.description || "")
8654
+ dangerouslySetInnerHTML: createMarkup(selectedTicketData.description || '')
8463
8655
  })));
8464
8656
  })), React.createElement("div", null, React.createElement(Button$2, {
8465
8657
  className: "book-button\n " + (bookButtonIsDisabled ? 'disabled' : '') + "\n " + (isButtonScrollable ? 'is-scrollable' : '') + "\n ",
@@ -8483,9 +8675,9 @@ var SeatMapContainer = function SeatMapContainer(props) {
8483
8675
  _props$timerMessage = props.timerMessage,
8484
8676
  timerMessage = _props$timerMessage === void 0 ? '' : _props$timerMessage,
8485
8677
  _props$onAddToCartSuc = props.onAddToCartSuccess,
8486
- onAddToCartSuccess = _props$onAddToCartSuc === void 0 ? identity : _props$onAddToCartSuc,
8678
+ onAddToCartSuccess = _props$onAddToCartSuc === void 0 ? _identity : _props$onAddToCartSuc,
8487
8679
  _props$onCountdownFin = props.onCountdownFinish,
8488
- onCountdownFinish = _props$onCountdownFin === void 0 ? identity : _props$onCountdownFin,
8680
+ onCountdownFinish = _props$onCountdownFin === void 0 ? _identity : _props$onCountdownFin,
8489
8681
  ticketDeleteButtonContent = props.ticketDeleteButtonContent,
8490
8682
  ticketInfoContent = props.ticketInfoContent;
8491
8683
  var _useState = useState({
@@ -8507,7 +8699,7 @@ var SeatMapContainer = function SeatMapContainer(props) {
8507
8699
  var _useState5 = useState(true),
8508
8700
  isLoadingSeatMapData = _useState5[0],
8509
8701
  setIsLoadingSeatMapData = _useState5[1];
8510
- var _useState6 = useState(true),
8702
+ var _useState6 = useState(false),
8511
8703
  isLoadingStatuses = _useState6[0],
8512
8704
  setIsLoadingStatuses = _useState6[1];
8513
8705
  var _useState7 = useState(false),
@@ -8594,10 +8786,14 @@ var SeatMapContainer = function SeatMapContainer(props) {
8594
8786
  });
8595
8787
  });
8596
8788
  localStorage.setItem('reservationData', JSON.stringify(reservationData));
8597
- setSeatMapStatuses(statusesResponse.data.attributes);
8598
- setReservedSeats(reservationData);
8789
+ if (!_isEqual(seatMapStatuses, statusesResponse.data.attributes)) {
8790
+ setSeatMapStatuses(statusesResponse.data.attributes);
8791
+ }
8792
+ if (!_isEqual(reservationData, reservedSeats)) {
8793
+ setReservedSeats(reservationData);
8794
+ }
8599
8795
  // automatically set ticket/table type if it's the only one
8600
- if (ticketTypeTierRelationsRef.current) {
8796
+ if (ticketTypeTierRelationsRef.current && !_isEqual(reservationData, reservedSeats)) {
8601
8797
  if (!isGuestCountsSet.current) {
8602
8798
  updateGuestCounts(reservationData);
8603
8799
  isGuestCountsSet.current = true;
@@ -8622,25 +8818,21 @@ var SeatMapContainer = function SeatMapContainer(props) {
8622
8818
  _context2.t0 = _context2["catch"](0);
8623
8819
  setError('Something went wrong');
8624
8820
  case 17:
8625
- _context2.prev = 17;
8626
- setIsLoadingStatuses(false);
8627
- return _context2.finish(17);
8628
- case 20:
8629
8821
  case "end":
8630
8822
  return _context2.stop();
8631
8823
  }
8632
- }, _callee2, null, [[0, 14, 17, 20]]);
8633
- })), [eventId]);
8824
+ }, _callee2, null, [[0, 14]]);
8825
+ })), [eventId, seatMapStatuses, reservedSeats]);
8634
8826
  var startTimer = useCallback(function (duration) {
8635
8827
  setShowTimer(true);
8636
8828
  if (!localStorage.getItem("reservationStart-" + eventId)) {
8637
8829
  localStorage.setItem("reservationStart-" + eventId, String(Date.now() + duration));
8638
8830
  }
8639
- }, []);
8831
+ }, [eventId]);
8640
8832
  var endTimer = useCallback(function () {
8641
8833
  localStorage.removeItem("reservationStart-" + eventId);
8642
8834
  setShowTimer(false);
8643
- }, []);
8835
+ }, [eventId]);
8644
8836
  var handleSeatReservation = /*#__PURE__*/function () {
8645
8837
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(eventId, tierId, seatId) {
8646
8838
  var reservationData, relations, _keys2, firstItem, _error$response, _error$response$data;
@@ -8668,7 +8860,9 @@ var SeatMapContainer = function SeatMapContainer(props) {
8668
8860
  case 15:
8669
8861
  _context3.prev = 15;
8670
8862
  _context3.t0 = _context3["catch"](1);
8671
- setError((_context3.t0 == null ? void 0 : (_error$response = _context3.t0.response) == null ? void 0 : (_error$response$data = _error$response.data) == null ? void 0 : _error$response$data.message) === 'Selected seat is not available' ? 'No more of this ticket type are available right now - they’re either sold out or in people’s shopping carts. Try refreshing the page!' : 'Something went wrong');
8863
+ setError((_context3.t0 == null ? void 0 : (_error$response = _context3.t0.response) == null ? void 0 : (_error$response$data = _error$response.data) == null ? void 0 : _error$response$data.message) === 'Selected seat is not available' ?
8864
+ // eslint-disable-next-line max-len
8865
+ 'No more of this ticket type are available right now - they’re either sold out or in people’s shopping carts. Try refreshing the page!' : 'Something went wrong');
8672
8866
  case 18:
8673
8867
  _context3.prev = 18;
8674
8868
  setIsReserving(false);
@@ -8830,23 +9024,28 @@ var SeatMapContainer = function SeatMapContainer(props) {
8830
9024
  while (1) switch (_context7.prev = _context7.next) {
8831
9025
  case 0:
8832
9026
  _context7.prev = 0;
8833
- _context7.next = 3;
9027
+ setIsLoadingStatuses(true);
9028
+ _context7.next = 4;
8834
9029
  return fetchSeatMapData();
8835
- case 3:
8836
- _context7.next = 5;
9030
+ case 4:
9031
+ _context7.next = 6;
8837
9032
  return fetchSeatMapReservations();
8838
- case 5:
8839
- _context7.next = 10;
9033
+ case 6:
9034
+ _context7.next = 11;
8840
9035
  break;
8841
- case 7:
8842
- _context7.prev = 7;
9036
+ case 8:
9037
+ _context7.prev = 8;
8843
9038
  _context7.t0 = _context7["catch"](0);
8844
9039
  setError('Something went wrong');
8845
- case 10:
9040
+ case 11:
9041
+ _context7.prev = 11;
9042
+ setIsLoadingStatuses(false);
9043
+ return _context7.finish(11);
9044
+ case 14:
8846
9045
  case "end":
8847
9046
  return _context7.stop();
8848
9047
  }
8849
- }, _callee7, null, [[0, 7]]);
9048
+ }, _callee7, null, [[0, 8, 11, 14]]);
8850
9049
  }));
8851
9050
  return function makeRequests() {
8852
9051
  return _ref7.apply(this, arguments);
@@ -8856,13 +9055,15 @@ var SeatMapContainer = function SeatMapContainer(props) {
8856
9055
  if (country) {
8857
9056
  localStorage.setItem('eventCountry', country);
8858
9057
  }
9058
+ }, [country, eventId, fetchSeatMapData]);
9059
+ useEffect(function () {
8859
9060
  var intervalId = setInterval(function () {
8860
9061
  fetchSeatMapReservations();
8861
9062
  }, 3000);
8862
9063
  return function () {
8863
9064
  clearInterval(intervalId);
8864
9065
  };
8865
- }, [fetchSeatMapData, fetchSeatMapReservations]);
9066
+ }, [fetchSeatMapReservations]);
8866
9067
  return React.createElement(React.Fragment, null, error && React.createElement(Alert, {
8867
9068
  severity: "error",
8868
9069
  onClose: function onClose() {
@@ -8909,7 +9110,7 @@ var SeatMapContainer = function SeatMapContainer(props) {
8909
9110
  tableMapEnabled: Boolean(tableMapEnabled),
8910
9111
  guestCounts: guestCounts,
8911
9112
  setGuestCounts: setGuestCounts
8912
- }), seatMapData.seatMap && seatMapStatuses && React.createElement(SeatMapComponent, {
9113
+ }), React.createElement(SeatMapComponent, {
8913
9114
  seatMapProps: {
8914
9115
  seatData: seatMapData.seatMap,
8915
9116
  statuses: seatMapStatuses,
@@ -8920,7 +9121,8 @@ var SeatMapContainer = function SeatMapContainer(props) {
8920
9121
  onSeatClick: onSeatClick
8921
9122
  },
8922
9123
  isReserving: isReserving,
8923
- predefinedSeats: seatMapData.predefinedSeats
9124
+ predefinedSeats: seatMapData.predefinedSeats,
9125
+ isLoadingSeatMapData: isLoadingSeatMapData
8924
9126
  },
8925
9127
  mapContainerId: mapContainerId
8926
9128
  }));