Yes of course:
We use ipaper (a magazine where you can buy some items) and when the user press "Shop" or checkout they REDIRECT with POST the user to our nopcommerce. Their POST comes to my www.mysite.com/iPaperCheckout so I added this method:
[HttpPost, ActionName("IPaperCheckout")]
public ActionResult IPaperCheckout()
{
var xd = new XmlDocument();
// try
// {
StreamReader reader = new StreamReader(Request.InputStream, System.Text.Encoding.UTF8);
String sXMLRequest = reader.ReadToEnd();
xd.LoadXml(sXMLRequest);
//xd.LoadXml(xmlTestData);
string sep = "<br />";
//Response.Write(xd.InnerXml);
foreach (XmlNode xn in xd.SelectNodes("//item"))
{
var item = new Item();
item.Amount = Convert.ToInt32(xn.SelectSingleNode("amount").InnerText);
item.ID = xn.SelectSingleNode("productid").InnerText;
Response.Write(string.Format("vareID = {0} - antal = {1}", item.ID, item.Amount));
ProductVariant productVariant = _productService.GetProductVariantBySku(item.ID);
if (productVariant != null)
{
var addToCartWarnings = _shoppingCartService.AddToCart(_workContext.CurrentCustomer,
productVariant, ShoppingCartType.ShoppingCart,
string.Empty, decimal.Zero, 1, true);
}
}
//}
//catch (Exception e)
// {
// return RedirectToAction("Index", "Home");
//}
return RedirectToAction("Index", "Home");
}
Maybe it does not help, but for you to better understand my code, their xml is like:
<shop paper=""/Products/Cocacola/"">
<item>
<amount>
2
</amount>
<productid>
<![CDATA[820]]>
</productid>
<price>
99.95
</price>
<name>
<![CDATA[Coca cola]]>
</name>
<description>
<![CDATA[Coca-Cola is a carbonated soft drink]]>
</description>
</item>
<item>
<amount>
1
</amount>
<productid>
<![CDATA[-821]]>
</productid>
<price>
99.95
</price>
<name>
<![CDATA[Coca cola]]>
</name>
<description>
<![CDATA[Coca-Cola is a carbonated soft drink]]>
</description>
</item>
</shop>
So I parse their xml succesfully, I found product from my nop db by SKU (actually my client put SKU there so don't be confuse that the xml tag is "productID") and add the corresponding product variant in the shopping cart...pretty simple..