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.
@@ -33,6 +33,7 @@ export interface IPaymentPage {
33
33
  stripePublishableKey?: string;
34
34
  stripeAccountId?: string;
35
35
  onStripeReady?: (stripe: any, elements: any) => void;
36
+ onPaymentElementChange?: (event: any) => void;
36
37
  enablePaymentPlan?: boolean;
37
38
  }
38
- export declare const PaymentContainer: ({ paymentFields, handlePayment, formTitle, errorText, checkoutData, onErrorClose, onGetPaymentDataSuccess, onGetPaymentDataError, onPaymentError, themeOptions, elementsOptions, paymentElementOptions, onCountdownFinish, enableTimer, orderInfoLabel, paymentInfoLabel, displayPaymentButton, hidePaymentForm, hideFieldsBlock, isSinglePageCheckout, stripePublishableKey, stripeAccountId, onStripeReady, enablePaymentPlan, }: IPaymentPage) => JSX.Element;
39
+ export declare const PaymentContainer: ({ paymentFields, handlePayment, formTitle, errorText, checkoutData, onErrorClose, onGetPaymentDataSuccess, onGetPaymentDataError, onPaymentError, themeOptions, elementsOptions, paymentElementOptions, onCountdownFinish, enableTimer, orderInfoLabel, paymentInfoLabel, displayPaymentButton, hidePaymentForm, hideFieldsBlock, isSinglePageCheckout, stripePublishableKey, stripeAccountId, onStripeReady, onPaymentElementChange, enablePaymentPlan, }: IPaymentPage) => JSX.Element;
@@ -5641,7 +5641,8 @@ var PaymentPlanSection = function PaymentPlanSection(props) {
5641
5641
  // Wrapper component to access Stripe hooks inside Elements context
5642
5642
  var StripeWrapper = function StripeWrapper(_ref) {
5643
5643
  var options = _ref.options,
5644
- onStripeReady = _ref.onStripeReady;
5644
+ onStripeReady = _ref.onStripeReady,
5645
+ onPaymentElementChange = _ref.onPaymentElementChange;
5645
5646
  var stripe = reactStripeJs.useStripe();
5646
5647
  var elements = reactStripeJs.useElements();
5647
5648
  React.useEffect(function () {
@@ -5650,7 +5651,8 @@ var StripeWrapper = function StripeWrapper(_ref) {
5650
5651
  }
5651
5652
  }, [stripe, elements, onStripeReady]);
5652
5653
  return React__default.createElement(reactStripeJs.PaymentElement, {
5653
- options: options
5654
+ options: options,
5655
+ onChange: onPaymentElementChange
5654
5656
  });
5655
5657
  };
5656
5658
  var initialPaymentPlanConfiguration = {
@@ -5742,6 +5744,7 @@ var PaymentContainer = function PaymentContainer(_ref2) {
5742
5744
  stripeAccountId = _ref2.stripeAccountId,
5743
5745
  _ref2$onStripeReady = _ref2.onStripeReady,
5744
5746
  onStripeReady = _ref2$onStripeReady === void 0 ? _identity : _ref2$onStripeReady,
5747
+ onPaymentElementChange = _ref2.onPaymentElementChange,
5745
5748
  _ref2$enablePaymentPl = _ref2.enablePaymentPlan,
5746
5749
  enablePaymentPlan = _ref2$enablePaymentPl === void 0 ? true : _ref2$enablePaymentPl;
5747
5750
  var _useState = React.useState(initialReviewValues),
@@ -6125,7 +6128,8 @@ var PaymentContainer = function PaymentContainer(_ref2) {
6125
6128
  options: elementsOptions
6126
6129
  }, React__default.createElement(StripeWrapper, {
6127
6130
  onStripeReady: onStripeReady,
6128
- options: paymentElementOptions
6131
+ options: paymentElementOptions,
6132
+ onPaymentElementChange: onPaymentElementChange
6129
6133
  })))) : displayPaymentButton ? React__default.createElement("div", {
6130
6134
  className: "payment_button " + (paymentIsLoading ? 'disabled-payment-button' : '')
6131
6135
  }, React__default.createElement("button", {
@@ -6442,38 +6446,34 @@ var useStripePayment = function useStripePayment(_ref) {
6442
6446
  isBrowser = _ref.isBrowser;
6443
6447
  var processPayment = /*#__PURE__*/function () {
6444
6448
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(paymentDataResponse, values, formikHelpers, checkoutResponse, checkoutUpdateResponse, paymentData) {
6445
- var attributes, isFreeTickets, updatedOrderData, eventId, _yield$elementsRef$cu, submitError, paymentContext, _yield$stripeRef$curr, confirmError, paymentResponse;
6449
+ var attributes, isFreeTickets, updatedOrderData, eventId, _yield$elementsRef$cu, submitError, paymentContext, confirmParams, rawPhone, e164Phone, _yield$stripeRef$curr, confirmError, paymentResponse;
6446
6450
  return _regeneratorRuntime().wrap(function _callee$(_context) {
6447
6451
  while (1) switch (_context.prev = _context.next) {
6448
6452
  case 0:
6449
6453
  attributes = paymentData.attributes, isFreeTickets = paymentData.isFreeTickets, updatedOrderData = paymentData.updatedOrderData, eventId = paymentData.eventId;
6450
6454
  if (isFreeTickets) {
6451
- _context.next = 25;
6455
+ _context.next = 23;
6452
6456
  break;
6453
6457
  }
6454
6458
  if (stripeRef.current) {
6455
- _context.next = 6;
6459
+ _context.next = 5;
6456
6460
  break;
6457
6461
  }
6458
6462
  setError('Stripe is not ready');
6459
- console.log('Stripe is not ready in billing-info-container');
6460
6463
  return _context.abrupt("return", null);
6461
- case 6:
6462
- console.log('Stripe confirmPayment in billing-info-container');
6463
- // Step 1: Submit elements first
6464
- _context.next = 9;
6464
+ case 5:
6465
+ _context.next = 7;
6465
6466
  return elementsRef.current.submit();
6466
- case 9:
6467
+ case 7:
6467
6468
  _yield$elementsRef$cu = _context.sent;
6468
6469
  submitError = _yield$elementsRef$cu.error;
6469
6470
  if (!submitError) {
6470
- _context.next = 15;
6471
+ _context.next = 12;
6471
6472
  break;
6472
6473
  }
6473
6474
  setError('' + (submitError == null ? void 0 : submitError.message));
6474
- console.log('Stripe elements.submit() error in billing-info-container', submitError);
6475
6475
  return _context.abrupt("return", null);
6476
- case 15:
6476
+ case 12:
6477
6477
  // Step 2: Store payment context before potential redirect
6478
6478
  paymentContext = {
6479
6479
  attributes: attributes,
@@ -6488,30 +6488,38 @@ var useStripePayment = function useStripePayment(_ref) {
6488
6488
  };
6489
6489
  localStorage.setItem('stripe_payment_context', JSON.stringify(paymentContext));
6490
6490
  // Step 3: Confirm payment with current page return URL
6491
- _context.next = 19;
6491
+ confirmParams = {
6492
+ return_url: window.location.href + (window.location.href.includes('?') ? '&' : '?') + 'payment_return=true'
6493
+ };
6494
+ if (values != null && values.phone) {
6495
+ rawPhone = String(values.phone).replace(/[\s\-().]/g, '');
6496
+ e164Phone = rawPhone.startsWith('+') ? rawPhone : "+" + rawPhone;
6497
+ confirmParams.payment_method_data = {
6498
+ billing_details: {
6499
+ phone: e164Phone
6500
+ }
6501
+ };
6502
+ }
6503
+ _context.next = 18;
6492
6504
  return stripeRef.current.confirmPayment({
6493
6505
  clientSecret: paymentDataResponse.data.attributes.payment_method.stripe_client_secret,
6494
6506
  elements: elementsRef.current,
6495
- confirmParams: {
6496
- return_url: window.location.href + (window.location.href.includes('?') ? '&' : '?') + 'payment_return=true'
6497
- },
6507
+ confirmParams: confirmParams,
6498
6508
  redirect: 'if_required'
6499
6509
  });
6500
- case 19:
6510
+ case 18:
6501
6511
  _yield$stripeRef$curr = _context.sent;
6502
6512
  confirmError = _yield$stripeRef$curr.error;
6503
6513
  if (!confirmError) {
6504
- _context.next = 25;
6514
+ _context.next = 23;
6505
6515
  break;
6506
6516
  }
6507
6517
  setError('' + (confirmError == null ? void 0 : confirmError.message));
6508
- console.log('Stripe confirmPayment error in billing-info-container');
6509
6518
  return _context.abrupt("return", null);
6510
- case 25:
6511
- console.log('Stripe confirmPayment success in billing-info-container');
6519
+ case 23:
6512
6520
  // Handle payment middleware for non-redirect payments
6513
6521
  paymentResponse = null;
6514
- _context.next = 29;
6522
+ _context.next = 26;
6515
6523
  return handlePaymentMiddleWare(null, {}, {
6516
6524
  reviewData: attributes,
6517
6525
  isFreeTickets: isFreeTickets,
@@ -6529,9 +6537,9 @@ var useStripePayment = function useStripePayment(_ref) {
6529
6537
  throw error;
6530
6538
  }
6531
6539
  });
6532
- case 29:
6540
+ case 26:
6533
6541
  return _context.abrupt("return", paymentResponse);
6534
- case 30:
6542
+ case 27:
6535
6543
  case "end":
6536
6544
  return _context.stop();
6537
6545
  }
@@ -7018,7 +7026,7 @@ var BillingInfoContainer = /*#__PURE__*/React__default.memo(function (_ref6) {
7018
7026
  setSingleCheckoutAddOns = _useState25[1];
7019
7027
  var orderIsFree = !Number(checkoutData == null ? void 0 : checkoutData.total);
7020
7028
  React.useEffect(function () {
7021
- var hasUniqueId = _get(dataWithUniqueIds, '[0].uniqueId');
7029
+ var hasUniqueId = _get(data, '[0].uniqueId');
7022
7030
  var isEqualData = _isEqual(prevData.current, data);
7023
7031
  if (!hasUniqueId || !isEqualData) {
7024
7032
  setDataWithUniqueIds(assingUniqueIds(data));
@@ -7026,7 +7034,7 @@ var BillingInfoContainer = /*#__PURE__*/React__default.memo(function (_ref6) {
7026
7034
  prevData.current = data;
7027
7035
  }
7028
7036
  }
7029
- }, [dataWithUniqueIds, data]);
7037
+ }, [data]);
7030
7038
  var getQuantity = React.useCallback(function (cart) {
7031
7039
  if (cart === void 0) {
7032
7040
  cart = [];
@@ -7982,6 +7990,11 @@ var BillingInfoContainer = /*#__PURE__*/React__default.memo(function (_ref6) {
7982
7990
  checkoutData: checkoutData,
7983
7991
  elementsOptions: elementsOptions,
7984
7992
  paymentElementOptions: {
7993
+ fields: {
7994
+ billingDetails: {
7995
+ phone: 'never'
7996
+ }
7997
+ },
7985
7998
  wallets: {
7986
7999
  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',
7987
8000
  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'