Skip to content

[solidus_admin] Add payment methods editor - #6619

Merged
tvdeyen merged 16 commits into
solidusio:mainfrom
benjaminwil:admin-payment-methods-crud
Sep 19, 2026
Merged

tvdeyen merged 16 commits into
solidusio:mainfrom
benjaminwil:admin-payment-methods-crud

Conversation

@benjaminwil

@benjaminwil benjaminwil commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Replaces #6302.

This pull request adds functionality to allow admins to add, edit, and remove payment methods from the solidus_admin.

Note that I have co-opted most of this work from the original author. I have resolved merge conflicts, ensured linting and tests pass, and so on. I will take responsibility for any issues that come up during code review.

Preview of the solidus_admin payment method creator interface Preview of the solidus_admin payment method editor interface Preview of the solidus_admin payment methods index

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@codecov

codecov Bot commented Sep 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.33%. Comparing base (3e7a91e) to head (bb27342).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6619   +/-   ##
=======================================
  Coverage   92.33%   92.33%           
=======================================
  Files        1050     1053    +3     
  Lines       21369    21382   +13     
=======================================
+ Hits        19731    19744   +13     
  Misses       1638     1638           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@benjaminwil
benjaminwil force-pushed the admin-payment-methods-crud branch from e5670df to 6428ecb Compare September 15, 2026 19:50
@benjaminwil benjaminwil mentioned this pull request Sep 15, 2026
4 tasks
@benjaminwil
benjaminwil force-pushed the admin-payment-methods-crud branch from 6428ecb to 5db7d5c Compare September 15, 2026 20:52
@benjaminwil benjaminwil moved this to Review in Solidus Admin Sep 15, 2026

@tvdeyen tvdeyen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice

@jarednorman jarednorman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Based on a quick review locally:

  1. I don't think validation errors are showing up.
  2. This doesn't render controls for additional preferences on the payment methods, making it kind of useless for many payment methods.
  3. Auto-capture is (sadly) not boolean. Null means something (use store default) and we should let people select that.
  4. When a preference source is chosen, the server/test-mode still looks editable even though changes to those are ignored. That's not a great user experience.
  5. Probably should sort gateway types in alphabetically or something.
  6. Changing a payment method's type on update doesn't convert the record to the new class the way the old admin did.
  7. New records no longer preselect the default store. ☹️
  8. We should use the shared discard and save button helpers and drop the unused translation keys, and name the HTML hint translations with the _html suffix instead of calling html_safe.
  9. I think the description a text area.
  10. Can we pull the store and type queries out of the template?
  11. We should use the payment method's name as the edit page title.

@benjaminwil
benjaminwil force-pushed the admin-payment-methods-crud branch from 5db7d5c to 42e04e4 Compare September 15, 2026 22:44
@benjaminwil

benjaminwil commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

@jarednorman I intend to add commits for a few of the trivial items here, but I would like to use the SolidusAdmin::.enable_alpha_features? flag and merge the scaffolding as Eugene wrote it. I would like to try to avoid making this a long-lived and giant pull request. I think it will be easier for me, and for code reviewers, to tackle some of these issues in subsequent pull requests.

What do you think about that approach?

@benjaminwil
benjaminwil force-pushed the admin-payment-methods-crud branch from 42e04e4 to fc4b1e1 Compare September 15, 2026 23:40
@benjaminwil

benjaminwil commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author
  1. I don't think validation errors are showing up.

They're showing up for me. Let me know if I've misunderstood. Example:

An example of payment method validation errors on the HTML form

And I've resolved the following items from your feedback so far:

\5. Probably should sort gateway types in alphabetically or something.
\8. We should use the shared discard and save button helpers and drop the unused translation keys, and name the HTML hint translations with the _html suffix instead of calling html_safe.
\10. Can we pull the store and type queries out of the template?

@jarednorman

Copy link
Copy Markdown
Member

Does it display object-level validation issues?

@jarednorman

Copy link
Copy Markdown
Member

What do you think about that approach?

Fine by me! Just make sure we keep track of all of the above. It's very important that the new admin be the same or better than the old one when it comes to all functionality.

@benjaminwil
benjaminwil force-pushed the admin-payment-methods-crud branch from fc4b1e1 to eeebcbf Compare September 15, 2026 23:55
@benjaminwil

benjaminwil commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

I pasted the following into some core models, like Spree::PaymentMethod and Spree::Zone, to test whether object validation errors were showing up on any of the new admin forms on validation error:

validate :fake_object_level_validation
def fake_object_level_validation
  errors.add(:base, "fake object-level validation error")
end

And it seems like the answer is no.

It's unclear to me whether there's been a regression recently, but I tried this against this branch, against main, and against main as of earlier this week (2294a17d9e).

If you all know this to have been working as expected (flash messages, I'd assume?) and there's been a regression, I can look into it. But I defer to you all who have a deeper knowledge of the current status of the admin.

Edit: I created #6629 to address missing presentation of object-level validation errors.

@jarednorman

Copy link
Copy Markdown
Member

I'm clearly just mistaken about the validation visibility. 😬

@benjaminwil
benjaminwil force-pushed the admin-payment-methods-crud branch from 2cea917 to de1f071 Compare September 16, 2026 16:48
@benjaminwil

Copy link
Copy Markdown
Contributor Author

I just rebased against the latest main to resolve merge conflicts in the solidus_admin routes file.

@benjaminwil

Copy link
Copy Markdown
Contributor Author

Regarding keeping track of the work to be finished:

@benjaminwil

Copy link
Copy Markdown
Contributor Author

@tvdeyen @jarednorman If y'all could prioritize re-reviewing this one and merging it if it's good to go: I intend to keep working on the payment methods UI and basing my next work off of these commits.

Inherit from resources controller, define necessary overriding methods.

We also do not need #index and #destroy actions other than the ones
defined on the ResourcesController.
Render links in the table.
chaimann and others added 12 commits September 19, 2026 08:51
Removes row_url and replaces it with edit_path and usages of new routing
paths.
For validation errors to be shown correctly we need a proper
identifier for turbo stream to replace, default one used by resources
controller is :resource_modal but this name does not fit for our page so
we use a custom name.
The HTML IDs were incorrect. While I was making this change I saw
opportunities to reduce the complexity of the component templates
and reduce the need generic translation strings at the component
level.
Based on Jared Norman's review, the work done so far on the payment
methods editor is missing a lot of functionality:

> 1. I don't think validation errors are showing up.
> 2. This doesn't render controls for additional preferences on the
>    payment methods, making it kind of useless for many payment
>    methods.
> 3. Auto-capture is (sadly) not boolean. Null means something (use
>    store default) and we should let people select that.
> 4. When a preference source is chosen, the server/test-mode still
>    looks editable even though changes to those are ignored. That's
>    not a great user experience.
> 5. Probably should sort gateway types in alphabetically or something.
> 6. Changing a payment method's type on update doesn't convert the
>    record to the new class the way the old admin did.
> 7. New records no longer preselect the default store. ☹️
> 8. We should use the shared discard and save button helpers and drop
>    the unused translation keys, and name the HTML hint translations
>    with the _html suffix instead of calling html_safe.
> 9. I think the description a text area.
> 10. Can we pull the store and type queries out of the template?
> 11. We should use the payment method's name as the edit page title.

I don't want to tackle all of this in a single pull request, though I
think it's all necessary changes to the functionality. Using the alpha
features flag lets us work more iteratively over this.
This was bad form, no pun intended.
@tvdeyen
tvdeyen force-pushed the admin-payment-methods-crud branch from de1f071 to bb27342 Compare September 19, 2026 06:51
@tvdeyen
tvdeyen enabled auto-merge September 19, 2026 06:51
@tvdeyen
tvdeyen merged commit e0a625a into solidusio:main Sep 19, 2026
43 checks passed
@github-project-automation github-project-automation Bot moved this from Review to Done in Solidus Admin Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants