| 1 |
/*--Start-- Manage Scheduled Plan Change State*/ |
| 2 |
var __tagembed__plan_status = null; |
| 3 |
var __tagembed__plan_order = { 53: 0, 42: 1, 28: 2, 29: 3, 67: 0, 69: 1, 68: 2, 66: 3 }; |
| 4 |
function __tagembed__isPlanChangeLocked() { |
| 5 |
return !!(__tagembed__plan_status && __tagembed__plan_status.lockPlanButtons); |
| 6 |
} |
| 7 |
function __tagembed__showPlanLockedToast() { |
| 8 |
let message = (__tagembed__plan_status && __tagembed__plan_status.message) ? __tagembed__plan_status.message : "A plan change is already scheduled on your account."; |
| 9 |
new TagembedToast().danger({ message: message, position: '__tagembed__is-top-right' }); |
| 10 |
} |
| 11 |
function __tagembed__planChangeDateText() { |
| 12 |
if (__tagembed__plan_status && __tagembed__plan_status.effectiveLabel) return __tagembed__plan_status.effectiveLabel; |
| 13 |
if (__tagembed__billing_summary && __tagembed__billing_summary.renewsLabel) return __tagembed__billing_summary.renewsLabel; |
| 14 |
return ""; |
| 15 |
} |
| 16 |
function __tagembed__isDowngradeSelection(planId, billingCycle) { |
| 17 |
if (!__tagembed__plan_status || !__tagembed__plan_status.currentPlanId) return false; |
| 18 |
let currentOrder = __tagembed__plan_order[__tagembed__plan_status.currentPlanId]; |
| 19 |
let newOrder = __tagembed__plan_order[planId]; |
| 20 |
if (currentOrder === undefined || newOrder === undefined) return false; |
| 21 |
if (currentOrder === 0) return false; |
| 22 |
if (newOrder > currentOrder) return false; |
| 23 |
if (newOrder < currentOrder) return true; |
| 24 |
return !(Number(__tagembed__plan_status.currentBillingCycle) === 0 && Number(billingCycle) === 1); |
| 25 |
} |
| 26 |
function __tagembed__render_plan_notice() { |
| 27 |
let noticeBox = document.querySelector("#__tagembed__plan_notice"); |
| 28 |
let noticeTitle = document.querySelector("#__tagembed__plan_notice_title"); |
| 29 |
let noticeMessage = document.querySelector("#__tagembed__plan_notice_message"); |
| 30 |
if (!noticeBox || !noticeTitle || !noticeMessage) return; |
| 31 |
if (!__tagembed__isPlanChangeLocked()) { |
| 32 |
noticeBox.style.display = "none"; |
| 33 |
return; |
| 34 |
} |
| 35 |
noticeTitle.textContent = __tagembed__plan_status.title ? __tagembed__plan_status.title : "Plan change scheduled"; |
| 36 |
let noticeText = __tagembed__plan_status.message ? __tagembed__plan_status.message : ""; |
| 37 |
noticeMessage.textContent = ""; |
| 38 |
if (typeof __tagembed__confirmDialogMessage === "function") __tagembed__confirmDialogMessage(noticeMessage, noticeText, [__tagembed__plan_status.effectiveLabel]); |
| 39 |
else noticeMessage.textContent = noticeText; |
| 40 |
noticeBox.style.display = "block"; |
| 41 |
} |
| 42 |
function __tagembed__applyPendingPlanState() { |
| 43 |
__tagembed__render_plan_notice(); |
| 44 |
if (!__tagembed__plan_status) return; |
| 45 |
let planWrap = document.querySelector("#__tagembed__plan"); |
| 46 |
if (!planWrap) return; |
| 47 |
if (__tagembed__isPlanChangeLocked()) { |
| 48 |
planWrap.querySelectorAll("[data-tagembed-action], .__tagembed__selectbtn_cancelled").forEach(function (planButton) { |
| 49 |
if (planButton.parentNode) planButton.parentNode.removeChild(planButton); |
| 50 |
}); |
| 51 |
} |
| 52 |
if (!__tagembed__plan_status.canResume) return; |
| 53 |
let activeBox = planWrap.querySelector(".__tagembed__activeplan"); |
| 54 |
if (!activeBox || activeBox.querySelector("[data-tagembed-action='resume-subscription']")) return; |
| 55 |
activeBox.querySelectorAll("[data-tagembed-action='cancel-subscription'], .__tagembed__selectbtn_cancelled").forEach(function (oldButton) { |
| 56 |
if (oldButton.parentNode) oldButton.parentNode.removeChild(oldButton); |
| 57 |
}); |
| 58 |
let resumeButton = document.createElement("a"); |
| 59 |
resumeButton.className = "__tagembed__selectbtn"; |
| 60 |
resumeButton.setAttribute("href", "javascript:void(0);"); |
| 61 |
resumeButton.setAttribute("data-tagembed-action", "resume-subscription"); |
| 62 |
resumeButton.textContent = "Restart Subscription"; |
| 63 |
resumeButton.addEventListener("click", function () { |
| 64 |
__tagembed__resume_subscription(); |
| 65 |
}); |
| 66 |
activeBox.appendChild(resumeButton); |
| 67 |
} |
| 68 |
function __tagembed__resume_subscription() { |
| 69 |
let changeDate = __tagembed__planChangeDateText(); |
| 70 |
let onText = changeDate ? (" Your plan will keep running and renew on " + changeDate + ".") : ""; |
| 71 |
__tagembed__confirmDialog({ |
| 72 |
title: 'Restart subscription?', |
| 73 |
message: 'Your cancellation will be removed and your current plan will continue.' + onText, |
| 74 |
buttonText: 'Restart', |
| 75 |
type: 'info', |
| 76 |
align: 'justify', |
| 77 |
highlight: [changeDate] |
| 78 |
}, function () { |
| 79 |
let __tagembed__toast = new TagembedToast; |
| 80 |
let formData = new FormData(); |
| 81 |
formData.append('action', 'tagembed_data'); |
| 82 |
formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); |
| 83 |
formData.append('__tagembed__ajax_action', '__tagembed__resume_subscription'); |
| 84 |
__tagembed__open_loader(); |
| 85 |
fetch(__tagembed__ajax_url, { |
| 86 |
method: 'POST', |
| 87 |
headers: { |
| 88 |
'x-requested-with': 'XMLHttpRequest', |
| 89 |
}, |
| 90 |
body: formData, |
| 91 |
}).then(response => { |
| 92 |
return response.json() |
| 93 |
}).then(response => { |
| 94 |
__tagembed__close_loader(); |
| 95 |
if (response.status == true) { |
| 96 |
__tagembed__toast.success({ message: response.hasOwnProperty("message") ? response.message : "Your subscription has been restarted", position: '__tagembed__is-top-right' }); |
| 97 |
setTimeout(function () { |
| 98 |
window.location.reload(); |
| 99 |
}, 1500); |
| 100 |
return; |
| 101 |
} |
| 102 |
__tagembed__toast.danger({ message: response.hasOwnProperty("message") ? response.message : "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); |
| 103 |
}).catch((error) => { |
| 104 |
console.log(error); |
| 105 |
__tagembed__close_loader(); |
| 106 |
__tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); |
| 107 |
}); |
| 108 |
}); |
| 109 |
} |
| 110 |
function __tagembed__get_plan_status() { |
| 111 |
let formData = new FormData(); |
| 112 |
formData.append('action', 'tagembed_data'); |
| 113 |
formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); |
| 114 |
formData.append('__tagembed__ajax_action', '__tagembed__get_plan_status'); |
| 115 |
fetch(__tagembed__ajax_url, { |
| 116 |
method: 'POST', |
| 117 |
headers: { |
| 118 |
'x-requested-with': 'XMLHttpRequest', |
| 119 |
}, |
| 120 |
body: formData, |
| 121 |
}).then(response => { |
| 122 |
return response.json() |
| 123 |
}).then(response => { |
| 124 |
if (response.status !== true || !response.hasOwnProperty("data")) return; |
| 125 |
__tagembed__plan_status = response.data; |
| 126 |
__tagembed__applyPendingPlanState(); |
| 127 |
}).catch((error) => { |
| 128 |
console.log(error); |
| 129 |
}); |
| 130 |
} |
| 131 |
window.addEventListener ? window.addEventListener("load", __tagembed__get_plan_status, false) : window.attachEvent && window.attachEvent("onload", __tagembed__get_plan_status); |
| 132 |
/*--End-- Manage Scheduled Plan Change State*/ |
| 133 |
/*--Start-- Manage Cancelled Subscription State*/ |
| 134 |
var __tagembed__billing_summary = null; |
| 135 |
function __tagembed__applyCancelledPlanState() { |
| 136 |
if (!__tagembed__billing_summary || !__tagembed__billing_summary.cancelled) return; |
| 137 |
let planWrap = document.querySelector("#__tagembed__plan"); |
| 138 |
if (!planWrap) return; |
| 139 |
planWrap.querySelectorAll('[data-tagembed-action="cancel-subscription"]').forEach(function (button) { |
| 140 |
let label = document.createElement("span"); |
| 141 |
label.className = "__tagembed__selectbtn __tagembed__selectbtn_cancelled"; |
| 142 |
label.textContent = "Cancelled"; |
| 143 |
if (__tagembed__billing_summary.renewsLabel) label.setAttribute("title", "Access ends on " + __tagembed__billing_summary.renewsLabel); |
| 144 |
if (button.parentNode) button.parentNode.replaceChild(label, button); |
| 145 |
}); |
| 146 |
} |
| 147 |
/*--End-- Manage Cancelled Subscription State*/ |
| 148 |
/*--Start-- Manage Upgrade Page Tabs*/ |
| 149 |
function __tagembed__manageUpgradeTab(tabName) { |
| 150 |
let planTab = document.querySelector("#__tagembed__upgrade_tab_plan"); |
| 151 |
let invoiceTab = document.querySelector("#__tagembed__upgrade_tab_invoice"); |
| 152 |
let planPanel = document.querySelector("#__tagembed__upgrade_plan_panel"); |
| 153 |
let invoicePanel = document.querySelector("#__tagembed__invoice_section"); |
| 154 |
if (!planTab || !invoiceTab || !planPanel || !invoicePanel) return; |
| 155 |
if (tabName === "invoice") { |
| 156 |
planTab.classList.remove("__tagembed__active"); |
| 157 |
invoiceTab.classList.add("__tagembed__active"); |
| 158 |
planPanel.style.display = "none"; |
| 159 |
invoicePanel.style.display = "block"; |
| 160 |
} else { |
| 161 |
invoiceTab.classList.remove("__tagembed__active"); |
| 162 |
planTab.classList.add("__tagembed__active"); |
| 163 |
invoicePanel.style.display = "none"; |
| 164 |
planPanel.style.display = "block"; |
| 165 |
} |
| 166 |
} |
| 167 |
/*--End-- Manage Upgrade Page Tabs*/ |
| 168 |
/*--Start--Manage All Feacture Hide Show*/ |
| 169 |
function __tagembed__manageAllFeactureHideShow() { |
| 170 |
let __tagembed__all_feacture_section = document.querySelector("#__tagembed__all_feacture_section"); |
| 171 |
let __tagembed__all_feacture_button = document.querySelector("#__tagembed__all_feacture_button"); |
| 172 |
if (__tagembed__all_feacture_section.style.display === "none") { |
| 173 |
__tagembed__all_feacture_section.style.display = "block"; |
| 174 |
__tagembed__all_feacture_button.textContent = "Hide Comparison"; |
| 175 |
} else { |
| 176 |
__tagembed__all_feacture_section.style.display = "none"; |
| 177 |
__tagembed__all_feacture_button.textContent = "Compare All Plans"; |
| 178 |
} |
| 179 |
} |
| 180 |
/*--End--Manage All Feacture Hide Show*/ |
| 181 |
/*--Start--Manage All Feacture Hide Show*/ |
| 182 |
function __tagembed__manageSelectPlanPrice(timePeriod) { |
| 183 |
let __tagembbed__monthely_price_button = document.querySelector("#__tagembbed__monthely_price_button"); |
| 184 |
let __tagembbed__yearly_price_button = document.querySelector("#__tagembbed__yearly_price_button"); |
| 185 |
if (timePeriod == "monthely") { |
| 186 |
document.querySelectorAll('.__tagembed__yearly_plan').forEach(function (el) { |
| 187 |
el.style.display = 'none'; |
| 188 |
}); |
| 189 |
document.querySelectorAll('.__tagembed__monthely_plan').forEach(function (el) { |
| 190 |
el.style.display = 'block'; |
| 191 |
}); |
| 192 |
document.querySelectorAll('.__tagembed__selectbtn_yearly').forEach(function (el) { |
| 193 |
el.style.display = 'none'; |
| 194 |
}); |
| 195 |
document.querySelectorAll('.__tagembed__selectbtn_monthely').forEach(function (el) { |
| 196 |
el.style.display = 'block'; |
| 197 |
}); |
| 198 |
__tagembbed__monthely_price_button.classList.add("__tagembed__active"); |
| 199 |
__tagembbed__yearly_price_button.classList.remove("__tagembed__active"); |
| 200 |
} else if (timePeriod == "yearly") { |
| 201 |
document.querySelectorAll('.__tagembed__yearly_plan').forEach(function (el) { |
| 202 |
el.style.display = 'block'; |
| 203 |
}); |
| 204 |
document.querySelectorAll('.__tagembed__monthely_plan').forEach(function (el) { |
| 205 |
el.style.display = 'none'; |
| 206 |
}); |
| 207 |
document.querySelectorAll('.__tagembed__selectbtn_yearly').forEach(function (el) { |
| 208 |
el.style.display = 'block'; |
| 209 |
}); |
| 210 |
document.querySelectorAll('.__tagembed__selectbtn_monthely').forEach(function (el) { |
| 211 |
el.style.display = 'none'; |
| 212 |
}); |
| 213 |
__tagembbed__yearly_price_button.classList.add("__tagembed__active"); |
| 214 |
__tagembbed__monthely_price_button.classList.remove("__tagembed__active"); |
| 215 |
} |
| 216 |
} |
| 217 |
/*--End--Manage All Feacture Hide Show*/ |
| 218 |
/*--Start-- Get User Accounts Details*/ |
| 219 |
window.addEventListener ? window.addEventListener("load", __tagembed__get_account_details, false) : window.attachEvent && window.attachEvent("onload", __tagembed__get_account_details); |
| 220 |
function __tagembed__get_account_details() { |
| 221 |
let __tagembed__all_feacture_section = document.querySelector("#__tagembed__all_feacture_section"); |
| 222 |
let allFeactureRemovableKeys = ['id', 'created', 'modified', 'webEmbed', 'status', 'collaborator', 'collaboratorStatus', 'themes', 'updatesIntervalCron', 'unit_cron', 'retainPost']; |
| 223 |
let allFeactureIcons = ['apiLimit', 'name', 'retainPostCount', 'support', 'walls', 'feeds', 'linkedInFeedLimit', 'linkedInFeedLimit', 'twitterFeedLimit', 'viewCount'] |
| 224 |
let freeTrialPlanIds = ['1']; |
| 225 |
let __tagembed__plan = document.querySelector("#__tagembed__plan"); |
| 226 |
let __tagembed__toast = new TagembedToast; |
| 227 |
let formData = new FormData(); |
| 228 |
formData.append('action', 'tagembed_data'); |
| 229 |
formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); |
| 230 |
formData.append('__tagembed__ajax_action', '__tagembed__get_account_details'); |
| 231 |
__tagembed__open_loader(); |
| 232 |
fetch(__tagembed__ajax_url, { |
| 233 |
method: 'POST', |
| 234 |
headers: { |
| 235 |
'x-requested-with': 'XMLHttpRequest', |
| 236 |
}, |
| 237 |
body: formData, |
| 238 |
}).then(response => { |
| 239 |
return response.json() |
| 240 |
}).then(response => { |
| 241 |
__tagembed__close_loader(); |
| 242 |
if (response.status == true) { |
| 243 |
|
| 244 |
/*--Start-- Manage Upgrade Plan Section Hide | Show*/ |
| 245 |
let __tagembed__upgrade_plan_section = document.querySelector("#__tagembed__upgrade_plan_section"); |
| 246 |
let __tagembed__support_section = document.querySelector("#__tagembed__support_section"); |
| 247 |
if (response.data.upgradeSection && response.data.upgradeSection === "hide") { |
| 248 |
if (__tagembed__upgrade_plan_section) { |
| 249 |
__tagembed__upgrade_plan_section.style.display = "none"; |
| 250 |
} |
| 251 |
if (__tagembed__support_section) { |
| 252 |
__tagembed__support_section.style.display = "block"; |
| 253 |
} |
| 254 |
return false; |
| 255 |
} |
| 256 |
/*--End-- Manage Upgrade Plan Section Hide | Show*/ |
| 257 |
|
| 258 |
/*--Start-- Manage All Feacture Section*/ |
| 259 |
let allFeactureHTML = ""; |
| 260 |
let i = 0; |
| 261 |
for (let indexxxxx in response.data.Product) { |
| 262 |
if (indexxxxx == "Plan") { |
| 263 |
for (let indexxxxxx in response.data.Product[indexxxxx]) { |
| 264 |
if (!freeTrialPlanIds.includes(response.data.Product[indexxxxx][indexxxxxx].Plan.id)) { |
| 265 |
const selectedKeys = [ |
| 266 |
'name', 'walls', 'feeds', 'Networks', 'branding', 'api', 'support', 'apiLimit', |
| 267 |
'customCss', 'manualModeration', 'automaticModeration', 'webAnalytic', |
| 268 |
'customPost', 'customBanner', 'profanityFilter', 'cta', 'cdn', 'retainPostCount', |
| 269 |
'linkedInFeedLimit', 'twitterFeedLimit', 'viewCount' |
| 270 |
]; |
| 271 |
if (i === 0) { |
| 272 |
allFeactureHTML += '<tr>'; |
| 273 |
|
| 274 |
for (const key of selectedKeys) { |
| 275 |
const planRuleData = response.data.Product[indexxxxx][indexxxxxx].PlanRule; |
| 276 |
if (planRuleData.hasOwnProperty(key) && !allFeactureRemovableKeys.includes(key)) { |
| 277 |
allFeactureHTML += `<th>${__tagembed__escapeText(key.replace(/([A-Z])/g, ' $1'))}</th>`; |
| 278 |
} |
| 279 |
} |
| 280 |
allFeactureHTML += '<th>Networks</th></tr>'; |
| 281 |
} |
| 282 |
i++; |
| 283 |
allFeactureHTML += '<tr>'; |
| 284 |
|
| 285 |
for (const key of selectedKeys) { |
| 286 |
const planRuleData = response.data.Product[indexxxxx][indexxxxxx].PlanRule; |
| 287 |
if (planRuleData.hasOwnProperty(key) && !allFeactureRemovableKeys.includes(key)) { |
| 288 |
if (allFeactureIcons.includes(key)) { |
| 289 |
allFeactureHTML += `<td>${__tagembed__escapeText(planRuleData[key])}</td>`; |
| 290 |
} else { |
| 291 |
if (planRuleData[key] == "1") { |
| 292 |
allFeactureHTML += `<td class="text-center mb-0"><img src="${__tagembed__plugin_url_for_js}assets/images/plan-ok.svg" alt="access" class="img-fluid"></td>`; |
| 293 |
} else { |
| 294 |
allFeactureHTML += `<td class="text-center mb-0"><img src="${__tagembed__plugin_url_for_js}assets/images/plan-cross.svg" alt="no-access" class="img-fluid"></td>`; |
| 295 |
} |
| 296 |
} |
| 297 |
} |
| 298 |
} |
| 299 |
allFeactureHTML += '<td>'; |
| 300 |
for (let network of response.data.Product[indexxxxx][indexxxxxx].Planrulenetwork) { |
| 301 |
allFeactureHTML += `<img style="height:14px; margin:2px;" src="${__tagembed__plugin_url_for_js}assets/images/network/${__tagembed__escapeAttr(network.network)}.png"/>`; |
| 302 |
} |
| 303 |
allFeactureHTML += '</td></tr>'; |
| 304 |
} |
| 305 |
} |
| 306 |
} |
| 307 |
} |
| 308 |
__tagembed__setSafeHtml(__tagembed__all_feacture_section, `<table> ${allFeactureHTML}</table>`); |
| 309 |
/*--End-- Manage All Feacture Section*/ |
| 310 |
/*--Start-- Manage Plan Serction Section*/ |
| 311 |
let elemHTML = ""; |
| 312 |
let __tagembed__activePlanId = (response.data.Product && response.data.Product.ActivePlan && response.data.Product.ActivePlan.id) ? response.data.Product.ActivePlan.id : ""; |
| 313 |
for (let indexx in response.data.Product) { |
| 314 |
if (indexx == "Plan") { |
| 315 |
for (let indexxx in response.data.Product[indexx]) { |
| 316 |
elemHTML = `${elemHTML}<div class="__tagembed__planbox ${(response.data.Product[indexx][indexxx].Plan.id == __tagembed__activePlanId) ? '__tagembed__activeplan' : ''}">`; |
| 317 |
if (response.data.Product[indexx][indexxx].Plan.id == __tagembed__activePlanId) |
| 318 |
elemHTML = `${elemHTML}<span class="__tagembed__currentplan">Current Plan</span>`; |
| 319 |
elemHTML = `${elemHTML}<strong>${__tagembed__escapeText(response.data.Product[indexx][indexxx].Plan.name)}</strong>`; |
| 320 |
let monthelyPrice = response.data.Product[indexx][indexxx].Plan.wordpessMonthlyPrice; |
| 321 |
let yearlyPrice = response.data.Product[indexx][indexxx].Plan.wordpressYearlyPrice; |
| 322 |
if (response.data.Product[indexx][indexxx].Plan.id == 67 || response.data.Product[indexx][indexxx].Plan.id == 53) { |
| 323 |
elemHTML = `${elemHTML}<h2>Free</h2>`; |
| 324 |
} else { |
| 325 |
elemHTML = `${elemHTML}<h2 class="__tagembed__monthely_plan" style="display:none;">$${__tagembed__escapeText(monthelyPrice)}/Mo</h2>`; |
| 326 |
elemHTML = `${elemHTML}<h2 class="__tagembed__yearly_plan">$${__tagembed__escapeText(yearlyPrice)}/Mo</h2>`; |
| 327 |
} |
| 328 |
elemHTML = `${elemHTML}<p>${__tagembed__escapeText(response.data.Product[indexx][indexxx].Plan.description)}</p>`; |
| 329 |
elemHTML = `${elemHTML}<ul>`; |
| 330 |
elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-ok.svg" alt="access" />${__tagembed__escapeText(response.data.Product[indexx][indexxx].PlanRule.feeds)} ${response.data.Product[indexx][indexxx].Plan.id == 67 || response.data.Product[indexx][indexxx].Plan.id == 53 ? `Feed` : `Feeds`}</li>`; |
| 331 |
elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-ok.svg" alt="access" />${__tagembed__escapeText(response.data.Product[indexx][indexxx].PlanRule.viewCount)} Views/Month</li>`; |
| 332 |
if (response.data.Product[indexx][indexxx].Plan.id != 67 && response.data.Product[indexx][indexxx].Plan.id != 53) { |
| 333 |
if (response.data.Product[indexx][indexxx].PlanRule.linkedInFeedLimit != 0) { |
| 334 |
elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-ok.svg" alt="access" />LinkedIn Auto Update (Max ${__tagembed__escapeText(response.data.Product[indexx][indexxx].PlanRule.linkedInFeedLimit)} Feeds)</li>`; |
| 335 |
} else { |
| 336 |
elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-ok.svg" alt="access" />LinkedIn Manual</li>`; |
| 337 |
} |
| 338 |
} else { |
| 339 |
elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-cross.svg" alt="no-access" />LinkedIn Feed</li>`; |
| 340 |
} |
| 341 |
elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-ok.svg" alt="access" />${__tagembed__escapeText(response.data.Product[indexx][indexxx].PlanRule.updatesIntervalCron)} ${(response.data.Product[indexx][indexxx].PlanRule.unit_cron == 3600) ? "Hours" : "Mins"} Update Time</li>`; |
| 342 |
if (response.data.Product[indexx][indexxx].PlanRule.customCss == 0) { |
| 343 |
elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-cross.svg" alt="no-access" />No Custom CSS</li>`; |
| 344 |
} else { |
| 345 |
elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-ok.svg" alt="access" />Custom CSS</li>`; |
| 346 |
} |
| 347 |
if (response.data.Product[indexx][indexxx].PlanRule.branding == 0) { |
| 348 |
elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-cross.svg" alt="no-access" />No Tagembed Branding</li>`; |
| 349 |
} else { |
| 350 |
elemHTML = `${elemHTML}<li><img src="${__tagembed__plugin_url_for_js}assets/images/plan-ok.svg" alt="access" />Tagembed Branding</li>`; |
| 351 |
} |
| 352 |
elemHTML = `${elemHTML}</ul>`; |
| 353 |
if (response.data.Product[indexx][indexxx].Plan.id != 1) { |
| 354 |
if (response.data.Product[indexx][indexxx].Plan.id == __tagembed__activePlanId) { |
| 355 |
if (response.data.Product[indexx][indexxx].Plan.id != 67 && response.data.Product[indexx][indexxx].Plan.id != 53) { |
| 356 |
elemHTML = `${elemHTML}<a href="javascript:void(0);" data-tagembed-action="cancel-subscription" data-tagembed-plan-id="${__tagembed__escapeAttr(response.data.Product[indexx][indexxx].Plan.id)}" class="__tagembed__selectbtn">Cancel Subscription</a>`; |
| 357 |
} |
| 358 |
} else { |
| 359 |
if (response.data.Product[indexx][indexxx].Plan.id == 67 || response.data.Product[indexx][indexxx].Plan.id == 53) { |
| 360 |
elemHTML = `${elemHTML}<a href="javascript:void(0);" data-tagembed-action="lite-payment" data-tagembed-plan-id="${__tagembed__escapeAttr(response.data.Product[indexx][indexxx].Plan.id)}" data-tagembed-price-code="${__tagembed__escapeAttr(response.data.Product[indexx][indexxx].Plan.wordpressStripeMonthlyPriceCode)}" data-tagembed-cycle="0" class="__tagembed__selectbtn __tagembed__selectbtn_monthely" style="display:none;">Select</a>`; |
| 361 |
elemHTML = `${elemHTML}<a href="javascript:void(0);" data-tagembed-action="lite-payment" data-tagembed-plan-id="${__tagembed__escapeAttr(response.data.Product[indexx][indexxx].Plan.id)}" data-tagembed-price-code="${__tagembed__escapeAttr(response.data.Product[indexx][indexxx].Plan.wordpressStripeYearlyPriceCode)}" data-tagembed-cycle="1" class="__tagembed__selectbtn __tagembed__selectbtn_yearly">Select</a>`; |
| 362 |
} else { |
| 363 |
elemHTML = `${elemHTML}<a href="javascript:void(0);" data-tagembed-action="payment" data-tagembed-plan-id="${__tagembed__escapeAttr(response.data.Product[indexx][indexxx].Plan.id)}" data-tagembed-price-code="${__tagembed__escapeAttr(response.data.Product[indexx][indexxx].Plan.wordpressStripeMonthlyPriceCode)}" data-tagembed-cycle="0" class="__tagembed__selectbtn __tagembed__selectbtn_monthely" style="display:none;">Select</a>`; |
| 364 |
elemHTML = `${elemHTML}<a href="javascript:void(0);" data-tagembed-action="payment" data-tagembed-plan-id="${__tagembed__escapeAttr(response.data.Product[indexx][indexxx].Plan.id)}" data-tagembed-price-code="${__tagembed__escapeAttr(response.data.Product[indexx][indexxx].Plan.wordpressStripeYearlyPriceCode)}" data-tagembed-cycle="1" class="__tagembed__selectbtn __tagembed__selectbtn_yearly">Select</a>`; |
| 365 |
} |
| 366 |
} |
| 367 |
} |
| 368 |
elemHTML = `${elemHTML}</div>`; |
| 369 |
} |
| 370 |
} |
| 371 |
} |
| 372 |
__tagembed__setSafeHtml(__tagembed__plan, elemHTML); |
| 373 |
/* The plan buttons carry their values in data attributes and are wired up here, |
| 374 |
so no event handler is written into the markup. */ |
| 375 |
__tagembed__applyCancelledPlanState(); |
| 376 |
__tagembed__applyPendingPlanState(); |
| 377 |
__tagembed__plan.querySelectorAll("[data-tagembed-action]").forEach(function (__tagembed__planButton) { |
| 378 |
__tagembed__planButton.addEventListener("click", function () { |
| 379 |
let __tagembed__action = (this.getAttribute("data-tagembed-action") || ""); |
| 380 |
let __tagembed__planId = (this.getAttribute("data-tagembed-plan-id") || ""); |
| 381 |
let __tagembed__priceCode = (this.getAttribute("data-tagembed-price-code") || ""); |
| 382 |
let __tagembed__billingCycle = (this.getAttribute("data-tagembed-cycle") || "0"); |
| 383 |
if (__tagembed__isPlanChangeLocked()) return __tagembed__showPlanLockedToast(); |
| 384 |
if ("cancel-subscription" === __tagembed__action) __tagembed__cancel_subscription(__tagembed__planId); |
| 385 |
else if ("lite-payment" === __tagembed__action) __tagembed__make_lite_plan_payment(__tagembed__planId, __tagembed__priceCode); |
| 386 |
else if ("payment" === __tagembed__action) __tagembed__confirm_plan_selection(__tagembed__planId, __tagembed__priceCode, __tagembed__billingCycle); |
| 387 |
}); |
| 388 |
}); |
| 389 |
/*--End-- Manage Plan Serction Section*/ |
| 390 |
|
| 391 |
/*Manage Upgrade Plan Section Hide | Show */ |
| 392 |
if (__tagembed__upgrade_plan_section) |
| 393 |
__tagembed__upgrade_plan_section.style.display = "block"; |
| 394 |
|
| 395 |
} else { |
| 396 |
if (response.hasOwnProperty("message")) { |
| 397 |
__tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' }); |
| 398 |
} else { |
| 399 |
__tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); |
| 400 |
} |
| 401 |
} |
| 402 |
}).catch((error) => { |
| 403 |
console.log(error); |
| 404 |
__tagembed__close_loader(); |
| 405 |
__tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); |
| 406 |
}); |
| 407 |
} |
| 408 |
/*--End-- Get User Accounts Details*/ |
| 409 |
/*--Start-- Manage Payment*/ |
| 410 |
function __tagembed__make_lite_plan_payment(planId, priceCode) { |
| 411 |
let changeDate = __tagembed__planChangeDateText(); |
| 412 |
let scheduleAtTermEnd = !!(__tagembed__plan_status && __tagembed__plan_status.scheduleAtTermEnd && __tagembed__plan_status.currentPlanId && __tagembed__plan_order[__tagembed__plan_status.currentPlanId] !== 0); |
| 413 |
let title = 'Opting Free Forever LITE Plan'; |
| 414 |
let message = "Your current plan will be canceled and changed to Lite Plan."; |
| 415 |
if (scheduleAtTermEnd) { |
| 416 |
title = 'Are you sure?'; |
| 417 |
let tillText = changeDate ? ("till " + changeDate) : "till your current billing cycle ends"; |
| 418 |
let onText = changeDate ? ("on " + changeDate) : "when your current billing cycle ends"; |
| 419 |
message = "Your current plan stays active " + tillText + " and your account moves to the Free plan " + onText + ". No further payment will be taken and no refund is given for the remaining time. You will not be able to change your plan until then."; |
| 420 |
} |
| 421 |
__tagembed__confirmDialog({ title: title, message: message, buttonText: 'Confirm', type: 'danger', align: 'justify', highlight: [changeDate] }, function () { |
| 422 |
__tagembed__make_payment(planId, priceCode); |
| 423 |
}); |
| 424 |
} |
| 425 |
function __tagembed__confirm_plan_selection(planId, priceCode, billingCycle) { |
| 426 |
if (!__tagembed__isDowngradeSelection(planId, billingCycle)) return __tagembed__make_payment(planId, priceCode); |
| 427 |
let changeDate = __tagembed__planChangeDateText(); |
| 428 |
let scheduleAtTermEnd = !!(__tagembed__plan_status && __tagembed__plan_status.scheduleAtTermEnd); |
| 429 |
let message = ""; |
| 430 |
if (scheduleAtTermEnd) { |
| 431 |
let tillText = changeDate ? ("till " + changeDate) : "till your current billing cycle ends"; |
| 432 |
let onText = changeDate ? ("on " + changeDate) : "when your current billing cycle ends"; |
| 433 |
message = "This is a downgrade. Your current plan stays active " + tillText + " and the new plan starts " + onText + ". Nothing is charged today and no refund is given for the remaining time. You will not be able to change your plan until then."; |
| 434 |
} else { |
| 435 |
message = "This is a downgrade. Your new plan starts right away and no refund is given for the remaining time of your current plan."; |
| 436 |
} |
| 437 |
__tagembed__confirmDialog({ title: 'Are you sure?', message: message, buttonText: 'Confirm Downgrade', type: 'danger', align: 'justify', highlight: [changeDate] }, function () { |
| 438 |
__tagembed__make_payment(planId, priceCode); |
| 439 |
}); |
| 440 |
} |
| 441 |
function __tagembed__make_payment(planId, priceCode) { |
| 442 |
let __tagembed__toast = new TagembedToast; |
| 443 |
if (!planId) { |
| 444 |
__tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); |
| 445 |
} else { |
| 446 |
__tagembed__open_loader(); |
| 447 |
let formData = new FormData(); |
| 448 |
formData.append('action', 'tagembed_data'); |
| 449 |
formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); |
| 450 |
formData.append('__tagembed__ajax_action', '__tagembed__make_payment'); |
| 451 |
formData.append('planId', planId); |
| 452 |
formData.append('priceCode', priceCode); |
| 453 |
fetch(__tagembed__ajax_url, { |
| 454 |
method: 'POST', |
| 455 |
headers: { |
| 456 |
'x-requested-with': 'XMLHttpRequest', |
| 457 |
}, |
| 458 |
body: formData, |
| 459 |
}).then(response => { |
| 460 |
return response.json() |
| 461 |
}).then(response => { |
| 462 |
if (response.status == true) { |
| 463 |
window.open(response.data.redirectUrl + '?__tagembed__paymentData=' + response.data.__tagembed__paymentData + '&__tagembed__requestCallBackUrl=' + response.data.__tagembed__requestCallBackUrl, '_self'); |
| 464 |
} else { |
| 465 |
__tagembed__close_loader(); |
| 466 |
if (response.hasOwnProperty("message")) { |
| 467 |
__tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' }); |
| 468 |
} else { |
| 469 |
__tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); |
| 470 |
} |
| 471 |
} |
| 472 |
}).catch((error) => { |
| 473 |
console.log(error); |
| 474 |
__tagembed__close_loader(); |
| 475 |
__tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); |
| 476 |
}); |
| 477 |
} |
| 478 |
} |
| 479 |
/*--End-- Manage Payment*/ |
| 480 |
function __tagembed__cancel_subscription(planId) { |
| 481 |
let __tagembed__toast = new TagembedToast; |
| 482 |
if (!planId) |
| 483 |
return __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); |
| 484 |
__tagembed__confirmDialog({ title: 'Are you sure!', message: 'Do you want to cancel subscription?', buttonText: 'Yes', type: 'danger' }, function () { |
| 485 |
let formData = new FormData(); |
| 486 |
formData.append('planId', planId); |
| 487 |
formData.append('action', 'tagembed_data'); |
| 488 |
formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); |
| 489 |
formData.append('__tagembed__ajax_action', '__tagembed__cancel_subscription'); |
| 490 |
__tagembed__open_loader(); |
| 491 |
var __tagembed__toast = new TagembedToast; |
| 492 |
fetch(__tagembed__ajax_url, { |
| 493 |
method: 'POST', |
| 494 |
headers: { |
| 495 |
'x-requested-with': 'XMLHttpRequest', |
| 496 |
}, |
| 497 |
body: formData, |
| 498 |
}).then(response => { |
| 499 |
return response.json() |
| 500 |
}).then(response => { |
| 501 |
__tagembed__close_loader(); |
| 502 |
if (response.status == true) { |
| 503 |
if (response.data.hasOwnProperty("message")) { |
| 504 |
__tagembed__toast.success({ message: response.data.message, position: '__tagembed__is-top-right' }); |
| 505 |
} |
| 506 |
setTimeout(function () { |
| 507 |
window.open('https://tagembed.com/subscription-cancelled/', '_blank'); |
| 508 |
setTimeout(function () { |
| 509 |
window.location.reload(); |
| 510 |
}, 500); |
| 511 |
}, 3000); |
| 512 |
} else { |
| 513 |
if (response.hasOwnProperty("message")) { |
| 514 |
__tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' }); |
| 515 |
} else { |
| 516 |
__tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); |
| 517 |
} |
| 518 |
} |
| 519 |
}).catch((error) => { |
| 520 |
console.log(error); |
| 521 |
__tagembed__close_loader(); |
| 522 |
__tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); |
| 523 |
}); |
| 524 |
}); |
| 525 |
} |
| 526 |
/*--Start--Hide Account Upgrade Modal*/ |
| 527 |
function __tagembed__hide_upgrade_account_popup() { |
| 528 |
let __tagembed__upgrade_account_popup = document.querySelector("#__tagembed__upgrade_account_popup"); |
| 529 |
__tagembed__upgrade_account_popup.style.display = "none"; |
| 530 |
} |
| 531 |
/*--End--Hide Account Upgrade Modal*/ |
| 532 |
|
| 533 |
/*--Start-- Billing History*/ |
| 534 |
window.addEventListener ? window.addEventListener("load", __tagembed__get_invoices, false) : window.attachEvent && window.attachEvent("onload", __tagembed__get_invoices); |
| 535 |
function __tagembed__is_stripe_receipt_url(url) { |
| 536 |
if (typeof url !== "string" || url.indexOf("https://") !== 0) return false; |
| 537 |
try { |
| 538 |
let parsed = new URL(url); |
| 539 |
return parsed.protocol === "https:" && (parsed.hostname === "stripe.com" || parsed.hostname.endsWith(".stripe.com") || parsed.hostname === "chargebee.com" || parsed.hostname.endsWith(".chargebee.com")); |
| 540 |
} catch (error) { |
| 541 |
return false; |
| 542 |
} |
| 543 |
} |
| 544 |
function __tagembed__invoice_table_html(rowsHTML) { |
| 545 |
return '<table class="__tagembed__invoice_table">' |
| 546 |
+ '<thead><tr>' |
| 547 |
+ '<th class="__tagembed__invoice_col_date">Date</th>' |
| 548 |
+ '<th class="__tagembed__invoice_col_number">Invoice</th>' |
| 549 |
+ '<th class="__tagembed__invoice_col_plan">Plan</th>' |
| 550 |
+ '<th class="__tagembed__invoice_col_amount">Amount</th>' |
| 551 |
+ '<th class="__tagembed__invoice_col_status">Status</th>' |
| 552 |
+ '<th class="__tagembed__invoice_col_action"> </th>' |
| 553 |
+ '</tr></thead>' |
| 554 |
+ '<tbody>' + rowsHTML + '</tbody>' |
| 555 |
+ '</table>'; |
| 556 |
} |
| 557 |
function __tagembed__download_invoice_pdf(invoiceId, linkEl) { |
| 558 |
let __tagembed__toast = new TagembedToast; |
| 559 |
if (!invoiceId) return __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); |
| 560 |
if (linkEl && linkEl.getAttribute("data-tagembed-busy") === "1") return; |
| 561 |
if (linkEl) { |
| 562 |
linkEl.setAttribute("data-tagembed-busy", "1"); |
| 563 |
linkEl.textContent = "Preparing\u2026"; |
| 564 |
} |
| 565 |
let formData = new FormData(); |
| 566 |
formData.append('action', 'tagembed_data'); |
| 567 |
formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); |
| 568 |
formData.append('__tagembed__ajax_action', '__tagembed__get_invoice_pdf'); |
| 569 |
formData.append('invoiceId', invoiceId); |
| 570 |
fetch(__tagembed__ajax_url, { |
| 571 |
method: 'POST', |
| 572 |
headers: { |
| 573 |
'x-requested-with': 'XMLHttpRequest', |
| 574 |
}, |
| 575 |
body: formData, |
| 576 |
}).then(response => { |
| 577 |
return response.json() |
| 578 |
}).then(response => { |
| 579 |
if (linkEl) { |
| 580 |
linkEl.removeAttribute("data-tagembed-busy"); |
| 581 |
linkEl.textContent = "Download PDF"; |
| 582 |
} |
| 583 |
if (response.status === true && response.data && response.data.downloadUrl) { |
| 584 |
window.open(response.data.downloadUrl, '_blank', 'noopener'); |
| 585 |
return; |
| 586 |
} |
| 587 |
__tagembed__toast.danger({ message: response.hasOwnProperty("message") ? response.message : "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); |
| 588 |
}).catch((error) => { |
| 589 |
console.log(error); |
| 590 |
if (linkEl) { |
| 591 |
linkEl.removeAttribute("data-tagembed-busy"); |
| 592 |
linkEl.textContent = "Download PDF"; |
| 593 |
} |
| 594 |
__tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); |
| 595 |
}); |
| 596 |
} |
| 597 |
function __tagembed__render_invoice_state(message) { |
| 598 |
let note = document.querySelector("#__tagembed__invoice_note"); |
| 599 |
if (note) note.style.display = "none"; |
| 600 |
let countBadge = document.querySelector("#__tagembed__upgrade_tab_count"); |
| 601 |
if (countBadge) countBadge.style.display = "none"; |
| 602 |
let wrap = document.querySelector("#__tagembed__invoice_wrap"); |
| 603 |
if (!wrap) return; |
| 604 |
__tagembed__setSafeHtml(wrap, __tagembed__invoice_table_html('<tr><td colspan="6" class="__tagembed__invoice_empty">' + __tagembed__escapeText(message) + '</td></tr>')); |
| 605 |
} |
| 606 |
function __tagembed__render_billing_summary(summary) { |
| 607 |
let box = document.querySelector("#__tagembed__billing_stats"); |
| 608 |
if (!box) return; |
| 609 |
if (!summary || typeof summary !== "object") { |
| 610 |
box.style.display = "none"; |
| 611 |
return; |
| 612 |
} |
| 613 |
let planText = summary.planName ? summary.planName : (summary.planLabel || ""); |
| 614 |
if (summary.priceLabel) planText = planText ? planText + " \u2014 " + summary.priceLabel : summary.priceLabel; |
| 615 |
let viewsText = ""; |
| 616 |
if (summary.viewsUsedLabel) viewsText = summary.viewsLimitLabel ? summary.viewsUsedLabel + " / " + summary.viewsLimitLabel : summary.viewsUsedLabel; |
| 617 |
let cells = [ |
| 618 |
{ id: "__tagembed__billing_stat_plan", value: planText }, |
| 619 |
{ id: "__tagembed__billing_stat_renews", value: summary.renewsLabel || "", title: summary.renewsTitle || "Renews" }, |
| 620 |
{ id: "__tagembed__billing_stat_views", value: viewsText } |
| 621 |
]; |
| 622 |
let shown = 0; |
| 623 |
cells.forEach(function (cell) { |
| 624 |
let node = document.querySelector("#" + cell.id); |
| 625 |
if (!node) return; |
| 626 |
if (cell.value) { |
| 627 |
node.textContent = cell.value; |
| 628 |
shown++; |
| 629 |
if (cell.title && node.parentNode) { |
| 630 |
let caption = node.parentNode.querySelector("span"); |
| 631 |
if (caption) caption.textContent = cell.title; |
| 632 |
} |
| 633 |
if (node.parentNode) node.parentNode.style.display = "block"; |
| 634 |
} else if (node.parentNode) { |
| 635 |
node.parentNode.style.display = "none"; |
| 636 |
} |
| 637 |
}); |
| 638 |
box.style.display = shown ? "flex" : "none"; |
| 639 |
} |
| 640 |
/*--Start-- Payment Method (Card) Section*/ |
| 641 |
function __tagembed__render_cards(data) { |
| 642 |
let wrap = document.querySelector("#__tagembed__card_wrap"); |
| 643 |
if (!wrap) return; |
| 644 |
let cards = (data && Array.isArray(data.cards)) ? data.cards : []; |
| 645 |
if (!data || data.canManage !== true || cards.length === 0) { /* Details Na Ho To Section Dikhana Hi Nahi */ |
| 646 |
wrap.style.display = "none"; |
| 647 |
return; |
| 648 |
} |
| 649 |
while (wrap.firstChild) wrap.removeChild(wrap.firstChild); |
| 650 |
|
| 651 |
let head = document.createElement("p"); |
| 652 |
head.className = "__tagembed__card_head"; |
| 653 |
head.textContent = "Payment Method"; |
| 654 |
wrap.appendChild(head); |
| 655 |
|
| 656 |
let row = document.createElement("div"); |
| 657 |
row.className = "__tagembed__card_row"; |
| 658 |
|
| 659 |
let card = cards.filter(function (item) { return item.isDefault; })[0] || cards[0]; |
| 660 |
|
| 661 |
let detail = document.createElement("div"); |
| 662 |
if (card) { |
| 663 |
detail.className = "__tagembed__card_detail"; |
| 664 |
let name = document.createElement("strong"); |
| 665 |
name.textContent = (card.brand ? card.brand : "Card") + " •••• " + (card.last4 ? card.last4 : "****"); |
| 666 |
detail.appendChild(name); |
| 667 |
if (card.expiry) { |
| 668 |
let exp = document.createElement("span"); |
| 669 |
exp.className = card.isExpired ? "__tagembed__card_expired" : "__tagembed__card_expiry"; |
| 670 |
exp.textContent = (card.isExpired ? " Expired " : " Expires ") + card.expiry; |
| 671 |
detail.appendChild(exp); |
| 672 |
} |
| 673 |
} |
| 674 |
row.appendChild(detail); |
| 675 |
|
| 676 |
let action = document.createElement("a"); |
| 677 |
action.className = "__tagembed__card_action"; |
| 678 |
action.setAttribute("href", "javascript:void(0);"); |
| 679 |
action.setAttribute("data-tagembed-action", "card-session"); |
| 680 |
action.textContent = "Update Card"; |
| 681 |
action.addEventListener("click", __tagembed__open_card_session); |
| 682 |
row.appendChild(action); |
| 683 |
|
| 684 |
wrap.appendChild(row); |
| 685 |
wrap.style.display = "block"; |
| 686 |
} |
| 687 |
function __tagembed__get_cards() { |
| 688 |
let formData = new FormData(); |
| 689 |
formData.append('action', 'tagembed_data'); |
| 690 |
formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); |
| 691 |
formData.append('__tagembed__ajax_action', '__tagembed__get_cards'); |
| 692 |
fetch(__tagembed__ajax_url, { |
| 693 |
method: 'POST', |
| 694 |
headers: { 'x-requested-with': 'XMLHttpRequest' }, |
| 695 |
body: formData, |
| 696 |
}).then(response => { |
| 697 |
return response.json() |
| 698 |
}).then(response => { |
| 699 |
if (response.status !== true || !response.hasOwnProperty("data")) return; |
| 700 |
__tagembed__render_cards(response.data); |
| 701 |
}).catch(() => { }); |
| 702 |
} |
| 703 |
function __tagembed__open_card_session() { |
| 704 |
let button = this; |
| 705 |
if (button && button.getAttribute("data-tagembed-busy") === "1") return; |
| 706 |
if (button) button.setAttribute("data-tagembed-busy", "1"); |
| 707 |
let formData = new FormData(); |
| 708 |
formData.append('action', 'tagembed_data'); |
| 709 |
formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); |
| 710 |
formData.append('__tagembed__ajax_action', '__tagembed__card_session'); |
| 711 |
fetch(__tagembed__ajax_url, { |
| 712 |
method: 'POST', |
| 713 |
headers: { 'x-requested-with': 'XMLHttpRequest' }, |
| 714 |
body: formData, |
| 715 |
}).then(response => { |
| 716 |
return response.json() |
| 717 |
}).then(response => { |
| 718 |
if (button) button.removeAttribute("data-tagembed-busy"); |
| 719 |
if (response.status !== true || !response.hasOwnProperty("data") || !response.data.url) { |
| 720 |
__tagembed__toast.danger({ message: "Card management is not available right now. Please try after sometime." }); |
| 721 |
return; |
| 722 |
} |
| 723 |
window.open(response.data.url, '_blank'); |
| 724 |
}).catch(() => { |
| 725 |
if (button) button.removeAttribute("data-tagembed-busy"); |
| 726 |
__tagembed__toast.danger({ message: "Card management is not available right now. Please try after sometime." }); |
| 727 |
}); |
| 728 |
} |
| 729 |
window.addEventListener ? window.addEventListener("load", __tagembed__get_cards, false) : window.attachEvent && window.attachEvent("onload", __tagembed__get_cards); |
| 730 |
/*--End-- Payment Method (Card) Section*/ |
| 731 |
function __tagembed__get_invoices() { |
| 732 |
let section = document.querySelector("#__tagembed__invoice_section"); |
| 733 |
let wrap = document.querySelector("#__tagembed__invoice_wrap"); |
| 734 |
if (!section || !wrap) return; |
| 735 |
let formData = new FormData(); |
| 736 |
formData.append('action', 'tagembed_data'); |
| 737 |
formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); |
| 738 |
formData.append('__tagembed__ajax_action', '__tagembed__get_invoices'); |
| 739 |
fetch(__tagembed__ajax_url, { |
| 740 |
method: 'POST', |
| 741 |
headers: { |
| 742 |
'x-requested-with': 'XMLHttpRequest', |
| 743 |
}, |
| 744 |
body: formData, |
| 745 |
}).then(response => { |
| 746 |
return response.json(); |
| 747 |
}).then(response => { |
| 748 |
let invoiceTabItem = document.querySelector("#__tagembed__upgrade_tab_invoice_item"); |
| 749 |
if (response.status !== true || !response.hasOwnProperty("data") || response.data.invoiceSection !== "show") { |
| 750 |
section.style.display = "none"; |
| 751 |
if (invoiceTabItem) invoiceTabItem.style.display = "none"; |
| 752 |
__tagembed__render_billing_summary(null); |
| 753 |
__tagembed__manageUpgradeTab("plan"); |
| 754 |
return; |
| 755 |
} |
| 756 |
__tagembed__billing_summary = response.data.summary || null; |
| 757 |
__tagembed__render_billing_summary(__tagembed__billing_summary); |
| 758 |
__tagembed__applyCancelledPlanState(); |
| 759 |
__tagembed__applyPendingPlanState(); |
| 760 |
let invoices = Array.isArray(response.data.invoices) ? response.data.invoices : []; |
| 761 |
let countBadge = document.querySelector("#__tagembed__upgrade_tab_count"); |
| 762 |
if (countBadge) { |
| 763 |
if (invoices.length) { |
| 764 |
countBadge.textContent = invoices.length; |
| 765 |
countBadge.style.display = "inline-block"; |
| 766 |
} else { |
| 767 |
countBadge.style.display = "none"; |
| 768 |
} |
| 769 |
} |
| 770 |
if (!invoices.length) { |
| 771 |
__tagembed__render_invoice_state("No payments yet. Your invoices will appear here after your first payment."); |
| 772 |
return; |
| 773 |
} |
| 774 |
let rowsHTML = ""; |
| 775 |
invoices.forEach(function (invoice) { |
| 776 |
let actionUrl = __tagembed__is_stripe_receipt_url(invoice.pdfUrl) ? invoice.pdfUrl : (__tagembed__is_stripe_receipt_url(invoice.receiptUrl) ? invoice.receiptUrl : ""); |
| 777 |
let actionText = __tagembed__is_stripe_receipt_url(invoice.pdfUrl) ? "Download PDF" : "View Receipt"; |
| 778 |
let actionHTML = '<span class="__tagembed__invoice_muted">–</span>'; |
| 779 |
if (actionUrl) |
| 780 |
actionHTML = '<a class="__tagembed__invoice_action_link" href="' + __tagembed__escapeAttr(actionUrl) + '" rel="noopener noreferrer">' + actionText + '</a>'; |
| 781 |
else if (invoice.gateway === 'chargebee' && invoice.invoiceId) |
| 782 |
actionHTML = '<a class="__tagembed__invoice_action_link" href="javascript:void(0);" data-tagembed-invoice-id="' + __tagembed__escapeAttr(invoice.invoiceId) + '">Download PDF</a>'; |
| 783 |
let planHTML = invoice.planLabel ? __tagembed__escapeText(invoice.planLabel) : (invoice.plan ? __tagembed__escapeText(invoice.plan) : '<span class="__tagembed__invoice_muted">–</span>'); |
| 784 |
if (invoice.discountLabel) { |
| 785 |
let couponText = invoice.coupon ? invoice.coupon : 'Discount'; |
| 786 |
if (invoice.couponOff) couponText += ' \u00b7 ' + invoice.couponOff; |
| 787 |
planHTML += '<span class="__tagembed__invoice_coupon">' + __tagembed__escapeText(couponText) + '</span>'; |
| 788 |
} |
| 789 |
let amountHTML = __tagembed__escapeText(invoice.amountLabel); |
| 790 |
if (invoice.discountLabel && invoice.subtotalLabel) |
| 791 |
amountHTML = '<span class="__tagembed__invoice_was">' + __tagembed__escapeText(invoice.subtotalLabel) + '</span>' + amountHTML; |
| 792 |
let stateClass = (invoice.state && invoice.state !== "paid") ? ' __tagembed__invoice_state_refunded' : ''; |
| 793 |
let stateHTML = '<span class="__tagembed__invoice_state' + stateClass + '">' + __tagembed__escapeText(invoice.stateLabel || 'PAID') + '</span>'; |
| 794 |
rowsHTML += '<tr>' |
| 795 |
+ '<td>' + __tagembed__escapeText(invoice.dateLabel) + '</td>' |
| 796 |
+ '<td class="__tagembed__invoice_number">' + __tagembed__escapeText(invoice.number) + '</td>' |
| 797 |
+ '<td class="__tagembed__invoice_plan">' + planHTML + '</td>' |
| 798 |
+ '<td class="__tagembed__invoice_amount">' + amountHTML + '</td>' |
| 799 |
+ '<td class="__tagembed__invoice_status">' + stateHTML + '</td>' |
| 800 |
+ '<td class="__tagembed__invoice_action">' + actionHTML + '</td>' |
| 801 |
+ '</tr>'; |
| 802 |
}); |
| 803 |
__tagembed__setSafeHtml(wrap, __tagembed__invoice_table_html(rowsHTML)); |
| 804 |
wrap.querySelectorAll("[data-tagembed-invoice-id]").forEach(function (invoiceLink) { |
| 805 |
invoiceLink.addEventListener("click", function () { |
| 806 |
__tagembed__download_invoice_pdf(this.getAttribute("data-tagembed-invoice-id") || "", this); |
| 807 |
}); |
| 808 |
}); |
| 809 |
wrap.querySelectorAll('.__tagembed__invoice_action_link').forEach(function (link) { |
| 810 |
link.setAttribute('target', '_blank'); |
| 811 |
link.setAttribute('rel', 'noopener noreferrer'); |
| 812 |
}); |
| 813 |
let note = document.querySelector("#__tagembed__invoice_note"); |
| 814 |
if (note) { |
| 815 |
note.textContent = invoices.length === 1 ? "Showing 1 invoice." : "Showing " + invoices.length + " invoices."; |
| 816 |
note.style.display = "block"; |
| 817 |
} |
| 818 |
}).catch((error) => { |
| 819 |
console.log(error); |
| 820 |
__tagembed__render_billing_summary(null); |
| 821 |
__tagembed__render_invoice_state("Billing history could not be loaded. Please refresh the page."); |
| 822 |
}); |
| 823 |
} |
| 824 |
/*--End-- Billing History*/ |
| 825 |
|