<commit_before>function StripeCheckoutView(config) {
    var self = this;
    var config = config || {};

    self.stripe = Stripe(config.stripeKey)
    self.formId = config.formId || '';
    self.levelId = config.levelId || '';
    self.checkoutSessionUrl = config.checkoutSessionUrl || '';
    self.csrfToken = config.csrfToken || '';

    self.initForm = function() {
        document
            .getElementById(self.formId)
            .addEventListener("click", function(event) {
                // Avoid submitting the form
                event.preventDefault();

                var priceId = document.getElementById(self.levelId).value;
                self.createCheckoutSession(priceId).then(function(result) {
                    // Call Stripe.js method to redirect to the new Checkout page
                    result.json().then(function(data) {
                        self.stripe
                            .redirectToCheckout({
                                sessionId: data.session_id
                            })
                    });
                });
            });
    };

    self.createCheckoutSession = function(priceId) {
        return fetch(self.checkoutSessionUrl, {
            method: "POST",
            headers: {
                "Content-Type": "application/json",
                "X-CSRFToken":self.csrfToken
            },
            body: JSON.stringify({
                priceId: priceId
            })
        });
    };
};


StripeCheckoutView.init = function(config) {
    var view = new StripeCheckoutView(config);
    view.initForm();
    return view;
};

module.exports.StripeCheckoutView = StripeCheckoutView;
<commit_msg>eslint<commit_after>function StripeCheckoutView(config) {
    var self = this;
    var config = config || {};

    self.stripe = Stripe(config.stripeKey);
    self.formId = config.formId || '';
    self.levelId = config.levelId || '';
    self.checkoutSessionUrl = config.checkoutSessionUrl || '';
    self.csrfToken = config.csrfToken || '';

    self.initForm = function () {
        document
            .getElementById(self.formId)
            .addEventListener("click", function (event) {
                // Avoid submitting the form
                event.preventDefault();

                var priceId = document.getElementById(self.levelId).value;
                self.createCheckoutSession(priceId).then(function (result) {
                    // Call Stripe.js method to redirect to the new Checkout page
                    result.json().then(function (data) {
                        self.stripe
                            .redirectToCheckout({
                                sessionId: data.session_id
                            });
                    });
                });
            });
    };

    self.createCheckoutSession = function (priceId) {
        return fetch(self.checkoutSessionUrl, {
            method: "POST",
            headers: {
                "Content-Type": "application/json",
                "X-CSRFToken": self.csrfToken
            },
            body: JSON.stringify({
                priceId: priceId
            })
        });
    };
}


StripeCheckoutView.init = function (config) {
    var view = new StripeCheckoutView(config);
    view.initForm();
    return view;
}

module.exports.StripeCheckoutView = StripeCheckoutView;

{'fraction_non_alphanumeric': 0.10905840286054827, 'fraction_numerical': 0.0, 'mean_word_length': 1.598297213622291, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3393219', 'n_tokens_mistral': 894, 'n_tokens_neox': 849, 'n_words': 152}