tf-checkout-react 1.7.8 → 1.7.13

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.
@@ -5634,7 +5634,8 @@ var PaymentPlanSection = function PaymentPlanSection(props) {
5634
5634
  // Wrapper component to access Stripe hooks inside Elements context
5635
5635
  var StripeWrapper = function StripeWrapper(_ref) {
5636
5636
  var options = _ref.options,
5637
- onStripeReady = _ref.onStripeReady;
5637
+ onStripeReady = _ref.onStripeReady,
5638
+ onPaymentElementChange = _ref.onPaymentElementChange;
5638
5639
  var stripe = useStripe();
5639
5640
  var elements = useElements();
5640
5641
  useEffect(function () {
@@ -5643,7 +5644,8 @@ var StripeWrapper = function StripeWrapper(_ref) {
5643
5644
  }
5644
5645
  }, [stripe, elements, onStripeReady]);
5645
5646
  return React.createElement(PaymentElement, {
5646
- options: options
5647
+ options: options,
5648
+ onChange: onPaymentElementChange
5647
5649
  });
5648
5650
  };
5649
5651
  var initialPaymentPlanConfiguration = {
@@ -5735,6 +5737,7 @@ var PaymentContainer = function PaymentContainer(_ref2) {
5735
5737
  stripeAccountId = _ref2.stripeAccountId,
5736
5738
  _ref2$onStripeReady = _ref2.onStripeReady,
5737
5739
  onStripeReady = _ref2$onStripeReady === void 0 ? _identity : _ref2$onStripeReady,
5740
+ onPaymentElementChange = _ref2.onPaymentElementChange,
5738
5741
  _ref2$enablePaymentPl = _ref2.enablePaymentPlan,
5739
5742
  enablePaymentPlan = _ref2$enablePaymentPl === void 0 ? true : _ref2$enablePaymentPl;
5740
5743
  var _useState = useState(initialReviewValues),
@@ -6118,7 +6121,8 @@ var PaymentContainer = function PaymentContainer(_ref2) {
6118
6121
  options: elementsOptions
6119
6122
  }, React.createElement(StripeWrapper, {
6120
6123
  onStripeReady: onStripeReady,
6121
- options: paymentElementOptions
6124
+ options: paymentElementOptions,
6125
+ onPaymentElementChange: onPaymentElementChange
6122
6126
  })))) : displayPaymentButton ? React.createElement("div", {
6123
6127
  className: "payment_button " + (paymentIsLoading ? 'disabled-payment-button' : '')
6124
6128
  }, React.createElement("button", {
@@ -6435,38 +6439,34 @@ var useStripePayment = function useStripePayment(_ref) {
6435
6439
  isBrowser = _ref.isBrowser;
6436
6440
  var processPayment = /*#__PURE__*/function () {
6437
6441
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(paymentDataResponse, values, formikHelpers, checkoutResponse, checkoutUpdateResponse, paymentData) {
6438
- var attributes, isFreeTickets, updatedOrderData, eventId, _yield$elementsRef$cu, submitError, paymentContext, _yield$stripeRef$curr, confirmError, paymentResponse;
6442
+ var attributes, isFreeTickets, updatedOrderData, eventId, _yield$elementsRef$cu, submitError, paymentContext, confirmParams, rawPhone, e164Phone, _yield$stripeRef$curr, confirmError, paymentResponse;
6439
6443
  return _regeneratorRuntime().wrap(function _callee$(_context) {
6440
6444
  while (1) switch (_context.prev = _context.next) {
6441
6445
  case 0:
6442
6446
  attributes = paymentData.attributes, isFreeTickets = paymentData.isFreeTickets, updatedOrderData = paymentData.updatedOrderData, eventId = paymentData.eventId;
6443
6447
  if (isFreeTickets) {
6444
- _context.next = 25;
6448
+ _context.next = 23;
6445
6449
  break;
6446
6450
  }
6447
6451
  if (stripeRef.current) {
6448
- _context.next = 6;
6452
+ _context.next = 5;
6449
6453
  break;
6450
6454
  }
6451
6455
  setError('Stripe is not ready');
6452
- console.log('Stripe is not ready in billing-info-container');
6453
6456
  return _context.abrupt("return", null);
6454
- case 6:
6455
- console.log('Stripe confirmPayment in billing-info-container');
6456
- // Step 1: Submit elements first
6457
- _context.next = 9;
6457
+ case 5:
6458
+ _context.next = 7;
6458
6459
  return elementsRef.current.submit();
6459
- case 9:
6460
+ case 7:
6460
6461
  _yield$elementsRef$cu = _context.sent;
6461
6462
  submitError = _yield$elementsRef$cu.error;
6462
6463
  if (!submitError) {
6463
- _context.next = 15;
6464
+ _context.next = 12;
6464
6465
  break;
6465
6466
  }
6466
6467
  setError('' + (submitError == null ? void 0 : submitError.message));
6467
- console.log('Stripe elements.submit() error in billing-info-container', submitError);
6468
6468
  return _context.abrupt("return", null);
6469
- case 15:
6469
+ case 12:
6470
6470
  // Step 2: Store payment context before potential redirect
6471
6471
  paymentContext = {
6472
6472
  attributes: attributes,
@@ -6481,30 +6481,38 @@ var useStripePayment = function useStripePayment(_ref) {
6481
6481
  };
6482
6482
  localStorage.setItem('stripe_payment_context', JSON.stringify(paymentContext));
6483
6483
  // Step 3: Confirm payment with current page return URL
6484
- _context.next = 19;
6484
+ confirmParams = {
6485
+ return_url: window.location.href + (window.location.href.includes('?') ? '&' : '?') + 'payment_return=true'
6486
+ };
6487
+ if (values != null && values.phone) {
6488
+ rawPhone = String(values.phone).replace(/[\s\-().]/g, '');
6489
+ e164Phone = rawPhone.startsWith('+') ? rawPhone : "+" + rawPhone;
6490
+ confirmParams.payment_method_data = {
6491
+ billing_details: {
6492
+ phone: e164Phone
6493
+ }
6494
+ };
6495
+ }
6496
+ _context.next = 18;
6485
6497
  return stripeRef.current.confirmPayment({
6486
6498
  clientSecret: paymentDataResponse.data.attributes.payment_method.stripe_client_secret,
6487
6499
  elements: elementsRef.current,
6488
- confirmParams: {
6489
- return_url: window.location.href + (window.location.href.includes('?') ? '&' : '?') + 'payment_return=true'
6490
- },
6500
+ confirmParams: confirmParams,
6491
6501
  redirect: 'if_required'
6492
6502
  });
6493
- case 19:
6503
+ case 18:
6494
6504
  _yield$stripeRef$curr = _context.sent;
6495
6505
  confirmError = _yield$stripeRef$curr.error;
6496
6506
  if (!confirmError) {
6497
- _context.next = 25;
6507
+ _context.next = 23;
6498
6508
  break;
6499
6509
  }
6500
6510
  setError('' + (confirmError == null ? void 0 : confirmError.message));
6501
- console.log('Stripe confirmPayment error in billing-info-container');
6502
6511
  return _context.abrupt("return", null);
6503
- case 25:
6504
- console.log('Stripe confirmPayment success in billing-info-container');
6512
+ case 23:
6505
6513
  // Handle payment middleware for non-redirect payments
6506
6514
  paymentResponse = null;
6507
- _context.next = 29;
6515
+ _context.next = 26;
6508
6516
  return handlePaymentMiddleWare(null, {}, {
6509
6517
  reviewData: attributes,
6510
6518
  isFreeTickets: isFreeTickets,
@@ -6522,9 +6530,9 @@ var useStripePayment = function useStripePayment(_ref) {
6522
6530
  throw error;
6523
6531
  }
6524
6532
  });
6525
- case 29:
6533
+ case 26:
6526
6534
  return _context.abrupt("return", paymentResponse);
6527
- case 30:
6535
+ case 27:
6528
6536
  case "end":
6529
6537
  return _context.stop();
6530
6538
  }
@@ -7011,7 +7019,7 @@ var BillingInfoContainer = /*#__PURE__*/React.memo(function (_ref6) {
7011
7019
  setSingleCheckoutAddOns = _useState25[1];
7012
7020
  var orderIsFree = !Number(checkoutData == null ? void 0 : checkoutData.total);
7013
7021
  useEffect(function () {
7014
- var hasUniqueId = _get(dataWithUniqueIds, '[0].uniqueId');
7022
+ var hasUniqueId = _get(data, '[0].uniqueId');
7015
7023
  var isEqualData = _isEqual(prevData.current, data);
7016
7024
  if (!hasUniqueId || !isEqualData) {
7017
7025
  setDataWithUniqueIds(assingUniqueIds(data));
@@ -7019,7 +7027,7 @@ var BillingInfoContainer = /*#__PURE__*/React.memo(function (_ref6) {
7019
7027
  prevData.current = data;
7020
7028
  }
7021
7029
  }
7022
- }, [dataWithUniqueIds, data]);
7030
+ }, [data]);
7023
7031
  var getQuantity = useCallback(function (cart) {
7024
7032
  if (cart === void 0) {
7025
7033
  cart = [];
@@ -7975,6 +7983,11 @@ var BillingInfoContainer = /*#__PURE__*/React.memo(function (_ref6) {
7975
7983
  checkoutData: checkoutData,
7976
7984
  elementsOptions: elementsOptions,
7977
7985
  paymentElementOptions: {
7986
+ fields: {
7987
+ billingDetails: {
7988
+ phone: 'never'
7989
+ }
7990
+ },
7978
7991
  wallets: {
7979
7992
  applePay: (checkoutUpdateData == null ? void 0 : (_checkoutUpdateData$a6 = checkoutUpdateData.additional_payment_information) == null ? void 0 : (_checkoutUpdateData$a7 = _checkoutUpdateData$a6.stripe_wallets) == null ? void 0 : _checkoutUpdateData$a7.applePay) || 'never',
7980
7993
  googlePay: (checkoutUpdateData == null ? void 0 : (_checkoutUpdateData$a8 = checkoutUpdateData.additional_payment_information) == null ? void 0 : (_checkoutUpdateData$a9 = _checkoutUpdateData$a8.stripe_wallets) == null ? void 0 : _checkoutUpdateData$a9.googlePay) || 'never'