Copied to clipboard

Flag this post as spam?

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


  • seanrock 262 posts 483 karma points
    Jun 24, 2020 @ 14:46
    seanrock
    0

    How does vendr handle zero value orders?

    Hi Matt

    We have scenarios where the order could be zero. How does vendr handle this? Will it still complete the order as if it was paid for or would we need to do some manual (in code) updates?

    Thanks

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jun 24, 2020 @ 14:52
    Matt Brailsford
    100

    Hey Sean,

    We recently had to implement this in the Vendr.Checkout package and the way we have done it is that in Vendr we now ship a "Zero Value" payment provider with the core. This payment provider essentially just lets the payment through, marking the order as paid, and sends you to the continue URL.

    To use it, you'd have to setup a zero value payment method (probably hiding it on your payment providers list on the front end) but then when you get to the payment stage of the checkout (which should be the last stage) if there is nothing to pay, then force the selection of the Zero Value payment provider, otherwise let the person choose.

    There may be a nicer way to do this in future, but this is how TC did it and we just needed to get something in place, so for now, this is the approach you'd need to follow.

    Hope that helps

    Matt

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jun 24, 2020 @ 14:55
    Matt Brailsford
    1

    As some additional reference, here is the code we use for the Vendr.Checkout packages "Payment Method" selection page

    https://github.com/vendrhub/vendr-checkout/blob/dev/src/Vendr.Checkout/Web/UI/App_Plugins/VendrCheckout/Views/VendrCheckoutPaymentMethodPage.cshtml

    @using Vendr.Checkout;
    @inherits Umbraco.Web.Mvc.UmbracoViewPage
    @{
        Layout = "VendrCheckoutMaster.cshtml";
    
        var store = Model.GetStore();
        var currentOrder = VendrApi.Instance.GetCurrentOrder(store.Id);
        var paymentMethods = VendrApi.Instance.GetPaymentMethods(store.Id);
    
        var checkoutPage = Model.GetCheckoutPage();
        var nextStepPage = Model.GetNextStepPage();
    
        var currentPaymentMethodId = currentOrder.PaymentInfo.PaymentMethodId.HasValue
            ? currentOrder.PaymentInfo.PaymentMethodId.Value
            : paymentMethods.First().Id;
    
        var zeroValuePaymentMethod = paymentMethods.FirstOrDefault(x => x.Alias == VendrCheckoutConstants.PaymentMethods.Aliases.ZeroValue);
    }
    
    @using (Html.BeginUmbracoForm("UpdateOrderPaymentMethod", "VendrCheckoutSurface"))
    {
        @Html.AntiForgeryToken();
    
        <input type="hidden" name="nextStep" value="@(nextStepPage?.Id)" />
    
        <h3 class="text-xl font-medium mb-4 mt-8">Payment Method</h3>
    
        if (currentOrder.TotalPrice.Value.WithTax > 0 || zeroValuePaymentMethod == null)
        {
            <ul class="border border-gray-300 rounded">
                @foreach (var item in paymentMethods.Where(x => zeroValuePaymentMethod == null || x.Alias != zeroValuePaymentMethod.Alias)
                    .Select((pm, i) => new { PaymentMethod = pm, Index = i }))
                {
                    <li class="border-gray-300 @(item.Index > 0 ? "border-t " : "")">
                        <label class="flex items-center py-4 px-4 cursor-pointer hover:bg-gray-100">
                            <input name="paymentMethod" type="radio" value="@item.PaymentMethod.Id" class="mr-3" @Html.Raw(currentPaymentMethodId == item.PaymentMethod.Id ? "checked=\"checked\"" : "") required />
                            <span class="font-medium">@(item.PaymentMethod.Name)</span>
                            <span class="flex-1 text-right">@(item.PaymentMethod.CalculatePrice()?.Formatted())</span>
                        </label>
                    </li>
                }
            </ul>
        }
        else
        {
            <input type="hidden" name="paymentMethod" value="@(zeroValuePaymentMethod.Id)" />
            <div class="border border-gray-300 rounded py-4 px-4 text-center">It looks like today is your lucky day, there is nothing for you to pay 🎉</div>
        }
    
        @Html.VendrCheckoutPartial("VendrCheckoutPrevNext")
    }
    

    Matt

  • seanrock 262 posts 483 karma points
    Jun 24, 2020 @ 15:27
    seanrock
    1

    Thanks Matt thats helpful.

    In addition to that we need to create a new payment provider (sagepay direct) because the client is adamant they want to take cc details on the site without redirecting the user to (qoute) 'one of those ugly payment pages'. :D

  • Matt Brailsford 4125 posts 22223 karma points MVP 9x c-trib
    Jun 24, 2020 @ 15:34
    Matt Brailsford
    0

    Lol. SagePay is definitely on our list, however we'd be going the hosted page route.

    Inline is certainly possible, but it's just not the route we are focused on for our core supported payment providers, purely due to the amount of integration work we find they need (The Inline Stripe provider for TC has been an absolute nightmare to maintain).

    Would love to hear how you get on with it though 👍

    Matt

Please Sign in or register to post replies

Write your reply to:

Draft