Unable to access proccess payment request data in OrderPlacedEvent

1 year 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;

        }
1 year 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?
1 year 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