The 5th annual nopCommerce conference will take place in India on the 10th-11th of October. Please find more about this event here

Unable to access proccess payment request data in OrderPlacedEvent

Posted: October 24, 2018 at 12:45 AM Quote #213504
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;

        }
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
- Adam K
www.aperturelabs.biz
Posted: October 24, 2018 at 12:58 AM Quote #213506
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?
This post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
Interested in the dedicated Premium support services provided by core developers? Please visit http://www.nopcommerce.com/supportservices.aspx

Regards,
Andrei Mazulnitsyn
Posted: October 24, 2018 at 10:10 AM Quote #213529
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 post/answer is useful
0
This post/answer is not useful

Please login or register
to vote for this post.

(click on this box to dismiss)
- Adam K
www.aperturelabs.biz
Premium support services
  • Dedicated premium support services provided by core developers are intended for persons who run mission critical websites, work on projects with tight deadlines, or want to get dedicated support.
Professional services
  • Want to open a new store? Want to take your store to the next level? Need a custom extension? We can customize nopCommerce to fit your store perfectly. Request a quote to get started.
eCommerce CONFERENCE 2019
Learn more