Export (0) Print
Expand All

Code to Invoke a Pipeline

Commerce Server 2002

To use a pipeline configuration file in a pipeline requires a little more set up than using a single component in the MicroPipe object. Generally, in addition to the steps outlined above, you will need to create a MessageManager object and add messages to it in the Global.asa file. The documentation for each component indicates whether or not it uses the MessageManager object. The following code shows how the Application_OnStart procedure creates a MessageManager object and adds messages to it specifically for the ValidateCCNumber pipeline component:

Sub Application_OnStart
    ' Set up the MessageManager and messages.
    Set oMessageManager = _
    Call oMessageManager.AddLanguage("usa",&h0409)
    oMessageManager.defaultLanguage = "usa"
    Call oMessageManager.AddMessage("pur_cc_expired", _
                                    "Credit card has expired.")
    Call oMessageManager.AddMessage("pur_badcc", _
                             "The credit-card number is not valid.")
    ' Set up the data functions.
    Set oDataFunctions = Server.CreateObject("Commerce.DataFunctions")
    oDataFunctions.Locale = &H0409
        Set Application("MSCSMessageManager") = oMessageManager
        Set Application("MSCSDataFunctions") = oDataFunctions
End Sub

Creating the Context dictionary and running the pipeline itself are so frequently done in a Commerce Server site that it makes sense to encapsulate this code in a one or more utility procedures contained in a separate Active Server Pages (ASP) page (for example, Util.asp):

Function GetPipeContextUtil()
Set dContext = GetDictionary() 
Set dContext.MessageManager = MSCSMessageManager 
Set dContext.DataFunctions = MSCSDataFunctions 
dContext.Language = sLanguage 
Set dContext.CatalogManager = Application("MSCSCatalogManager") 
Set dContext.CacheManager = Application("MSCSCacheManager") 
Set dContext.ProfileService = MSCSProfileService

    Set GetPipeContextUtil = dContext
End Function
Function ExecPipeUtil(sPcfFile, dOrderForm, dContext)
    Dim sPcfPath
    sPcfPath = Request.ServerVariables("APPL_PHYSICAL_PATH") + _
                                                  "\config\" + _
    Set pPooled = Server.CreateObject("Commerce.PooledPipeline")
    Call pPooled.LoadPipe(sPcfPath)
    iErrLevel = pPooled.Execute(1, dOrderForm, dContext, 0)
    ExecPipeUtil = iErrLevel
End Function

The following shows only the code that runs the pipeline. In a full application, more values would likely be added to the OrderForm object:

<%@ Language=VBScript %>
<!-- #include file="util.asp" -->
    ' Create dictionary object orderform.
    Set dOrderForm = Server.CreateObject("Commerce.OrderForm")
    dOrderForm.[cc_type] = sCardType
    dOrderForm.[_cc_number] = sCardNumber
    dOrderForm.[_cc_expmonth] = sExpMonth
    dOrderForm.[_cc_expyear] = sExpYear

    ' Create the pipe context.

    Set dPipeContext = GetPipeContextUtil()

    ' Run the pipeline.
    iErrLevel = ExecPipeUtil("plan.pcf", dOrderForm, dPipeContext)

If you intend to store the credit card information associated with the order, the credit card properties should be encrypted. For more information, see Encrypted Profile Properties.

Copyright © 2005 Microsoft Corporation.
All rights reserved.
© 2016 Microsoft