Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • ianhoughton 281 posts 605 karma points c-trib
    Jul 12, 2021 @ 14:15
    ianhoughton
    0

    Order missing PaymentMethod

    We are updating the payment method on an Order with this code:

    using (var uow = _uowProvider.Create())
    {
        var order = _sessionManager.GetOrCreateCurrentOrder(store.Id).AsWritable(uow);
    
        var store = GetStore();
    
        // other code remove for brevity    
    
        var paymentId = _paymentMethodService.GetPaymentMethods(storeId).FirstOrDefault(x => x.PaymentProviderAlias == "total-processing").Id;
    
        order.SetPaymentMethod(paymentId);
    
        _orderService.SaveOrder(order);
    
        uow.Complete();
    }
    

    On the _orderService.SaveOrder line, when we look at the order.PaymentInfo.PaymentMethodId property, I can see the Guid of the payment provider.

    If I then step past this line and the order is saved, when I then look at the order.PaymentInfo.PaymentMethodId property it is null again.

    This is causing us issues when we then retrieve the Order in another controller as the payment provider hasn't been saved.

    Any ideas what we're doing wrong?

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jul 12, 2021 @ 14:48
    Matt Brailsford
    0

    Are you using Vendr Checkout?

  • ianhoughton 281 posts 605 karma points c-trib
    Jul 12, 2021 @ 15:05
    ianhoughton
    0

    I saw the other forum post about Vendr Checkout and no we're not using it.

    We are in the process of setting up another language site, which is running off a 2nd Vendr shop all within the same Umbraco instance.

    The 1st site has been up and running for months without issue, so I'm a little nervous to start changing what was a working checkout process, but the new site is currently not working because of this payment issue.

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jul 12, 2021 @ 15:15
    Matt Brailsford
    100

    Ok, then if you aren’t running Vendr Checkout on either store, I’d double check what event handlers you have configured and whether any of them are resetting it.

    Also, make sure all units of work have their Complete(); method called otherwise things will just be reset.

  • ianhoughton 281 posts 605 karma points c-trib
    Jul 12, 2021 @ 15:34
    ianhoughton
    0

    Thanks Matt, that was it!!

    There are some OrderEventHandlers hidden in the codebase that are clearing out the shipping and payment details if the order isn't finalised. We do need them, but just not firing on the last page of the checkout.

    Inherited project so didn't even know they were there.....

Please Sign in or register to post replies

Write your reply to:

Draft