# Course pricing and access Learning content is sold through one-time course purchases. A verified purchase permanently unlocks premium content in that course only. Subscription plans no longer grant access to the current learning catalog, including for existing subscribers. Subscription and payment history remain available. Courses expose `price` (up to two decimal places, nonnegative) and `currency` (three uppercase letters; default `ETB`). Set these with the existing admin course create/update APIs. No chapter or lesson has its own price. A positive course price is required for checkout. Existing courses start at zero during migration: configure their actual selling prices before enabling checkout in clients. Zero-priced premium content stays locked until a price is configured or its access tier is changed. Courses retain `FREE` and `PREMIUM`. Chapters and lessons accept `INHERIT`, `FREE`, or `PREMIUM`. Omission on creation defaults to `INHERIT`; omission on update preserves the current value. Send `INHERIT` to reset an override. The nearest explicit tier wins: | Course | Chapter | Lesson | Effective lesson access | | --- | --- | --- | --- | | PREMIUM | INHERIT | INHERIT | PREMIUM | | FREE | INHERIT | INHERIT | FREE | | PREMIUM | FREE | INHERIT | FREE | | PREMIUM | PREMIUM | FREE | FREE | | FREE | FREE | PREMIUM | PREMIUM | Changing a parent changes all descendants that inherit it. Explicit child overrides remain in place. A free course may have a positive price for its explicitly premium descendants; the course's tier controls default access, while its price is the purchase amount. Quizzes inherit the chapter's effective tier. Publication restrictions still apply. Staff and `OPEN_LEARNER` retain their existing bypass behavior. ## API - `POST /api/v1/courses/:courseId/checkout`, authenticated: optional `{ "phone": "..." }`. The server loads the course's price/currency and learner email, creates a Chapa checkout, and returns `payment_id`, `session_id`, `payment_url`, `course_id`, `amount`, and `currency`. Purchasing an owned course returns 409; unpublished, archived, or zero-price courses cannot be purchased. - Existing payment verification, signed webhook, and callback endpoints confirm payment. Amount and currency must match the checkout snapshot. Payment success and course entitlement commit atomically; repeated confirmation is idempotent. - Course catalog responses include `price` and `currency`. Learner course/chapter/lesson responses expose purchase restrictions through `access.is_accessible` and `access.reason`. Locked lesson lists omit `video_url`; an explicit free preview remains available without purchase. - Premium lesson retrieval, quiz/practice questions, completion, and video heartbeats require the containing course purchase. A blocked consumption request returns 403 with `code: COURSE_PURCHASE_REQUIRED` and `course_id`. File URL generation/refresh also checks course access for known lesson videos. - Learner subscription-plan listing and subscription checkout routes now return 410, directing clients to course checkout. Historical subscription status, history, cancellation, and payment records remain available. Old direct subscription payment initiation routes also return 410. Existing pending subscription payments may still settle for historical accounting, but do not grant course access. Example admin course body: ```json {"name":"Bridal Makeup","access_tier":"PREMIUM","price":1500,"currency":"ETB"} ``` Example preview lesson body: ```json {"title":"Introduction","access_tier":"FREE"} ``` ## Rollout Apply `000008_course_purchases` before running this backend. It adds course pricing, a course reference on payments, and course purchase records. Existing effective access restrictions are preserved; redundant child tiers become inherited so later parent edits cascade. Legacy internal chapter containers inherit rather than overriding the chapter. Configure course prices and update frontend/mobile checkout to use course IDs instead of plan IDs. Existing subscribers must purchase courses after this switch; this migration intentionally grants no ownership from subscription records. No existing subscription/payment history is deleted. Rollback removes course purchases/pricing and restores legacy tier constraints, so export purchase records before rolling back a live rollout.