Events in Commerce? When payment is completed

rated by 0 users
This post has 7 Replies | 2 Followers

Top 25 Contributor
Posts 7
Anders Vindberg Posted: 2 Feb 2010 4:14 AM

Hi guys, is there a way to initiate some code when the event of a completed order has happened? Maybe in the same way Telligent do it with the CSModule implementation eg. csa.PostUserUpdate += new CSUserEventHandler(UpdateUser);

Thanks.

Top 10 Contributor
Posts 258

There certainly is, create a class and inherit it from IShopModule

Add a handler eg

em.AddShopEvent ( typeof ( OrderItemEvent ), new ShopEventHandler ( AutoCompleteOrderEvent ) ); 

and then do your work.

You can register for events for types of the following objects:

OrderEvent
OrderItemEvent
Item
Subscription
SubscriptionEvent

Cheers,
Rob

Top 25 Contributor
Posts 7

Thanks Rob, thats perfect.

Now that I have you, is there anything I need to check to identify if this particular subscription is active? I can't find any status parameter on the item.

This is what I got so far:

        void SubscriptionCompleted(object eventItem, ShopEventArgs e)
        {
            SubscriptionItem item = eventItem as SubscriptionItem;

            if(item != null)
            {

// Do something

            }
        }

 

Top 10 Contributor
Posts 258

SubscriptionItem is just the event, it contains the real subscription and on there there is a property called Active

Cheers,
Rob

Top 25 Contributor
Posts 7

How about this:

            SubscriptionEvent subscription = eventItem as SubscriptionEvent;

            if(subscription != null && subscription.RequestEventType == SubscriptionEvent.EventType.Activated)
            {


// Do something

           }

Top 10 Contributor
Posts 258

Give it a try, it should work.

Top 25 Contributor
Posts 7

It works! Cheers.

Top 50 Contributor
Posts 2

Yep, worked for me too. Thanks for the step-by-step guide Robert Nash!

hot tubs          ventrillo server

Page 1 of 1 (8 items) | RSS
Chronos Commerce Nexus Scribus Services

Copyright 2007-2010, Four Roads LLC, All rights reserved.

3617 Betty Drive STE I
Colorado Springs, CO 80917