send sms CMSNotificationGateway

Mehrdad ilchizadeh asked on January 11, 2016 15:56

hello,

i want develop custom send sms by custom web service method... i need send sms when order in e-commerce site is paid send customer... or when user register send sms for him..

how to use this???

please help me

Correct Answer

Bryan Soltis answered on January 11, 2016 16:25

Hi Mehrdad,

If you need to handle the sending of the SMS when the order is paid, you could add a System Event Handler for the OrderPaid event in the CMS.Ecommerce namespace. This event would happen anytime an event is paid. when that happens, you can call your SMS integration code inside the event handler.

You can find out more about the System Event here:

https://docs.kentico.com/display/K9/Reference+-+Global+system+events#Reference-Globalsystemevents-EcommerceEvents

You can find sample code for writing your event handler here:

https://docs.kentico.com/display/K9/Handling+object+events

  • Bryan
1 votesVote for this answer Unmark Correct answer

Recent Answers


Mehrdad ilchizadeh answered on January 12, 2016 07:10

i use kentico 8.2 please send me document link for 8.2..'

thank you

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on January 12, 2016 08:17

1 votesVote for this answer Mark as a Correct answer

Mehrdad ilchizadeh answered on January 19, 2016 10:38

[CustomEcommerceEvents]

public partial class CMSModuleLoader : CMSModuleLoaderBase { /// public CMSModuleLoader() : base("CMSModuleLoader") { } /// /// private class CustomEcommerceEventsAttribute : CMSLoaderAttribute { /// public override void Init() { // Assigns custom handlers to events EcommerceEvents.NewOrderCreated.Execute += NewOrderCreated; EcommerceEvents.OrderPaid.Execute += OrderPaid; }

    private void NewOrderCreated(object sender, NewOrderCreatedEventArgs e)
    {
        // Add custom actions here
        EventLogProvider.LogEvent(EventType.INFORMATION, "Proddoc", "varintcolor", eventDescription: "SMS");
        if (ValidationHelper.GetString(MembershipContext.AuthenticatedUser.GetValue("UserPhone"), "") != "")
        {

            string[] number = null;
            number[1] = "+98" + MembershipContext.AuthenticatedUser.GetValue("UserPhone").ToString();
            EventLogProvider.LogEvent(EventType.INFORMATION, "Proddoc", "varintcolor", eventDescription: number[1]);
            Myclass.sendSms(number, string.Format("کاربر گرامی {0} {1}، پرداخت شما با موفقیت انجام شد.", MembershipContext.AuthenticatedUser.FirstName, MembershipContext.AuthenticatedUser.LastName), "+985000171");
            EventLogProvider.LogEvent(EventType.INFORMATION, "Proddoc", "varintcolor", eventDescription: "sms2");
        }

    }

    private void OrderPaid(object sender, OrderPaidEventArgs e)
    {
        EventLogProvider.LogEvent(EventType.INFORMATION, "Proddoc", "varintcolor", eventDescription: "SMS");
        if (ValidationHelper.GetString(MembershipContext.AuthenticatedUser.GetValue("UserPhone"), "") != "")
        {

            string[] number = null;
            number[1] = "+98" + MembershipContext.AuthenticatedUser.GetValue("UserPhone").ToString();
            EventLogProvider.LogEvent(EventType.INFORMATION, "Proddoc", "varintcolor", eventDescription: number[1]);
            Myclass.sendSms(number, string.Format("کاربر گرامی {0} {1}، پرداخت شما با موفقیت انجام شد.", MembershipContext.AuthenticatedUser.FirstName, MembershipContext.AuthenticatedUser.LastName), "+985000171");
            EventLogProvider.LogEvent(EventType.INFORMATION, "Proddoc", "varintcolor", eventDescription: "sms2");
        }
    }
}

i have error:

Message: Object reference not set to an instance of an object.

Exception type: System.NullReferenceException Stack Trace: at CMSModuleLoader.CustomEcommerceEventsAttribute.OrderPaid(Object sender, OrderPaidEventArgs e) at CMS.Base.AbstractHandler.CallEventHandler[TArgs](EventHandler1 h, TArgs e) at CMS.Base.AbstractHandler.Raise[TArgs](String partName, List1 list, TArgs e, Boolean important) at CMS.Base.SimpleHandler2.RaiseExecute(TArgs e) at CMS.Base.SimpleHandler2.RaiseExecute(TArgs e) at CMS.Base.SimpleHandler`2.StartEvent(TArgs e) at CMS.Ecommerce.OrderInfoProvider.SetOrderInfoInternal(OrderInfo orderObj) at CMS.FormControls.UIForm.SaveDataInternal()

Message: Object reference not set to an instance of an object.

plese help me

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.