Alex Vandiver
61fc838179
python: Switch mocking of timezone_now to time_machine.
2023-11-28 15:10:39 -08:00
Alex Vandiver
f4cbb494ac
test_remote_counts: Insert in date order.
...
Inserting these in order means that they have dates which ascend with
their ids and remote_ids, for a more accurate simulation.
2023-11-28 09:46:48 -08:00
Aman Agrawal
e8fed998ce
test_stripe: Add method to better mock stripe invoice creation.
2023-11-28 08:58:19 -08:00
Aman Agrawal
28a49be161
get_initial_upgrade_context: Use tier passed as part of request.
2023-11-28 08:58:19 -08:00
Alya Abbott
fcd0783202
upgrade: Simplify free trial upgrade page.
2023-11-28 08:57:27 -08:00
Alya Abbott
9788e7514f
billing: Edit text of free trial upgrade page.
2023-11-27 14:17:18 -08:00
Aman Agrawal
b35a792623
billing: Allow free trial orgs to switch billing frequency.
...
Fixes #27855
2023-11-27 14:17:18 -08:00
Aman Agrawal
1f8d3fc48f
stripe: Extract method to get next billing cycle.
2023-11-27 14:17:18 -08:00
Aman Agrawal
482b5d8871
upgrade: Minor text changes to free trial page.
...
Fixes #27684
2023-11-27 14:17:18 -08:00
Aman Agrawal
fe1a40279c
billing: Downgrade realm at the end of free trial.
...
Fixes #27875
Instead of immediately ending the free trial, we end the free trial
at the end of the cycle.
2023-11-27 14:17:18 -08:00
Aman Agrawal
22c333d135
stripe: Don't allow free trial users to have paid plan states.
...
Free trial users can only switch to `ACTIVE` or `ENDED`
as possible states. To switch to any other state, they need to
be `ACTIVE` first.
2023-11-27 14:17:18 -08:00
Aman Agrawal
d43a60eb9d
models: Add status text for some plan status states.
2023-11-27 14:17:18 -08:00
Tim Abbott
7de061cf10
billing: Inline is_realm_on_paid_plan.
...
This helps simplify the BillingSession interface to have less
realm-specific functions outside RealmBillingSesssion.
2023-11-27 09:01:56 -08:00
Prakhar Pratyush
f8b0e16ff2
stripe: Add get_sponsorship_request_context method to BillingSession.
...
This commit refactors 'sponsorship_request' view and adds
'BillingSession.get_sponsorship_request' method.
This refactoring will help in minimizing duplicate code
while supporting both realm and remote_Server customers.
2023-11-27 09:01:56 -08:00
Prakhar Pratyush
1b17626327
stripe: Add 'is_sponsored' method to 'BillingSession' class.
...
This prep commit adds a 'is_sponsored' method as we need
to explicitly check this in 'event_status' view.
2023-11-27 09:01:56 -08:00
Prakhar Pratyush
29f77bfd31
stripe: Add 'get_event_status' method to the 'BillingSession' class.
...
This commit refactors 'event_status' view and adds
'BillingSession.get_event_status' method.
This refactoring will help in minimizing duplicate code
while supporting both realm and remote_server customers.
2023-11-27 09:01:56 -08:00
Aman Agrawal
20cae359d1
sponsorship: Show correct plan for sponsored without CustomerPlan.
...
For users on limited plan, if approved for full sponsorship
via support page, we don't create a CustomerPlan for them, but
they are fully sponsored.
2023-11-27 08:23:36 -08:00
Aman Agrawal
3615fa4745
sponsorship: Use customer instead of realm to store sponsorship data.
...
Since Customer already stores the realm it is linked to and
customer is always created to store sponsorship request, we directly
use customer to link to the sponsorship data for the realm.
2023-11-27 08:23:36 -08:00
Aman Agrawal
ede73fc2c6
decorator: Add wrapper to directly pass remote_realm to view_func.
2023-11-26 20:23:24 -08:00
Aman Agrawal
354330d81b
decorator: Move self_hosting_management_endpoint wrapper to corporate.
2023-11-26 20:23:24 -08:00
Mateusz Mandera
c79d116f8c
tests: Add basic tests for remote billing auth flow.
2023-11-26 19:57:12 -08:00
Lauryn Menard
b167eeff08
corporate: Create change plan tier function for BillingSession.
...
Moves and generalizes `switch_realm_from_standard_to_plus_plan`
in stripe.py to be a more general function for changing a
CustomerPlan to a new and valid tier, `do_change_plan_to_new_tier`.
Adds a helper function with the previous function name to be used
for the support view and management command for changing a realm
from the Standard plan tier to the Plus plan tier.
2023-11-26 19:39:52 -08:00
Lauryn Menard
a00e687d02
corporate: Update stripe create_balance_transaction description.
2023-11-26 19:39:52 -08:00
Lauryn Menard
1f1f1b913b
corporate: Simplify initial plan tier switch check.
...
Simplifies the initial check for switching a customer plan tier
for an existing and active plan, so that it is more generic.
2023-11-26 19:39:52 -08:00
Lauryn Menard
39bfab0ec4
corporate: Move plan tier change to separate helper function.
...
Renames CustomerPlan.SWITCH_NOW_FROM_STANDARD_TO_PLUS to be more
generic, CustomerPlan.SWITCH_PLAN_TIER_NOW.
Because the plan tier change is immediate, moves the code to end
the current plan with the old tier and create the new plan with
the new tier from `make_end_of_cycle_updates_if_needed` to instead
be in a separate helper function, `switch_plan_tier`.
2023-11-26 19:39:52 -08:00
Lauryn Menard
30f0005799
corporate: Extract calculation of amount to credit for tier change.
2023-11-26 19:39:52 -08:00
Aman Agrawal
3cfcd0efee
remote_upgrade_page: Add /upgrade URL for self hosted realms.
2023-11-24 09:22:02 -08:00
Aman Agrawal
caf2b7da26
stripe: Use remote_billing_url for redirecting to sponsorship page.
...
The will make redirects to sponsorship page work for all
BillingSession child classes.
2023-11-24 09:22:02 -08:00
Aman Agrawal
6ad9217fbf
stripe: Set discount to None for 0 discount.
2023-11-24 09:22:02 -08:00
Aman Agrawal
6040ffb94b
stripe: Verify context via TypedDict for upgrade page.
2023-11-24 09:22:02 -08:00
Aman Agrawal
e3abd57dce
stripe: Rename update_context_initial_upgrade.
2023-11-24 09:22:02 -08:00
Aman Agrawal
053f30ca25
stripe: Sort upgrade page context keys.
...
This will help us verify changes easily.
2023-11-24 09:22:02 -08:00
Aman Agrawal
4844ef9810
upgrade: Pass customer_name instead of realm object to upgrade context.
...
This will help simplify things for remote realms.
2023-11-24 09:22:02 -08:00
Aman Agrawal
ace14e5a7d
remote_billing_page: Extract method to get RemoteBillingIdentityDict.
...
This will likely be used in other files.
2023-11-24 09:22:02 -08:00
Aman Agrawal
f006be0cdf
initial_upgrade: Rename to upgrade_page.
...
Replaced for "(initial_upgrade)", " initial_upgrade"
`'initial_upgrade'` and `"initial_upgrade"`.
2023-11-24 09:22:02 -08:00
Aman Agrawal
95f5d8bdb8
billing: Note applied discount on upgrade and billing pages.
...
Fixes #27526
2023-11-23 10:32:39 -08:00
Aman Agrawal
07d29126fd
sponsorship: Improve page for sponsorship pending orgs.
...
Fixes #27686
2023-11-23 10:32:39 -08:00
Aman Agrawal
003b29ba14
billing_page: Redirect orgs on paid plans with sponsorship pending.
...
Redirect sponsorship pending realms on a paid plan to billing page
with banner which reflects the current status of their request.
2023-11-23 10:32:39 -08:00
Aman Agrawal
74d8a050e4
billing_page: Extract method to check if realm is on paid plan.
2023-11-23 10:32:39 -08:00
Aman Agrawal
5422dd3661
sponsorship: Improve sponsorship page for sponsored realms.
2023-11-23 10:32:39 -08:00
Prakhar Pratyush
51b39cb682
stripe: Add 'do_update_plan' method to the 'BillingSession' class.
...
This commit moves a major portion of the 'update_plan`
view to a new shared 'BillingSession.do_update_plan' method.
This refactoring will help in minimizing duplicate code
while supporting both realm and remote_server customers.
2023-11-23 09:01:45 -08:00
Tim Abbott
efa423395f
billing: Make support_session an explicit parameter.
2023-11-23 09:01:45 -08:00
Mateusz Mandera
3958743b33
corporate: Add prototype authentication system for self-hosters.
...
This makes it possible for a self-hosted realm administrator to
directly access a logged-page on the push notifications bouncer
service, enabling billing, support contacts, and other administrator
for enterprise customers to be managed without manual setup.
2023-11-22 17:03:47 -08:00
Aman Agrawal
d82efbd503
free_trial: Remove extra onboarding flow.
...
We still redirect free trial users to upgrade page on first
signup but no longer pass the onboarding param.
2023-11-22 08:06:22 -08:00
Aman Agrawal
2218c49244
billing: Minor changes to text for free trial.
...
Fixes #27685
2023-11-22 08:06:22 -08:00
Prakhar Pratyush
476b44ae67
stripe: Use 'get_price_per_license' in 'get_initial_upgrade_context'.
...
This commit updates the 'get_initial_upgrade_context' method
to use 'get_price_per_license' for determining 'annual_price'
and 'monthly_price' based on tier and discount instead of hardcoding.
Also, removed the 'percent_off' page_params as
'get_price_per_license' already performs the price calculation
taking discount into consideration.
2023-11-21 23:39:18 -08:00
Aman Agrawal
de267b964c
event_status: Return user back to same license management after session.
...
If the update / add card session is successful, return user to
manual license management page if user was on it before clicking
the add / update card button.
2023-11-21 11:44:04 -08:00
Aman Agrawal
69d8442ab4
billing: Allow user to switch between billing frequencies.
2023-11-21 10:42:12 -08:00
Tim Abbott
e3a3f36225
billing: Rename do_initial_upgrade.
...
This function gets context without doing anything, and so deserves a
name that hints that.
2023-11-20 12:04:56 -08:00
Aman Agrawal
09009ab03a
upgrade: Separate add card and purchase upgrade flow.
...
We now let user add / update card in a separate session and then
charge users after clicking on the purchase button.
2023-11-20 12:04:56 -08:00