I’ve just implemented an interface with a third party payment service, for subscriptions to the site I’m busy with. The service is called PayFast, sort of like a local PayPal. I am currently saddled with umpteen items in my AppSettings config node with keys prefixed with ‘PayFast’, so I’m exploring options to factor these out of the main web.config file.
The simplest that comes to mine is to use an external .config file for these service specific settings, but this is cumbersome and I’m constrained by the key/value structure of the add elements. I would rather implement a custom section handler, section group, and sections, for each payment service (I plan to add PayPal later as well, and possibly more).
How should I structure this custom section handling so I can have multiple sections, one for local mocking of the service, one for online testing of the service, one for live use of the service etc. I think the outermost element should have attributes that determine which one of the inner sections to use, mock, test etc. I don’t have much trouble doing this in XML, and maybe a tool that could generate handlers from XML would be useful.
As an added bonus, I would ideally like the top level structures for each payment service to be grouped in a general PaymentServiceProviders node as well, but that is mere wishful thinking at the moment.
I am not sure what properties you need on each environment but I start with something like this:
I am not sure how much you have done with custom configuration sections but in my experience it’s usually a pain in the butt to parse something complex as this inside a custom configuration in your web.config whereas it’s a breeze to do it as an external XML file.