improvement(promos): promo codes should be only stripe codes#3591
improvement(promos): promo codes should be only stripe codes#3591icecrasher321 merged 2 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryHigh Risk Overview Removes the legacy referral/bonus-credit system end-to-end: deletes Written by Cursor Bugbot for commit 3cedb74. Configure here. |
Greptile SummaryThis PR migrates the promo/referral code system from an internal DB-backed implementation to Stripe-native promotion codes. All custom referral infrastructure (DB tables, API routes for UTM attribution and code redemption, the client-side attribution hook, and the UTM cookie logic in the proxy) is deleted, and the admin endpoint is rewritten to create and list Stripe coupons and promotion codes directly. Key changes:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Admin as Admin Client
participant API as /api/v1/admin/referral-campaigns
participant Stripe as Stripe API
Note over Admin,Stripe: Before this PR — DB-backed system
Admin->>API: POST (name, bonusCreditAmount, code, utm*)
API->>API: Insert into referral_campaigns table
API-->>Admin: { id, code, bonusCreditAmount, ... }
Admin->>API: POST /api/referral-code/redeem (code)
API->>API: Lookup campaign in DB
API->>API: Insert referralAttribution + apply bonus credits
API-->>Admin: { redeemed: true, bonusAmount }
Note over Admin,Stripe: After this PR — Stripe-only system
Admin->>API: POST (name, percentOff, code, duration, ...)
API->>Stripe: stripe.coupons.create(...)
Stripe-->>API: Coupon object
API->>Stripe: stripe.promotionCodes.create(coupon, code, ...)
Stripe-->>API: PromotionCode object
API-->>Admin: { id, code, couponId, percentOff, ... }
Admin->>API: GET (?limit, ?starting_after, ?active)
API->>Stripe: stripe.promotionCodes.list(...)
Stripe-->>API: Paginated PromotionCode list
API-->>Admin: { data[], hasMore, nextCursor }
Note over API,Stripe: ⚠️ If promotionCodes.create fails,<br/>the already-created coupon is orphaned in Stripe
|
|
bugbot run |
Summary
Moving promo code system to be only based on stripe coupons. Update admin route as well. Cleanup old code.
Type of Change
Testing
Tested using Stripe sandbox env
Checklist