Call web service after order created

Posted by Community Admin on 05-Aug-2018 18:36

Call web service after order created

All Replies

Posted by Community Admin on 05-Sep-2011 00:00

After a user checks out, I want to pass the order to a 3rd party web service. The two ways I can think of doing these are in Checkout.cs and Global.asax.cs.

I extended the toolbox widget "Telerik.Sitefinity.Modules.Ecommerce.Orders.Web.UI.Checkout" and trying to use the PreRender or subscribe to one of the events. The events are not firing consistently though:

using System;
using Telerik.Sitefinity.Modules.Ecommerce.Orders.Web.UI;
 
namespace SitefinityWebApp.Custom
    public class CustomCheckout : Checkout
    
        protected override void InitializeControls(Telerik.Sitefinity.Web.UI.GenericContainer container)
        
            base.InitializeControls(container);
            this.ConfirmationStep.NextStepRequested += new EventHandler<EventArgs>(ConfirmationStep_NextStepRequested);
        
 
        protected override void OnPreRender(EventArgs e)
        
            base.OnPreRender(e);
            //this.ShoppingCart;
        
 
        void ConfirmationStep_NextStepRequested(object sender, EventArgs e)
        
             
        
 
        protected override void Step_NextStepRequested(object sender, EventArgs e)
        
            base.Step_NextStepRequested(sender, e);
        
 
        protected override void Step_StepChangedRequested(object sender, Telerik.Sitefinity.Modules.Ecommerce.Orders.Web.UI.RequestStepChangeEventArgs e)
        
            base.Step_StepChangedRequested(sender, e);
             
            switch (e.RequestedStep)
            
                case CheckoutWizardStep.Confirmation:
                    //this.ShoppingCart;
                    break;
                case CheckoutWizardStep.Payment:
                    break;
                case CheckoutWizardStep.Preview:
                    break;
                case CheckoutWizardStep.ShippingAndBillingInformation:
                    break;
                case CheckoutWizardStep.ShippingOptions:
                    break;
                default:
                    break;
            
        
    

Also here is what I could come up with in the Global.asax as another way:

    public class Global : System.Web.HttpApplication
    
 
        protected void Application_Start(object sender, EventArgs e)
        
            Telerik.Sitefinity.Modules.Ecommerce.Orders.OrdersManager.Executed += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Orders_Executed);
        
 
        protected void Orders_Executed(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs args)
        
            if (args.CommandName.StartsWith("Create")) //args.CommandName == "CreateOrderPayment")
            
                var order = args.Data as Telerik.Sitefinity.Model.IOrderedItem;
 
                //implement your logic here to send email notifications                  
            
        

Can anyone shed light on the best way to do this?

Posted by Community Admin on 08-Sep-2011 00:00

Hello Basem,

From what I understand you are trying to do some post purchase tasks after your order has been placed, but
with 4.2 release the ways to override the default behaviour is minimal. We have since added two new events that you can subscribe in Global.asax to do custom tasks after an order is placed for the upcoming service pack release. We will also have examples on how to use these events in the SP release shortly on our blogs.

Kind regards,
Venkata Koppaka
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

This thread is closed