Unable to access proccess payment request data in OrderPlacedEvent

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
Hi all,

I've noticed that in the OrderPlacedEvent, certain ProcessPaymentRequest data is missing (v4.1) compared to previous versions.  It looks like with a recent update we're now serializing the request as json which occurs pretty early on in order placement, so the updated information is never persisted.  Although most of the relevant data is attached to the Order, having access to the ppr can be useful for things like fraud-screening.  

My current workaround -

in CustomOrderProcessingService
    
 protected override Order SaveOrderDetails(ProcessPaymentRequest processPaymentRequest,
            ProcessPaymentResult processPaymentResult, PlaceOrderContainer details)
        {
            var order = base.SaveOrderDetails(processPaymentRequest, processPaymentResult, details);

            _httpContextAccessor.HttpContext.Session.Set("OrderPaymentInfo", processPaymentRequest);

            return order;

        }
5 years ago
Hi Adam,

OrderPlacedEvent was always invoked after the payment and order placement. And it always had only "order" as an argument. We never passed "processPaymentRequest" to this event. It happends in 4.10 and happended in the previous versions

Could you please clarify?
5 years ago
Yep, I'd access like this:




        public void HandleEvent(OrderPlacedEvent eventMessage)
        {
            var paymentInfo = _httpContextAccessor.HttpContext.Session.Get<ProcessPaymentRequest>("OrderPaymentInfo");
             ...
        }


In the current version, only properties that are assigned by the payment processor are present as the ppr is serialized to json using SessionExtensions.  Formerly, as the ppr was updated, any updated properties (especially CustomValues) persisted, and I'd leverage that to pass data around.  I'd prefer to implement an IConsumer wherever possible.

I know there are other workarounds, perhaps this isn't a bug, just different behavior.

Most importantly, overall we love nopCommerce 4.1 - thank you!

-Adam
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.