Skip to content

Commit

Permalink
request 데이터 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
KangYeonbae committed Dec 3, 2024
1 parent d77a04d commit c673e71
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 23 deletions.
1 change: 0 additions & 1 deletion src/components/steps/BookingStep3.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const BookingStep3 = ({ bookingData, handleInputChange, price }) => {
// 전달받은 시간당 가격 사용
setCalculatedPrice(diffHours * priceNumber);


}
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/steps/BookingStep4.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const BookingStep4 = ({ bookingData, bookingInfo, totalPrice }) => (
<h3 className="booking_step4-booking-info">예약정보</h3>
<p>공간: {bookingInfo.title}</p>
<p>날짜: {bookingData.date}</p>
<p>시간: {bookingData.startTime} ~ {bookingData.endTime}</p>
<p>시간: {bookingData.start_Time} ~ {bookingData.end_Time}</p>
<p>인원: {bookingData.numberOfPeople}</p>
{bookingData.requirements && (
<p>요청사항: {bookingData.requirements}</p>
Expand Down
22 changes: 17 additions & 5 deletions src/pages/booking.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('결제 처리 중 오류가 발생했습니다.');
Expand Down Expand Up @@ -90,7 +102,7 @@ export default function BookingForm() {
usageUnit={usageUnit}
/>)}
{step === 2 && <BookingStep2 bookingData={bookingData} handleInputChange={handleInputChange} />}
{step === 3 && <BookingStep3 bookingData={bookingData} handleInputChange={handleInputChange} totalPrice={totalPrice} price={bookingInfo.price} intprice={bookingInfo.intprice} spaceName={bookingData.name} />}
{step === 3 && <BookingStep3 bookingData={bookingData} handleInputChange={handleInputChange} totalPrice={totalPrice} price={bookingInfo.price} spaceName={bookingData.name} />}
{step === 4 && <BookingStep4 bookingData={bookingData} bookingInfo={bookingInfo} totalPrice={totalPrice} />}

<div className="booking_next-button">
Expand Down
1 change: 0 additions & 1 deletion src/pages/spaceDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
28 changes: 13 additions & 15 deletions src/utils/paymentService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
}
Expand Down

0 comments on commit c673e71

Please sign in to comment.