Skip to content

Conversation

@lohanidamodar
Copy link
Member

@lohanidamodar lohanidamodar commented Dec 2, 2025

What does this PR do?

(Provide a description of what this PR does.)

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work.)

Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

Have you read the Contributing Guidelines on issues?

YES

Summary by CodeRabbit

  • Bug Fixes
    • Payment retry flow now accepts the sentinel for newly added payment methods.
    • Improved handling for card submissions that require US state information — prompts for state when needed.
    • Separated processing paths for expanded card responses vs. external payment-method records to avoid misclassification.
    • More reliable validation and deferral to external payment-method data when appropriate.

✏️ Tip: You can customize this high-level summary in your review settings.

@appwrite
Copy link

appwrite bot commented Dec 2, 2025

Console (appwrite/console)

Project ID: 688b7bf400350cbd60e9

Sites (1)
Site Status Logs Preview QR
 console-stage
688b7cf6003b1842c9dc
Ready Ready View Logs Preview URL QR Code

Tip

Global CDN and DDoS protection come free with every Sites deployment

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 2, 2025

Walkthrough

Validation for paymentMethodId now accepts the sentinel string "$new" in addition to null. Stripe card handling was restructured: if a submitted card is an expanded Stripe PaymentMethod (has an id and card payload) and the card country is "US", the code sets the payment method and triggers state selection; non-US or non-expanded paths no longer assume a $id payload and instead fall through to handling Appwrite PaymentMethodData. A distinct branch now treats objects carrying a $id as Appwrite PaymentMethodData. An import for Console was added.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify correct discrimination between expanded Stripe PaymentMethod objects and Appwrite PaymentMethodData (card.id + card payload vs $id).
  • Confirm "$new" sentinel is validated/handled consistently wherever paymentMethodId is used.
  • Check the US-specific branch that sets the payment method and prompts for state selection; ensure country detection is robust.
  • Review the new fall-through logic for non-US/non-expanded cards to ensure Appwrite PaymentMethodData is captured correctly.
  • Inspect the added Console import to determine if it is unused and should be removed.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main change: fixing retry payment functionality when adding a new payment method, which aligns with the code changes to payment validation and card handling logic.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-retry-payment-model

📜 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 f7a5bfc and 4f386f6.

📒 Files selected for processing (1)
  • src/routes/(console)/organization-[organization]/billing/retryPaymentModal.svelte (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/routes/(console)/organization-[organization]/billing/retryPaymentModal.svelte
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build

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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e977a00 and f7a5bfc.

📒 Files selected for processing (1)
  • src/routes/(console)/organization-[organization]/billing/retryPaymentModal.svelte (3 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx,js,jsx,svelte}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx,svelte}: Import reusable modules from the src/lib directory using the $lib alias
Use minimal comments in code; reserve comments for TODOs or complex logic explanations
Use $lib, $routes, and $themes aliases instead of relative paths for module imports

Files:

  • src/routes/(console)/organization-[organization]/billing/retryPaymentModal.svelte
src/routes/**/*.svelte

📄 CodeRabbit inference engine (AGENTS.md)

Use SvelteKit file conventions: +page.svelte for components, +page.ts for data loaders, +layout.svelte for wrappers, +error.svelte for error handling, and dynamic route params in square brackets like [param]

Files:

  • src/routes/(console)/organization-[organization]/billing/retryPaymentModal.svelte
**/*.{ts,tsx,js,jsx,svelte,json}

📄 CodeRabbit inference engine (AGENTS.md)

Use 4 spaces for indentation, single quotes, 100 character line width, and no trailing commas per Prettier configuration

Files:

  • src/routes/(console)/organization-[organization]/billing/retryPaymentModal.svelte
**/*.svelte

📄 CodeRabbit inference engine (AGENTS.md)

Use Svelte 5 + SvelteKit 2 syntax with TypeScript for component development

Files:

  • src/routes/(console)/organization-[organization]/billing/retryPaymentModal.svelte
src/routes/**

📄 CodeRabbit inference engine (AGENTS.md)

Configure dynamic routes using SvelteKit convention with [param] syntax in route directory names

Files:

  • src/routes/(console)/organization-[organization]/billing/retryPaymentModal.svelte
🪛 GitHub Actions: Tests
src/routes/(console)/organization-[organization]/billing/retryPaymentModal.svelte

[error] 25-25: TS error: 'Console' is declared but its value is never read. (ts)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: e2e
🔇 Additional comments (2)
src/routes/(console)/organization-[organization]/billing/retryPaymentModal.svelte (2)

59-59: LGTM!

Adding the '$new' sentinel value check correctly handles the "add new payment method" flow alongside the existing null case.


69-81: The original concern is incorrect. submitStripeCard guarantees it returns either a US PaymentMethod or PaymentMethodData with $id. Non-US PaymentMethod objects are explicitly excluded—when pm is a non-US Stripe object, the function extracts the ID and calls setPaymentMethod, returning PaymentMethodData (line 136). Therefore, method will always be defined when line 82 executes, and no runtime error is possible.

@lohanidamodar lohanidamodar merged commit 20874f5 into main Dec 3, 2025
4 checks passed
@lohanidamodar lohanidamodar deleted the fix-retry-payment-model branch December 3, 2025 00:32
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.

3 participants