Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

support: Update billing modality for remote server current plan.

Lauryn Menardf5ab9419d207
diff --git a/analytics/views/support.py b/analytics/views/support.py
index f77a3c52341..8bb5bd8b57a 100644
--- a/analytics/views/support.py
+++ b/analytics/views/support.py
@@ -389,6 +389,9 @@ def remote_servers_support(
discount: Optional[Decimal] = REQ(default=None, converter=to_decimal),
sponsorship_pending: Optional[bool] = REQ(default=None, json_validator=check_bool),
approve_sponsorship: bool = REQ(default=False, json_validator=check_bool),
+ billing_modality: Optional[str] = REQ(
+ default=None, str_validator=check_string_in(VALID_BILLING_MODALITY_VALUES)
+ ),
) -> HttpResponse:
context: Dict[str, Any] = {}
@@ -424,6 +427,11 @@ def remote_servers_support(
support_type=SupportType.attach_discount,
discount=discount,
)
+ elif billing_modality is not None:
+ support_view_request = SupportViewRequest(
+ support_type=SupportType.update_billing_modality,
+ billing_modality=billing_modality,
+ )
if support_view_request is not None:
billing_session = RemoteServerBillingSession(
support_staff=acting_user, remote_server=remote_server
diff --git a/templates/analytics/remote_server_support.html b/templates/analytics/remote_server_support.html
index 3ce1aeb7258..34160275beb 100644
--- a/templates/analytics/remote_server_support.html
+++ b/templates/analytics/remote_server_support.html
@@ -107,6 +107,17 @@
<b>End date</b>: {{ plan_data[remote_server.id].current_plan.end_date.strftime('%d %B %Y') }}<br />
{% endif %}
</div>
+
+ <form method="POST" class="remote-server-form">
+ <b>Billing collection method</b><br />
+ {{ csrf_input }}
+ <input type="hidden" name="remote_server_id" value="{{ remote_server.id }}" />
+ <select name="billing_modality" class="billing-modality-select" required>
+ <option value="charge_automatically" {% if plan_data[remote_server.id].current_plan.charge_automatically %}selected{% endif %}>Charge automatically</option>
+ <option value="send_invoice" {% if not plan_data[remote_server.id].current_plan.charge_automatically %}selected{% endif %}>Pay by invoice</option>
+ </select>
+ <button type="submit" class="btn btn-default support-submit-button">Update</button>
+ </form>
{% endif %}
</div>
{% endfor %}