Commit Graph

552 Commits

Author SHA1 Message Date
Anders Kaseorg 96fbe060a6 python: Mark regexes as raw strings.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-04-26 12:30:31 -07:00
Aman Agrawal 263d1ae38e demo_request: Add form for user to request a demo.
This sends an email to us after user fills out and sends the form.
2024-04-25 13:09:05 -07:00
Aman Agrawal 42bbeb6247 stripe: Change pricing for plus plan.
This also now allows user to upgrade to plus plan from pricing page.

Note that since we don't pass customer_plan on pages like self-hosting
and for/business, `Current plan` status is not displayed on these pages.
2024-04-19 09:57:43 -07:00
Aman Agrawal 8a807949df stripe: Disable free trial for customer with any plan in the past. 2024-04-11 21:57:33 -07:00
Aman Agrawal ed2de77895 stripe: Send invoice to customer at the start of free trial.
We send customer an invoice at the start of free trial, if customer
pays we upgrade them to the active plan at the end of free trial,
else we downgrade them and show a custom message on the upgrade
page regarding the current status.
2024-04-11 21:57:33 -07:00
Aman Agrawal 8715ead8bc stripe: Regenerate stripe fixtures with fixed tests.
Tests were broken since #29221 and #28875 didn't account for
other tests failing due to changed stripe data. Also, there
was a bug where we were not fetching the correct setup intent
and stripe session for the current test, it was fixed by narrowing
the fetch to the current customer.

Also, we now run `invoice_plans` in a `while` loop until
`next_invoice_date` is greater than the provided event_time. It
makes sense to generate all the invoices for a customer that
needs to paid by them when `invoice_plans_as_needed` is called
for a `event_time`.
2024-04-11 21:57:33 -07:00
Anders Kaseorg e5fd761562 test_stripe: Replace deprecated stripe.Event.to_dict_recursive.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-04-04 11:23:11 -07:00
Anders Kaseorg 040e8aa7f1 test_stripe: Remove unused stripe.util import.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-04-04 11:20:26 -07:00
Anders Kaseorg ccb95e76dc ruff: Fix RUF007 Prefer `itertools.pairwise()` over `zip()`.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-04-01 18:32:52 -07:00
Aman Agrawal b86e37a979 stripe: Add period information for generated invoices.
Invoices need to have period to avoid charges being marked as
point-in-time revenue rather than monthly revenue.
2024-03-30 14:56:12 -07:00
Mateusz Mandera 374178903e remote_billing: Move stripe_customer_id from server to realm if needed.
As explained in the comment, when we're moving the server plan to the
remote realm's Customer object, the realm Customer may not have
stripe_customer_id set and therefore that value needs to get moved from
the server Customer.
2024-03-29 16:27:03 -07:00
Prakhar Pratyush a0cec2c378 stripe: Skip invoice overdue mail for free plans with no next plan.
Earlier, if a free plan (say legacy plan) with no next plan scheduled
was invoiced, we used to send an invoice overdue email if the last
audit log update is stale.

Actually, we don't need this data as the invoice step is just going
to downgrade the current plan. We should not wait for customer to
start uploading data in this case. Skip the email sending step and
invoice the plan to downgrade.
2024-03-28 09:29:23 -07:00
Lauryn Menard 373671080d remote-support: Include billing entity name in internal billing notice.
Adds a line to the top of the internal_billing_notice email with
the billing entity's display name.

Makes sure all internal_billng_notice email subjects also include
the billing entity's display name.

Makes small updates to the notice text for some cases.
2024-03-20 11:58:15 -07:00
Prakhar Pratyush c9d25b2a95 stripe: Redirect to /plans if plans downgraded on /billing page visit.
When a customer with plan's status 'DOWNGRADE_AT_END_OF_FREE_TRIAL'
visits /billing page on the free-trial end date before the invoice
cron runs, the 'make_end_of_cycle_updates_if_needed' downgrades the
plan.

Earlier, when such a customer visited /billing page in this time window
it resulted in an assertion error.

This commit fixes the incorrect behaviour by redirecting to '/plans'
page in such cases.
2024-03-19 09:25:07 -07:00
Aman Agrawal 3b4abc94ee stripe: Revive an old test case for payment method. 2024-03-15 08:39:46 -07:00
Aman Agrawal e10f81197f upgrade: Fix allowed free trails for ended legacy plans on server.
If the remote realm registered after the legacy plan on server
ENDED, we never migrate the plan to the remote realm. So, we need
to check the server of remote realm whenever we are check remote
realm for legacy plan.
2024-03-15 08:38:46 -07:00
Aman Agrawal b26326815a billing: Adjust strings on billing page for invoice payment method. 2024-03-14 16:43:52 -07:00
Aman Agrawal caba57fe1e stripe: Bill manually managed licenses monthly for additional licenses.
Regardless of plan renewal schedule, we try to invoice all plans
monthly with some exceptions like free trial and fixed price plans,
which help us charge users for additional licenses used during
the previous month.
2024-03-14 16:43:52 -07:00
Aman Agrawal c84b9cbc97 upgrade: Allow payment by invoice. 2024-03-14 16:43:52 -07:00
Aman Agrawal b1ea8f3c1c stripe: Change plan type immediately after creating a live plan.
Minor refactor that makes sense to do.
2024-03-14 16:43:52 -07:00
Lauryn Menard 8f5b8dbf1a stripe: Remove unused do_change_remote_server_plan_type.
This was implemented instead as part of the BillingSession class
with the do_change_plan_type method.
2024-03-12 11:19:29 -07:00
Lauryn Menard c9caad20d0 support: Have distinct labels for remote vs Cloud support views. 2024-03-08 09:40:43 -08:00
Lauryn Menard ef11619e73 support: Clean up options for realm plan_type and org_type.
Removes adding get_org_type_display_name to support context as
its use was removed in commit f25230c7d4.
2024-03-08 09:40:43 -08:00
Prakhar Pratyush 7e9212a1a0 corporate: Use 'next_invoice_date' as the event_time in invoice_plan.
Earlier, we were using 'timezone_now' (the time cron job runs)
as the event_time while invoicing plans in 'invoice_plan'.
This is not accurate as it will lead to invoicing ledger entries
created after 'next_invoice_date' and before 'timezone_now'.

We should only invoice the ledger entries created till
next_invoice_date. It should be independent of the time
at which cron job runs.

This commit updates the logic to use next_invoice_date
as the event_time while invoicing via cron.
2024-03-08 09:25:46 -08:00
Prakhar Pratyush 31a0aa2a83 test_stripe: Fix time travel to incorrect datetime.
Earlier, at few places in test_stripe we were doing
incorrect time travel. For example:
A plan was invoiced till self.next_year & while checking
the billing page, we were using the self.now datetime.
To correctly check the billing page state after plan is
invoiced, we should use a datetime greater than or equal
to the time at which plan was invoiced.

This commit fixes such logically incorrect time-travel.
2024-03-08 09:25:46 -08:00
Prakhar Pratyush 72d9a4a074 test_support_views: Fix event_time of LicenseLedger entry created.
While creating a LicenseLedger entry in 'create_customer_and_plan',
we should set the 'event_time' to the same time at which the plan
is created.

Earlier, the 'event_time' for ledger entry & 'billing_cycle_anchor'
of the plan were set to different values, which is not the
correct behavior.
2024-03-08 09:25:46 -08:00
Lauryn Menard f3906f4a2f remote-support: Add ability to deactivate and reactivate remote servers. 2024-03-07 11:51:00 -08:00
Mateusz Mandera e952c3b627 remote_billing: Tweak /self-hosted-billing/ endpoints access model.
It's best for these to just be consistent. Therefore:
1. The .../not-configured/ error page endpoint should be restricted to
   .has_billing_access users only.
2. For consistency, self_hosting_auth_view_common is tweaked to also do
   the .has_billing_access check as the first thing, to avoid revealing
   configuration information via its redirect/error-handling behavior.

The revealed configuration information seems super harmless, but it's
simpler to not have to worry about it and just be consistent.
2024-03-05 11:53:51 -08:00
Mateusz Mandera e39f400f94 remote_billing: Make "plan management" always available.
Just shows a config error page if the bouncer is not enabled. Uses a new
endpoint for this so that it can work nicely for both browser and
desktop app clients.
It's necessary, because the desktop app expects to get a json response
with either an error or billing_access_url to redirect to. Showing a
nice config error page can't be done via the json error mechanism, so
instead we just serve a redirect to the new error page, which the app
will open in the browser in a new window or tab.
2024-03-05 11:53:51 -08:00
Lauryn Menard 666041e480 remote-support: Show deactivated servers in search results.
The remote support view now returns results for deactivated remote
servers with those results sorted to the end and formatted to
visually stand out.

Forms to change sponsorship and discount fields on the customer
for the remote server or realm are not shown, but the data stored
on the customer object is shown, including any sponsorship request
information (if the customer had a sponsorship request pending when
it was deactivated).

Forms to schedule a plan are also not shown for deactivated servers
and their associated remote realms.

Forms and information for any current plan or scheduled plan, for
either the deactivated remote server or its associated remote
realms, are shown so that support staff can update those plans if
necessary.
2024-03-01 14:11:19 -08:00
Prakhar Pratyush a513489f38 corporate: Fix invoicing of plans on free-trial with changed schedule.
Earlier, the 'next_invoice_date', 'invoiced_through', and
'invoicing_status' fields in 'do_change_schedule_after_free_trial'
were not set correctly.

It resulted in invoicing the ENDED plan and the ledger we create
in this function.

Multiple invoices were created depending on the number of times the
billing frequency was changed for customers who started free-trial
& changed their billing frequency.

This commit sets those fields correctly leading to create only one
invoice.
2024-03-01 10:47:55 -08:00
Anders Kaseorg 82a9fd927b ruff: Fix E226 Missing whitespace around arithmetic operator.
This is a preview rule, not yet enabled by default.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-03-01 09:30:04 -08:00
Lauryn Menard 8d60ca548b remote-support: Use remote server or realm UUID in support URL.
Because the remote support page now supports searching by UUID,
the support URL for remote billing entities, which is used for
sponsorship request emails and overdue invoice emails, can now
use the remote server or realm UUID.

Adds the remote realm UUID to the remote support view information.
2024-02-29 11:21:00 -08:00
Prakhar Pratyush 24f902f3c6 corporate: Fix next payment info on billing page for fixed-price plans.
Earlier, for fixed-price plans we were showing the generic
next payment info on billing page which stated that plan
will automatically renew on end_date. It is no longer correct
for fixed-price plans.

This commit fixes the next payment info for fixed-price plans.

When the next_billing_cycle is the end_date, we inform the customer
that their plan will end on end_date and zulip sales will contact
them a couple of month ago before the end_date for renewal.
2024-02-28 08:48:18 -08:00
Lauryn Menard 1914b881d9 remote-support: Add ability to search by billing user email. 2024-02-23 13:21:54 -08:00
Lauryn Menard e4e65074df remote-support: Add push notification status information.
Adds the information returned by get_push_status_for_remote_request
for remote billing users to the support page. Note that getting
the current push status data will result in some duplicate database
queries (getting customer, plan, current billed users, next billing
cycle) when generating the remote support view.
2024-02-23 09:08:21 -08:00
Lauryn Menard 423af9916a remote-support: Add specific class for support section headers. 2024-02-23 09:08:21 -08:00
Aman Agrawal bddb44eebf stripe: Disable free trial for legacy customer with ended plan.
This ensures that customer who had legacy plan any time in the past
cannot avail free trial.
2024-02-21 21:40:47 -08:00
Lauryn Menard 907c209296 remote-support: Add search results for remote server/realm uuid. 2024-02-21 12:40:34 -08:00
Lauryn Menard 1eca9b3f6e remote-support: Return server results for realms with host match.
Checks for remote realm hosts that match the search query. Adds a
database query to getting the initial search results.
2024-02-21 12:40:34 -08:00
Mateusz Mandera ea863bab5b remote_billing: Remove code migrating Legacy plan from server to realms.
We no longer want to migrate Legacy plans from server to realms, since
Legacy plans are not really a thing in the original sense anymore, since
February 15th.

Now they're just a tool to give temporary extensions of access to the
push notification service for users, when needed. And as such, it makes
no sense to migrate like that.

The remaining code in this function is for migrating (any) plan from the
server object to the realm object, if the server has just a single
realm.
2024-02-21 11:10:45 -08:00
Prakhar Pratyush 2f8e4a71d6 corporate: Send a reminder email 2 months before the end date.
For fixed-price plans, we send a reminder email to
sales@zulip.com, 2 months before the end date, to review
the pricing and configure a new fixed-price plan accordingly.
2024-02-21 10:43:23 -08:00
Prakhar Pratyush 06e48fd553 corporate: Add end_date to fixed-price plans.
Earlier, we were not configuring the end_date while creating
a fixed-price plan which would result in the automatic renewal
of the plan at the end of billing cycle.

Our plan is to re-evaluate the pricing when we are close to the
end date, then:
1. Schedule a new fixed-price plan with the updated or same price.
2. or Don't do anything - the plan will end on the end_date.

Now, we add an end_date of 1 year from the start date when
creating a fixed-price plan.
2024-02-21 10:43:23 -08:00
Mateusz Mandera 834dbd552b remote_billing: Make handle_customer_migration_... more robust.
The logic in the case where there's only one realm and the function
tries to migrate the server's plan to it, had two main unhandled edge
cases that would throw exceptions:
1.
```
        remote_realm = RemoteRealm.objects.get(
            uuid=realm_uuids[0], plan_type=RemoteRealm.PLAN_TYPE_SELF_MANAGED
        )
```

This could throw an exception if the RemoteRealm exists, but has an
active e.g. Legacy plan. Then there'd be no object matching the
plan_type in the query, raising RemoteRealm.DoesNotExist.

2. If the RemoteRealm had e.g. a Legacy plan in the past, that's now
   expired, then it'd have a Customer object. Meaning that the attempt
   to move the server's customer to the realm:
   `server_plan.customer = remote_realm_customer`
   would trigger an IntegrityError since a RemoteRealm can't have two
   Customer objects.

In simple cases the situation in (2) can still be easily migrated, by
moving the plan from the server's customer to the realm's customer.
2024-02-20 16:02:03 -08:00
Mateusz Mandera 5e6f4faad2 test_remote_billing: Rename server_on_active_plan_error helper arg.
This is kind of too specific, allowing testing for only one single error
when accessing signed_auth_url. Instead, this should use a general
pattern, which will allow other tests to use this to assert other kinds
of error responses that may be returned.
2024-02-20 16:02:03 -08:00
Mateusz Mandera 1c61bb2fad remote_billing: Fix two tests that shouldn't be asserting in a loop.
It doesn't make sense to run a loop over "all" query results, when those
results are just two, and each of them has its own distinct asserts.

That for loop is there probably due to copying the structure of the
earlier test_transfer_legacy_plan_from_server_to_all_realms test, for
which the loop does make sense.
2024-02-20 16:02:03 -08:00
Lauryn Menard b6d50c158d support: Add CSS grid for confirmation objects in query results. 2024-02-20 15:46:55 -08:00
Mateusz Mandera be03dabf76 zilencer: Implement do_reactivate_remote_server utility function.
The inverse of do_deactivate_remote_server. It's just flipping the
.deactivated flag, but we also should have an AuditLog for these events.
2024-02-19 20:26:47 -08:00
Prakhar Pratyush 9648256c3c corporate: Fix next_invoice_date not updated on end_date extension.
Earlier, on extending end_date for legacy plans, next_invoice_date
was not extended which resulted in invoice_plan() run for such
legacy plans before the end_date.

The intended behaviour is that the legacy plan should be invoiced
only once on the end_date to downgrade or switch to a new tier.

This commit adds logic to update next_invoice_date when end_date
is extended via /support.
2024-02-16 08:30:17 -08:00
Lauryn Menard 230294cfb3 remote-activity: Add column for remote server or realm creation date.
Expands the main query for remote servers to get the audit log
event datetime for when the server was created/registered.

The remote realm object has a field for when the remote realm
was created on the remote server.
2024-02-15 10:29:12 -08:00
Alex Vandiver 7f46773ef1 tests: Clear in-memory Client caches before testing query counts.
This makes counts more apples-to-apples comparable when run
back-to-back.
2024-02-14 12:27:03 -08:00
Lauryn Menard b275e9c4d6 stripe: Add billing portal for customer name and address.
Adds a link on the upgrade and billing pages that opens a stripe
billing portal for the customer to update their name and address
that will appear on invoices and receipts.

On the billing page, updating the credit card information will
no longer update the customer billing address, since they can
now do this directly through the billing portal. To be consistent
with the credit card form on the upgrade page, we still require
inputting a billing address for the card.

Note that, once an invoice is paid/complete, then changes to the
customer's name and address will not be applied to those invoices.
2024-02-13 14:18:38 -08:00
Aman Agrawal 8cba101e05 support: Add button to delete configured fixed next plan.
This will help us modify the configured plan if we need to.
2024-02-13 09:40:53 -08:00
Aman Agrawal 7b33d660eb billing: Rename self-managed to free. 2024-02-12 21:25:19 -08:00
Aman Agrawal 7ca85bed71 stripe: Fix $0 invoices being generated on upgrade.
Instead of charging the customer using the attached payment
method and then creating the invoice, we create an invoice and
force an immediate payment for the invoice via the attached
payment method.
2024-02-12 15:15:56 -08:00
Prakhar Pratyush 2055dfa83e support: Add support to configure fixed-price plan with pay-by-invoice.
* Manually create & send invoice
* Configure a fixed-price plan with sent invoice-id.
* When customer pays, upgrade them to concerned plan.
2024-02-06 18:43:23 -08:00
Aman Agrawal de33aa4b7b stripe: Add page to show list of past customer invoices. 2024-02-04 17:38:24 -08:00
Prakhar Pratyush c4b6cfe142 support: Fix next plan info missing for customers with no current plan.
Earlier, when a fixed-price plan for a customer with
no current plan was configured via /support, the next plan
info was missing on support page.

It was because we were considering next plan only if the
customer had a current plan.

This commit fixes the incorrect behaviour.
2024-01-31 12:25:31 -08:00
Lauryn Menard df2f4b6469 corporate: Move support and activity views to /corporate.
View functions in `analytics/views/support.py` are moved to
`corporate/views/support.py`.

Shared activity functions in `analytics/views/activity_common.py`
are moved to `corporate/lib/activity.py`, which was also renamed
from `corporate/lib/analytics.py`.
2024-01-30 10:06:48 -08:00
Prakhar Pratyush edec29e0b6 support: Add support to configure fixed_price plan. 2024-01-29 11:23:20 -08:00
Anders Kaseorg 93198a19ed requirements: Upgrade Python requirements.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-01-29 10:41:54 -08:00
Prakhar Pratyush 3a6c98f6a9 stripe: Fix invoicing for new plans scheduled to upgrade.
Earlier, the next_invoicing_date and invoicing_status
for new plan weren't set correctly, resulting in the
scheduled switching of legacy plan to a new plan not
working as expected.

This commit fixes the incorrect behaviour.
2024-01-25 10:57:29 -08:00
Prakhar Pratyush 026eb37c28 stripe: Fix legacy plans not being invoiced.
Earlier, in 'migrate_customer_to_legacy_plan`, we set
'next_invoice_date' to None for legacy plans.
This will result in legacy plans not getting invoiced.
We need to invoice legacy plans on their end date to
either downgrade them or switch to a new plan.

We set next_invoice_date for legacy plans to end_date.
2024-01-25 10:57:29 -08:00
Aman Agrawal 5a97a4d8dc stripe: End legacy plan on end_date. 2024-01-19 09:34:36 -08:00
Mateusz Mandera 649b4885e8 remote_billing: Add rate-limiting for confirmation email sending.
These should be rate-limited by both IP using our regular
sends_email_by_ip bucket as well as by server, using a new bucket
dedicated to this.
2024-01-18 12:06:16 -08:00
Alya Abbott 57b5be6c91 billing: Rename button to apply for sponsorship or discount.
It was not clear that the button could be used for discounts.
2024-01-18 08:33:08 -08:00
Alya Abbott 91ee0bf676 emails: Remove organization type from sponsorship request emails.
This makes the subject nicer for replying to these emails.
2024-01-17 16:44:06 -08:00
Mateusz Mandera fc247cba3f remote_billing: Fix /self-hosted-billing/ handling for desktop app.
When you click "Plan management", the desktop app opens
/self-hosted-billing/ in your browser immediately. So that works badly
if you're already logged into another account in the browser, since that
session will be used and it may be for a different user account than in
the desktop app, causing unintended behavior.

The solution is to replace the on click behavior for "Plan management"
in the desktop app case, to instead make a request to a new endpoint
/json/self-hosted-billing, which provides the billing access url in a
json response. The desktop app takes that URL and window.open()s it (in
the browser). And so a remote billing session for the intended user will
be obtained.
2024-01-15 16:50:48 -08:00
Lauryn Menard a5f2883a75 remote-support: Add ability to set a required plan tier for customer. 2024-01-15 03:10:04 -08:00
Lauryn Menard f27b6d896a audit-logs: Add generic property changed for Customer and CustomerPlan.
Change audit logs for changing a Customer or CustomerPlan property
to use a generic event type and specify the property name in the
extra data.
2024-01-15 03:10:04 -08:00
Prakhar Pratyush 89f9e097db stripe: Add cron-based plan invoicing to remote server billing system. 2024-01-14 15:47:55 -08:00
Prakhar Pratyush 11908c4c2e stripe: Add cron-based plan invoicing to remote realm billing system. 2024-01-14 15:47:55 -08:00
Prakhar Pratyush 4c47b9ef2b test_stripe: Rename 'realm_user_count' to 'server_user_count'.
This commit renames the variable 'realm_user_count' to
'server_user_count' in 'test_upgrade_user_to_monthly_basic_plan'.

The variable was incorrectly named earlier as it stores
the user count of the whole server.
2024-01-14 15:47:55 -08:00
Mateusz Mandera 3a12e41c35 remote_billing: Fix handle_customer_migration_from_server_to_realms.
This was a bug from 4715a058b0 where this
was just incorrectly called. get_realms_info_for_push_bouncer() is a
function meant to be called on a self-hosted server - and this
handle_... call happens on the bouncer. Therefore this returns all
zulipchat realms in product.

With the way, handle_... is being called right now, there's no reason
for it to have an argument for passing a list of realms. It should just
fetch the relevant RemoteRealm entries  by itself, given the server arg.
2024-01-12 15:28:41 -08:00
Aman Agrawal 02a4b3ce62 stripe: Add some test for self hosted free trial.
Cannot test invoice until it is implemented.
2024-01-12 08:50:51 -08:00
Mateusz Mandera 63254f18ec remote_billing: Handle two confirmation links for same user correctly.
The bug was that a user could do the first part of the flow twice,
receiving two confirmation links, before finishing signup. Then they
could use the first link, followed by the second, which would case an
IntegrityError due to trying to create the RemoteRealmBillingUser
for the second time.

When the second link gets clicked, we should just transparently redirect
the user further into the flow so that they can proceed.
2024-01-12 08:39:48 -08:00
Prakhar Pratyush 976354dbda stripe: Fix the invoice item description for flat discounts.
Earlier, in process_initial_upgrade, the flat_discount value
wasn't converted into dollars when specified in the invoice
description, resulting in showing the incorrect value of $2000
as a discount.

This commit converts the value in cents to dollars and adds tests
to verify the invoice generated.
2024-01-11 12:35:58 -08:00
Aman Agrawal 073f432a69 stripe: Set min license count based on flat discount.
For self hosted basic plan, we need to allow customers to subscribe
without purchasing 10 licenses and also we need to allow customer
take fully use the available discount so that if the add more
users in the future, the full discount was already applied.

To fix above, we set minimum user count to the least number
of licenses we require for the charge to be positive after applying
the complete discount.
2024-01-08 14:17:56 -08:00
Prakhar Pratyush 4715a058b0 migrate_customers: Migrate customer from server to realms during login.
Earlier, the 'handle_customer_migration_from_server_to_realms'
function was called during the send analytics step.

It resulted in an error for customers having multiple Zulip servers,
one for testing and the others for not-testing, sharing a
push bouncer registration.

The migration step when run in a test instance caused customers to
have their legacy plan migrated to a test realm, resulting in them
losing their legacy plan.

This commit moves the migration step to run during plan management
login step. This reduces the chances of losing legacy
plan as we expect them to only verify that 8.0 upgrade works and
not bother trying to login to plan management from their test instance.
2024-01-05 12:02:54 -08:00
Lauryn Menard fb29a35262 support: Add updating minimum licenses requirement after discount.
Adds a support action for updating the minimum licenses on a
customer object once a default discount has also been set.

In the case that the current billing entity has a current active
plan or a scheduled upgrade to a new plan, then the minimum
licenses will not be updated.
2024-01-04 18:42:07 -08:00
Lauryn Menard cc957e92f4 support: Raise errors for support requests that are not processed.
Previously, the message string was sent as a success response to
the context, which could have been confusing or ignored when shown
in the support admin view.
2024-01-04 18:42:07 -08:00
Tim Abbott 2436df6fa6 zilencer: Don't migrate plans with sponsorship pending. 2024-01-04 18:31:16 -08:00
Prakhar Pratyush a03f9078e5 test_stripe: Add migrate customer from server to realms E2E test. 2024-01-02 11:20:56 -08:00
Mateusz Mandera 367d552052 billing: Improve make_end_of_cycle_... interactions with audit logs.
- Make `self.write_to_audit_log` support a `background_update:
  bool=False` parameter that can be passed when code that might have an
  acting user happens to trigger a background update.
- Make `make_end_of_cycle_updates_if_needed` pass that parameter for its
  direct audit log writes.
- Audit code that `make_end_of_cycle_updates_if_needed` calls and make
  sure those write audit logs this way too.
- Pass the user in the `billing_page` code that had to avoid it as a
  workaround:
```
    # BUG: This should pass the acting_user; this is just working
    # around that make_end_of_cycle_updates_if_needed doesn't do audit
    # logging not using the session user properly.
    billing_session = RealmBillingSession(user=None, realm=user.realm)
```
2024-01-02 10:59:05 -08:00
Anders Kaseorg 089c8f61c5 test_remote_billing: Use unordered comparison for deactivation test.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-12-29 14:12:43 -08:00
Prakhar Pratyush 2883bd92c2 test_stripe: Add E2E test for deactivate registration with bouncer. 2023-12-23 14:58:52 -08:00
Aman Agrawal e192aef23d billing: Apply a flat discount for self hosted plans. 2023-12-20 23:09:21 -08:00
Prakhar Pratyush 63bb63ad80 corporate: Remove '#nocoverage' comments.
This commit removes '#nocoverage' comment as we have added
few E2E tests in 'test_stripe.py'.
2023-12-19 10:59:38 -08:00
Prakhar Pratyush f278e21c7a test_stripe: Add legacy remote server schedule upgrade E2E test. 2023-12-19 10:59:38 -08:00
Prakhar Pratyush 2a6c93a2b9 test_stripe: Add remote server non-sponsorship E2E test. 2023-12-18 23:49:03 -08:00
Prakhar Pratyush 1380319708 test_stripe: Improve non-sponsorship remote realm billing test.
This commit improves the test to check the internal states
of the database e.g. check what /billing/ says about the
next renewal date and amount.
2023-12-18 23:49:03 -08:00
Aman Agrawal b2faa5c5bb stripe: Add a CustomerPlan for self hosted sponsored customers. 2023-12-18 12:55:34 -08:00
Aman Agrawal d962814a30 upgrade: Make it possible to upgrade to a provided tier.
Main work is maintaining context during various redirects and
and passing the context to the final upgrade process.
2023-12-18 12:23:46 -08:00
Anders Kaseorg cd96193768 models: Extract zerver.models.realms.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-12-16 22:08:44 -08:00
Anders Kaseorg 45bb8d2580 models: Extract zerver.models.users.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-12-16 22:08:44 -08:00
Tim Abbott 9423ccecd4 docs: Document plan management login tips. 2023-12-15 11:03:42 -08:00
Aman Agrawal 0fe725fdbd test_stripe: Add tests to check sponsorship approval. 2023-12-15 09:08:48 -08:00
Prakhar Pratyush 1588f49b4f test_stripe: Add end-to-end test for RemoteRealm billing flow. 2023-12-15 09:08:48 -08:00
Prakhar Pratyush 33e04362e1 test_stripe: Add 'billing_session" to StripeTest.
This prep commit adds a 'billing_session' field to StripeTest class.

Creates 'client_billing_get', 'client_billing_post', and
'client_billing_patch' helper functions.

This will help in reusing code for RemoteRealm and
RemoteZulipServer end-to-end tests.
2023-12-15 09:08:48 -08:00
Aman Agrawal 53b7e956ea test_remote_billing: Extract remote server / realm login methods. 2023-12-15 09:08:48 -08:00