From 86e81f61e0a6155bf2aeaa7e4a67cf75f4da6cea Mon Sep 17 00:00:00 2001 From: Yun Seongmin Date: Mon, 23 Feb 2026 10:57:52 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EA=B2=B0=EC=A0=9C=20=EC=83=81?= =?UTF-8?q?=ED=83=9C=EB=A5=BC=20=ED=99=95=EC=9D=B8=ED=95=98=EA=B3=A0=20?= =?UTF-8?q?=EA=B2=B0=EC=A0=9C=20=EC=83=9D=EC=84=B1=20=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/errorMessage.ts | 6 ------ src/pages/Payment/Payment.Api.ts | 2 +- src/pages/Payment/usePaymentPolling.ts | 16 ++++++++++++++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/api/errorMessage.ts b/src/api/errorMessage.ts index 8749aeb..688a33d 100644 --- a/src/api/errorMessage.ts +++ b/src/api/errorMessage.ts @@ -45,12 +45,6 @@ const specificMessages: Record< 409: "이미 완료되었거나 처리할 수 없는 상태의 결제입니다.", }, }, - "/payments/status": { - GET: { - 404: "사용자 정보를 찾을 수 없습니다.", - }, - }, - // --- 쿠폰 (Coupons) --- "/coupons/code": { POST: { diff --git a/src/pages/Payment/Payment.Api.ts b/src/pages/Payment/Payment.Api.ts index 7c8d651..8720986 100644 --- a/src/pages/Payment/Payment.Api.ts +++ b/src/pages/Payment/Payment.Api.ts @@ -21,7 +21,7 @@ export const makePayment = async (selectedCoupons: number[]) => { }; interface PaymentPollingResult { - status: string; + status: "NOT_CREATED" | "PENDING" | "COMPLETED"; finalPrice: number; } diff --git a/src/pages/Payment/usePaymentPolling.ts b/src/pages/Payment/usePaymentPolling.ts index a1eb12f..233c70d 100644 --- a/src/pages/Payment/usePaymentPolling.ts +++ b/src/pages/Payment/usePaymentPolling.ts @@ -88,11 +88,23 @@ export const usePaymentPolling = () => { // 결제 생성 및 폴링 시작 로직 const initializePayment = async () => { try { - await makePayment([]); + const paymentStatus = await pollPaymentStatus(); + setFinalPrice(paymentStatus.finalPrice); + + if (paymentStatus.status === "COMPLETED") { + setStatus("success"); + return; + } + if (paymentStatus.status === "PENDING") { + startPolling(); + return; + } + + await makePayment([]); startPolling(); } catch (error) { - // 409 에러는 이미 결제가 생성된 경우이므로, 정상적으로 폴링을 시작합니다. + // 409 에러는 상태 조회 이후 동시 요청으로 이미 결제가 생성된 경우이므로 정상적으로 폴링을 시작합니다. if (error instanceof ServerError && error.status === 409) { startPolling(); } else {