billing: Redirect to stripe card change page on clicking change card.

This commit is contained in:
Aman Agrawal 2023-11-08 14:59:03 +00:00
parent 8c4ef3e9aa
commit e185e91581
3 changed files with 7 additions and 5 deletions

View File

@ -102,7 +102,7 @@
</div>
{% if charge_automatically %}
<div class="user-stripe-card-update input-box billing-page-field no-validation">
<button class="user-stripe-card-update-button">
<button class="user-stripe-card-update-button" id="update-card-button">
<span class="billing-button-text">Update card</span>
<object class="loader billing-button-loader" type="image/svg+xml" data="{{ static('images/loading/loader-white.svg') }}"></object>
</button>

View File

@ -12,9 +12,6 @@
{% block content %}
<div class="app portico-page">
{% include 'zerver/billing_nav.html' %}
<div class="billing-upgrade-page">
<div class="hero small-hero"></div>

View File

@ -36,6 +36,8 @@ export function initialize(): void {
helpers.set_tab("billing");
$("#update-card-button").on("click", (e) => {
$("#update-card-button .billing-button-text").text("");
$("#update-card-button .loader").show();
helpers.create_ajax_request(
"/json/billing/session/start_card_update_session",
"cardchange",
@ -44,7 +46,10 @@ export function initialize(): void {
(response) => {
const response_data = helpers.stripe_session_url_schema.parse(response);
window.location.replace(response_data.stripe_session_url);
},
}, () => {
$("#update-card-button .loader").hide();
$("#update-card-button .billing-button-text").text("Update card");
}
);
e.preventDefault();
});