π Overview
Implement a Rewards & Cashback system to incentivize users with cashback (1β5%), scratch cards, and referral bonuses (βΉ50β200).
This drives user engagement, increases transaction frequency, and promotes organic growth through referrals.
π‘ Why Add It
- Engagement Boost: Cashback encourages repeat transactions (PhonePeβs model drives +20% volume).
- Acquisition: Referrals bring in new users with minimal marketing cost.
- Revenue: More transactions β higher Razorpay MDR earnings (1β2%).
βοΈ Implementation
π§βπ» Userapp (Next.js)
π Webhook (Express)
ποΈ Database (Prisma)
Add to schema.prisma:
model Reward {
id Int @id @default(autoincrement())
userId Int
type String // CASHBACK, SCRATCH, REFERRAL
amount Int // in paise
status String // PENDING, CREDITED, FAILED
transactionId Int? // link to Transaction table
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
π Overview
Implement a Rewards & Cashback system to incentivize users with cashback (1β5%), scratch cards, and referral bonuses (βΉ50β200).
This drives user engagement, increases transaction frequency, and promotes organic growth through referrals.
π‘ Why Add It
βοΈ Implementation
π§βπ» Userapp (Next.js)
Page:
/app/rewards/page.tsxβ Central rewards dashboard.UI Components:
react-scratchcardor canvas).bg-zinc-800,text-zinc-100,border-zinc-700.API Routes:
GET /app/api/rewards/fetchβ Fetch user rewards and balance.POST /app/api/rewards/scratchβ Trigger random scratch reward (βΉ10ββΉ100).POST /app/api/rewards/referralβ Validate and credit referral bonuses.Razorpay Integration:
State Management:
useStateβ Scratch state, referral code input.TanStack Queryβ Fetch & refresh reward data dynamically.Error Handling:
border-red-500,bg-zinc-700).disabled:bg-zinc-600/50.π Webhook (Express)
Endpoint:
/webhook/rewardTrigger Conditions:
payment.succeededreferral.completedLogic Flow:
2% of amount).type: CASHBACK)./api/notify/push(e.g., βYou earned βΉ20 cashback!β).Security:
express-rate-limit.ποΈ Database (Prisma)
Add to
schema.prisma: