tf-checkout-react 1.7.32-beta.0 → 1.7.32-beta.2
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/tf-checkout-react.cjs.development.js +56 -17
- package/dist/tf-checkout-react.cjs.development.js.map +1 -1
- package/dist/tf-checkout-react.cjs.production.min.js +1 -1
- package/dist/tf-checkout-react.cjs.production.min.js.map +1 -1
- package/dist/tf-checkout-react.esm.js +56 -17
- package/dist/tf-checkout-react.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/billing-info-container/hooks/useStripePayment.ts +63 -28
|
@@ -6599,27 +6599,30 @@ var usePaymentRedirect = function usePaymentRedirect(_ref) {
|
|
|
6599
6599
|
}, [stripeRef.current, setError, setLoading, removeReferralKey, removeAdditionalConfigs, handleSubmit, isBrowser]);
|
|
6600
6600
|
};
|
|
6601
6601
|
|
|
6602
|
+
var SUCCESSFUL_INTENT_STATUSES = ['succeeded', 'processing', 'requires_capture'];
|
|
6603
|
+
var PAYMENT_FAILED_MESSAGE = 'Your payment was not completed. Please try again or use another payment method.';
|
|
6604
|
+
var PAYMENT_RECEIVED_MESSAGE = 'Your payment was received and we are confirming your order. ' + 'Please check your email for your tickets before trying again.';
|
|
6602
6605
|
var useStripePayment = function useStripePayment(_ref) {
|
|
6603
6606
|
var stripeRef = _ref.stripeRef,
|
|
6604
6607
|
elementsRef = _ref.elementsRef,
|
|
6605
|
-
|
|
6608
|
+
_setError = _ref.setError,
|
|
6606
6609
|
isBrowser = _ref.isBrowser;
|
|
6607
6610
|
var processPayment = /*#__PURE__*/function () {
|
|
6608
6611
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(paymentDataResponse, values, formikHelpers, checkoutResponse, checkoutUpdateResponse, paymentData) {
|
|
6609
|
-
var attributes, isFreeTickets, updatedOrderData, eventId, _yield$elementsRef$cu, submitError, paymentContext, confirmParams, rawPhone, e164Phone,
|
|
6612
|
+
var attributes, isFreeTickets, updatedOrderData, eventId, _yield$elementsRef$cu, submitError, paymentContext, confirmParams, rawPhone, e164Phone, confirmResult, _confirmResult, confirmError, paymentIntent, paymentResponse;
|
|
6610
6613
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
6611
6614
|
while (1) switch (_context.prev = _context.next) {
|
|
6612
6615
|
case 0:
|
|
6613
6616
|
attributes = paymentData.attributes, isFreeTickets = paymentData.isFreeTickets, updatedOrderData = paymentData.updatedOrderData, eventId = paymentData.eventId;
|
|
6614
6617
|
if (isFreeTickets) {
|
|
6615
|
-
_context.next =
|
|
6618
|
+
_context.next = 33;
|
|
6616
6619
|
break;
|
|
6617
6620
|
}
|
|
6618
6621
|
if (stripeRef.current) {
|
|
6619
6622
|
_context.next = 5;
|
|
6620
6623
|
break;
|
|
6621
6624
|
}
|
|
6622
|
-
|
|
6625
|
+
_setError('Stripe is not ready');
|
|
6623
6626
|
return _context.abrupt("return", null);
|
|
6624
6627
|
case 5:
|
|
6625
6628
|
_context.next = 7;
|
|
@@ -6631,7 +6634,7 @@ var useStripePayment = function useStripePayment(_ref) {
|
|
|
6631
6634
|
_context.next = 12;
|
|
6632
6635
|
break;
|
|
6633
6636
|
}
|
|
6634
|
-
|
|
6637
|
+
_setError('' + (submitError == null ? void 0 : submitError.message));
|
|
6635
6638
|
return _context.abrupt("return", null);
|
|
6636
6639
|
case 12:
|
|
6637
6640
|
// Step 2: Store payment context before potential redirect
|
|
@@ -6660,26 +6663,44 @@ var useStripePayment = function useStripePayment(_ref) {
|
|
|
6660
6663
|
}
|
|
6661
6664
|
};
|
|
6662
6665
|
}
|
|
6663
|
-
_context.
|
|
6666
|
+
_context.prev = 16;
|
|
6667
|
+
_context.next = 19;
|
|
6664
6668
|
return stripeRef.current.confirmPayment({
|
|
6665
6669
|
clientSecret: paymentDataResponse.data.attributes.payment_method.stripe_client_secret,
|
|
6666
6670
|
elements: elementsRef.current,
|
|
6667
6671
|
confirmParams: confirmParams,
|
|
6668
6672
|
redirect: 'if_required'
|
|
6669
6673
|
});
|
|
6670
|
-
case
|
|
6671
|
-
|
|
6672
|
-
|
|
6674
|
+
case 19:
|
|
6675
|
+
confirmResult = _context.sent;
|
|
6676
|
+
_context.next = 26;
|
|
6677
|
+
break;
|
|
6678
|
+
case 22:
|
|
6679
|
+
_context.prev = 22;
|
|
6680
|
+
_context.t0 = _context["catch"](16);
|
|
6681
|
+
// Stripe.js throws (instead of returning { error }) on integration errors
|
|
6682
|
+
_setError(_get(_context.t0, 'message') || PAYMENT_FAILED_MESSAGE);
|
|
6683
|
+
return _context.abrupt("return", null);
|
|
6684
|
+
case 26:
|
|
6685
|
+
_confirmResult = confirmResult, confirmError = _confirmResult.error, paymentIntent = _confirmResult.paymentIntent;
|
|
6673
6686
|
if (!confirmError) {
|
|
6674
|
-
_context.next =
|
|
6687
|
+
_context.next = 30;
|
|
6675
6688
|
break;
|
|
6676
6689
|
}
|
|
6677
|
-
|
|
6690
|
+
_setError('' + (confirmError == null ? void 0 : confirmError.message));
|
|
6678
6691
|
return _context.abrupt("return", null);
|
|
6679
|
-
case
|
|
6692
|
+
case 30:
|
|
6693
|
+
if (!(paymentIntent && !SUCCESSFUL_INTENT_STATUSES.includes(paymentIntent.status))) {
|
|
6694
|
+
_context.next = 33;
|
|
6695
|
+
break;
|
|
6696
|
+
}
|
|
6697
|
+
_setError(_get(paymentIntent, 'last_payment_error.message') || PAYMENT_FAILED_MESSAGE);
|
|
6698
|
+
return _context.abrupt("return", null);
|
|
6699
|
+
case 33:
|
|
6680
6700
|
// Handle payment middleware for non-redirect payments
|
|
6681
6701
|
paymentResponse = null;
|
|
6682
|
-
_context.
|
|
6702
|
+
_context.prev = 34;
|
|
6703
|
+
_context.next = 37;
|
|
6683
6704
|
return handlePaymentMiddleWare(null, {}, {
|
|
6684
6705
|
reviewData: attributes,
|
|
6685
6706
|
isFreeTickets: isFreeTickets,
|
|
@@ -6689,7 +6710,9 @@ var useStripePayment = function useStripePayment(_ref) {
|
|
|
6689
6710
|
paymentResponse = data;
|
|
6690
6711
|
},
|
|
6691
6712
|
setPaymentIsLoading: _identity,
|
|
6692
|
-
setError:
|
|
6713
|
+
setError: function setError(message) {
|
|
6714
|
+
if (message && isFreeTickets) _setError(message);
|
|
6715
|
+
},
|
|
6693
6716
|
orderData: updatedOrderData,
|
|
6694
6717
|
eventId: eventId,
|
|
6695
6718
|
isBrowser: isBrowser,
|
|
@@ -6697,13 +6720,29 @@ var useStripePayment = function useStripePayment(_ref) {
|
|
|
6697
6720
|
throw error;
|
|
6698
6721
|
}
|
|
6699
6722
|
});
|
|
6700
|
-
case
|
|
6723
|
+
case 37:
|
|
6724
|
+
_context.next = 45;
|
|
6725
|
+
break;
|
|
6726
|
+
case 39:
|
|
6727
|
+
_context.prev = 39;
|
|
6728
|
+
_context.t1 = _context["catch"](34);
|
|
6729
|
+
if (!isFreeTickets) {
|
|
6730
|
+
_context.next = 43;
|
|
6731
|
+
break;
|
|
6732
|
+
}
|
|
6733
|
+
throw _context.t1;
|
|
6734
|
+
case 43:
|
|
6735
|
+
// Stripe has already taken the payment and the webhook will still settle the order,
|
|
6736
|
+
// so never invite a retry (double charge) whatever the backend error looks like
|
|
6737
|
+
_setError(PAYMENT_RECEIVED_MESSAGE);
|
|
6738
|
+
return _context.abrupt("return", null);
|
|
6739
|
+
case 45:
|
|
6701
6740
|
return _context.abrupt("return", paymentResponse);
|
|
6702
|
-
case
|
|
6741
|
+
case 46:
|
|
6703
6742
|
case "end":
|
|
6704
6743
|
return _context.stop();
|
|
6705
6744
|
}
|
|
6706
|
-
}, _callee);
|
|
6745
|
+
}, _callee, null, [[16, 22], [34, 39]]);
|
|
6707
6746
|
}));
|
|
6708
6747
|
return function processPayment(_x, _x2, _x3, _x4, _x5, _x6) {
|
|
6709
6748
|
return _ref2.apply(this, arguments);
|