Grades 4 and 5, Bazaar purchase from the app, pack SKUs

- rag: MATH_4 / MATH_5 textbooks (TOC and page offsets read from the PDFs)
- content: grades 4 and 5 in the seed files: 7 units / 28 nodes each,
  204 + 194 questions (every node >= 4), all re-solved blind once
- subscription: Plan.bazaar_sku (admin); POST /api/subscription/purchase
  accepts paymentMethod=bazaar for packs, rejects unknown methods (was ignored)
- payment: idempotency key cannot switch provider; discount codes refused
  on Bazaar orders (Bazaar charges the fixed SKU price)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-03 20:01:44 +03:30
parent ab5e53730a
commit 8cb326ba94
15 changed files with 16699 additions and 3897 deletions

View File

@@ -15,6 +15,8 @@ class PlanSerializer(serializers.Serializer):
kind = serializers.ChoiceField(choices=['pack', 'subscription'])
questionCredits = serializers.IntegerField(help_text='بسته: سوال‌هایی که به اعتبار اضافه می‌شود (منقضی نمی‌شود).')
heartsDays = serializers.IntegerField(help_text='بسته: روزهای قلبِ نامحدودِ هدیه.')
bazaarSku = serializers.CharField(
allow_blank=True, help_text='SKUِ همین بسته در کافه‌بازار؛ خالی یعنی در بازار خریدنی نیست.')
class PlansListResponseSerializer(serializers.Serializer):
@@ -27,12 +29,17 @@ class PurchaseRequestSerializer(serializers.Serializer):
# هدر Idempotency-Key هم روی همین درخواست لازمه (بخش ۴.۳ سند API)؛
# از request.headers خونده می‌شه، نه از بدنه.
planId = serializers.CharField()
paymentMethod = serializers.CharField(required=False, default='zarinpal')
# تا ۲۰۲۶-۱۰-۰۳ هر مقداری پذیرفته و نادیده گرفته می‌شد، پس «bazaar» بی‌صدا به زرین‌پال می‌رفت.
paymentMethod = serializers.ChoiceField(choices=['zarinpal', 'bazaar'], required=False, default='zarinpal')
class PurchaseResponseSerializer(serializers.Serializer):
orderId = serializers.CharField()
paymentUrl = serializers.CharField()
paymentUrl = serializers.CharField(
allow_null=True, help_text='زرین‌پال: آدرسی که کاربر به آن برود. بازار: null.')
bazaarSku = serializers.CharField(
required=False, help_text='فقط بازار: SKUی که اپِ اندروید با Poolakey می‌خرد؛ '
'developerPayload همان orderId باشد.')
class SubscriptionStatusResponseSerializer(serializers.Serializer):