99% of developers still look at Commerce Server as Web Platform…
in my project experience, I understood to appreciate Commerce Server as an application platform for E-Commerce architectures….
well the difference between a Web Platform and an Application platform is quite big, and this post want to demonstrate and explain hot to run the CS MultiChannel foundation outside from a web application.
More specifically I will explain how to place an order (running pipelines and so on…) in a console application.
you can get the full source code, the exe and all the proper documentation here
this kind of scenario could be very useful to test your schema changes, Order Components, Commerce Query, Pipeline, Pipeline Components and so on much more quickly than in a classic web Context.
this project could also used to instrument your own Unit – Integration – Load test environment running test on the CS Components.
the most important configuration setting belong in the channel configuration
as you can see the code is quite simple and use a lot of the CSSamples
and the contemporary site.
//Add LineItem to the Basket
Basket mybskt= BasketManager.AddLineItem( new Microsoft.Samples.Commerce.Order.CommerceEntities.LineItem("Adventure Works Catalog","AW075-03","64",1));
var myShippingAddress = new Address();
myShippingAddress.AddressName = "any";
myShippingAddress.AddressType = 2;
myShippingAddress.Id = Guid.NewGuid().ToString();
var myBillingAddress = new Address();
myBillingAddress.AddressName = "any name";
myBillingAddress.AddressType = 2;
myBillingAddress.Id = Guid.NewGuid().ToString();
var myCreditCard = new CreditCard();
myCreditCard.AuthorizationCode = "AuthCode";
myCreditCard.CustomerName = "custName";
myCreditCard.CreditCardNumber = "4111111111111111";
myCreditCard.DisplayName = "test displayname";
myCreditCard.ExpirationMonth = 1;
myCreditCard.ExpirationYear = 2015;
myCreditCard.BillingAddressId = myBillingAddress.Id;
myCreditCard.PaymentMethod = new CommerceRelationship();
myCreditCard.PaymentMethod.Id = paymentMethodId;
//Set the Shipping, BillingAddress, ShippingMethod,CreditCard and run basket and checkoutPipeline
BasketManager.PrepareForCheckout(myShippingAddress, myBillingAddress, myCreditCard, shippingMethodId, mystr.ToArray(), paymentMethodId);
//Place the Order and run the CheckoutPipeline
this post was also inspired by the following post http://notepuddle.com/2009/02/10/using-commerce-server-2009-outside-of-a-web-application/
you can check also the following reosurces for CS 2007 http://msdn.microsoft.com/en-us/library/bb219215.aspx
and this application that do the same thing on CS 2007http://blogs.msdn.com/nihitk/archive/2006/08/07/RunningPipelinesFromAConsoleApp.aspx