Commit Graph

1156 Commits

Author SHA1 Message Date
Lauryn Menard
6326b07905 billing: Update CustomerPlan.invoiced_through documentation.
Clarify what the invoiced_through field on a CustomerPlan indicates
after the changes to the billing state machine as ledger entries
are processed in invoice_plan.

Updates the plan activity page where this field is shown to support
admin users for these changes as well.

Follow-up to #34643.
2025-05-20 07:05:02 -07:00
Alya Abbott
dd7e871b11 portico: Add partnership program page. 2025-05-19 16:36:26 -07:00
Alex Vandiver
33f7da23a0 stripe: Do not place Realm objects into context. 2025-05-16 11:30:48 -07:00
Aman Agrawal
ac671e2e4b stripe: Fix bugged tracking of invoicing status of plan.
Properly track the current invoicing status using `invoicing_status`
and `invoiced_through` fields.
2025-05-16 10:55:57 -07:00
Aman Agrawal
906b96cdfc test_stripe: Fix weak URL testing.
The host of this URL could have been forged to redirect user
to a different subdomain and tests would still pass.

This also fixes the CodeQL warnings related to it.
2025-05-14 13:45:35 -07:00
Aman Agrawal
e04a32dee6 stripe: Upgrade API_VERSION to "2025-04-30.basil".
This involves the following major changes to the code:
* `Invoice.upcoming` removed in https://docs.stripe.com/changelog/basil/2025-03-31/invoice-preview-api-deprecations.

* InvoiceItem always needs to be created with an Invoice id for
  InvoiceItem to be attached to the Invoice.

  This seems to just be required after the upgrade and looking at
  stripe python SDK history, this was how it was always supposed to work.

  This is a welcome change since it adds to the clarity of the code.

* Change due to following breaking changes:

  - https://docs.stripe.com/changelog/basil/2025-03-31/invoice-pricing-configurations
  - https://docs.stripe.com/changelog/basil/2025-03-31/add-support-for-multiple-partial-payments-on-invoices

  which removes and adds various parameters and attributes to the
  invoice related objects.

  Also, out of band invoices now count in `amount_paid` in Invoice as
  part of above linked changes.

  See https://github.com/stripe/stripe-python/blob/master/CHANGELOG.md
  for an easier to search list of changes.

* Removed `proration` parameter from testing since we were not using it
  and testing its constant `false` value would require us writing more
  custom code to access its value.

* Added test for "usd" for the currency, since there were some changes
  in the API related local currency and I wanted to check Invoices
  were being created as expected.
2025-05-14 13:45:35 -07:00
Aman Agrawal
3cdda91afe stripe: Link InvoiceItem to Invoice.
This is required for upgrading to the basil version of stripe.
Changes haven't been tested in this commit. It is just for easy
verification of changes.
2025-05-14 13:45:35 -07:00
Aman Agrawal
6fb7a21cef stripe: Update plan in database outside for loop.
Since we are not doing an early return here and the updated information
is not immediately used, we can skip updating the plan in database
till the end of for loop.
2025-05-14 13:45:35 -07:00
Aman Agrawal
ba9d183721 stripe: Only create flat discounts for renewal invoices.
If we only created invoice for additional licenses, we don't need
to add discount to the invoice.

Changes haven't been tested in this commit. It is just for easy
verification of changes.
2025-05-14 13:45:35 -07:00
Aman Agrawal
0a1f84fba1 stripe: Link InvoiceItem to Invoice.
This is required for upgrading to the basil version of stripe.
Changes haven't been tested in this commit. It is just for easy
verification of changes.
2025-05-14 13:45:35 -07:00
Aman Agrawal
c0504777b2 stripe: Link InvoiceItem to Invoice.
This is required for upgrading to the basil version of stripe.
Changes haven't been tested in this commit. It is just for easy
verification of changes.
2025-05-14 13:45:35 -07:00
Aman Agrawal
1a516f8b04 stripe: Link InvoiceItem to Invoice.
This is required for upgrading to the basil version of stripe.
Changes haven't been tested in this commit. It is just for easy
verification of changes.
2025-05-14 13:45:35 -07:00
Aman Agrawal
cfa7458797 stripe: Link InvoiceItem to Invoice.
This is required for upgrading to the basil version of stripe.
Changes haven't been tested in this commit. It is just for easy
verification of changes.
2025-05-14 13:45:35 -07:00
Aman Agrawal
af4cee9479 stripe: Link InvoiceItem to Invoice.
This is required for upgrading to the basil version of stripe.
Changes haven't been tested in this commit. It is just for easy
verification of changes.
2025-05-14 13:45:35 -07:00
Aman Agrawal
f8abfa2936 test_stripe: Add check for initially added card. 2025-05-14 13:45:35 -07:00
Aman Agrawal
625118bbb5 test_stripe: Add explanatory comment. 2025-05-14 13:45:35 -07:00
Aman Agrawal
567cf3c127 test_stripe: Fix incorrect pattern replacement in fixtures.
When normalizing fixture data, all numbers were being
replaced if they matched `exp_month`. This can lead to various
errors and flaky fixture generation. We use a pattern match
which includes the parameter being matched to fix this.
2025-05-14 13:45:35 -07:00
Aman Agrawal
104a7dd7a0 test_stripe: Don't return None on mocked return of stripe functions.
When mocking stripe function, don't return `None` as it can be
treated as the call was unsuccessful by the code being tested.
2025-05-14 13:45:35 -07:00
Aman Agrawal
9bcdaee065 test_stripe: Add clarification comment.
Wasted some time on this today, so decided to leave a comment here.
2025-05-14 13:45:35 -07:00
Aman Agrawal
fbec6ab123 stripe: Only attempt payment if invoice is not paid.
Since it is possible that invoice can be paid before we reach here,
so only attempt payment if the invoice is not marked as 'paid'.

Fixes invoice already paid error from stripe when running tests.
2025-05-14 13:45:35 -07:00
Lauryn Menard
c2007ebf30 support: Fix unit for file upload usage information. 2025-05-09 09:04:57 -07:00
Lauryn Menard
7fc9d29c1e support: Show file upload usage compared to realm upload quota.
Implemented on Zulip Cloud support view only since this information
isn't relevant for self-hosted support actions.

Looking up the realm's currently used upload space adds 3 database
queries to the support view test as there is no RealmCount data for
the upload quota used in the test. And therefore installation_epoch
is called for the realm.

With RealmCount upload quota used data, only 2 additional database
queries would be made for the realm's support view data.
2025-05-08 09:38:02 -07:00
Lauryn Menard
4d1bfe6537 demo-orgs: Disable corporate upgrade and sponsorship pages.
Use a shared error template for demo organizations when rendering
the upgrade or sponsorship pages.

Demo organizations must be converted into a permanent organization,
i.e., not be automatically scheduled for deletion, to either apply
for a sponsorship/discount or upgrade to a paid plan.
2025-04-23 09:23:24 -07:00
Lauryn Menard
cb3dc88dcf corporate: Show "Fixed" as rate for fixed-rate plans in activity charts. 2025-04-21 11:18:40 -07:00
Lauryn Menard
b074288bac upgrade: Remove demo_organization_scheduled_deletion_date page param.
The demo_organization_scheduled_deletion_date has never been used
on the upgrade page, and currently raises a Zod error as what is
being sent for the value of that page param is a datetime object,
and not the datetime object converted to an integer.

We really only need the boolean value that checks if the demo
organization scheduled deletion date is not None for the upgrade
page logic, which is set in the context dict for that page, but
not in the page params.
2025-04-17 10:49:02 -07:00
Ethan Mayer
c12b94aea4 models: Refactor corporate/models.py into models package.
Fixes #34318.

Seperated models file into a package with component files.
2025-04-08 10:16:35 -07:00
Prakhar Pratyush
41df472d41 corporate: Replace /try-zulip with /?show_try_zulip_modal.
This commit removes the `/try-zulip` landing page.

The URLs are replaced with `chat.zulip.org/?show_try_zulip_modal`,
which leads to display a modal for spectators.

Fixes #34181.
2025-04-03 13:01:48 -07:00
Lauryn Menard
ec89e5afd2 billing: Improve error handling when invoicing plans as needed.
When we're unable to process an invoice for a customer due to a billing
or assertion error, we log the error and add the customer ID to a set
of failed customer IDs. This allows us to continuing invoicing other
customers, and at the same time not invoice any other pending plans
attached to a customer we failed to invoice.
2025-03-27 12:51:52 -07:00
Lauryn Menard
10fff6a691 billing: Extract helper for invoicing check of remote server audit log.
Extracts the logic for making sure that, for self-hosted plans, the
remote server audit log data is current before invoicing an active
plan.
2025-03-27 12:51:52 -07:00
Lauryn Menard
0f567a1a66 billing: Extract helper for sending invoice overdue email.
Extracts the logic for sending an email to billing support when
a remote server's audit log data is stale and there is an active
CustomerPlan that needs to be invoiced.
2025-03-27 12:51:52 -07:00
Lauryn Menard
10a02142dc billing: Extract helper for sending fixed price plan renewal email.
Extracts the logic for sending a reminder email about the end of a
fixed price plan to billing support into a separate function.
2025-03-27 12:51:52 -07:00
Anders Kaseorg
13bd8771f9 corporate: Parse Accept header instead of X-Requested-With.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-03-26 22:29:09 -07:00
Aman Agrawal
c490b1cbb4 support: Show current billing admins on cloud support page. 2025-03-24 16:00:48 -07:00
Anders Kaseorg
67fb7daa63 ruff: Fix RUF051 Use pop instead of key in dictdel dict[key].
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-03-14 17:31:50 -07:00
Vector73
c049259d07 user: Remove is_billing_admin user property.
Removed `is_billing_admin` user property as it is no longer used since
billing permissions are now determined by `can_manage_billing_group`
realm setting.
2025-03-10 09:36:30 -07:00
Vector73
158fd58cde settings: Add "can_manage_billing_group" realm setting.
Added "can_manage_billing_group" realm group permission setting
to control who can manage billing and plans in the organization.

Fixes #32745.
2025-03-10 09:36:30 -07:00
ImDooMLorD
6dea58623c errors: Standardize "already in use" error messages.
Updates these error messages to have "X is already in use." format,
e.g., "Channel name is already in use." and "Name is already in use."

Fixes #33629.
2025-03-04 16:10:25 -08:00
Lauryn Menard
c4e3ccafa2 stripe: Delete fixed price plan offer if customer on comp access plan.
Updates delete_fixed_price_plan to use the same structure as
configure_fixed_price_plan. If there is a customer plan and it's
billable, then we delete the configured CustomerPlan object. If
there is no customer plan or it's a complimentary access plan, we
delete the configured CustomerPlanOffer object.
2025-02-28 17:42:04 -08:00
Lauryn Menard
add58e3795 billing: Use customer.minimum_licenses for minimum plan check.
Allow for manually setting a minimum_licenses value on a customer
to return that for min_licenses_for_plan in cases where we wanted
to override the general plan minimum for a particular case.
2025-02-20 14:17:25 -08:00
Anders Kaseorg
4e04eed745 typos: Fix typos caught by typos and mwic.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-02-18 19:44:02 -08:00
Anders Kaseorg
dd99ed019a requirements: Upgrade Django from 5.0.10 to 5.1.6.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-02-18 09:50:34 -08:00
Mateusz Mandera
0caf815e36 do_activate_mirror_dummy_user: Assert user_profile is a mirror dummy.
If this is called on a user without is_mirror_dummy=True, that seems
certain to be a bug. Therefore, an assert is preferable in order to
catch this, rather than returning early with noop like some other
function such as do_deactivate_user.
2025-01-28 09:38:56 -08:00
Anders Kaseorg
3b84dd3b8c stripe_event_handler: Fix UP038.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-01-24 22:59:58 -08:00
Aman Agrawal
b549562a4d sponsorship: Ask user how they plan to use Zulip.
This will help avoid some back-and-forth on sponsorship requests.
2025-01-22 09:22:52 -08:00
Aman Agrawal
6e1bb56519 stripe: Check for min_licenses when switching plan tier.
When we are upgrading a customer to a different plan tier, we should
check if switching plans would lead to different licenses due to
different minimum license requirement between plans.
2025-01-21 15:53:53 -08:00
Lauryn Menard
10b2e2a092 support: Update support view PlanData to use "complimentary access".
Prep for implementing a complimentary access plan for Zulip Cloud.
2025-01-21 15:40:27 -08:00
Lauryn Menard
1297541059 stripe-tests: Update uses of "legacy" to "complimentary access". 2025-01-21 15:40:27 -08:00
Lauryn Menard
8d638363da corporate: Update self-hosted complimentary access plan name.
Updates the name for the self-hosted complimentary access plan
to "Zulip Basic (complimentary)" instead of "Free (legacy plan)".

Since these plans are never billed in Stripe, we don't need to
hold to the 22 character limit for the plan name.
2025-01-21 15:40:27 -08:00
Lauryn Menard
261333c37f corporate: Clean up code remaining comments with "legacy plan".
Replaces documentation in billing code and tests to use
"complimentary access plan" instead of "legacy plan".
2025-01-21 15:40:27 -08:00
Lauryn Menard
bc20a0f086 support: Update "temporary courtesy" to "complimentary access".
Updates support actions for "temporary courtesy" plans to instead
use "complimentary access" to refer to these plans and actions.

Prep for implementing a complimentary access plan for Zulip Cloud.
2025-01-21 15:40:27 -08:00