findID.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. const FindID = {
  2. emailAuthOk: false,
  3. tossCertOk: false,
  4. // 토스 인증서 본인확인 요청
  5. requestTossCertToPopup: function () {
  6. $.ajax({
  7. url: (BASE_URL + "/api/requestTossCertToPopup"),
  8. type: "POST",
  9. async: true,
  10. cache: true,
  11. timeout: 3000,
  12. processData: true,
  13. dataType: "JSON",
  14. beforeSend: function (xhr) {
  15. xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  16. },
  17. success: function (response) {
  18. if (response.resultType === "FAIL") { // 실패
  19. alert(response.error.reason);
  20. // 만료되었을 경우
  21. if (response.error.errorCode === "CE1000" || response.error.errorCode === "CE3103") {
  22. location.reload();
  23. }
  24. } else {
  25. let tossCert = TossCert();
  26. tossCert.preparePopup();
  27. tossCert.start({
  28. authUrl: response.success.authUrl,
  29. txId: response.success.txId,
  30. onSuccess: function () {
  31. document.getElementById("txId").value = response.success.txId;
  32. document.getElementById("fFindID").submit();
  33. },
  34. onFail: function (error) {
  35. console.error('에러가 발생했습니다', error);
  36. },
  37. });
  38. }
  39. },
  40. error: function (xhr, status, error) {
  41. procErrorEvent(xhr, status, error);
  42. }
  43. });
  44. }
  45. }
  46. // 토스 인증서 본인확인 요청
  47. $(document).on("click", "#btnTossCertRequest", FindID.requestTossCertToPopup);