Skip to content

feat: specify product types for Stripe migration - #9

Merged
aagarwal1012 merged 4 commits into
dodopayments:mainfrom
yashranaway:main
Oct 10, 2025
Merged

aagarwal1012 merged 4 commits into
dodopayments:mainfrom
yashranaway:main

Conversation

@yashranaway

@yashranaway yashranaway commented Sep 27, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • New Features
    • Product migrations now explicitly categorize items as subscription or one-time, improving billing accuracy and downstream reporting.
    • Reduces misclassification risk during migrations without changing existing workflows or error behavior.
    • Applies automatically; no configuration or user action required.

@coderabbitai

coderabbitai Bot commented Sep 27, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a type field to product migration payloads in the Stripe provider: sets type: 'subscription' for recurring prices and type: 'one_time' for non-recurring prices. No control-flow, error handling, or exported/public API changes.

Changes

Cohort / File(s) Summary
Stripe provider payloads
src/providers/stripe/index.ts
When building product migration data, set data.type to 'subscription' for recurring (subscription) prices and 'one_time' for non-recurring (one-time) prices; no other logic changed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

A rabbit nibble, quick and bright,
I tag each price by day or night.
Subscription hops, one-time chews,
Payloads now wear clearer shoes.
Thump! The migration skips with delight. 🥕✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly and concisely describes the primary change of adding product type fields to the Stripe migration process, matching the changeset’s focus. It uses a conventional commit style and avoids extraneous details while accurately summarizing the feature.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3d74afc and 04e09ac.

📒 Files selected for processing (1)
  • src/providers/stripe/index.ts (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/providers/stripe/index.ts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 invalid type field 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_recurring flag to true for subscriptions.
  • Use price.type = 'recurring_price' for subscriptions (and one_time_price for one-time) as per Dodo Payments docs.

185-195: Remove top-level type on product payload
Dodo’s Create Product API doesn’t accept type='one_time_product' — use is_recurring: false (or omit) and keep price.type='one_time_price'.

🧹 Nitpick comments (2)
src/providers/stripe/index.ts (2)

138-195: Deduplicate product type to avoid drift between wrapper and payload

You’re now storing the product type twice: wrapper type and data.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: any with 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;
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 363b027 and 3d74afc.

📒 Files selected for processing (1)
  • src/providers/stripe/index.ts (2 hunks)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants