EventContext

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
Have just written a little plugin using EventContext (yes, we're still working to get our shop ready!) and it's great.

Is it correct that I have to attach my event handler at the start of every application request in global.asax? If I attach at application start it doesn't work.

Currently I'm using the order placed handler, could we get an order paid handler?

Thanks very much Andrei for adding this really useful little feature.
13 years ago
Bump.
13 years ago
You have to attach event handler at the start of every application request (Application_BeginRequest). It works fine.
13 years ago
That's what I've been doing and yes it works great.

Any chance of getting an Order Paid event? I know I can probably write some code in Order Changed but it would be better if the app did it for us.
13 years ago
Sure, we'll be adding more and more events to EventContext
13 years ago
Hi Andrei, Been looking at the code and from what I can tell certain payment providers such as SagePay return PaymentStatusEnum.Pending from IPaymentMethod.ProcessPayment() and then there is another call later (not sure why) to IPaymentMethod.PostProcessPayment() via PaymentManager.PostProcessPayment(). The call is made from btnNextStep_Click in CheckOutConfirm.ascx.cs. Unless I'm mistaken it doesn't look like there's any call to EventContext so the order being marked as paid at this point wouldn't propagate to plugins? I don't have an account to test with.

Presumably need to add an EventContext call at PaymentManager.PostProcessPayment().

Ah ok, looks like we call Capture() and the payment status is updated there, but that's an admin action.

What I really need is to be notified of when the order has been paid or rejected. Using EventContext.OrderPlaced is a bit of a kludge because of the above issue and because of payment providers such as Purchase Order. If in EventContext.OrderPlaced I only action code for orders which have been paid I will miss some, if I action the code for orders with PaymentStatusEnum.Pending I'll be giving some customers service who will shortly have their payment or orders declined.

So, can we please get an Order Paid or Order Payment Process or best of all Order Payment Status Changed completed handler? If this delegate is only called when the payment status has changed I will know definitively whether to process or cancel the order.

I need a solution asap. Happy to roll my own but it all seems horribly complicated. Why aren't we updating the Order.PaymentStatus property every time there is a change? Then all we need to do is raise the event from there (being careful not to raise it before the object is properly hydrated, e.g. set that value last when constructing).

Also why does PaymentStatusEnum have no values for NotPaid or Declined?
13 years ago
Quick synopsis: I have a plugin which will, when the relevant licence products have been ordered, extend the user's expiry period on our fleet tracking site and set up various addons for them. This is also done programatically. I need to process the order as soon as it's been successfully paid (or insert an order note as soon as the payment has been declined or the order rejected) and ideally no earlier.
13 years ago
You may want to fire your event in OrderManager.MarkOrderAsPaid.
13 years ago
That might be one place to put an EventContext call in. Thanks for that. I'm doubting that's the only place in the code where the order payment status gets set though.
13 years ago
OK. So why not fire the event at the source, i.e. the setter method of PaymentStatus for the Order class in Order.cs. Raise a PaymentStatusChanged event passing in the old and the new status as event arguments. You can then wire up your event handler and process any status changes.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.