Skip to content

Commit 6dec846

Browse files
authored
fix: 모바일 결제 오류 (#425)
1 parent 41aaa00 commit 6dec846

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/pages/payment/Purchase.jsx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ const Purchase = () => {
214214
// setIsLoading(false);
215215
// return;
216216
// }
217-
217+
218218
if (buyPerform && !phoneValid) {
219219
alert("전화번호 입력 형식을 다시 확인해 주세요 (010-****-****)");
220220
setIsLoading(false);
@@ -239,7 +239,6 @@ const Purchase = () => {
239239
},
240240
],
241241
paymentMethod: payableAmount === 0 ? 0 : 1, // 0원: 0, 유료: 1,
242-
userId,
243242
};
244243

245244
if (buyPerform) {
@@ -267,6 +266,24 @@ const Purchase = () => {
267266
return;
268267
}
269268

269+
const orderRes = await axios.post(
270+
`${SERVER_URL}order/item`,
271+
requestBody,
272+
{
273+
headers: {
274+
"Content-Type": "application/json",
275+
Authorization: `Bearer ${Cookies.get("accessToken")}`,
276+
},
277+
}
278+
);
279+
280+
const orderId = orderRes.data?.orderId;
281+
282+
if (!orderId) {
283+
alert(orderRes.data?.error ?? "주문 생성 실패");
284+
return;
285+
}
286+
270287
// 5) 유료 결제: NICEPAY 결제창 호출
271288
if (!nicepayReady) {
272289
alert(
@@ -299,16 +316,16 @@ const Purchase = () => {
299316
"podo_payment_request",
300317
JSON.stringify(requestBody)
301318
);
302-
319+
303320
setIsPayModalOpen(true);
304321

305322
requestPay({
306323
clientId: import.meta.env.VITE_NICEPAY_CLIENT_KEY,
307324
method: nicepayMethod, // 'card' | 'bank' | 'vbank'
308-
orderId: nicepayOrderId,
325+
orderId,
309326
amount: payableAmount,
310327
goodsName,
311-
returnUrl: `${SERVER_URL}order/item`,
328+
returnUrl: `${SERVER_URL}order/nicepay/return`,
312329
mallReserved: JSON.stringify(requestBody),
313330
fnError: (e) => {
314331
const msg = e?.errorMsg || "";

0 commit comments

Comments
 (0)