자동결제 시 catch 부분이 작동하지 않습니다.

    "@tosspayments/payment-sdk": "^1.7.0",

.

.

const loadPayment = async (userId: string) => {
  const tossPayments = await loadTossPayments(clientKey);

  tossPayments
    .requestBillingAuth('카드', {
      customerKey: userId,
      successUrl: `${clientUrl}/credit/purchase?result=success`,
      failUrl: `${clientUrl}/credit/purchase?result=fail`,
    })
    .catch((error: any) => {
      // 여기서 사용자가 결제창을 닫았거나, 기타 오류를 처리합니다.
      if (error.code === 'USER_CANCEL') {
        // 사용자가 결제창을 닫은 경우의 처리 로직
        alert('결제창이 닫혔습니다.');
      }
    });
};

iframe된 UI
시 successUrl,
.
(iframe )
catch 서 cancelPayments나 error당 catch.

, .
{
    "code": "4246",
    "message": "이미 결제가 완료되었습니다.",
    "data": {
        "bypassMessage": true
    }
}

requestPayments 땐 catch??
2024-02-22_5.50.10.png
Was this page helpful?