PageSourceSearch

https://www.hypersuggest.com/assets/main/js/subscription/subscription.js?v=1.0.0

js hypersuggest.com collected 2026-09-29 03:06:01 UTC 13,546 bytes, 381 lines download raw bytes

1(function ($) {
2    "use strict";
3
4    let trackFacebookConversion = async function(data) {
5        if (typeof fbq !== 'undefined') {
6            let payload = {
7                value: data.data.totals.total,
8                currency: data.data.currency_code,
9                content_name: data.data.items[0].product.name,
10                num_items: 1,
11                content_type: 'product'
12            };
13            fbq('track', 'Purchase', payload);
14        }
15    }
16
17    let trackGoogleAnalyticsConversion = async function(data) {
18        if (typeof gtag !== 'undefined') {
19            let payload = {
20                transaction_id: data.data.transaction_id,
21                value: data.data.totals.total,
22                currency: data.data.currency_code
23            };
24            gtag("event", "purchase", payload);
25        }
26    }
27
28    $(document).on("change", "input[name='billing-interval']", function () {
29        let billingInterval = $(this).val();
30
31        if (billingInterval === "yearly") {
32            $(".pricing-toggle-monthly").hide();
33            $(".pricing-toggle-yearly").show();
34        } else {
35            $(".pricing-toggle-monthly").show();
36            $(".pricing-toggle-yearly").hide();
37        }
38    });
39
40    $(document).on("submit", "form.subscription-feedback", function (e) {
41        e.preventDefault();
42
43        let $form = $(this);
44        let $button = $form.find("button[type=submit]");
45        $button.attr("data-button-loading", "").prop("disabled", true);
46
47        let data = {
48            user_name: $form.find("input[name=user-name]").val(),
49            user_email: $form.find("input[name=user-email]").val(),
50            subscription_feedback: $form
51                .find("textarea[name=subscription-feedback]")
52                .val(),
53        };
54
55        let formData = new FormData();
56        formData.append("data", JSON.stringify(data));
57
58        $.when(
59            hypertool.ajax(
60                "subscription_feedback",
61                formData,
62                function (response) {
63                    $button
64                        .removeAttr("data-button-loading")
65                        .prop("disabled", false);
66
67                    if (response["status"] === "success") {
68                        hypertool.hideModal("#subscription-pause");
69                        $("body").append(response["data"]["message"]);
70                        hypertool.showModal(
71                            "#" + response["data"]["message_id"]
72                        );
73                    }
74
75                    if (
76                        response["status"] == "error" &&
77                        response["data"]["error_code"] === "invalid_auth"
78                    ) {
79                        $("#request-validation-error").modal("show");
80                        return;
81                    }
82                }
83            )
84        );
85    });
86
87    $(document).on("submit", "form.subscription-pause", function (e) {
88        e.preventDefault();
89
90        let $form = $(this);
91        let $button = $form.find("button[type=submit]");
92        $button.attr("data-button-loading", "").prop("disabled", true);
93
94        $.when(
95            hypertool.ajax("pause_subscription", null, function (response) {
96                $button
97                    .removeAttr("data-button-loading")
98                    .prop("disabled", false);
99
100                if (response["status"] == "success") {
101                    hypertool.hideModal("#subscription-pause");
102                    $("body").append(response["data"]["message"]);
103                    hypertool.showModal("#" + response["data"]["message_id"]);
104                }
105
106                if (
107                    response["status"] == "error" &&
108                    response["data"]["error_code"] === "invalid_auth"
109                ) {
110                    $("#request-validation-error").modal("show");
111                    return;
112                }
113            })
114        );
115    });
116
117    $(document).on("click", ".update-payment-method", function () {
118        $.when(
119            hypertool.ajax(
120                "payment_update_transaction",
121                null,
122                function (response) {
123                    // Handle create subscription
124                    if (response["status"] == "success") {
125                        Paddle.Initialize({
126                            token: hypertool.environment.paddle_client_token,
127                            eventCallback: async function (data) {
128                                if (data.name == "checkout.completed") {
129                                    try {
130                                        await trackFacebookConversion(data);
131                                        await trackGoogleAnalyticsConversion(data);
132                                    } catch {}
133
134                                    Paddle.Checkout.close();
135                                    
136                                    hypertool.showModal(
137                                        "#notify-update-payment-method"
138                                    );
139                                }
140                            },
141                        });
142                        Paddle.Checkout.open({
143                            allowLogout: false,
144                            transactionId: response["data"]["transaction_id"],
145                        });
146                    } else {
147                        alert("there was an error.");
148                    }
149                }
150            )
151        );
152    });
153
154    $(document).on("click", ".pricing-compare button.start-trial", function () {
155        let $button = $(this);
156        $(".pricing-compare button.start-trial").prop("disabled", true);
157
158        let type = "trial";
159        let billingInterval = $button.attr("data-billing-interval");
160        let plan = $button.attr("data-plan");
161
162        let checkoutUrl = new URL(hypertool.environment.url + "/checkout");
163        checkoutUrl.searchParams.append("plan", plan);
164        checkoutUrl.searchParams.append("billing_interval", billingInterval);
165        checkoutUrl.searchParams.append("type", type);
166
167        window.location.href = checkoutUrl;
168    });
169
170    let initializeCheckout = function (plan, billingInterval) {
171        let $buttons = $(".pricing-compare button");
172        $buttons.prop("disabled", true);
173
174        let data = {
175            plan: plan,
176            billing_interval: billingInterval,
177            affiliate_id: hypertool.cookie.getCookie("ref"),
178        };
179
180        let formData = new FormData();
181        formData.append("data", JSON.stringify(data));
182
183        $.when(
184            hypertool.ajax(
185                "checkout_transaction_id",
186                formData,
187                function (response) {
188                    $buttons
189                        .removeAttr("data-button-loading")
190                        .prop("disabled", false);
191
192                    if (response["status"] === "success") {
193                        let transactionId = response["data"]["transaction_id"];
194                        setupPaddle(transactionId);
195                    }
196
197                    if (response["status"] == "error") {
198                        $("body").append(response["data"]["message"]);
199                        hypertool.showModal(
200                            "#" + response["data"]["message_id"]
201                        );
202                    }
203                }
204            )
205        );
206    };
207
208    let initializeUpdate = function (plan, billingInterval) {
209        let $buttons = $(".pricing-compare button");
210        $buttons.prop("disabled", true);
211
212        let data = {
213            billing_interval: billingInterval,
214            plan: plan,
215        };
216
217        let formData = new FormData();
218        formData.append("data", JSON.stringify(data));
219
220        $.when(
221            hypertool.ajax(
222                "update_subscription",
223                formData,
224                function (response) {
225                    if (response["status"] == "success") {
226                        let successUrl = new URL(
227                            hypertool.environment.url + "/checkout/success"
228                        );
229                        successUrl.searchParams.append("type", "subscription");
230
231                        window.location.href = successUrl;
232                    } else {
233                        $buttons.prop("disabled", false);
234                        $("body").append(response["data"]["message"]);
235                        hypertool.showModal(
236                            "#" + response["data"]["message_id"]
237                        );
238                    }
239                }
240            )
241        );
242    };
243
244    $(document).on(
245        "click",
246        ".pricing-compare button.update-subscription",
247        function () {
248            let $button = $(this);
249
250            let billingInterval = $button.attr("data-billing-interval");
251            let plan = $button.attr("data-plan");
252            let type = $button.attr("data-type");
253
254            switch (type) {
255                case "signup":
256                    hypertool.cookie.setCookie(
257                        "hypertool_plan",
258                        JSON.stringify({
259                            plan: plan,
260                            billing_interval: billingInterval,
261                        }),
262                        90
263                    );
264                    window.location.href =
265                        hypertool.environment.url + "/signup";
266                    break;
267
268                case "create":
269                    initializeCheckout(plan, billingInterval);
270                    break;
271
272                case "update":
273                    initializeUpdate(plan, billingInterval);
274                    break;
275            }
276        }
277    );
278
279    $(document).on("change", "select.credit-description-select", function () {
280        let tool = $(this).val();
281        $("#credit-description .collapse.show").collapse("toggle");
282        $(
283            "#credit-description .collapse[credit-description=" + tool + "]"
284        ).collapse("toggle");
285    });
286
287    let setupPaddle = function (transactionId) {
288        if (!transactionId) {
289            return;
290        }
291
292        Paddle.Initialize({
293            token: hypertool.environment.paddle_client_token,
294            eventCallback: async function (data) {
295                if (data.name == "checkout.completed") {
296                    let checkoutSuccessUrl = new URL(
297                        hypertool.environment.url + "/checkout/success"
298                    );
299                    checkoutSuccessUrl.searchParams.append(
300                        "type",
301                        "subscription"
302                    );
303                    checkCheckoutStatus(checkoutSuccessUrl);
304                }
305            },
306        });
307
308        Paddle.Checkout.open({
309            transactionId: transactionId,
310            customer: {
311                email: hypertool.user.email,
312            },
313            settings: {
314                allowLogout: false,
315            },
316        });
317    };
318
319    $(window).on("load", function () {
320        if ($(".pricing").length > 0) {
321            let planJson = hypertool.cookie.getCookie("hypertool_plan");
322            if (planJson !== "") {
323                hypertool.cookie.deleteCookie("hypertool_plan");
324                let plan = JSON.parse(planJson);
325                if (hypertool.user.isMember) {
326                    initializeCheckout(plan.plan, plan.billing_interval);
327                }
328            }
329        }
330    });
331
332    $(window).on("load", function () {
333        if ($(".checkout-success-overview").length > 0) {
334            let url = new URL(window.location.href);
335            let params = new URLSearchParams(url.search);
336            let name = params.get("name");
337
338            $("[data-checkout-success-name]").text(name);
339            animateConfetti($(".checkout-success-overview"));
340        }
341    });
342
343    let animateConfetti = function ($element) {
344        let originX =
345            ($element.offset().left + $element.width() / 2) / $(window).width();
346        let originY = $element.offset().top + $element.height() / 2;
347
348        confetti({
349            particleCount: 90,
350            spread: 150,
351            zIndex: 100,
352            origin: { x: originX, y: 0.4 },
353            colors: ["#FFD260"],
354        });
355    };
356
357    let checkCheckoutStatus = function (checkoutSuccessUrl) {
358        let data = {};
359        let formData = new FormData();
360        formData.append("data", JSON.stringify(data));
361
362        $.when(
363            hypertool.ajax(
364                "checkout_check_status",
365                formData,
366                function (response) {
367                    if (
368                        response["status"] == "success" &&
369                        response["data"]["checkout_status"] === "succeeded"
370                    ) {
371                        window.location.replace(checkoutSuccessUrl);
372                    } else {
373                        setTimeout(function () {
374                            checkCheckoutStatus(checkoutSuccessUrl);
375                        }, 1000);
376                    }
377                }
378            )
379        );
380    };
381})(jQuery);

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.