Customizing Commerce Server Business Logic

Commerce Server 2009 R2 provides a wide variety of business logic and infrastructure that is generally common to commercial Web applications. For example, product catalogs, orders and checkout processing, marketing infrastructure, and so on. However, within these common features, you are likely to find yourself needing to customize the particular aspects of the features to suit your individual business needs. Such customizations fall into several categories, as follows.

Customizing Business Logic with Pipelines

Commerce Server 2009 R2 uses a framework known as a "pipeline" to implement a variety of sequential processing tasks. For example, when a user decides to check out and complete a purchase, an order processing pipeline is used to complete a series of calculations that include the application of any relevant discounts, subtotaling the order, adding the cost of tax and shipping, and so on. The pipeline framework is extensible in several ways, as summarized here.

For more information, see Developing with Core Systems Pipelines.

Modifying PCF File Configuration

Pipeline components are the objects that perform individual pieces of work within pipelines and pipeline objects are used to execute the series of pipeline components at run-time. Pipeline configuration files, with the extension .pcf, are what tie these two types of objects together by persisting the information about the stages in each pipeline and the pipeline components that are configured to run within those stages. You create and modify PCF files by using the Pipeline Editor, which provides a graphical representation of the stages and components that together define an individual pipeline. Editing pipelines is fundamental to creating a Web application with Commerce Server 2009 R2 and will usually be one of the required development tasks involved in creating such an application.

For more information, see Using the Pipeline Editor.

Developing Custom Pipeline Components

There may be circumstances in which the various pipeline components provided with Commerce Server 2009 R2 do not perform one or more pipeline tasks your Web application requires, or do not perform those tasks in quite the manner that your Web application requires. When this occurs, you can develop a custom pipeline component that is designed specifically to meet your needs. Every pipeline component is required to support the IPipelineComponent interface, which allows it to be executed by a pipeline object. There are a number of other interfaces that are ultimately optional, but recommended, primarily so that your pipeline component can integrate smoothly into the Pipeline Editor.

For more information, see Building Pipeline Components and Pipeline Component Reference.

Integrating Third Party Payment Systems

Some pipeline components provide such specialized services that their development is better left to companies other than Microsoft that focus on those areas, credit card processing being a primary example. Several third party companies have developed pipeline components for Commerce Server 2009 R2. You can acquire these components directly from these companies and use them in your pipeline development.

Extending the Orders System Object Model

If you find that you need to extend the functionality of the Orders System, you can either derive a new class from an Orders class or you can add a new property to an Orders class by using the weakly-typed property indexer that each Orders class provides. Each method has its own advantages and disadvantages that you can evaluate with regard to your particular needs.

For more information, see Extending the Orders System.

Customizing the Other Commerce Server Core Systems

Unlike the Orders System, the other core systems within Commerce Server 2009 R2, such as the Catalog System, the Inventory System, the Marketing System, and so on, cannot be extended through inheritance. Instead, in order to extend these core systems, you must use a technique known as "containment" or "building a facade".

For more information about extending these other Commerce Server 2009 R2 systems, see the individual development sections for each of those systems:

Extending Web Services

All of the Commerce Server 2009 R2 Web service objects use virtual methods so that their behavior can be overridden. If you consider that the various business management applications such as the Catalog Manager and the Marketing Manager, as well as the BizTalk adapters, communicate with Commerce Server 2009 R2 through the Web services, customizing the Web services by deriving new Web service objects from them provides a comprehensive way to splice new functionality into existing aspects of Commerce Server 2009 R2. You can build your own class that inherits from a Commerce Server 2009 R2 Web service class and then change the .ASMX file for the Web service to reference your class.

One example of how this type of customization could be useful is replacing Authorization Manager authorization with a custom authorization scheme. First, you would need to disable authorization in the Web.config file for the Web service(s) you are modifying. Next, you would create a class that inherits from the corresponding Web service class for each Web service that you are modifying. Finally, you would implement a version of each method in each class that performs the custom authorization functionality and then calls its base class method to perform the remainder of the work.

Another example would be to add auditing to one or more Commerce Service Web services. In this case, you would leave Authorization Manager authorization intact and then add the auditing functionality to each of the derived methods along with a call to its base class method.

You can also add new methods to the Commerce Server 2009 R2 Web services to enable new functionality.

For more information about the Commerce Server 2009 R2 Web service classes, see the individual reference sections for each of those classes: