Copied to clipboard

Flag this post as spam?

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

  • Johnny Kristensen 6 posts 96 karma points
    Feb 21, 2018 @ 14:36
    Johnny Kristensen

    Inconsistent amount with custom order line calculator and Payment provider in finalized order when using Umbraco Member

    I've set up a custom order line calculator. It works perfectly fine and everything looks fine in the purchase flow. When using e.g. invoice it works aswell and the finalized order is updated correctly.

    But when going trough a payment provider, in this case Bambora (epay), the finalized orders total amount is incorrect compared to the calculator. Bombora does collect the correct calculated price, just seems like something happens when it is calculated for the finalized order. So in backoffice I get this:

    enter image description here

    And the front end user sees the wrong price as well at the end of the purchase flow.

    I'm guessing it is in the finalized order process something goes wrong, but a bit uncertain how to handle it. Am I missing a step for a custom calculator to work with a payment provider?

    Just in case it helps, here is the code for the custom calculator, but as mentioned this part works as expected:

        [SuppressDependency("TeaCommerce.Api.PriceCalculators.IOrderLineCalculator", "TeaCommerce.Api")]
    public class MemberOrderLineCalculator : OrderLineCalculator
        public MemberOrderLineCalculator(IVatGroupService vatGroupService, IProductInformationExtractor productInformationExtractor)
          : base(vatGroupService, productInformationExtractor)
        public override Price CalculatePrice(OrderLine orderLine, Currency currency, Order order)
            decimal price;
            var originalPrice = orderLine.OriginalUnitPrices.Get(currency.Id).Value;
            var helper = new Umbraco.Web.UmbracoHelper(Umbraco.Web.UmbracoContext.Current);
            var product = helper.TypedContent(orderLine.ProductIdentifier);
            var allowMemberPrice = product.GetPropertyValue<string>("memberPriceAuthorized", true).Split(',');
            var isMemberAuthorized = helper.MembershipHelper.IsMemberAuthorized(allowGroups: allowMemberPrice);
            if (product == null || !isMemberAuthorized)
                return new Price(originalPrice, orderLine.VatRate, currency);
            price = product.GetPropertyValue<decimal>("memberPriceDKR");
            if (price == 0)
                return new Price(originalPrice, orderLine.VatRate, currency);
            return new Price(price, orderLine.VatRate, currency);

    Best regards, Johnny.

  • Johnny Kristensen 6 posts 96 karma points
    Feb 22, 2018 @ 07:57
    Johnny Kristensen

    When hooking the gateway (Payment provider) to the local environment it actually works as it should. It's just on the live environment it is an issue it seems. Does Tea Commerce cache the order with a different logic?

  • Brian Lyk Larsen 19 posts 269 karma points
    Feb 22, 2018 @ 09:55
    Brian Lyk Larsen

    Hi Johnny,

    The order is calculated one final time before being finalized when the callback from ePay arrives. This callback is in a different session than the logged in customer, which results in IsMemberAuthorized returning false.

    This might also explain why it works on your local environment, where your session is still used when you simulate the call from ePay.

    The ID of the member who placed the order is saved as CustomerId on the order. You can probably use this to check whether or not the customer should get the special price.

  • Johnny Kristensen 6 posts 96 karma points
    Feb 22, 2018 @ 14:23
    Johnny Kristensen

    That did the trick. Did not have customerId from the order initially, but that was an easy fix. But using it further down the process solved the problem with the payment provider. Thanks a lot for a great answer Brian. : )

Please Sign in or register to post replies

Write your reply to: