2019-01-02 09:12:19 +01:00
|
|
|
var billing = (function () {
|
|
|
|
var exports = {};
|
2018-09-06 15:14:54 +02:00
|
|
|
|
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-01-02 09:12:19 +01:00
|
|
|
var stripe_key = $("#payment-method").data("key");
|
|
|
|
var card_change_handler = StripeCheckout.configure({ // eslint-disable-line no-undef
|
|
|
|
key: stripe_key,
|
|
|
|
image: '/static/images/logo/zulip-icon-128x128.png',
|
|
|
|
locale: 'auto',
|
|
|
|
token: function (stripe_token) {
|
|
|
|
helpers.create_ajax_request("/json/billing/sources/change", "cardchange", stripe_token = stripe_token);
|
|
|
|
},
|
2018-11-25 08:02:51 +01:00
|
|
|
});
|
|
|
|
|
2019-01-02 09:12:19 +01:00
|
|
|
$('#update-card-button').on('click', function (e) {
|
|
|
|
var email = $("#payment-method").data("email");
|
|
|
|
card_change_handler.open({
|
|
|
|
name: 'Zulip',
|
|
|
|
zipCode: true,
|
|
|
|
billingAddress: true,
|
|
|
|
panelLabel: "Update card",
|
|
|
|
email: email,
|
|
|
|
label: "Update card",
|
|
|
|
allowRememberMe: false,
|
|
|
|
});
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
};
|
2018-11-25 22:43:45 +01:00
|
|
|
|
2019-01-02 09:12:19 +01:00
|
|
|
return exports;
|
|
|
|
}());
|
2018-12-21 18:44:24 +01:00
|
|
|
|
2019-01-02 09:12:19 +01:00
|
|
|
if (typeof module !== 'undefined') {
|
|
|
|
module.exports = billing;
|
|
|
|
}
|
2018-12-26 10:45:30 +01:00
|
|
|
|
2019-01-02 09:12:19 +01:00
|
|
|
window.billing = billing;
|
2018-12-21 18:44:24 +01:00
|
|
|
|
2019-01-02 09:12:19 +01:00
|
|
|
$(function () {
|
|
|
|
billing.initialize();
|
2018-09-06 15:14:54 +02:00
|
|
|
});
|