Skip to content

[FEAT] create sponsor for opensox #230

@apsinghdev

Description

@apsinghdev

Sponsor System - Featured Projects + Razorpay Integration

Description

Build a complete sponsor system that allows companies to purchase a single sponsor plan, upload their assets, and get displayed on the landing page and dashboard/home page.

The system must be automated end-to-end using razorpay subscriptions.

Plan

What We Will Build

A sponsor slot system that shows featured projects on:

  • / landing page (below hero section)
  • /dashboard/home

Components:

  • A single sponsor plan purchase flow
  • An asset submission form (logo/banner + text + website)
  • Automated razorpay webhook handling
  • Cloudinary storage for images
  • DB storage for sponsor metadata
  • Full edge-case handling (failed payment, cancellation, missing assets)

User Flow

  1. User visits /sponsor page
  2. User clicks "become a sponsor" → razorpay subscription checkout for the single plan
  3. After successful payment → user is redirected to the submission form
  4. User uploads logo/banner + text + website url
  5. Backend stores images + metadata
  6. Sponsor is marked active
  7. Sponsor appears on:
    • Landing page
    • Dashboard/home under featured projects

Edge Cases:

  • If payment fails or subscription is cancelled → sponsor becomes inactive and is removed
  • If user never uploads assets → show a reminder on dashboard until complete

Code Flow

On Payment (Razorpay Checkout)

  • Razorpay returns payment_id and subscription_id
  • Backend creates sponsor record with:
    • plan_status = pending_submission
    • razorpay_payment_id
    • razorpay_sub_id

Submission Form

  • User uploads assets
  • Images sent to cloudinary → secure url returned
  • Backend stores:
    • Image url
    • Company name
    • Description
    • Website
  • Backend sets plan_status = active

Webhooks

Handle following razorpay events:

  • subscription.charged → mark sponsor active
  • subscription.pendingpending_payment
  • subscription.halted → unpaid (hide)
  • subscription.cancelled → cancelled (remove)
  • payment.failed → failed (remove)

Display Flow

  • Landing page fetches sponsors with plan_status = active
  • Dashboard/home fetches the same list
  • If no sponsors → show "your ad here" placeholder

DB Schema Suggestion

Prisma
model Sponsor {
  id                  String   @id @default(cuid())
  company_name        String
  description         String
  website             String
  image_url           String
  razorpay_payment_id String?
  razorpay_sub_id     String?
  plan_status         String   // active, cancelled, pending_payment, pending_submission, failed
  created_at          DateTime @default(now())
}

Tasks

Frontend

  • Create /sponsor page explaining benefits + pricing
  • Integrate razorpay subscription checkout
  • Create submission form for assets
  • Build sponsor cards for landing page
  • Build sponsor cards for dashboard/home
  • Add placeholder for empty slots

Backend

  • Create sponsor model
  • Cloudinary upload endpoint
  • Endpoint to save sponsor data after form submission
  • Razorpay subscription integration
  • Webhook handler for:
    • subscription.charged
    • subscription.pending
    • subscription.halted
    • subscription.cancelled
    • payment.failed
  • Update sponsor status from webhook events
  • Filter active sponsors for both pages

Edge Cases

  • User pays but doesn't upload assets → keep reminding
  • Payment fails → mark inactive and hide
  • Subscription cancelled → auto-remove sponsor
  • Image ratio or file invalid → validate
  • User submits multiple times → allow updates but store latest

Acceptance Criteria

  • After successful payment + asset upload, sponsor automatically appears on landing + dashboard/home
  • Cancelled or failed payments immediately remove sponsor
  • No admin approval required
  • Images stored in cloudinary and metadata stored in db
  • Full user flow works smoothly end-to-end

Sub-issues

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions