Checkout Pipeline failing to execute

I am doing some calculation in pipeline component as follows

publicint Execute(object pdispOrder,object pdispContext,int lFlags)

{

Int32 ReturnValue = StatusSuccess;

try

{

IDictionary orderForm = (IDictionary)pdispOrder;

OrderForm oOrderForm =newOrderForm(orderForm);

Product oProduct;

CatalogSiteAgent oCatalogSiteAgent =newCatalogSiteAgent();

oCatalogSiteAgent.SiteName = strSiteName;

CatalogContext oCatalogContext =CatalogContext.Create(oCatalogSiteAgent);

double dVAT = 0.0;

double dListPrice =0.0;

int iIndexOfLineItem =0;

Boolean bAllTotalInitialize =false;

foreach (LineItem oLineItemin oOrderForm.LineItems)

{

OrderAddress oOrderAddress = oOrderForm.Addresses[oLineItem.ShippingAddressId];

if (oOrderAddress !=null)

{

if (!bAllTotalInitialize)

{

oOrderForm.Total =decimal.Zero;

oOrderForm.SubTotal =decimal.Zero;

oOrderForm.TaxTotal =decimal.Zero;

bAllTotalInitialize =true;

}

oProduct = oCatalogContext.GetProduct(oLineItem.ProductCatalog, oLineItem.ProductId);

dListPrice =Convert.ToDouble(oLineItem.ListPrice);

dVAT =Convert.ToDouble(oProduct["VAT"].ToString());

dListPrice += dListPrice * (dVAT / 100);

oOrderForm.LineItems[iIndexOfLineItem].ListPrice =Convert.ToDecimal(dListPrice);

oOrderForm.LineItems[iIndexOfLineItem].TaxTotal =Decimal.Zero;

if (oOrderAddress.CountryName.Trim().ToUpper().Equals("UNITED KINGDOM",StringComparison.Ordinal))

oOrderForm.LineItems[iIndexOfLineItem].TaxTotal +=Convert.ToDecimal(dVAT);

oOrderForm.TaxTotal +=Convert.ToDecimal(oLineItem.TaxTotal);

oOrderForm.SubTotal +=Convert.ToDecimal(oLineItem.PlacedPrice);

oOrderForm.Total +=Convert.ToDecimal(oLineItem.ListPrice);

}

else

{

ReturnValue = StatusWarning;

}

iIndexOfLineItem +=1;

}

}

catch

{

ReturnValue = StatusError;

}

return ReturnValue;

}

I have inserted this in total pipeline after

After executing this pipeline the checkout pipeline is throwing an exception. Its Inner exception is...

Component Execution failed for component[0x0] hr: 0x80070057
ProgID: Commerce.PaymentMethodRouter
Total of the payments being processed is not same as order form total.

Please let me know

[5319 byte] By [Minah] at [2008-1-7]
# 1

I am not sure if this is related to your problem but I see a couple of issues with your implementation.

  1. The variable strSiteName is not set, and will generate an error.
    1. Creating a Catalog Context is a performance hit, but you can do this if you really want. There are two ways to do this:
    2. Create the context like you have (making sure you have a valid site name).
  2. Pass the Catalog context pdispContext.
  3. If I were you I would pass the values into the lineitem so you don't have to create the Catalog context.

I would enable the pipeline logging and see exactly what is generating the error.

I hope this helps,

-Max

MaxAkbar at 2007-10-2 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 2

Thanks Max,

I do understand using CatalogContext is a performance hit. But I need to get a property("VAT" in productCatalog Table) of the Product. How to get it without using CatalogContext.

And regarding the pipeline failing issue. I deleted the component from total.pcf and added to it to the Checkout.Pcf and is working perfectly. But I wanted it in total.pcf because now the user know about the final amount only after submiting the order. I m going to give a try after enabling pipeline logging.

Regards Hanim.

Minah at 2007-10-2 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 3

You can use CommerceContext.Current.CatalogSystem to get the CatalogContext used by the site instead of creating one.

SudhaRaghavan-MSFT at 2007-10-2 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 4

Thank you for your valuable suggestion. That really helps.

Tell me why the check out pipeline is falling if I change the order form total(please see the thread starter question). If I dont change the order total its working fine. what would be the reson for this.

Minah at 2007-10-2 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 5
If you look at each pipeline component you will notice that each reads specific values and writes and has some optional and context value dependencies.

To get a list of a pcf files values read\written\context values read open the pfc file then select file->Save values read and written… this should dump out a text file with that data. Examining this file should tell you where each pipeline component set values and reading the documentation about each of these pipeline components should give you the answer.

Good luck,
-Max

MaxAkbar at 2007-10-2 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 6

Hi,

Can someone please help me with an issue I am having trying to send the CatalogSystem through to the Basket Pipeline.

I keep getting the following error:

An exception of type 'System.ArgumentException' occurred in Microsoft.CommerceServer.Runtime.dll but was not handled in user code

Additional information: The dictionary parameter must be of type Microsoft.CommerceServer.Runtime.IDictionary

I have tried to do the following:

if (CommerceContext.Current.CatalogSystem != null)
{
pipeline.Profiles.Add("CatalogContext", CommerceContext.Current.CatalogSystem);
}

Can someone please give me some advice how to send a Catalog object into the pipeline.

I need to use the CatalogSystem to retrieve a user defined attribute from the catalog database not stored in a line_item object.

Thank you.

SteveDDAY at 2007-10-2 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 7
In your aspx code:
PipelineInfo pipeinfo = new PipelineInfo("basket");
if (CommerceContext.Current.CatalogSystem != null)
{

pipeinfo["CatalogContext"] = CommerceContext.Current.CatalogSystem;
}

In your pipeline code:
public int Execute(object pdispOrder, object pdispContext, int lFlags)
{
Int32 ReturnValue = StatusSuccess;
IDictionary Context = (IDictionary)pdispContext;
CatalogContext CtlgContext = (CatalogContext )Context["CatalogContext"];
return ReturnValue;
}

MaxAkbar at 2007-10-2 > top of Msdn Tech,Commerce Server,Commerce Server 2007...
# 8

Hi Max,

I couldnt log to the Froumn for past few weeks.

My requirement is to calculate the tax according to the shipping address selected. But always i get the Order Address as NULL. If i put this component in checkout pipeline, its working fine. But its not the correct way as user sees the tax calculation only after he submits the order. So how to get the shipping address in total pipeline in my component.

Regards Minah

Minah at 2007-10-2 > top of Msdn Tech,Commerce Server,Commerce Server 2007...