mirror of https://github.com/zulip/zulip.git
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.
This commit is contained in:
parent
cda7ed7101
commit
476b44ae67
|
@ -450,6 +450,7 @@ class UpgradeRequest:
|
|||
class InitialUpgradeRequest:
|
||||
onboarding: bool
|
||||
manual_license_management: bool
|
||||
tier: int
|
||||
|
||||
|
||||
class AuditLogEventType(Enum):
|
||||
|
@ -1239,6 +1240,7 @@ class BillingSession(ABC):
|
|||
|
||||
seat_count = self.current_count_for_billed_licenses()
|
||||
signed_seat_count, salt = sign_string(str(seat_count))
|
||||
tier = initial_upgrade_request.tier
|
||||
context: Dict[str, Any] = {
|
||||
"seat_count": seat_count,
|
||||
"signed_seat_count": signed_seat_count,
|
||||
|
@ -1251,9 +1253,8 @@ class BillingSession(ABC):
|
|||
"onboarding": onboarding,
|
||||
"page_params": {
|
||||
"seat_count": seat_count,
|
||||
"annual_price": 8000,
|
||||
"monthly_price": 800,
|
||||
"percent_off": float(percent_off),
|
||||
"annual_price": get_price_per_license(tier, CustomerPlan.ANNUAL, percent_off),
|
||||
"monthly_price": get_price_per_license(tier, CustomerPlan.MONTHLY, percent_off),
|
||||
},
|
||||
"manual_license_management": initial_upgrade_request.manual_license_management,
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ from corporate.lib.stripe import (
|
|||
UpgradeRequest,
|
||||
)
|
||||
from corporate.lib.support import get_support_url
|
||||
from corporate.models import ZulipSponsorshipRequest
|
||||
from corporate.models import CustomerPlan, ZulipSponsorshipRequest
|
||||
from zerver.actions.users import do_change_is_billing_admin
|
||||
from zerver.decorator import require_organization_member, zulip_login_required
|
||||
from zerver.lib.request import REQ, has_request_variables
|
||||
|
@ -94,6 +94,7 @@ def initial_upgrade(
|
|||
initial_upgrade_request = InitialUpgradeRequest(
|
||||
onboarding=onboarding,
|
||||
manual_license_management=manual_license_management,
|
||||
tier=CustomerPlan.STANDARD,
|
||||
)
|
||||
billing_session = RealmBillingSession(user)
|
||||
redirect_url, context = billing_session.get_initial_upgrade_context(initial_upgrade_request)
|
||||
|
|
|
@ -6,7 +6,6 @@ import $ from "jquery";
|
|||
export const page_params: {
|
||||
annual_price: number;
|
||||
monthly_price: number;
|
||||
percent_off: number;
|
||||
seat_count: number;
|
||||
} = $("#page-params").data("params");
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ import type {Prices} from "./helpers";
|
|||
import {page_params} from "./page_params";
|
||||
|
||||
const prices: Prices = {
|
||||
annual: page_params.annual_price * (1 - page_params.percent_off / 100),
|
||||
monthly: page_params.monthly_price * (1 - page_params.percent_off / 100),
|
||||
annual: page_params.annual_price,
|
||||
monthly: page_params.monthly_price,
|
||||
};
|
||||
|
||||
const ls = localstorage();
|
||||
|
|
Loading…
Reference in New Issue