Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/api/errorMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ const specificMessages: Record<
409: "이미 완료되었거나 처리할 수 없는 상태의 결제입니다.",
},
},
"/payments/status": {
GET: {
404: "사용자 정보를 찾을 수 없습니다.",
},
},

// --- 쿠폰 (Coupons) ---
"/coupons/code": {
POST: {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Payment/Payment.Api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const makePayment = async (selectedCoupons: number[]) => {
};

interface PaymentPollingResult {
status: string;
status: "NOT_CREATED" | "PENDING" | "COMPLETED";
finalPrice: number;
}

Expand Down
16 changes: 14 additions & 2 deletions src/pages/Payment/usePaymentPolling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down