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
21b51ba8d1
billing: Remove mix option from backend.
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
fe280fc38c
billing: Create StripeTestCase.
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
7958ac96a8
billing: Use CASCADE instead of models.CASCADE in models.py.
...
models.CASCADE will make lines too long in models we're about to add.
2019-01-18 11:46:17 +05:30
Rishi Gupta
112eb01728
billing: Remove PLAN_NAMES and other legacy code.
2019-01-18 11:46:17 +05:30
Rishi Gupta
955dfc6397
billing: Remove references to Realm.has_seat_based_plan.
2018-12-24 10:27:56 -08:00
Rishi Gupta
7c38300949
billing: Add info line to logger for failed upgrades.
2018-12-24 10:27:56 -08:00
Rishi Gupta
653416ab23
billing: Update /billing to work with new subscription model.
2018-12-23 00:18:21 -08:00
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
Vishnu Ks
8176d112fe
billing: Add frontend for license-based billing system.
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
Vishnu Ks
0fd6ff722b
billing: Migrate /upgrade endpoint to JSON.
...
The fixture changes are because self.upgrade formerly used to cause a page load
of /billing, which in turn calls Customer.retrieve.
If we ran the full test suite with GENERATE_STRIPE_FIXTURES=True, we would
likely see several more Customer.retrieve.N.json's being deleted. But
keeping them there for now to keep the diff small.
2018-12-13 17:01:12 -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
Vishnu Ks
a8113ae296
billing: Remove dont_mock argument from mock_stripe.
2018-12-04 12:19:57 -08:00
Rishi Gupta
c21a05a3b1
billing: Zero out timestamps that aren't being tested.
...
f52e9d1
ended up not going far enough. Keeping f52e9d1
in place in case we
ever want to go back to that sort of solution.
Also removes the keep argument from test_billing_quantity_changes_end_to_end,
since that test is actually testing the arguments to
stripe.Subscription.save(), not what is returned by Stripe.
2018-12-03 16:25:21 -08:00
Rishi Gupta
2453ab2a21
billing: Normalize a few more fields in normalize_fixture_data.
2018-12-03 16:24:16 -08:00
Rishi Gupta
84f7a779c4
billing: Take advantage of re match notation in normalize_fixture_data.
...
No change in behavior; just visual code cleanup.
2018-12-03 16:24:16 -08:00
Rishi Gupta
f52e9d143b
billing: Further normalize timestamps in tests.
...
Hopefully this will make it easier still to look at diffs with
GENERATE_STRIPE_FIXTURES = True.
2018-12-03 16:24:16 -08:00
Vishnu Ks
24917f2e9b
billing: Maintain a global list of stripe functions to mock.
...
Looks like payment_method_string was missing a Customer.save before. Not
sure how it was passing tests in that case.
2018-12-03 11:38:54 -08:00
Vishnu Ks
0191bb593a
billing: Make test functions accept *mocks instead of separate args.
2018-12-02 13:42:38 -08:00
Vishnu Ks
48618adf13
billing: Normalize several additional keys in mock_stripe.
...
Reran every test with GENERATE_STRIPE_FIXTURES = True, which also caused a
few fixtures to get updates unrelated to these changes (likely due to API
updates that hadn't been previously applied).
2018-12-02 13:32:19 -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
c59da02936
billing: Reflect discounts on /upgrade.
2018-11-30 11:19:07 -08:00
Rishi Gupta
16b7737da3
billing: Fix enforcement of seat_count in tests.
2018-11-30 11:19:07 -08:00
Rishi Gupta
5a47ac96de
billing: Fix test flake in test_payment_method_string.
2018-11-30 11:19:07 -08:00
Rishi Gupta
1ba037201c
billing: Move all price computations into billing.js.
2018-11-30 11:19:07 -08:00
Rishi Gupta
5fdc2e5161
billing: Ensure seat_count is always 8 in billing tests.
2018-11-28 23:08:27 -08:00
Rishi Gupta
f3ecb05762
billing: Rename stripeToken to stripe_token.
...
When we started the billing system we started by following conventions used
in the Stripe documentation, but in hindsight it makes more sense to follow
conventions used in the Zulip codebase.
2018-11-28 22:29:29 -08:00
Rishi Gupta
d302fae31b
billing: Rename self.quantity to self.seat_count in tests.
2018-11-28 22:29:29 -08:00
Rishi Gupta
10d3d94a2a
billing: Use common pathway for upgrading in tests.
2018-11-28 22:29:29 -08:00
Rishi Gupta
b3b1b47fb0
billing: Remove references to legacy stripe_fixtures.json.
2018-11-28 22:29:29 -08:00
Rishi Gupta
053778fdd7
billing: Update test_billing_quantity_changes_end_to_end to use mock_stripe.
2018-11-28 22:29:29 -08:00
Rishi Gupta
191d8101a3
billing: Update test_redirect_for_billing_home.
...
The part that was removed is better tested in many other tests, like
test_initial_upgrade.
2018-11-28 10:45:00 -08:00
Rishi Gupta
f0538293de
billing: Update test_replace_payment_source to use mock_stripe.
2018-11-28 10:45:00 -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
Vishnu Ks
8343ed6ceb
billing: Use mock_stripe in test_downgrade_with_money_owed.
2018-11-26 15:59:19 -08:00
Vishnu Ks
a8b95ff801
billing: Use mock_stripe in test_downgrade_with_no_subscription.
2018-11-26 15:16:26 -08:00
Vishnu Ks
1ec9097f55
billing: Use mock_stripe in test_downgrade.
2018-11-26 14:59:46 -08:00
Vishnu Ks
a2c0ec207e
billing: Use mock_stripe in test_attach_discount_to_realm.
2018-11-26 14:59:46 -08:00
Rishi Gupta
e2838a49db
billing: Delete fixture data before regenerating it.
2018-11-26 14:59:46 -08:00
Rishi Gupta
0dffb58797
billing: Fix fixture_files_for_function including too many files.
...
Previously, this function would return the fixture files for any test that
had the test's name as a prefix.
2018-11-26 14:59:45 -08:00
Vishnu Ks
189e5e1fbd
billing: Add frontend for upgrading by invoice.
2018-11-24 11:56:13 -08:00
Rishi Gupta
6afbc2726f
billing: Add billing_modality to upgrade form.
2018-11-24 11:56:13 -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
63614f28fe
billing: Upgrade to Stripe API version 2018-11-08.
...
Was hoping to do this after adding timestamp normalization to
normalize_fixture_data, which would have turned this into a <10 line
diff. There is a potentially material change in this API upgrade though
(around how invoices are handled), so just doing it now.
2018-11-17 18:09:56 -08:00
Rishi Gupta
0670976cb1
billing: Remove PRINT_STRIPE_FIXTURE_DATA.
...
Made obsolete by mock_stripe.
2018-11-16 19:41:46 -08:00
Rishi Gupta
b847a100a3
billing: Prevent setup_stripe from being run in production.
2018-11-16 19:29:31 -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
Vishnu Ks
a7c33e12cb
billing: Make mock_stripe handle calls which dont return object.
2018-11-16 13:30:16 -08:00
Vishnu Ks
2d140bae3e
billing: Cast return value of _mock_stripe to CallableT.
...
Without the cast mypy raises the following error:
Incompatible return value type (got "Callable[..., Any]",
expected "CallableT")
This is a known issue: https://github.com/python/mypy/issues/1927
2018-11-12 23:42:59 -08:00
Vishnu Ks
20c41f3d3e
billing: Replace IDs and other values before writing fixtures.
...
This makes a few other changes to the fixtures as well. Most are from API
updates, though I'm not sure why "Zulip Cloud Standard" got changed to
"Zulip Cloud Premium".
[Substantial edits by Rishi Gupta]
2018-11-12 23:24:33 -08:00
Vishnu Ks
f812b76c3b
billing: Allow mock_stripe to take multiple function_name arguments.
2018-11-10 00:38:32 -05:00
Rishi Gupta
2e89ffb0e2
billing: Make it easier to access /billing in tests.
2018-11-07 22:18:54 -05:00
Rishi Gupta
9b6b842f00
billing: Merge test_billing_home into test_initial_upgrade.
2018-11-07 22:18:54 -05:00
Rishi Gupta
7dc021a6b2
billing: Improve error message for require_billing_access.
2018-11-01 14:17:36 -07:00
Vishnu Ks
677f34c2b9
billing: Use require_billing_access decorator in JSON endpoints.
2018-11-01 12:45:29 -07:00
Vishnu Ks
b527c3c4ef
billing: Make mock_stripe handle StripeErrors.
2018-10-30 09:55:13 -07:00
Vishnu Ks
be162d5428
billing: Disable fixture generation in setUp function.
...
This means you'll need access to our Stripe API key to add new fixtures.
Will be undone eventually, but having this in place will make it easier to
finish the mock.patch to mock_stripe migration.
2018-10-30 09:33:02 -07:00
Vishnu Ks
0cf4a75fb5
coverage: Enforce full test coverage for corporate/views.py.
2018-10-24 19:39:23 -07:00
Vishnu Ks
052640dfd5
billing: Add test for error during source replacement.
2018-10-24 19:39:23 -07:00
Vishnu Ks
20de90066b
billing: Add test for exception during initial upgrade.
2018-10-24 18:54:53 -07:00
Vishnu Ks
a7f4ea4b2c
billing: Add test for billing disabled settings.
2018-10-24 18:54:18 -07:00
Rishi Gupta
458169928c
billing: Rename Zulip Premium to Zulip Standard.
2018-10-24 10:42:16 -07:00
Rishi Gupta
a4d3606bad
billing: Assume we are charging right away when adding new users.
...
The actual implementation of the change will be a cron job that runs once a
day and generates invoices for anyone with an account_balance > 0.
There are currently no tests for that part of the flow, so no tests had to
change.
2018-10-23 16:19:47 -07:00
Rishi Gupta
fbd884f934
billing: Rename MAX_INVITES_PREMIUM.
...
Largely to have parallel structure with INVITES_DEFAULT_REALM_DAILY_MAX.
2018-10-23 14:47:00 -07:00
Vishnu Ks
3b026559d4
stripe: Make stripe.error stubs more similiar to stripe python lib.
...
This will also fix the error that is generated during
the mypy 0.641 upgrade in PR #10691 .
2018-10-22 13:51:05 +05:30
Rishi Gupta
690705858a
billing: Update test_upgrade_where_..._fails_at_first to use @mock_stripe.
2018-10-18 11:16:00 -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
Rishi Gupta
80c482428d
billing: Update test_upgrade_with_outdated_seat_count to use @mock_stripe.
2018-10-18 10:08:40 -07:00
Rishi Gupta
509707007c
billing: Update test_billing_page_permissions to use @mock_stripe.
2018-10-18 09:49:50 -07:00
Rishi Gupta
c4bad258f7
billing: Import from mock in test_stripe.py.
...
The string 'mock' appears over 200 times in this file. This removes about 80
of them.
2018-10-17 21:06:09 -07:00
Vishnu Ks
50de59102d
billing: Add system to generate fixture data from the billing tests.
...
This will improve both the maintainability and accuracy of the fixture
data. It also makes it less scary to upgrade Stripe API versions.
[With significant changes by Rishi Gupta.]
2018-10-17 20:35:42 -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
Vishnu Ks
c01ebaa8d8
billing: Move billing management commands from zilencer to corporate.
2018-10-01 15:43:55 -07:00
Vishnu Ks
93b398bc0a
billing: Move zilencer/lib/stripe to corporate.
2018-10-01 15:43:44 -07:00
Vishnu Ks
daf3b46262
billing: Move billing related templates from zilencer to corporate.
2018-10-01 15:43:39 -07:00
Vishnu Ks
6914ee126c
billing: Move billing-related views and urls to corporate.
2018-10-01 15:43:21 -07:00
rht
c4f09156ff
corporate: Remove unused imports (F401).
2017-11-07 16:37:04 -08:00
K.Kanakhin
4891a8d850
Add default response for `terms` and `privacy` endpoints.
...
- Add setting for `privacy policy` template defining.
- Configure default templates for `privacy policy` and
`terms of service` pages.
- Add route for privacy page.
- Remove condition for showing `privacy` and `terms` pages.
- Add `privacy_policy` setting to context processor.
- Add documentaion part for `privacy` and `terms` templates
configuration.
- Add tests.
Fixes #3686 .
2017-04-12 14:09:14 -07:00
Umair Khan
a45f8b463a
app_filters.py: Use Django to load template.
...
This commit allows us to load template using Django in
render_markdown_path.
2017-04-07 15:52:15 -07:00
Tim Abbott
bd6f71580e
docs: Remove obsolete terms-enterprise page.
...
This was documentation for the old zulip.com enterprise service that
no longer exists.
2017-01-28 18:12:19 -08:00
Tim Abbott
9cc83f87fc
lint: Clean up E241 PEP-8 rule.
2017-01-23 21:21:14 -08:00
Tim Abbott
9fec519b3d
Zephyr: Remove obsolete mit.html template.
2016-11-16 17:33:42 -08:00
Umair Khan
b140236fcf
Django 1.10: Do not use patterns function.
2016-11-04 10:06:00 -07:00
acrefoot
b7ccf64c79
Move Zulip's TOS to TERMS_OF_SERVICE markdown file.
...
This reimplements zulip.com/terms using the new markdown system.
2016-07-29 20:47:42 -07:00
Umair Khan
f9bbc5d6ff
Enable i18n support in URL configuration.
...
This supports i18n using all of the following:
- I18N urls
- Session
- Cookie
- HTTP header
2016-05-19 08:33:30 -07:00
Luke Faraone
5c28b0340a
Don't show Zulip.com terms on other sites
...
While we already don't link to /terms anywhere on the site, they can still be
accessed if you navigate to /terms directly. Now, those routes will only be
exported on the Zulip.com service.
We should ideally provide a mechanism for deployments to specify their own
terms without modifying source code; in the interim, sites that have already
customised the provided Zulip.com terms can simply carry a patch reverting this
commit.
2016-03-21 05:46:28 +00:00
Anders Kaseorg
bded0d9d54
Remove corporate beta signup form
...
(imported from commit 1b3a0cd8a59a124905fa4cbd3121a78d23aeb3a2)
2015-08-20 18:40:34 -07:00
Anders Kaseorg
cb88147ca9
Remove corporate marketing page
...
(imported from commit 24128853fd78ef9e89df7f3353f45ac2531a42e1)
2015-08-20 18:40:34 -07:00
Anders Kaseorg
1b5f9e4374
Remove corporate jobs pages
...
(imported from commit 3f1789f6a4f90a33ddd2352fab85d3cf751b0f46)
2015-08-20 18:40:34 -07:00
acrefoot
3a982c7c06
Modify /hello to go to register instead of signup on Enterprise
...
Also move the urls.py lines to the right place
(imported from commit f9d9805fe599ceffb6cdd1ed572d8656cb0d6d95)
2013-11-22 13:50:24 -05:00
Steve Howell
c3d176a480
Move marketing pages to corporate app.
...
(imported from commit 70528b544ceb4be12fb02be32889e1b9ca8caeb4)
2013-11-06 12:07:32 -05:00
Steve Howell
6193f60d45
Move static MIT-related pages to corporate app.
...
(imported from commit e2c5f72d3f3e4d8f8fa888326b2ba455beb9156c)
2013-11-06 12:07:31 -05:00
Steve Howell
a827d727cc
Create non-localserver "corporate" app with jobs pages.
...
The corporate "app" is not a full-fledged Django app, but it has
a urls.py and a templates directory. This commit creates the app
and moves the jobs pages into it. Localserver deployments will
not see any of the corporate code.
(imported from commit 35889c3cf92329258c30741fdfa564769a4fac1a)
2013-11-06 12:07:31 -05:00