Bazaar: subscriptions (10343/10344), dynamic price (discount codes on Bazaar), auto-renewal sync
- Purchase with paymentMethod=bazaar now works for subscription plans with a bazaar_sku (not only packs);
response carries bazaarProductType. Migration subscription.0014 puts 10343/10344 on the 90/180-day plans.
- Verify asks Bazaar for the right product type (from the order) and stores validUntil (payment.0012).
- POST /api/payment/bazaar/orders/{id}/start: SKU, type, and an HS256 dynamic-price JWT when a discount
code lowered the price (BAZAAR_DYNAMIC_PRICE_KEY); discount on Bazaar orders allowed only with that key
and only before start.
- Auto-renewal: sync_bazaar_renewals re-asks Bazaar when the paid period is near its end (status page and
the paywall via has_subscription_access); each new period becomes a paid order.
- Default BAZAAR_PACKAGE_NAME = com.tadrisino.math.app; health shows bazaarDynamicPrice.
979 tests green. No real Bazaar purchase or renewal tested.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -330,10 +330,10 @@ def unit_is_free(unit_id: int, grade_id: int) -> bool:
|
||||
|
||||
|
||||
def has_unit_access(user_id, unit_id: int, grade_id: int) -> bool:
|
||||
from subscription.services import has_active_subscription
|
||||
from subscription.services import has_subscription_access
|
||||
if unit_is_free(unit_id, grade_id):
|
||||
return True
|
||||
return user_id is not None and has_active_subscription(user_id)
|
||||
return user_id is not None and has_subscription_access(user_id)
|
||||
|
||||
|
||||
def subscription_required_response() -> Response:
|
||||
@@ -468,8 +468,8 @@ class HomeView(APIView):
|
||||
).values_list('node_id', flat=True)
|
||||
)
|
||||
|
||||
from subscription.services import has_active_subscription
|
||||
subscribed = user_id is not None and has_active_subscription(user_id)
|
||||
from subscription.services import has_subscription_access
|
||||
subscribed = user_id is not None and has_subscription_access(user_id)
|
||||
unlock_all = user_has_all_nodes_unlocked(user_id)
|
||||
units_payload = []
|
||||
for index, unit in enumerate(tree):
|
||||
|
||||
Reference in New Issue
Block a user