자동빌링 관련한 문제
TypeError: Cannot read properties of undefined (reading 'customerKey') 오류가 Toss Payments SDK 내부(v1:8:493552)에서 발생하고 있는데, 어떻게 디버깅해야할까요?
어떻게 해도, 고쳐지지가 않습니다. 일반 결제에서 자동결제(빌링)으로 코드를 바꾸는데, 일반결제는 테스트결제로도 넘어가는데, 지금은 아예 넘어가지질 않는 상태입니다.
저희 코드에서는 customerKey가 명확하게 정의되어 Toss Payments SDK로 전달되고 있습니다. src/components/SubscriptionModal.tsx 파일의 handlePayment 함수를 안에서, 다음과 같이 customerKey를 생성하고 있습니다:
const customerKey =
그리고 이 customerKey는 billingAuthOptions 객체에 포함되어 tossPayments.requestBillingAuth() 함수로 전달됩니다:
const billingAuthOptions = {
customerKey: customerKey,
successUrl: successUrl,
failUrl: failUrl,
customerName: customerName,
customerEmail: userEmail
};
await tossPayments.requestBillingAuth(billingAuthOptions);
또한, 제공해주신 콘솔 로그에서도 customerKey가 올바르게 생성되어 billingAuthOptions 객체에 포함된 것을 확인할 수 있습니다:
Customer info prepared: {customerKey: 'customer_1_1753760036255', customerEmail: '이메일, customerName: '아이디', userId: 1}
Billing auth options: Object (이 객체 안에 customerKey가 포함되어 있습니다.)
따라서, 저희 코드에서 customerKey는 분명히 정의되어 올바르게 전달되고 있습니다. TypeError: Cannot read properties of undefined (reading 'customerKey') 오류가 발생하는 것은 Toss Payments SDK 내부에서 billingAuthOptions 객체를 처리하는 과정에서 customerKey를 제대로 참조하지 못하는 문제인지, 아니면 제 코드에서 변경을 해야하는것인지, 도와주시면 감사하겠습니다.
어떻게 해도, 고쳐지지가 않습니다. 일반 결제에서 자동결제(빌링)으로 코드를 바꾸는데, 일반결제는 테스트결제로도 넘어가는데, 지금은 아예 넘어가지질 않는 상태입니다.
저희 코드에서는 customerKey가 명확하게 정의되어 Toss Payments SDK로 전달되고 있습니다. src/components/SubscriptionModal.tsx 파일의 handlePayment 함수를 안에서, 다음과 같이 customerKey를 생성하고 있습니다:
const customerKey =
customer_${userId}_${Date.now()};그리고 이 customerKey는 billingAuthOptions 객체에 포함되어 tossPayments.requestBillingAuth() 함수로 전달됩니다:
const billingAuthOptions = {
customerKey: customerKey,
successUrl: successUrl,
failUrl: failUrl,
customerName: customerName,
customerEmail: userEmail
};
await tossPayments.requestBillingAuth(billingAuthOptions);
또한, 제공해주신 콘솔 로그에서도 customerKey가 올바르게 생성되어 billingAuthOptions 객체에 포함된 것을 확인할 수 있습니다:
따라서, 저희 코드에서 customerKey는 분명히 정의되어 올바르게 전달되고 있습니다. TypeError: Cannot read properties of undefined (reading 'customerKey') 오류가 발생하는 것은 Toss Payments SDK 내부에서 billingAuthOptions 객체를 처리하는 과정에서 customerKey를 제대로 참조하지 못하는 문제인지, 아니면 제 코드에서 변경을 해야하는것인지, 도와주시면 감사하겠습니다.