Tim Abbott
f83871c182
corporate: Consistently use delivery_email for billing.
...
This is yet another corner case where EMAIL_ADDRESS_VISIBILITY_ADMINS
broke existing code.
2019-11-18 17:02:57 -08:00
Anders Kaseorg
93b1c3d94b
settings: Extract config file functions to a module.
...
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-11-13 12:38:45 -08:00
Rishi Gupta
0b39263ec0
billing: Rename get_seat_count to get_latest_seat_count.
...
This will help as our billing system becomes more async to accommodate
on-prem billing.
2019-10-21 16:06:18 -07:00
Rishi Gupta
e10361a832
models: Replace is_guest and is_realm_admin with UserProfile.role.
...
This new data model will be more extensible for future work on
features like a primary administrator.
2019-10-06 16:24:37 -07:00
Anders Kaseorg
9a9de156c3
lint: Fix calls to _() on computed strings.
...
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-04-23 15:23:03 -07:00
Rishi Gupta
1a7a449572
billing: Add backend support for downgrading.
2019-04-11 23:27:42 -07:00
Rishi Gupta
a529080f01
billing: Rename add_plan_renewal_to_license_ledger_if_needed.
2019-04-11 23:20:29 -07:00
Rishi Gupta
03d21c6317
billing: Refactor renewal_amount to return 0 instead of None.
2019-04-11 23:20:29 -07:00
Rishi Gupta
447ae77b24
billing: Add another live CustomerPlan.status.
...
Only CustomerPlan.ACTIVE is being used in the code / in production, so don't
need a db migration to move the other CustomerPlan.status constants around.
2019-04-11 23:20:29 -07:00
Rishi Gupta
4430f78aa3
billing: Rename next_renewal_date to start_of_next_billing_cycle.
2019-04-11 23:20:29 -07:00
Rishi Gupta
2270d4d192
billing: Try paying invoices when user puts a new card on file.
...
Previously, when users got a "payment failed" email from Stripe (e.g. if
their card failed on renewal), they would enter in a new card on
/billing#payment-method, and wouldn't find out if the card worked till
Stripe retried the payment 4 days later.
2019-04-05 13:36:03 -07:00
Rishi Gupta
28a586e502
billing: Add default value for event_time in invoice_plans_as_needed.
2019-04-05 11:24:45 -07:00
Vishnu Ks
ca1276961d
billing: Create get_discount_for_realm function.
2019-03-11 12:01:11 -07:00
Anders Kaseorg
f5197518a9
analytics/zilencer/zproject: Remove unused imports.
...
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-02-02 17:31:45 -08:00
Rishi Gupta
8f7e38c559
billing: Remove deprecated billing tables and fields from corporate/models.
2019-01-31 15:12:43 -08:00
Rishi Gupta
a37558b021
billing: Update get_seat_count to incorporate guests.
2019-01-30 10:35:01 -08:00
Rishi Gupta
db6e6472b1
billing: Set idempotency key to None when running test suite.
2019-01-30 10:35:01 -08:00
Rishi Gupta
4ccbeeb4a9
billing: Add an event_time argument to renewal_amount.
2019-01-29 07:37:21 -08:00
Rishi Gupta
a5324b6ea7
billing: Add a test for a race condition in process_initial_upgrade.
2019-01-29 07:01:31 -08:00
Rishi Gupta
9018ef5175
billing: Do not require a Stripe account to store Customer discounts.
2019-01-29 06:09:11 -08:00
Rishi Gupta
4aa2ac1b52
billing: Add functions for automatic invoicing of plans.
2019-01-28 16:04:11 -08:00
Rishi Gupta
421cda0e34
billing: Adding invoicing fields to CustomerPlan.
2019-01-28 16:04:11 -08:00
Rishi Gupta
83a7595feb
billing: Update next_renewal_date to take an event_time.
...
Also changes a < into a <= in add_plan_renewal_to_license_ledger_if_needed.
2019-01-28 16:04:11 -08:00
Rishi Gupta
7c11fe819a
billing: Update license ledger when users are added and removed.
2019-01-28 16:04:11 -08:00
Rishi Gupta
03c71dad17
billing: Fix misuses of CustomerPlan.discount.
2019-01-28 16:04:11 -08:00
Rishi Gupta
ad7a7b246e
billing: Move license management from CustomerPlan into its own table.
2019-01-19 16:00:44 +05:30
Rishi Gupta
112eb01728
billing: Remove PLAN_NAMES and other legacy code.
2019-01-18 11:46:17 +05:30
Rishi Gupta
e7220fd71f
billing: Do subscription management in-house instead of with Stripe Billing.
...
This is a major rewrite of the billing system. It moves subscription
information off of stripe Subscriptions and into a local CustomerPlan
table.
To keep this manageable, it leaves several things unimplemented
(downgrading, etc), and a variety of other TODOs in the code. There are also
some known regressions, e.g. error-handling on /upgrade is broken.
2018-12-22 13:39:30 -08:00
Rishi Gupta
5633049292
billing: Restructure validation of upgrade parameters.
2018-12-22 13:30:15 -08:00
Rishi Gupta
b4a28f3147
billing: Rename seat_count to licenses where appropriate.
2018-12-22 13:30:15 -08:00
Rishi Gupta
7ab1406962
billing: Prepare for moving Plan to CustomerPlan.billing_schedule.
2018-12-22 13:30:15 -08:00
Rishi Gupta
7b5d15d254
billing: Move discount to local Customer object.
...
A lot of the seemingly unrelated test fixture changes are because we're
removing a query to stripe in the upgrade path, in cases when the user's
realm has an existing Customer object.
2018-12-22 13:30:15 -08:00
Rishi Gupta
8ec91fc42d
billing: Remove process_downgrade.
2018-12-22 13:30:15 -08:00
Rishi Gupta
84a31ca800
billing: Remove BillingProcessor.
...
Leaving the model in place, so that we can do the database migration by
hand.
2018-12-22 13:30:15 -08:00
Rishi Gupta
b245c661da
billing: Change do_change_plan_type to take a realm instead of a user.
...
More often than not, changes in plan type are not directly due to user
action.
2018-12-13 13:26:24 -08:00
Rishi Gupta
c9c842ae2b
billing: Add randomness to idempotency key while testing.
...
Makes it easier to test or regenerate fixtures for
test_billing_quantity_changes_end_to_end with generate=True.
2018-11-30 23:14:52 -08:00
Rishi Gupta
698aeddc85
billing: Delete test_subscribe_customer_to_second_plan.
...
This used to be a more likely codepath, before we introduced
Customer.has_billing_relationship. It is no longer literally impossible to
hit this race condition, so I'm not deleting the code, but it's unlikely
enough that it's not worth figuring out how to test it.
2018-11-28 10:45:00 -08:00
Rishi Gupta
33ec86aa00
billing: Delete test_extract_current_subscription.
...
Already better tested by the upgrade and downgrade tests using mock_stripe.
Note that the line that was removed is actually not possible to reach, since
canceled subscriptions aren't shown on the Customer object.
2018-11-28 10:45:00 -08:00
Rishi Gupta
7bc23a8f85
billing: Turn off process_downgrade.
2018-11-26 16:24:54 -08:00
Rishi Gupta
08daefa4a3
billing: Update payment method string to incorporate billing by invoice.
...
Also fixes a bug in process_initial_upgrade. If you have a card on file
(e.g. from a previous subscription), and try to upgrade by billing by
invoice, neither the if nor the elif condition applies.
2018-11-24 11:56:13 -08:00
Vishnu Ks
d8804a2474
billing: Change plan_interval to plan.interval.
...
There is no attribute called plan_interval. The reason
this was missed by mypy is moost likely due to us using
Any instead of Subscription in extract_current_subscription.
2018-11-19 12:36:25 +05:30
Rishi Gupta
99506b486a
billing: Add backend for paying by invoice.
2018-11-17 23:08:48 -08:00
Rishi Gupta
61e0c2693d
billing: Use Subscription.save() instead of calling save on instances.
...
Continuation of 03d77bc
.
2018-11-17 18:59:21 -08:00
Rishi Gupta
0670976cb1
billing: Remove PRINT_STRIPE_FIXTURE_DATA.
...
Made obsolete by mock_stripe.
2018-11-16 19:41:46 -08:00
Vishnu Ks
2e04cdbe5e
billing: Show estimated subscription revenue on /activity.
...
[Substantial edits by Rishi Gupta]
2018-11-16 13:30:16 -08:00
Rishi Gupta
2e89ffb0e2
billing: Make it easier to access /billing in tests.
2018-11-07 22:18:54 -05:00
Rishi Gupta
458169928c
billing: Rename Zulip Premium to Zulip Standard.
2018-10-24 10:42:16 -07:00
Rishi Gupta
03d77bc6af
billing: Replace instance.save() Stripe API calls with class.save(instance).
...
This will make it easier to mock the calls in our new stripe mocking
framework. I believe the two forms are equivalent, assuming the Stripe
Python bindings aren't doing anything crazy. And if not, well hopefully our
new testing framework will catch it :).
[Idea originally from Vishnu KS.]
2018-10-18 11:16:00 -07:00
Vishnu Ks
d8c19cb003
models: Move billing models from zilencer to corporate.
2018-10-11 14:54:29 -07:00
Vishnu Ks
59865797ac
billing: Move billing tests from zilencer to corporate.
2018-10-01 15:44:02 -07:00