File tree Expand file tree Collapse file tree
app/(pages)/order/[orderId]/process Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33import { useEffect , useState } from "react" ;
44import { useRouter , useSearchParams } from "next/navigation" ;
5+ import { isAxiosError } from "axios" ;
56
67import { usePaymentConfirmMutation } from "@/data/payments/postPaymentConfirm/mutation" ;
78import { LoadingWithLayout } from "@/shared/components/LoadingWithLayout" ;
@@ -32,15 +33,21 @@ const PaymentProcessPage = () => {
3233 `${ window . location . origin } /order/${ searchParams . get ( "orderId" ) } /success?eventName=${ encodeURIComponent ( eventName ) } &eventDate=${ encodeURIComponent ( eventDate ) } ` ,
3334 ) ;
3435 } catch ( error ) {
35- // TODO: 에러 처리 로직 추가
3636 // 에러 메시지 세분화 요청
37- // 결제 실패 페이지로 라우팅
38- alert ( "결제 실패" ) ;
37+ if ( isAxiosError ( error ) ) {
38+ alert ( error . message ) ;
39+ }
3940
41+ // 결제 실패 페이지로 라우팅
4042 window . location . replace (
4143 `${ window . location . origin } /order/${ searchParams . get ( "orderId" ) } /fail` ,
4244 ) ;
45+
46+ return ;
4347 }
48+
49+ alert ( "알 수 없는 이유로 결제에 실패했습니다. 다시 시도해주세요." ) ;
50+ window . location . replace ( `${ window . location . origin } ` ) ;
4451 } ;
4552
4653 handlePaymentConfirm ( ) ;
Original file line number Diff line number Diff line change @@ -39,7 +39,10 @@ instance.interceptors.response.use(
3939 return Promise . reject ( error ) ;
4040 }
4141
42- if ( error . response ?. status === ERROR_CODE . SERVER_ERROR ) {
42+ if ( error . response ?. status === 500 ) {
43+ // 결제 에러는 공통 alert 미노출
44+ if ( error . response ?. data . code === ERROR_CODE . PAYMENT ) return ;
45+
4346 alert ( "서버에러가 발생하였습니다. 관리자에게 문의해주세요." ) ;
4447
4548 return ;
Original file line number Diff line number Diff line change @@ -3,5 +3,5 @@ export const ERROR_CODE = {
33 ACCESS_TOKEN_EXPIRED : 40103 ,
44 REFRESH_TOKEN_EXPIRED : 40104 ,
55 NO_ACCESS_TOKEN : 40403 ,
6- SERVER_ERROR : 500 ,
6+ PAYMENT : 50004 ,
77} as const ;
You can’t perform that action at this time.
0 commit comments