Uh oh!
There was an error while loading. Please reload this page.
feat(billing): add appliesTo plan restriction for coupon codes - #3744
Conversation
PR SummaryMedium Risk Overview The endpoint validates Written by Cursor Bugbot for commit 903ff2d. Configure here. |
The latest updates on your projects. Learn more about Vercel for GitHub. |
Greptile SummaryThis PR extends the Key implementation details:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Admin
participant POST Handler
participant resolveProductIds
participant getPlans
participant Stripe
Admin->>POST Handler: POST /api/v1/admin/referral-campaigns\n{ appliesTo: ['pro'] }
POST Handler->>POST Handler: Validate appliesTo values
POST Handler->>resolveProductIds: stripe, ['pro']
resolveProductIds->>getPlans: getPlans()
getPlans-->>resolveProductIds: [pro_6000, pro_25000, ...]
resolveProductIds->>resolveProductIds: Match plans via isPro/isTeam\nCollect priceIds
resolveProductIds->>Stripe: Promise.allSettled(prices.retrieve × N)
Stripe-->>resolveProductIds: price objects (or failures)
resolveProductIds->>resolveProductIds: Any failures? → throw Error
resolveProductIds-->>POST Handler: unique productIds[]
POST Handler->>Stripe: coupons.create({ applies_to: { products } })
Stripe-->>POST Handler: coupon
POST Handler->>Stripe: promotionCodes.create({ coupon })
Stripe-->>POST Handler: promoCode
POST Handler-->>Admin: 200 { appliesToProductIds, ... }
Reviews (2): Last reviewed commit: "fix(billing): fail coupon creation on pa..." | Re-trigger Greptile |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
waleedlatif1
commented
Mar 24, 2026
@cursor review |
waleedlatif1
commented
Mar 24, 2026
Uh oh!
There was an error while loading. Please reload this page.
* feat(billing): add appliesTo plan restriction for coupon codes * fix(billing): fail coupon creation on partial product resolution
Summary
appliesTofield toPOST /api/v1/admin/referral-campaignsto restrict coupons to specific Stripe productspro,team) and specific plan names (pro_6000,pro_25000,team_6000,team_25000)coupon.applies_to.productsappliesToProductIdsfor existing couponsType of Change
Testing
Tested manually
Checklist