2020-08-01 03:43:15 +02:00
|
|
|
"use strict";
|
|
|
|
|
2019-01-02 09:12:19 +01:00
|
|
|
exports.initialize = function () {
|
2019-01-02 09:44:45 +01:00
|
|
|
helpers.set_tab("billing");
|
2018-11-25 08:02:51 +01:00
|
|
|
|
2019-11-02 00:06:25 +01:00
|
|
|
const stripe_key = $("#payment-method").data("key");
|
2020-07-15 00:34:28 +02:00
|
|
|
const card_change_handler = StripeCheckout.configure({
|
|
|
|
// eslint-disable-line no-undef
|
2019-01-02 09:12:19 +01:00
|
|
|
key: stripe_key,
|
2020-07-15 01:29:15 +02:00
|
|
|
image: "/static/images/logo/zulip-icon-128x128.png",
|
|
|
|
locale: "auto",
|
2020-07-20 22:18:43 +02:00
|
|
|
token(stripe_token) {
|
2020-04-24 17:36:20 +02:00
|
|
|
helpers.create_ajax_request("/json/billing/sources/change", "cardchange", stripe_token);
|
2019-01-02 09:12:19 +01:00
|
|
|
},
|
2018-11-25 08:02:51 +01:00
|
|
|
});
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
$("#update-card-button").on("click", (e) => {
|
2019-11-02 00:06:25 +01:00
|
|
|
const email = $("#payment-method").data("email");
|
2019-01-02 09:12:19 +01:00
|
|
|
card_change_handler.open({
|
2020-07-15 01:29:15 +02:00
|
|
|
name: "Zulip",
|
2019-01-02 09:12:19 +01:00
|
|
|
zipCode: true,
|
|
|
|
billingAddress: true,
|
|
|
|
panelLabel: "Update card",
|
2020-07-20 22:18:43 +02:00
|
|
|
email,
|
2019-01-02 09:12:19 +01:00
|
|
|
label: "Update card",
|
|
|
|
allowRememberMe: false,
|
|
|
|
});
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
2020-04-24 17:38:13 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
$("#change-plan-status").on("click", (e) => {
|
2020-07-15 00:34:28 +02:00
|
|
|
helpers.create_ajax_request("/json/billing/plan/change", "planchange", undefined, [
|
|
|
|
"status",
|
|
|
|
]);
|
2020-04-24 17:38:13 +02:00
|
|
|
e.preventDefault();
|
|
|
|
});
|
2019-01-02 09:12:19 +01:00
|
|
|
};
|
2018-11-25 22:43:45 +01:00
|
|
|
|
2019-10-25 09:45:13 +02:00
|
|
|
window.billing = exports;
|
2018-12-21 18:44:24 +01:00
|
|
|
|
2020-07-02 01:45:54 +02:00
|
|
|
$(() => {
|
2019-10-25 09:45:13 +02:00
|
|
|
exports.initialize();
|
2018-09-06 15:14:54 +02:00
|
|
|
});
|