Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 754355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:00:12+00:00 2026-05-14T15:00:12+00:00

I’m using ASP.NET MVC 2. Keeping it simple, I have three payment types: credit

  • 0

I’m using ASP.NET MVC 2.

My current payment types with properties

Keeping it simple, I have three payment types: credit card, e-check, or “bill me later”. I want to:

  1. choose one payment type
  2. display some fields for one payment type in my view
  3. run some logic using those fields (specific to the type)
  4. display a confirmation view
  5. run some more logic using those fields (specific to the type)
  6. display a receipt view

Each payment type has fields specific to the type… maybe 2 fields, maybe more. For now, I know how many and what fields, but more could be added. I believe the best thing for my views is to have a partial view per payment type to handle the different fields and let the controller decide which partial to render (if you have a better option, I’m open). My real problem comes from the logic that happens in the controller between views. Each payment type has a variable number of fields. I’d like to keep everything strongly typed, but it feels like some sort of dictionary is the only option. Add to that specific logic that runs depending on the payment type.

In an effort to keep things strongly typed, I’ve created a class for each payment type. No interface or inherited type since the fields are different per payment type. Then, I’ve got a Submit() method for each payment type. Then, while the controller is deciding which partial view to display, it also assigns the target of the submit action.

This is not elegant solution and feels very wrong. I’m reaching out for a hand. How would you do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:00:12+00:00Added an answer on May 14, 2026 at 3:00 pm

    It’s one for thing for, say, an Order object to not really care about the particular payment type–just knowing that there is a PledgedAmount and a DepositedAmount property, for example, is enough for that class to do its job (e.g., “don’t allow myself to go to Shipped status if order is not charged, via whatever payment method, I don’t really care, as long as it’s charged somehow I’m cool”).

    It’s another thing for the UI to not really care: you either write a switch to load the right view and be done with it, or you end up creating a dictionary-like collection of fields, rules, and validation metadata and let the UI generate itself dynamically.

    For example, I took the latter approach when I was adding international address support for one of my applications. I abstracted addresses into a common set of fields: AdministrativeArea, Municipality, etc, and defined an AddressScheme class which defined AddressFieldRules for each field, stating whether or not it was required, if a regex should be applied, if there is a specific set of allowed values, etc. It was appropriate since we could add or remove countries to the allowed list at any time without recompiling and redeploying the application; the UI could dynamically generate itself based on the AddressScheme, which itself was loaded from the database. Sweet.

    But are you really going to be adding payment types (a) with great frequency or (b) without re-compiling your application? Sometimes you really do need an actual Toaster instead of a Breakfast Cooking Machine w/ Bread and Other Yeast-Based Goods Browning Module, so just add a switch or a dictionary that maps a type to the correct view: I think it’s perfectly acceptable for the UI to have to be able to distinguish among these types, and, more importantly, for you to custom-write and tailor the presentation of each type–but the higher-up parts might benefit from some abstraction. I talked about that in my answer to a different question related to billing.

    In your example, you can share common code for steps 1, 4, and 6, but delegate to specific UI methods and views for steps 2, 3, and 5. And the world will still spin round.

    My two cents. Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.