-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from Spaces-Place/dusqo
카카오결제 팝업 > 페이지로 변경
- Loading branch information
Showing
4 changed files
with
84 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,45 @@ | ||
// PaymentResult.js | ||
import { useEffect, useState } from 'react'; | ||
import { useSearchParams, useNavigate } from 'react-router-dom'; | ||
import { handlePaymentResult } from '../utils/paymentService'; | ||
import "../styles/booking.css" | ||
|
||
// PaymentResult.js | ||
export default function PaymentResult() { | ||
const [searchParams] = useSearchParams(); | ||
const navigate = useNavigate(); | ||
const [status, setStatus] = useState('결제 처리중...'); | ||
const [searchParams] = useSearchParams(); | ||
const navigate = useNavigate(); | ||
const [status, setStatus] = useState('결제 처리중...'); | ||
|
||
useEffect(() => { | ||
const processPaymentResult = async () => { | ||
try { | ||
const result = await handlePaymentResult(searchParams); | ||
setStatus('결제가 완료되었습니다.'); | ||
|
||
// 결제 성공 시 4단계로 이동 | ||
setTimeout(() => { | ||
navigate('/booking', { | ||
state: { | ||
paymentSuccess: true, | ||
orderNumber: searchParams.get('order_number') | ||
} | ||
}); | ||
}, 3000); | ||
} catch (error) { | ||
setStatus('결제 처리 중 오류가 발생했습니다.'); | ||
setTimeout(() => { | ||
navigate('/booking'); | ||
}, 3000); | ||
} | ||
}; | ||
useEffect(() => { | ||
const processPayment = async () => { | ||
const orderNumber = searchParams.get('order_number'); | ||
const pgToken = searchParams.get('pg_token'); | ||
|
||
processPaymentResult(); | ||
}, [searchParams, navigate]); | ||
if (orderNumber && pgToken) { | ||
try { | ||
const result = await handlePaymentResult(searchParams); | ||
if (result) { | ||
setStatus('결제가 완료되었습니다.'); | ||
setTimeout(() => { | ||
navigate('/booking', { | ||
state: { paymentSuccess: true } | ||
}); | ||
}, 1500); | ||
} | ||
} catch (error) { | ||
setStatus('결제 처리 중 오류가 발생했습니다.'); | ||
setTimeout(() => navigate('/booking'), 2000); | ||
} | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="booking_payment-result"> | ||
<h2 className="booking_payment-title">결제 처리 결과</h2> | ||
<p className="booking_payment-status">{status}</p> | ||
<p className="booking_payment-redirect"> | ||
잠시 후 자동으로 이동합니다... | ||
</p> | ||
</div> | ||
); | ||
} | ||
processPayment(); | ||
}, [searchParams, navigate]); | ||
|
||
return ( | ||
<div className="booking_payment-result"> | ||
<h2 className="booking_payment-title">결제 처리 결과</h2> | ||
<p className="booking_payment-status">{status}</p> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters