(function() { var take = async function() { //DDP const chatform=localStorage.getItem("chatform") const BASE_URL = "https://pr.aqur.com"; const fetchOptions = { method: "POST", headers: { "Content-Type": "application/json" } }; var path = window.location.pathname; if(chatform && path.includes('/lp/confirm')){ var ComfirmExe=()=>{ var ComfirmInterval = setInterval(function () { const ComfirmPC = document.querySelector('.submit_bottom_ec') const ComfirmSP = document.querySelector('.submit_bottom_sp_ec') if(ComfirmPC){ console.log("confirm pc") clearInterval(ComfirmInterval); ComfirmPC.click() }else if(ComfirmSP){ console.log("confirm sp") clearInterval(ComfirmInterval); ComfirmSP.click() } }, 100); } ComfirmExe() } if(chatform && path.includes('/lp/complete')){ console.log("complete") async function track(trackingData) { try { await fetch(`${BASE_URL}/track`, { ...fetchOptions, body: trackingData }); localStorage.removeItem("chatform"); const orderId = new URLSearchParams(window.location.search).get('order_id'); console.log("Test => ", orderId) if (orderId) { let chatformData = JSON.parse(chatform); const response2 = await fetch(`${BASE_URL}/pdi/${chatformData.uuId}`); const data2 = await response2.json(); data2.data.data.order_id = orderId; data2.data.Completed = true; data2.data.status = "Completed"; await fetch(`${BASE_URL}/pdi/set`, { ...fetchOptions, body: JSON.stringify(data2.data) }); } } catch (error) { console.error('Error:', error); } } track(chatform); } if(/\/lp/.test(path) || /\/lp\/new/.test(path)) { await new Promise(resolve => setTimeout(resolve, 4000)) async function checkErrors(){ console.log("checkerror") let errors= "" const alert_danger = document.querySelector('#alert-box'); if (alert_danger) { errors = alert_danger.textContent alert_danger.remove() } return errors } let error = await checkErrors() if(error) { let chatformData = JSON.parse(chatform); const response2 = await fetch(`${BASE_URL}/pdi/${chatformData.uuId}`); const data2 = await response2.json(); data2.data.Completed = false; if(/カード情報を確認してください/.test(error)) { data2.data.status = "creditcardCheckNG"; } else if(/与信審査が通りませんでした/.test(error)) { data2.data.status = "postpaymentCheckNG"; } else { data2.data.message = error } await fetch(`${BASE_URL}/pdi/set`, { ...fetchOptions, body: JSON.stringify(data2.data) }); } } } setTimeout(take, 0); }())