Skip to content

Commit 250be33

Browse files
committed
Try harder to discover subscription price on Subscriptions page
1 parent b960f8d commit 250be33

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tcms_github_marketplace/views.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -799,15 +799,20 @@ def get_context_data(self, **kwargs):
799799
cancel_url = self.object.payload["data"]["account"]["url"]
800800

801801
purchase_data = self.object.payload["marketplace_purchase"]
802-
if purchase_data["billing_cycle"] == "monthly":
802+
803+
# try yearly billing first
804+
subscription_price = (
805+
purchase_data["plan"].get("yearly_price_in_cents", 0) // 100
806+
)
807+
# default to monthly price next. FastSpring yearly billing subscriptions
808+
# also send the price in this field
809+
if subscription_price == 0:
803810
subscription_price = (
804811
purchase_data["plan"].get("monthly_price_in_cents", 0) // 100
805812
)
813+
if purchase_data["billing_cycle"] == "monthly":
806814
subscription_period = _("mo")
807815
elif purchase_data["billing_cycle"] == "yearly":
808-
subscription_price = (
809-
purchase_data["plan"].get("yearly_price_in_cents", 0) // 100
810-
)
811816
subscription_period = _("yr")
812817

813818
subscription_price = int(subscription_price)

0 commit comments

Comments
 (0)