1import { receiptTemplate , orderTemplate } from "panel-pages-order-template"; 2import { checkAPI } from "api-panel"; 3import { submitOrderAPI } from "api-service"; 4import { getWalletBalance, getUserToken } from "helpers-auth-helper"; 5import { separate, copyToClipboard } from "helpers-other-helper"; 6import alert from "components-basic-alert"; 7import loading from "components-basic-loading"; 8//import {orderTemplate} from "./template"; 9 10const params = new URLSearchParams(window.location.search); 11 12let panelContent = jQuery(".panel-content"); 13let boxPageTitle = jQuery(panelContent).find(".page-title h3"); 14let boxButton = jQuery(panelContent).find(".box-btn"); 15let boxPageBody = jQuery(panelContent).find(".page-body"); 16let boxPageFooter = jQuery(panelContent).find(".page-footer"); 17 18// ========== Print receipt ========== 19// function printTable() { 20// var win = window.open('', '', 'height=50vh,width=50vw'); 21// win.document.write(); 22// win.document.close(); 23// win.print(); 24// } 25 26// ========== Fetch receipt data ========== 27function fetchReceipt({email , user_token , trackingCode}) { 28 // Start loading 29 loading(boxPageBody); 30 31 32 checkAPI(trackingCode , { 33 onSuccess: (res) => { 34 getWalletBalance((balance) => { 35 localStorage.setItem("user_wallet-en", balance); 36 jQuery("#charg-now").text(separate(balance)); 37 }); 38 39 //res = res["data"]; 40 let data = res["data"]["items"][0]; 41 42 // if (res["success"]) { 43 // Append data to receipt template 44 jQuery(boxPageBody).html(receiptTemplate.apply(data)); 45 46 // Copy to clipboard button 47 jQuery(".copyToClipboard").click(function () { 48 copyToClipboard(jQuery(this).siblings("span").text()); 49 }); 50 // } else if (res["code"] === -1) { 51 // jQuery(boxPageBody).html(alert.apply({ 52 // message: `There is no email address! Please logout of your account and login again.`, 53 // status : "danger" 54 // })); 55 // 56 // } else if (res["code"] === -2) { 57 // jQuery(boxPageBody).html(alert.apply({ 58 // message: `There is no tracking code.`, status: "danger" 59 // })); 60 // } 61 }, 62 onFailure: ({response}) => { 63 jQuery(boxPageBody).html(alert.apply({ 64 message: `There is no tracking code.`, status: "danger" 65 })); 66 } 67 // ? ---------- Handle Response ---------- 68 // if (isOk) { 69 // // Get wallet balance 70 // getWalletBalance((balance) => { 71 // localStorage.setItem("user_wallet-en", balance); 72 // jQuery("#charg-now").text(separate(balance)); 73 // }); 74 // 75 // res = res["data"]; 76 // let data = res["message"]["order"]; 77 // 78 // if (res["success"]) { 79 // // Append data to receipt template 80 // jQuery(boxPageBody).html(receiptTemplate.apply(data)); 81 // 82 // // Copy to clipboard button 83 // jQuery(".copyToClipboard").click(function () { 84 // copyToClipboard(jQuery(this).siblings("span").text()); 85 // }); 86 // } else if (res["code"] === -1) { 87 // jQuery(boxPageBody).html(alert.apply({ 88 // message: `There is no email address! Please logout of your account and login again.`, 89 // status : "danger" 90 // })); 91 // 92 // } else if (res["code"] === -2) { 93 // jQuery(boxPageBody).html(alert.apply({ 94 // message: `There is no tracking code.`, status: "danger" 95 // })); 96 // } 97 // // ? ---------- Handle Error ---------- 98 // } else { 99 // jQuery(boxPageBody).html(`<div class="alert alert-danger">Unfortunately, there was a problem! Please try again in a few minutes</div>`); 100 // } 101 });
102} 103 104// ========== Submit order ========== 105const submitOrder = (formData) => { 106 // Start loading 107 loading(boxPageBody); 108 109 if (formData?.gateway == 8) { 110 if (formData.success == 0) { 111 jQuery(boxPageBody).html(alert.apply({ 112 message: `The order was canceled by you.`, 113 status : "danger" 114 })); 115 } else if (formData.success == 1) { 116 jQuery(boxPageBody).html(alert.apply({ 117 message: `Payment successfully<br />Please wait for 2-20 minutes to confirm.<br /><b>We will send you email after confirmation.</b>`, 118 status : "success" 119 })); 120 } 121 } else { 122 submitOrderAPI( { 123 data:formData, 124 onSuccess(res) { 125 126 // Get wallet balance 127 getWalletBalance((balance) => { 128 localStorage.setItem("user_wallet-en", balance); 129 jQuery("#charg-now").text(separate(balance)); 130 }); 131 132 if (res?.["success"]) { 133 // res = res["data"]; 134 let data = res["data"]; 135 136 // Append data to receipt template 137 jQuery(boxPageBody).html(orderTemplate.apply(data)); 138 139 // Copy to clipboard button 140 jQuery(".copyToClipboard").click(function () { 141 copyToClipboard(jQuery(this).siblings("span").text()); 142 }); 143 } 144 }, 145 onFailure(error) { 146 jQuery(boxPageBody).html(alert.apply({ 147 message: `${error['response']['messages']['notification']['text']}`, status: "danger" 148 })); 149 } 150 // ? ---------- Handle Response ---------- 151 // if (isOk) { 152 // // Get wallet balance 153 // getWalletBalance((balance) => { 154 // localStorage.setItem("user_wallet-en", balance); 155 // jQuery("#charg-now").text(separate(balance)); 156 // }); 157 // 158 // res = res["data"]; 159 // if (res) { 160 // 161 // let data = res["message"]["order"]; 162 // 163 // if (res["success"]) { 164 // // Append data to receipt template 165 // jQuery(boxPageBody).html(receiptTemplate.apply(data)); 166 // 167 // // Copy to clipboard button 168 // jQuery(".copyToClipboard").click(function () { 169 // copyToClipboard(jQuery(this).siblings("span").text()); 170 // }); 171 // } else if (res["code"] === -2) { 172 // jQuery(boxPageBody).html(alert.apply({ 173 // message: `Your tracking code does not exist!`, status: "danger" 174 // })); 175 // } else if (res["code"] === -10) { 176 // jQuery(boxPageBody).html(alert.apply({ 177 // message: `Tracking code, transaction code and mobile number do not match!`, status: "danger" 178 // })); 179 // } else if (res["code"] === -11) { 180 // jQuery(boxPageBody).html(alert.apply({ 181 // message: `Your tracking code has already been registered!`, status: "danger" 182 // })); 183 // } else if (res["code"] === -12) { 184 // jQuery(boxPageBody).html(alert.apply({ 185 // message: `Unfortunately, there is a problem in confirming the order!`, status: "danger" 186 // })); 187 // } else if (res["code"] === -25) { 188 // jQuery(boxPageBody).html(alert.apply({ 189 // message: `The payment was canceled by the user!`, status: "danger" 190 // })); 191 // } else if (res["code"] === -51) { 192 // jQuery(boxPageBody).html(alert.apply({
193 // message: `The order was canceled by you!`, status: "danger" 194 // })); 195 // } else { 196 // jQuery(boxPageBody).html(alert.apply({ 197 // message: `Unknown problem! Please notify site support if you see this error`, 198 // status : "warning" 199 // })); 200 // } 201 // } else { 202 // jQuery(boxPageBody).html(alert.apply({ 203 // message: `Unknown problem! Please notify site support if you see this error`, status: "warning" 204 // })); 205 // } 206 // 207 // // ? ---------- Handle Error ---------- 208 // } else { 209 // jQuery(boxPageBody).html(alert.apply({ 210 // message: `Unfortunately, there was a problem! Please try again in a few minutes`, status: "danger" 211 // })); 212 // } 213 }); 214 } 215}; 216 217// Show receipt 218const showReceipt = () => { 219 jQuery(boxPageTitle).text("Order receipt"); 220 jQuery(boxButton).html(`<a href="${jQuery(document).config("baseUrl")}/my-account/?p=orders" class="btn btn-outline-secondary btn-sm"><i class="fas fa-shopping-bag"></i><span>Orders</span></a>`); 221 222 if (params.get("gateway")) { 223 let formData = {}; 224 225 switch (params.get("gateway")) { 226 case "1": 227 formData = { 228 PAYEE_ACCOUNT : params.get("PAYEE_ACCOUNT"), 229 PAYMENT_AMOUNT : params.get("PAYMENT_AMOUNT"), 230 PAYMENT_UNITS : params.get("PAYMENT_UNITS"), 231 PAYMENT_ID : params.get("PAYMENT_ID"), 232 PAYMENT_BATCH_NUM: params.get("PAYMENT_BATCH_NUM"), 233 TIMESTAMPGMT : params.get("TIMESTAMPGMT"), 234 V2_HASH : params.get("V2_HASH"), 235 SUGGESTED_MEMO : params.get("SUGGESTED_MEMO"), 236 PAYER_ACCOUNT : params.get("PAYER_ACCOUNT"), 237 gateway : 1, 238 tracking_code : params.get("trackingcode"), 239 authority : params.get("PAYMENT_BATCH_NUM"), 240 email : localStorage.getItem("email-en"), 241 user_token : getUserToken(), 242 site : "followeran_buy" 243 }; 244 break; 245 case "2": 246 formData = { 247 m_operation_id : params.get("m_operation_id"), 248 m_operation_ps : params.get("m_operation_ps"), 249 m_operation_date : params.get("m_operation_date"), 250 m_operation_pay_date: params.get("m_operation_pay_date"), 251 m_shop : params.get("m_shop"), 252 m_orderid : params.get("m_orderid"), 253 m_amount : params.get("m_amount"), 254 m_curr : params.get("m_curr"), 255 m_desc : params.get("m_desc"), 256 m_status : params.get("m_status"), 257 m_sign : params.get("m_sign"), 258 lang : params.get("lang"), 259 tracking_code : params.get("m_orderid"), 260 authority : params.get("m_operation_id"), 261 gateway : 2, 262 email : localStorage.getItem("email-en"), 263 user_token : getUserToken(), 264 site : "followeran_buy" 265 }; 266 break; 267 case "4": 268 formData = { 269 tracking_code: params.get("tracking_code"), 270 authority : params.get("tracking_code"), 271 gateway : 4, 272 email : localStorage.getItem("email-en"), 273 user_token : getUserToken(), 274 site : "followeran_buy" 275 }; 276 break; 277 case "5": 278 formData = { 279 tracking_code: params.get("tracking_code"), 280 authority : params.get("tracking_code"), 281 gateway : params.get("gateway"), 282 email : localStorage.getItem("email-en"), 283 user_token : getUserToken(), 284 site : "followeran_buy" 285 }; 286 break; 287 case "8": 288 formData = { // not important using form data 289 success : params.get("success"), 290 gateway : 8, 291 email : localStorage.getItem("email-en"), 292 user_token: getUserToken(), 293 site : "followeran_buy" 294 }; 295 break; 296 case "9": 297 formData = { 298 tracking_code: params.get("tracking_code"), 299 authority : params.get("transaction"), 300 gateway : 9, 301 email : localStorage.getItem("email-en"), 302 user_token : getUserToken(), 303 site : "followeran_buy" 304 }; 305 break; 306 case "16": 307 formData = { 308 tracking_code: params.get("tracking_code"), 309 authority : params.get("transaction"), 310 gateway : 16, 311 email : localStorage.getItem("email-en"), 312 user_token : getUserToken(), 313 site : "followeran_buy" 314 }; 315 break; 316 case "11": 317 formData = { 318 tracking_code: params.get("tracking_code"), 319 authority : params.get("tracking_code"), 320 gateway : params.get("gateway"), 321 email : localStorage.getItem("email-en"), 322 user_token : getUserToken(), 323 site : "followeran_buy" 324 }; 325 break; 326 case "17": 327 formData = { 328 tracking_code: params.get("tracking_code"), 329 authority : params.get("tracking_code"), 330 gateway : params.get("gateway"), 331 success : params.get("success"), 332 email : localStorage.getItem("email-en"), 333 user_token : getUserToken(), 334 site : "followeran_buy" 335 }; 336 break; 337 338 case "21": 339 formData = { 340 tracking_code: params.get("tracking_code"), 341 authority : params.get("tracking_code"), 342 gateway : params.get("gateway"), 343 success : params.get("success"), 344 email : localStorage.getItem("email-en"), 345 user_token : getUserToken(), 346 site : "followeran_buy" 347 }; 348 break; 349 default: 350 break; 351 } 352 353 // ========== Submit Order ========== 354 submitOrder(formData); 355 } else if ((params.get("trackingCode") || params.get("trackingcode") || params.get("tracking_code"))) { 356 const formData = { 357 email : params.get("email") || localStorage.getItem("email-en"), 358 user_token : getUserToken(), 359 trackingCode : params.get("trackingCode") || params.get("trackingcode") || params.get("tracking_code"), 360 }; 361 362 363 // ? ========== Fetch receipt data ========== 364 fetchReceipt(formData); 365 } else { 366 // Push data to template 367 jQuery(boxPageBody).html(alert.apply({
368 message: "Order not registered! Click the button below to track your order.", 369 status : "warning", 370 btn : {link: "orders", label: "Order tracking", icon: "<i class='fas fa-headphones-alt'></i>"} 371 })); 372 373 // jQuery(boxPageBody).find(".alert-wrapper").append(` 374 // <div style="width: fit-content;margin: 10px auto;"> 375 // <a href="https://followeran.com/my-account/?p=orders" class="btn btn-outline-secondary btn-lg active"> 376 // <span>Return to the home page</span> 377 // <i class="fas fa-arrow-left"></i> 378 // </a> 379 // </div> 380 // `); 381 } 382 383 // Refresh data button handler 384 jQuery("#refresh-data-btn").click(function () { 385 receiptPage(); 386 387 // Scroll to top 388 scrollTo(".panel-content", {offset: 200, delay: 400}); 389 }); 390}; 391 392export const receiptPage = () => { 393 jQuery(boxButton).find("button").remove(); 394 395 // Show receipt 396 showReceipt(); 397};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.