From c673e7143e129d6d66131063d86047a9f14ecafb Mon Sep 17 00:00:00 2001 From: KangYeonbae Date: Tue, 3 Dec 2024 18:13:19 +0900 Subject: [PATCH] =?UTF-8?q?request=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/steps/BookingStep3.js | 1 - src/components/steps/BookingStep4.js | 2 +- src/pages/booking.js | 22 +++++++++++++++++----- src/pages/spaceDetail.js | 1 - src/utils/paymentService.js | 28 +++++++++++++--------------- 5 files changed, 31 insertions(+), 23 deletions(-) diff --git a/src/components/steps/BookingStep3.js b/src/components/steps/BookingStep3.js index 8bb6433..0025388 100644 --- a/src/components/steps/BookingStep3.js +++ b/src/components/steps/BookingStep3.js @@ -21,7 +21,6 @@ const BookingStep3 = ({ bookingData, handleInputChange, price }) => { // 전달받은 시간당 가격 사용 setCalculatedPrice(diffHours * priceNumber); - } }; diff --git a/src/components/steps/BookingStep4.js b/src/components/steps/BookingStep4.js index 20e6219..a8de749 100644 --- a/src/components/steps/BookingStep4.js +++ b/src/components/steps/BookingStep4.js @@ -9,7 +9,7 @@ export const BookingStep4 = ({ bookingData, bookingInfo, totalPrice }) => (

예약정보

공간: {bookingInfo.title}

날짜: {bookingData.date}

-

시간: {bookingData.startTime} ~ {bookingData.endTime}

+

시간: {bookingData.start_Time} ~ {bookingData.end_Time}

인원: {bookingData.numberOfPeople}명

{bookingData.requirements && (

요청사항: {bookingData.requirements}

diff --git a/src/pages/booking.js b/src/pages/booking.js index 8ad75aa..8fd44aa 100644 --- a/src/pages/booking.js +++ b/src/pages/booking.js @@ -55,13 +55,25 @@ export default function BookingForm() { try { setPaymentProcessing(true); if (bookingData.paymentMethod === 'kakao') { - const response = await initiateKakaoPayment(bookingData, totalPrice, bookingInfo.spaceId); - // 카카오페이 결제창으로 바로 이동 + // 날짜와 시간을 합쳐서 전달 + const paymentData = { + date: new Date(bookingData.start_time).toISOString().split('T')[0], // YYYY-MM-DD 형식 + startTime: new Date(bookingData.start_time).toISOString(), + endTime: new Date(bookingData.end_time).toISOString(), + name: bookingData.name, + phone: bookingData.phone, + email: bookingData.email + }; + + const response = await initiateKakaoPayment( + paymentData, + totalPrice, + bookingInfo.spaceId + ); + if (response.next_redirect_pc_url) { window.location.href = response.next_redirect_pc_url; } - } else { - alert('현재 카카오페이만 지원됩니다.'); } } catch (error) { alert('결제 처리 중 오류가 발생했습니다.'); @@ -90,7 +102,7 @@ export default function BookingForm() { usageUnit={usageUnit} />)} {step === 2 && } - {step === 3 && } + {step === 3 && } {step === 4 && }
diff --git a/src/pages/spaceDetail.js b/src/pages/spaceDetail.js index d7f1e40..7968781 100644 --- a/src/pages/spaceDetail.js +++ b/src/pages/spaceDetail.js @@ -100,7 +100,6 @@ export default function SpaceDetail({type: propType}) { spacetype: spaceData.space_type, spaceId: spaceData.space_id, name: spaceData.space_name, - intprice: spaceData.unit_price.toLocaleString(), price: `${spaceData.unit_price.toLocaleString()}원 / ${spaceData.usage_unit}`, usageUnit: spaceData.usage_unit } diff --git a/src/utils/paymentService.js b/src/utils/paymentService.js index ed0e4a5..dd38c8c 100644 --- a/src/utils/paymentService.js +++ b/src/utils/paymentService.js @@ -22,15 +22,18 @@ export const initiateKakaoPayment = async (bookingData, totalPrice, spaceId) => throw new Error('로그인이 필요합니다.'); } - try { - // 요청 데이터 구성 - const requestData = { - space_id: spaceId, - use_date: bookingData.date, - start_time: bookingData.startTime, - end_time: bookingData.endTime - }; + // requestData를 try 블록 밖으로 이동 + const requestData = { + space_id: spaceId, + use_date: bookingData.date, + start_time: bookingData.startTime, + end_time: bookingData.endTime, + name: bookingData.name, + phone: bookingData.phone, + email: bookingData.email + }; + try { // 데이터 유효성 사전 체크 console.log('Request Data:', { ...requestData, @@ -49,18 +52,13 @@ export const initiateKakaoPayment = async (bookingData, totalPrice, spaceId) => } return response.data; - } catch (error) { + } catch (error) { console.error('Server Error Details:', { message: error.message, response_data: error.response?.data, status: error.response?.status, serverMessage: error.response?.data?.message || error.response?.data?.detail, - requestData: { - space_id: spaceId, - use_date: bookingData.date, - start_time: bookingData.startTime, - end_time: bookingData.endTime - } + requestData: requestData // 이제 접근 가능 }); throw error; }