2019-01-02 09:12:19 +01:00
|
|
|
exports.initialize = () => {
|
2019-01-02 09:44:45 +01:00
|
|
|
helpers.set_tab("upgrade");
|
2019-01-02 09:12:19 +01:00
|
|
|
|
|
|
|
var add_card_handler = StripeCheckout.configure({ // eslint-disable-line no-undef
|
|
|
|
key: $("#autopay-form").data("key"),
|
|
|
|
image: '/static/images/logo/zulip-icon-128x128.png',
|
|
|
|
locale: 'auto',
|
|
|
|
token: function (stripe_token) {
|
|
|
|
helpers.create_ajax_request("/json/billing/upgrade", "autopay", stripe_token = stripe_token);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#add-card-button').on('click', function (e) {
|
|
|
|
var license_management = $('input[type=radio][name=license_management]:checked').val();
|
2019-01-29 18:28:50 +01:00
|
|
|
if (helpers.is_valid_input($("#" + license_management + "_license_count")) === false) {
|
2019-01-02 09:12:19 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
add_card_handler.open({
|
|
|
|
name: 'Zulip',
|
|
|
|
zipCode: true,
|
|
|
|
billingAddress: true,
|
|
|
|
panelLabel: "Make payment",
|
|
|
|
email: $("#autopay-form").data("email"),
|
|
|
|
label: "Add card",
|
|
|
|
allowRememberMe: false,
|
|
|
|
description: "Zulip Cloud Standard",
|
|
|
|
});
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#invoice-button").on("click", function (e) {
|
2019-01-29 18:28:50 +01:00
|
|
|
if (helpers.is_valid_input($("#invoiced_licenses")) === false) {
|
2019-01-02 09:12:19 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
e.preventDefault();
|
|
|
|
helpers.create_ajax_request("/json/billing/upgrade", "invoice");
|
|
|
|
});
|
|
|
|
|
|
|
|
var prices = {};
|
|
|
|
prices.annual = page_params.annual_price * (1 - page_params.percent_off / 100);
|
|
|
|
prices.monthly = page_params.monthly_price * (1 - page_params.percent_off / 100);
|
|
|
|
|
2019-01-27 22:44:58 +01:00
|
|
|
$('input[type=radio][name=license_management]').on("change", function () {
|
2019-01-30 13:59:19 +01:00
|
|
|
helpers.show_license_section(this.value);
|
2019-01-02 09:12:19 +01:00
|
|
|
});
|
|
|
|
|
2019-01-27 22:44:58 +01:00
|
|
|
$('input[type=radio][name=schedule]').on("change", function () {
|
2019-01-30 13:59:19 +01:00
|
|
|
helpers.update_charged_amount(prices, this.value);
|
2019-01-02 09:12:19 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
$("#autopay_annual_price").text(helpers.format_money(prices.annual));
|
|
|
|
$("#autopay_annual_price_per_month").text(helpers.format_money(prices.annual / 12));
|
|
|
|
$("#autopay_monthly_price").text(helpers.format_money(prices.monthly));
|
|
|
|
$("#invoice_annual_price").text(helpers.format_money(prices.annual));
|
|
|
|
$("#invoice_annual_price_per_month").text(helpers.format_money(prices.annual / 12));
|
|
|
|
|
|
|
|
helpers.show_license_section($('input[type=radio][name=license_management]:checked').val());
|
|
|
|
helpers.update_charged_amount(prices, $('input[type=radio][name=schedule]:checked').val());
|
|
|
|
};
|
|
|
|
|
2019-10-25 09:45:13 +02:00
|
|
|
window.upgrade = exports;
|
2019-01-02 09:12:19 +01:00
|
|
|
|
|
|
|
$(function () {
|
2019-10-25 09:45:13 +02:00
|
|
|
exports.initialize();
|
2019-01-02 09:12:19 +01:00
|
|
|
});
|