File tree Expand file tree Collapse file tree 1 file changed +19
-19
lines changed
frontend/src/components/forms/StripeCheckoutForm Expand file tree Collapse file tree 1 file changed +19
-19
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,25 @@ export default function StripeCheckoutForm({setSubmitHandler}: {
2222 const { data : order , isFetched : isOrderFetched } = useGetOrderPublic ( eventId , orderShortId , [ 'event' ] ) ;
2323 const event = order ?. event ;
2424
25+ const handleSubmit = async ( ) => {
26+ if ( ! stripe || ! elements ) {
27+ return ;
28+ }
29+
30+ const { error} = await stripe . confirmPayment ( {
31+ elements,
32+ confirmParams : {
33+ return_url : window ?. location . origin + `/checkout/${ eventId } /${ orderShortId } /payment_return`
34+ } ,
35+ } ) ;
36+
37+ if ( error ?. type === "card_error" || error ?. type === "validation_error" ) {
38+ setMessage ( error . message ) ;
39+ } else {
40+ setMessage ( t `An unexpected error occurred.` ) ;
41+ }
42+ } ;
43+
2544 useEffect ( ( ) => {
2645 if ( ! stripe ) {
2746 return ;
@@ -88,25 +107,6 @@ export default function StripeCheckoutForm({setSubmitHandler}: {
88107 ) ;
89108 }
90109
91- const handleSubmit = async ( ) => {
92- if ( ! stripe || ! elements ) {
93- return ;
94- }
95-
96- const { error} = await stripe . confirmPayment ( {
97- elements,
98- confirmParams : {
99- return_url : window ?. location . origin + `/checkout/${ eventId } /${ orderShortId } /payment_return`
100- } ,
101- } ) ;
102-
103- if ( error ?. type === "card_error" || error ?. type === "validation_error" ) {
104- setMessage ( error . message ) ;
105- } else {
106- setMessage ( t `An unexpected error occurred.` ) ;
107- }
108- } ;
109-
110110 const paymentElementOptions : stripeJs . StripePaymentElementOptions = {
111111 layout : {
112112 type : "accordion" ,
You can’t perform that action at this time.
0 commit comments