Skip to content

v6 - Checkout controller submit flow#2635

Draft
OscarSpruit wants to merge 3 commits intomainfrom
chore/checkout-controller-submit-flow
Draft

v6 - Checkout controller submit flow#2635
OscarSpruit wants to merge 3 commits intomainfrom
chore/checkout-controller-submit-flow

Conversation

@OscarSpruit
Copy link
Copy Markdown
Contributor

Description

This PR improves the submit flow for the new Checkout controller. The controller is now fully in control of a component, keeping the component "dumb".

This gives full control to the controller and keeps a component "dumb"
@OscarSpruit OscarSpruit requested a review from a team as a code owner March 16, 2026 15:18
@OscarSpruit OscarSpruit added the Chore [PRs only] Indicates any task that does not need to be mentioned in the public release notes label Mar 16, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the payment submission flow within the new Checkout controller architecture. The core change involves shifting the responsibility for initiating and managing the submission process from individual payment components to the NewCheckoutController. This is achieved by introducing a new NewPaymentComponent interface, which components now implement, allowing the controller to directly handle validation, loading states, and the final submission. This design centralizes control, simplifies component logic, and enhances the overall modularity of the checkout process.

Highlights

  • Refactored Submit Flow: The NewCheckoutController now orchestrates the payment submission process, including validation and managing loading states, centralizing control over the submit lifecycle.
  • Introduced NewPaymentComponent Interface: A new interface, NewPaymentComponent, has been defined to standardize how payment components interact with the NewCheckoutController, providing methods for validation, setting loading states, and retrieving component state.
  • Centralized Component Control: Payment components, exemplified by the MBWay component, now implement NewPaymentComponent and delegate their submit-related logic (validation, loading, state retrieval) to the NewCheckoutController, making them 'dumb' as intended by the new architecture.
  • Asynchronous Submission Handling: The submit function in NewCheckoutController is no longer a suspend function and now utilizes a CoroutineScope to launch asynchronous operations, improving responsiveness and separating concerns.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • core/src/main/java/com/adyen/checkout/core/components/NewCheckoutController.kt
    • Updated CheckoutControllerInterface to include a validate() function and a non-suspending submit() function.
    • Modified the NewCheckoutController constructor to accept a CoroutineScope.
    • Replaced the componentStateFlow property with paymentComponent and added an attach method to link components.
    • Implemented the validate() method by delegating to the attached component and refactored submit() to manage component interaction and asynchronous execution.
  • core/src/main/java/com/adyen/checkout/core/components/internal/ui/PaymentComponent.kt
    • Introduced the NewPaymentComponent interface, defining validate(), setLoading(), and getState() methods for component interaction.
  • example-app/src/main/java/com/adyen/checkout/example/ui/v6/V6Screen.kt
    • Integrated rememberCoroutineScope and passed the created CoroutineScope to the NewCheckoutController constructor.
  • mbway/src/main/java/com/adyen/checkout/mbway/internal/ui/MBWayViewModel.kt
    • Removed the NewCheckoutController dependency from its constructor.
    • Adapted the ViewModel to implement the NewPaymentComponent interface, providing concrete implementations for validate(), setLoading(), and getState().
    • Removed the internal submit logic, delegating it to the controller.
  • mbway/src/main/java/com/adyen/checkout/mbway/internal/ui/view/MBWayComponent.kt
    • Updated MBWayViewModel instantiation to no longer pass the controller directly.
    • Called controller.attach(viewModel) to establish the link between the component's ViewModel and the controller.
    • Changed the onSubmitClick action to invoke controller::submit instead of the ViewModel's internal submit function.
Activity
  • No specific activity (comments, reviews) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the checkout submission flow by giving the NewCheckoutController more control over the payment components. The changes centralize the submission logic, including validation and loading state management, within the controller. This is a good architectural improvement. However, I've identified a potential issue with how the loading state is managed during submission, which could lead to a confusing user experience. I've also noted a minor potential issue in the MBWayViewModel implementation.

@github-actions
Copy link
Copy Markdown
Contributor

✅ No public API changes

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@araratthehero araratthehero marked this pull request as draft March 20, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Chore [PRs only] Indicates any task that does not need to be mentioned in the public release notes size:small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant