tf-checkout-react 1.5.8 → 1.5.9-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,6 +18,7 @@ export interface ICheckoutForm {
18
18
  paymentButtonText?: string;
19
19
  forPaymentPlan?: boolean;
20
20
  orderId?: string;
21
+ hasSeatMapActions: boolean;
21
22
  }
22
- declare const CheckoutForm: ({ total, orderId, onSubmit, stripeCardOptions, error, stripe_client_secret, currency, billing_info, isLoading, handleSetLoading, conditions, disableZipSection, paymentButtonText, forPaymentPlan, }: ICheckoutForm) => JSX.Element;
23
+ declare const CheckoutForm: ({ total, orderId, onSubmit, stripeCardOptions, error, stripe_client_secret, currency, billing_info, isLoading, handleSetLoading, conditions, disableZipSection, paymentButtonText, forPaymentPlan, hasSeatMapActions, }: ICheckoutForm) => JSX.Element;
23
24
  export default CheckoutForm;
@@ -4356,6 +4356,68 @@ var getCurrencySymbolByCurrency = function getCurrencySymbolByCurrency(currency)
4356
4356
  }
4357
4357
  };
4358
4358
 
4359
+ var adaptStripeError = function adaptStripeError(error) {
4360
+ var _error$payment_intent;
4361
+ var adaptedError = _extends({}, error, {
4362
+ isStripeError: true
4363
+ });
4364
+ switch (error.code) {
4365
+ case 'payment_intent_unexpected_state':
4366
+ if ((error == null ? void 0 : (_error$payment_intent = error.payment_intent) == null ? void 0 : _error$payment_intent.status) === 'succeeded') {
4367
+ return _extends({}, adaptedError, {
4368
+ message: 'You cannot confirm this PaymentIntent because it has already succeeded after being previously confirmed.'
4369
+ });
4370
+ }
4371
+ return _extends({}, adaptedError);
4372
+ default:
4373
+ return adaptedError;
4374
+ }
4375
+ };
4376
+
4377
+ var style$4 = {
4378
+ position: 'absolute',
4379
+ top: '50%',
4380
+ left: '50%',
4381
+ transform: 'translate(-50%, -50%)',
4382
+ minWidth: 480,
4383
+ backgroundColor: '#e3e3e3',
4384
+ border: '1px solid white',
4385
+ outline: 'none',
4386
+ padding: '14px',
4387
+ maxHeight: '85vh',
4388
+ overflow: 'auto'
4389
+ };
4390
+ var ConfirmModal = function ConfirmModal(_ref) {
4391
+ var _ref$message = _ref.message,
4392
+ message = _ref$message === void 0 ? '' : _ref$message,
4393
+ _ref$loading = _ref.loading,
4394
+ loading = _ref$loading === void 0 ? false : _ref$loading,
4395
+ _ref$hideCancelBtn = _ref.hideCancelBtn,
4396
+ hideCancelBtn = _ref$hideCancelBtn === void 0 ? false : _ref$hideCancelBtn,
4397
+ _ref$onClose = _ref.onClose,
4398
+ onClose = _ref$onClose === void 0 ? _identity : _ref$onClose,
4399
+ _ref$onConfirm = _ref.onConfirm,
4400
+ onConfirm = _ref$onConfirm === void 0 ? _identity : _ref$onConfirm;
4401
+ return React__default.createElement(Modal$1, {
4402
+ open: true,
4403
+ onClose: onClose,
4404
+ "aria-labelledby": "modal-modal-title",
4405
+ "aria-describedby": "modal-modal-description",
4406
+ className: "confirm-modal"
4407
+ }, React__default.createElement(Box, {
4408
+ style: style$4
4409
+ }, React__default.createElement("p", null, message), React__default.createElement("div", {
4410
+ className: "footer"
4411
+ }, !hideCancelBtn && React__default.createElement(Button, {
4412
+ onClick: onClose,
4413
+ disabled: loading
4414
+ }, "Cancel"), React__default.createElement(Button, {
4415
+ onClick: onConfirm
4416
+ }, loading ? React__default.createElement(CircularProgress, {
4417
+ size: "22px"
4418
+ }) : 'OK'))));
4419
+ };
4420
+
4359
4421
  var options = {
4360
4422
  style: {
4361
4423
  base: {
@@ -4396,7 +4458,9 @@ var CheckoutForm = function CheckoutForm(_ref) {
4396
4458
  disableZipSection = _ref.disableZipSection,
4397
4459
  paymentButtonText = _ref.paymentButtonText,
4398
4460
  _ref$forPaymentPlan = _ref.forPaymentPlan,
4399
- forPaymentPlan = _ref$forPaymentPlan === void 0 ? false : _ref$forPaymentPlan;
4461
+ forPaymentPlan = _ref$forPaymentPlan === void 0 ? false : _ref$forPaymentPlan,
4462
+ _ref$hasSeatMapAction = _ref.hasSeatMapActions,
4463
+ hasSeatMapActions = _ref$hasSeatMapAction === void 0 ? false : _ref$hasSeatMapAction;
4400
4464
  var stripe = reactStripeJs.useStripe();
4401
4465
  var elements = reactStripeJs.useElements();
4402
4466
  var _useState = React.useState(''),
@@ -4495,28 +4559,33 @@ var CheckoutForm = function CheckoutForm(_ref) {
4495
4559
  _yield$stripe$confirm = _context.sent;
4496
4560
  _error = _yield$stripe$confirm.error;
4497
4561
  if (!_error) {
4562
+ _context.next = 39;
4563
+ break;
4564
+ }
4565
+ setStripeError(adaptStripeError(_error));
4566
+ _context.t0 = hasSeatMapActions;
4567
+ if (!_context.t0) {
4498
4568
  _context.next = 37;
4499
4569
  break;
4500
4570
  }
4501
- _context.next = 34;
4571
+ _context.next = 37;
4502
4572
  return refreshSeatReservation(eventId, orderId || '');
4503
- case 34:
4504
- setStripeError(_error.message);
4573
+ case 37:
4505
4574
  handleSetLoading(false);
4506
4575
  return _context.abrupt("return");
4507
- case 37:
4576
+ case 39:
4508
4577
  onSubmit(null);
4509
- _context.next = 43;
4578
+ _context.next = 45;
4510
4579
  break;
4511
- case 40:
4512
- _context.prev = 40;
4513
- _context.t0 = _context["catch"](1);
4514
- onSubmit(_context.t0);
4515
- case 43:
4580
+ case 42:
4581
+ _context.prev = 42;
4582
+ _context.t1 = _context["catch"](1);
4583
+ onSubmit(_context.t1);
4584
+ case 45:
4516
4585
  case "end":
4517
4586
  return _context.stop();
4518
4587
  }
4519
- }, _callee, null, [[1, 40]]);
4588
+ }, _callee, null, [[1, 42]]);
4520
4589
  }));
4521
4590
  return function handleSubmit(_x) {
4522
4591
  return _ref2.apply(this, arguments);
@@ -4560,9 +4629,13 @@ var CheckoutForm = function CheckoutForm(_ref) {
4560
4629
  var buttonIsDiabled = !stripe || !!error || isLoading || !allowSubmit;
4561
4630
  return React__default.createElement("div", {
4562
4631
  className: "stripe_payment_container"
4563
- }, !!stripeError && React__default.createElement("div", {
4564
- className: "checkout_error_block"
4565
- }, stripeError), React__default.createElement("form", {
4632
+ }, !!stripeError && React__default.createElement(ConfirmModal, {
4633
+ hideCancelBtn: true,
4634
+ onConfirm: function onConfirm() {
4635
+ return onSubmit(stripeError);
4636
+ },
4637
+ message: stripeError == null ? void 0 : stripeError.message
4638
+ }), React__default.createElement("form", {
4566
4639
  onSubmit: handleSubmit
4567
4640
  }, React__default.createElement("div", {
4568
4641
  className: "card_form_inner"
@@ -4727,7 +4800,8 @@ var initialReviewValues = {
4727
4800
  stripe_payment_plan_enabled: false,
4728
4801
  stripe_payment_plan_configuration: {}
4729
4802
  },
4730
- billing_info: {}
4803
+ billing_info: {},
4804
+ flagSeatMapAllowed: false
4731
4805
  };
4732
4806
  var PaymentContainer = function PaymentContainer(_ref) {
4733
4807
  var _ref$paymentFields = _ref.paymentFields,
@@ -4936,7 +5010,7 @@ var PaymentContainer = function PaymentContainer(_ref) {
4936
5010
  // 3. redirect to confirmation page
4937
5011
  var handlePaymentMiddleWare = /*#__PURE__*/function () {
4938
5012
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(error, data) {
4939
- var order_hash, paymentSuccessResponse, _window;
5013
+ var order_hash, paymentSuccessResponse, _window, _window$dataLayer;
4940
5014
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
4941
5015
  while (1) switch (_context3.prev = _context3.next) {
4942
5016
  case 0:
@@ -4984,7 +5058,7 @@ var PaymentContainer = function PaymentContainer(_ref) {
4984
5058
  localStorage.removeItem('ownReservations');
4985
5059
  localStorage.removeItem('tierId');
4986
5060
  if (isBrowser) {
4987
- (_window = window) == null ? void 0 : _window.dataLayer.push({
5061
+ (_window = window) == null ? void 0 : (_window$dataLayer = _window.dataLayer) == null ? void 0 : _window$dataLayer.push({
4988
5062
  event: 'Purchase',
4989
5063
  orderValue: orderData.total,
4990
5064
  orderCurrency: orderData.currency,
@@ -4999,7 +5073,7 @@ var PaymentContainer = function PaymentContainer(_ref) {
4999
5073
  _context3.t0 = _context3["catch"](0);
5000
5074
  setError(_get(_context3.t0, 'response.data.message'));
5001
5075
  setPaymentIsLoading(false);
5002
- onPaymentError(_context3.t0.response);
5076
+ onPaymentError(_context3.t0.response || _context3.t0);
5003
5077
  case 27:
5004
5078
  case "end":
5005
5079
  return _context3.stop();
@@ -5173,6 +5247,7 @@ var PaymentContainer = function PaymentContainer(_ref) {
5173
5247
  options: elementsOptions
5174
5248
  }, React__default.createElement(CheckoutForm, {
5175
5249
  stripe_client_secret: paymentPlanIsAvailable && showPaymentPlanSection ? paymentPlanConfig.stripe_setup_intent_secret : _get(reviewData, 'payment_method.stripe_client_secret'),
5250
+ hasSeatMapActions: reviewData.flagSeatMapAllowed,
5176
5251
  total: orderData.guest_count ? orderData.pay_now : orderData.total,
5177
5252
  onSubmit: handlePaymentMiddleWare,
5178
5253
  error: error,
@@ -5799,50 +5874,6 @@ function useLocalStorageListener(key, callback) {
5799
5874
  return value;
5800
5875
  }
5801
5876
 
5802
- var style$4 = {
5803
- position: 'absolute',
5804
- top: '50%',
5805
- left: '50%',
5806
- transform: 'translate(-50%, -50%)',
5807
- minWidth: 480,
5808
- backgroundColor: '#e3e3e3',
5809
- border: '1px solid white',
5810
- outline: 'none',
5811
- padding: '14px',
5812
- maxHeight: '85vh',
5813
- overflow: 'auto'
5814
- };
5815
- var ConfirmModal = function ConfirmModal(_ref) {
5816
- var _ref$message = _ref.message,
5817
- message = _ref$message === void 0 ? '' : _ref$message,
5818
- _ref$loading = _ref.loading,
5819
- loading = _ref$loading === void 0 ? false : _ref$loading,
5820
- _ref$hideCancelBtn = _ref.hideCancelBtn,
5821
- hideCancelBtn = _ref$hideCancelBtn === void 0 ? false : _ref$hideCancelBtn,
5822
- _ref$onClose = _ref.onClose,
5823
- onClose = _ref$onClose === void 0 ? _identity : _ref$onClose,
5824
- _ref$onConfirm = _ref.onConfirm,
5825
- onConfirm = _ref$onConfirm === void 0 ? _identity : _ref$onConfirm;
5826
- return React__default.createElement(Modal$1, {
5827
- open: true,
5828
- onClose: onClose,
5829
- "aria-labelledby": "modal-modal-title",
5830
- "aria-describedby": "modal-modal-description",
5831
- className: "confirm-modal"
5832
- }, React__default.createElement(Box, {
5833
- style: style$4
5834
- }, React__default.createElement("p", null, message), React__default.createElement("div", {
5835
- className: "footer"
5836
- }, !hideCancelBtn && React__default.createElement(Button, {
5837
- onClick: onClose,
5838
- disabled: loading
5839
- }, "Cancel"), React__default.createElement(Button, {
5840
- onClick: onConfirm
5841
- }, loading ? React__default.createElement(CircularProgress, {
5842
- size: "22px"
5843
- }) : 'OK'))));
5844
- };
5845
-
5846
5877
  var isTimeExpired = function isTimeExpired(startDate, timezone) {
5847
5878
  return !moment(startDate).isAfter(moment.tz(moment(), timezone).format('YYYY-MM-DD HH:mm:ss'));
5848
5879
  };