File tree Expand file tree Collapse file tree 1 file changed +17
-15
lines changed
src/pages/Plan/summary/components Expand file tree Collapse file tree 1 file changed +17
-15
lines changed Original file line number Diff line number Diff line change @@ -44,21 +44,23 @@ const BuyButton = ({ isStretched }: { isStretched?: boolean }) => {
4444 disabled = { status === 'approved' }
4545 onClick = { async ( ) => {
4646 setIsPaymentInProgress ( true ) ;
47-
48- await postCheckout ( {
49- body : {
50- meta : JSON . stringify ( checkoutItemData ?. metadata ) ,
51- price_id : checkoutItemData ?. price_id ?? '' ,
52- cancel_url : `${ baseUrl } /plans/${ planId } ?payment=failed` ,
53- success_url : `${ baseUrl } /plans/${ planId } ?payment=success` ,
54- } ,
55- } )
56- . unwrap ( )
57- . then ( ( response ) => {
58- if ( response . url ) {
59- window . location . href = response . url ;
60- }
61- } ) ;
47+ try {
48+ const response = await postCheckout ( {
49+ body : {
50+ meta : JSON . stringify ( checkoutItemData ?. metadata ) ,
51+ price_id : checkoutItemData ?. price_id ?? '' ,
52+ cancel_url : `${ baseUrl } /plans/${ planId } ?payment=failed` ,
53+ success_url : `${ baseUrl } /plans/${ planId } ?payment=success` ,
54+ } ,
55+ } ) . unwrap ( ) ;
56+ if ( response . url ) {
57+ window . location . href = response . url ;
58+ } else {
59+ setIsPaymentInProgress ( false ) ;
60+ }
61+ } catch ( error ) {
62+ setIsPaymentInProgress ( false ) ;
63+ }
6264 } }
6365 >
6466 { t ( '__PLAN_PAGE_BUY_BUTTON_LABEL' ) }
You can’t perform that action at this time.
0 commit comments