Page 1 of 1

Connect to web service after successful checkout

Posted: Fri Jan 15, 2010 9:19 am
by mezojeff
Hello,

I'm trying to figure out the best way to provision a user account through an API on a remote site once the user's purchase has been successful for a certain SKU (it's a subscription to a backup service). In a perfect world it would look something like this?

//purchase is successful
//loop through order, if the order contains the sku for our backup subscription
if (product.sku=="mybackupplan")
{
//code to provision user account on remote system using the users email address
}

Where in able commerce would be the best place to do this? Would it be the receipt page (page that appears after successful purchase?)

Thanks,
Jeff

Re: Connect to web service after successful checkout

Posted: Fri Jan 15, 2010 9:37 am
by mazhar
You can trigger this code form CheckedOut method of OnePageCheckout. This is basically an event handler which is called upon completion of checkout(order placement) on store side. You in CheckedOut method you can get newly placed order like

Code: Select all

Order order = OrderDataSource.Load(e.OrderId,false);
foreach(OrderItem item in order.Items)
{
if(item.OrderItemType == OrderItemType.Product && item.Product.Sku="your sku")
{
//Connect to webservice and trigger your code
}

}

Re: Connect to web service after successful checkout

Posted: Fri Jan 15, 2010 9:47 am
by mezojeff
awesome, thanks for the prompt reply! I will try this out and see if it works now.