ebook#

“Cape Town for First Timers 2026” eBook sales via Stripe checkout with R2-based file distribution.

Models#

Model

Description

EbookPurchase

Stripe checkout session tracking with product code and payment status

URL Routes#

Path

View

Description

/ebook/

ebook_landing

Product landing page with Stripe pricing

/ebook/checkout/

create_checkout_session

POST: create Stripe checkout session

/ebook/success/

checkout_success

Post-purchase success page

/ebook/cancel/

checkout_cancel

Cancellation page

/ebook/download/

ebook_download

Download via session_id or tier subscription

Download Flow#

sequenceDiagram participant User participant App as ebook_download participant R2 as Cloudflare R2 User->>App: GET /ebook/download/?session_id=xxx alt Has EbookPurchase (paid=True) App->>R2: Generate presigned URL R2-->>App: Signed URL (60 min TTL) App-->>User: Redirect to signed URL else Has premium tier subscription App->>R2: Generate presigned URL R2-->>App: Signed URL App-->>User: Redirect to signed URL else No access App-->>User: 403 Forbidden end

Key Design Decisions#

  • Dual access path: Users can buy the eBook directly or access it via a premium-tier subscription (includes_ebooks = True).

  • R2 presigned URLs provide time-limited download links without proxying the file through Django.