feat(paykit): add subscription quantity support#201
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (10)
📝 WalkthroughWalkthroughSubscription quantity now flows from the subscribe request schema into provider contracts, Stripe checkout and subscription calls, and subscription sync/update paths. The API, webhook, and billing-state handlers now carry quantity into stored subscription records. ChangesSubscription quantity propagation
Sequence Diagram(s)sequenceDiagram
participant subscription.api.ts as subscription.api.ts
participant subscribeToPlan as subscribeToPlan
participant stripe-provider.ts as stripe-provider.ts
participant PayKitDatabase as PayKitDatabase
subscription.api.ts as subscription.api.ts->>subscribeToPlan: pass ctx.input.quantity
subscribeToPlan->>stripe-provider.ts as stripe-provider.ts: create/update subscription with quantity
stripe-provider.ts as stripe-provider.ts-->>subscribeToPlan: normalized subscription quantity
subscribeToPlan->>PayKitDatabase: sync subscription record and billing state
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
e7a75e8 to
49431ec
Compare
|
@Pascoooo is attempting to deploy a commit to the maxktz Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/paykit/src/stripe/stripe-provider.ts`:
- Line 192: The Stripe subscription mapping in stripe-provider.ts is defaulting
quantity to 1 when firstItem is missing, which can overwrite the stored local
quantity during syncSubscriptionFromProvider(...). Update the
subscription-to-local mapping logic so quantity is only set when
subscription.items.data[0] exists and has an explicit quantity, and otherwise
leave it undefined; use the existing firstItem handling in the provider sync
path to locate the change.
In `@packages/paykit/src/subscription/subscription.service.ts`:
- Around line 49-52: The same-plan quantity branch in subscription.service’s
subscription flow currently jumps straight to handleQuantityChange, which can
skip clearing or resuming pending same-plan provider changes first. Update the
same-plan path so quantity-only changes either go through
handleSamePlanSubscribe or explicitly resume/cancel any pending schedule before
calling handleQuantityChange, and make sure the same fix is applied anywhere the
same logic is duplicated in the broader subscription update flow.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 263f070f-8549-4752-9e43-b9e2837ed844
📒 Files selected for processing (9)
packages/paykit/src/providers/provider.tspackages/paykit/src/stripe/__tests__/stripe-provider.test.tspackages/paykit/src/stripe/stripe-provider.tspackages/paykit/src/subscription/__tests__/subscription.service.test.tspackages/paykit/src/subscription/__tests__/subscription.types.test.tspackages/paykit/src/subscription/subscription.api.tspackages/paykit/src/subscription/subscription.service.tspackages/paykit/src/subscription/subscription.types.tspackages/paykit/src/types/events.ts
49431ec to
08d878b
Compare
There was a problem hiding this comment.
1 issue found and verified against the latest diff
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
08d878b to
541a9e5
Compare
Summary
Out of scope
Test Plan
Summary by CodeRabbit
New Features
Bug Fixes
Tests