COMMON_ERROR
Toss payment error: {
result: 'ERROR',
error: {
code: 'COMMON_ERROR',
message: '처리 중 오류가 발생했습니다'
}
}
터미널에 이런 에러가 뜨면서 결제정보가 데이터베이스에 저장되지 않습니다. 어떻게 해결할 수 있나요?
17 Replies
⏳ 잠시만 기다려주세요! 곧 답변드리겠습니다
오류 문의일 경우 아래 정보를 미리 전달해주시면, 빠른 답변에 도움이 됩니다.
- 주문번호(orderId) :
- 문의 내용 :
(img를 함께 첨부해주시면 도움이됩니다)
* 계약관련 내용은 1544-7772로 문의주세요.
* 주말/공휴일에는 답변이 늦을 수 있어요.
주문번호 ogVuyT1kZ3iWfCWiTN99A 입니다
테스트 결제입니다
어떤 api 호출하다가 받은에러에요?
예약생성 API 입니다.
호텔 객실 선택 후 예약자 정보 입력하고 결제완료할 때 받은 에러 입니다. 테스트 결제 창은 잘 뜨고 신용카드 또는 실시간 계좌이체로 결제하도록 하고 있고 결제 창 마지막 단계에서 결좌완료 버튼 누르면 화면에 결제성공 메시지와 주문번호 잘뜨고 토스 개발자센터 > 테스트 결제내역에도 로그가 남는데 데이터베이스에 reservations 테이블과 예약정보가 저장되지 않고 있습니다. 데이터베이스는 supabase 이용하고 있습니다.
아니요. COMMON_ERROR를 Response받은 저희 API요
next dev▲ Next.js 15.1.4 - Local: http://localhost:3000 - Network: http://172.30.1.24:3000 - Environments: .env.local ✓ Starting... ✓ Ready in 1171ms ○ Compiling / ... ✓ Compiled / in 1134ms (804 modules) ✓ Compiled in 76ms (323 modules) GET / 200 in 1947ms ○ Compiling /rooms/[id] ... ✓ Compiled /rooms/[id] in 1220ms (2663 modules) Error: Route "/rooms/[id]" used
params.id
. params
should be awaited before using its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis
at id (app/rooms/[id]/page.tsx:66:44)
64 | export default async function RoomPage(props: Props) {
65 | try {
66 | const room = await getRoom(props.params.id);| ^ 67 | 68 | if (!room) { 69 | return <div>객실을 찾을 수 없습니다.</div>; Error: Route "/rooms/[id]" used
params.id
. params
should be awaited before using its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis
at id (app/rooms/[id]/page.tsx:58:42)
56 |
57 | export async function generateMetadata(props: Props): Promise<Metadata> {
58 | const room = await getRoom(props.params.id);| ^ 59 | return { 60 | title: room ?
${room.name} - 힐링호텔
: "객실 정보",
61 | };
GET /rooms/ondol 200 in 1764ms
✓ Compiled /api/payments in 409ms (2681 modules)
Toss payment error: {
result: 'ERROR',
data: null,
error: {
code: 'COMMON_ERROR',
message: '처리 중 오류가 발생했습니다',
data: {
failUrl: 'https://pages.tosspayments.com/error/?code=COMMON_ERROR&message=%EC%B2%98%EB%A6%AC%20%EC%A4%91%20%EC%98%A4%EB%A5%98%EA%B0%80%20%EB%B0%9C%EC%83%9D%ED%96%88%EC%8A%B5%EB%8B%88%EB%8B%A4&orderId='
}
}
}
POST /api/payments 200 in 661ms
✓ Compiled /payments/success in 399ms (2699 modules)
PUT /api/payments 200 in 849ms
GET /payments/success?orderId=ogVuyT1kZ3iWfCWiTN99A&paymentKey=tviva20250206135640lwwa2&amount=60000 200 in 1376msDynamic APIs are Asynchronous
Learn more about why accessing certain APIs synchronously now warns.
이렇게 나오는데 /api/payments 이걸 호출할 때 나오는 에러인거 같습니다
/api/payments가 귀사 API이고, 토스페이먼츠 API 엔드포인트는 아닌 것 같은데요,
토스페이먼츠 API의 어떤 엔드포인트를 요청하셨을 때 그렇게 응답을 받으셨는지를 여쭤보고 있는 부분이라서 이 부분 확인 부탁드립니다.
ogVuyT1kZ3iWfCWiTN99A이 주문번호는 정상적으로 결제가 된건이네요\
토스페이먼츠의 두 가지 API 엔드포인트를 사용하고 있습니다:
결제 생성 API: POST https://api.tosspayments.com/v1/payments
결제 승인 API:POST https://api.tosspayments.com/v1/payments/{paymentKey}
COMMON_ERROR 에러받을 때 저희에게 발송한 payload전체 알 수 있을까요?
정확히 호출하신 endpoint 와 호출하신 시간 그리고 payload 를 확인해 주시기 바랍니다.
payload는 이걸 보내드리면 되나요?
// 토스 페이먼츠 요청 타입
export interface ITossPaymentProps {
amount: number;
orderId: string;
orderName: string;
customerName: string;
successUrl: string;
failUrl: string;
}
// 토스 페이먼츠 응답 타입
export interface ITossPaymentResponse {
paymentKey?: string;
orderId: string;
amount: number;
status: string;
receiptUrl?: string;
}
1. 결제 초기화 요청 (POST /api/payments):
{
amount: totalAmount, // 결제 금액
orderId: orderId, // nanoid()로 생성된 주문번호
orderName: "객실 예약", // 주문명
customerName: customerName, // 고객 이름
successUrl:
결제일시 2025-02-06 15:00:38
주문번호2yVuxRHi0rrSL5mlPId_J 완료 1. 예약 생성 시 Payload (POST /api/reservations): { roomName: string; // 객실 이름 checkIn: string; // 체크인 날짜 checkOut: string; // 체크아웃 날짜 guestName: string; // 투숙객 이름 guestPhone: string; // 투숙객 전화번호 guestEmail: string; // 투숙객 이메일 numberOfGuests: number; // 투숙 인원 numberOfRooms: number; // 객실 수 specialRequests?: string; // 특별 요청사항 totalAmount: number; // 총 결제 금액 basePrice: number; // 기본 요금 extraPersonFee: number; // 추가 인원 요금 } 2. 결제 초기화 요청 Payload (POST /api/payments): { amount: number; // 결제 금액 orderId: string; // 주문번호 (nanoid로 생성) orderName: string; // 주문명 ("객실 예약") customerName: string; // 고객 이름 successUrl: string; // 성공 시 리다이렉트 URL failUrl: string; // 실패 시 리다이렉트 URL } 3. 토스 페이먼츠 SDK 요청 Payload (requestPayment): { amount: number; // 결제 금액 orderId: string; // 주문번호 orderName: string; // 주문명 customerName: string; // 고객 이름 successUrl: string; // 성공 시 리다이렉트 URL failUrl: string; // 실패 시 리다이렉트 URL method: PaymentMethod; // 결제 수단 ("card" | "bank_transfer" | "simple_payment") } 4. 결제 승인 요청 Payload (POST /v1/payments/${paymentKey}): { paymentKey: string; // 결제 키 orderId: string; // 주문번호 amount: number; // 결제 금액 } 5.예약 상태 업데이트 Payload: { status: "pending" | "confirmed" | "cancelled"; // 예약 상태 paymentStatus: "pending" | "completed" | "failed" | "cancelled"; // 결제 상태 paymentMethod: "card" | "bank_transfer" | "simple_payment"; // 결제 수단 paymentKey?: string; // 결제 키 receiptUrl?: string; // 영수증 URL cancelReason?: string; // 취소 사유 } 6. 데이터베이스에 저장되는 예약 정보: { id: string; // UUID reservationNumber: string; // 예약번호 roomId: string; // 객실 ID checkIn: string; // 체크인 날짜 checkOut: string; // 체크아웃 날짜 status: "pending" | "confirmed" | "cancelled"; // 예약 상태 guestName: string; // 투숙객 이름 guestPhone: string; // 투숙객 전화번호 guestEmail: string; // 투숙객 이메일 numberOfGuests: number; // 투숙 인원 numberOfRooms: number; // 객실 수 specialRequests?: string; // 특별 요청사항 totalAmount: number; // 총 결제 금액 basePrice: number; // 기본 요금 extraPersonFee: number; // 추가 인원 요금 paymentStatus: "pending" | "completed" | "failed" | "cancelled"; // 결제 상태 paymentMethod?: "card" | "bank_transfer" | "simple_payment"; // 결제 수단 paymentKey?: string; // 결제 키 receiptUrl?: string; // 영수증 URL cancelReason?: string; // 취소 사유 createdAt: string; // 생성 일시 updatedAt: string; // 수정 일시 } 이것이 전체 결제 프로세스에서 사용되는 모든 payload입니다.
${window.location.origin}/payments/success
, // 성공 시 리다이렉트 URL
failUrl: ${window.location.origin}/payments/fail
// 실패 시 리다이렉트 URL
}
2. 토스 페이먼츠 SDK 요청 (requestPayment):
{
amount: totalAmount, // 결제 금액
orderId: orderId, // nanoid()로 생성된 주문번호
orderName: "객실 예약", // 주문명
customerName: customerName, // 고객 이름
successUrl: ${window.location.origin}/payments/success
, // 성공 시 리다이렉트 URL
failUrl: ${window.location.origin}/payments/fail
// 실패 시 리다이렉트 URL
}
3. 결제 승인 요청 (POST /v1/payments/${paymentKey}):
{
orderId: orderId, // 주문번호
amount: amount // 결제 금액
}
4. 이 요청들은 다음과 같은 헤더와 함께 전송됩니다:
headers: {
Authorization: Basic ${Buffer.from(TOSS_SECRET_KEY + ":").toString("base64")}
,
"Content-Type": "application/json"
}
주문일시 2025-02-06
15:00:09결제일시 2025-02-06 15:00:38
주문번호2yVuxRHi0rrSL5mlPId_J 완료 1. 예약 생성 시 Payload (POST /api/reservations): { roomName: string; // 객실 이름 checkIn: string; // 체크인 날짜 checkOut: string; // 체크아웃 날짜 guestName: string; // 투숙객 이름 guestPhone: string; // 투숙객 전화번호 guestEmail: string; // 투숙객 이메일 numberOfGuests: number; // 투숙 인원 numberOfRooms: number; // 객실 수 specialRequests?: string; // 특별 요청사항 totalAmount: number; // 총 결제 금액 basePrice: number; // 기본 요금 extraPersonFee: number; // 추가 인원 요금 } 2. 결제 초기화 요청 Payload (POST /api/payments): { amount: number; // 결제 금액 orderId: string; // 주문번호 (nanoid로 생성) orderName: string; // 주문명 ("객실 예약") customerName: string; // 고객 이름 successUrl: string; // 성공 시 리다이렉트 URL failUrl: string; // 실패 시 리다이렉트 URL } 3. 토스 페이먼츠 SDK 요청 Payload (requestPayment): { amount: number; // 결제 금액 orderId: string; // 주문번호 orderName: string; // 주문명 customerName: string; // 고객 이름 successUrl: string; // 성공 시 리다이렉트 URL failUrl: string; // 실패 시 리다이렉트 URL method: PaymentMethod; // 결제 수단 ("card" | "bank_transfer" | "simple_payment") } 4. 결제 승인 요청 Payload (POST /v1/payments/${paymentKey}): { paymentKey: string; // 결제 키 orderId: string; // 주문번호 amount: number; // 결제 금액 } 5.예약 상태 업데이트 Payload: { status: "pending" | "confirmed" | "cancelled"; // 예약 상태 paymentStatus: "pending" | "completed" | "failed" | "cancelled"; // 결제 상태 paymentMethod: "card" | "bank_transfer" | "simple_payment"; // 결제 수단 paymentKey?: string; // 결제 키 receiptUrl?: string; // 영수증 URL cancelReason?: string; // 취소 사유 } 6. 데이터베이스에 저장되는 예약 정보: { id: string; // UUID reservationNumber: string; // 예약번호 roomId: string; // 객실 ID checkIn: string; // 체크인 날짜 checkOut: string; // 체크아웃 날짜 status: "pending" | "confirmed" | "cancelled"; // 예약 상태 guestName: string; // 투숙객 이름 guestPhone: string; // 투숙객 전화번호 guestEmail: string; // 투숙객 이메일 numberOfGuests: number; // 투숙 인원 numberOfRooms: number; // 객실 수 specialRequests?: string; // 특별 요청사항 totalAmount: number; // 총 결제 금액 basePrice: number; // 기본 요금 extraPersonFee: number; // 추가 인원 요금 paymentStatus: "pending" | "completed" | "failed" | "cancelled"; // 결제 상태 paymentMethod?: "card" | "bank_transfer" | "simple_payment"; // 결제 수단 paymentKey?: string; // 결제 키 receiptUrl?: string; // 영수증 URL cancelReason?: string; // 취소 사유 createdAt: string; // 생성 일시 updatedAt: string; // 수정 일시 } 이것이 전체 결제 프로세스에서 사용되는 모든 payload입니다.
로직을 다 안알려주셔 됩니다. 제가 궁금한건 COMMON_ERROR받은 api endpoint만 알려주시면 되요
아래 주문번호로는 에러 받은 내역이 없이 결제 완료되었어요
2yVuxRHi0rrSL5mlPId_J
네, COMMON_ERROR가 발생한 API endpoint와 관련 payload만 알려드리겠습니다.
API Endpoint: https://api.tosspayments.com/v1/payments
HTTP Method: POST
Request Headers:
{
Authorization:
Basic ${Buffer.from(TOSS_SECRET_KEY + ":").toString("base64")}
,
"Content-Type": "application/json"
}
Request Payload:
{
amount: number, // 결제 금액
orderId: string, // nanoid()로 생성된 주문번호
orderName: "객실 예약", // 주문명
customerName: string, // 고객 이름
successUrl: ${window.location.origin}/payments/success
, // 성공 시 리다이렉트 URL
failUrl: ${window.location.origin}/payments/fail
, // 실패 시 리다이렉트 URL
method: "card" | "bank_transfer" | "simple_payment" // 결제 수단
}
Error Response:
{
result: 'ERROR',
data: null,
error: {
code: 'COMMON_ERROR',
message: '처리 중 오류가 발생했습니다',
data: {
failUrl: 'https://pages.tosspayments.com/error/?code=COMMON_ERROR&message=%EC%B2%98%EB%A6%AC%20%EC%A4%91%20%EC%98%A4%EB%A5%98%EA%B0%80%20%EB%B0%9C%EC%83%9D%ED%96%88%EC%8A%B5%EB%8B%88%EB%8B%A4&orderId='
}
}
}2yVuxRHi0rrSL5mlPId_J 에서도 터미널 오류, 데이터베이스 저장 안되는 오류가 계속 되고 있는데 이건 토스페이먼츠 코드와는 상관이 없는건가요?
터미널에 common_error 오류가 동일하게 뜨거든요
자체적으로 에러 해결해서 문의 클로징 하겠습니다
❤️ 기술문의 경험이 어떠셨나요?!
간단히 코멘트 남겨주세요! 제품 발전에 큰 힘이 됩니다.