Repository navigation
feat: specify product types for Stripe migration - #9
Conversation
WalkthroughAdds a Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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 |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/providers/stripe/index.ts (2)
166-176: Replace invalidtypefield and use documented values
src/providers/stripe/index.ts (L166–176)
- Remove
type: 'subscription_product'from the product payload (not a supported enum).- Set the product’s
is_recurringflag to true for subscriptions.- Use
price.type = 'recurring_price'for subscriptions (andone_time_pricefor one-time) as per Dodo Payments docs.
185-195: Remove top-leveltypeon product payload
Dodo’s Create Product API doesn’t accepttype='one_time_product'— useis_recurring: false(or omit) and keepprice.type='one_time_price'.
🧹 Nitpick comments (2)
src/providers/stripe/index.ts (2)
138-195: Deduplicate product type to avoid drift between wrapper and payloadYou’re now storing the product type twice: wrapper
typeanddata.type. Reduce risk by deriving both from a single variable.Apply this diff:
@@ - for (const price of prices.data) { - const isRecurring = price.type === 'recurring'; + for (const price of prices.data) { + const isRecurring = price.type === 'recurring'; + const productType: 'subscription_product' | 'one_time_product' = + isRecurring ? 'subscription_product' : 'one_time_product'; @@ - ProductsToMigrate.push({ - type: 'subscription_product', + ProductsToMigrate.push({ + type: productType, data: { @@ - tax_category: 'saas', - type: 'subscription_product', + tax_category: 'saas', + type: productType, @@ - ProductsToMigrate.push({ - type: 'one_time_product', + ProductsToMigrate.push({ + type: productType, data: { @@ - tax_category: 'saas', - type: 'one_time_product', + tax_category: 'saas', + type: productType,
138-139: Strongly type the payload (avoid any)Replace
data: anywith a typed payload to catch enum/value regressions at compile time. If the SDK exports a create‑product type, import it; otherwise declare a minimal local interface.Would you like me to add a local type like below if the SDK doesn’t export one?
type DodoProductType = 'one_time_product' | 'subscription_product'; type DodoPriceType = 'one_time_price' | 'recurring_price'; interface DodoProductPricePayload { currency: string; price: number; discount: number; purchasing_power_parity: boolean; type: DodoPriceType; billing_period?: 'monthly' | 'yearly'; } interface DodoProductCreatePayload { name: string; description?: string; tax_category: string; type: DodoProductType; price: DodoProductPricePayload; brand_id: string; }
Summary by CodeRabbit