Show shipping methods
Show the shipping options inside the Qliro iframe by following these instructions.
Note
Your Qliro site should be publicly visible to Qliro for Shipping methods to work. See below for setting up localhost when developer testing.
- In the Qliro config file, enable set the enableShippingMethods attribute to "true"
- You need to override the default shipping method implementation to send the list of shipping options to Qliro. Qliro calls the Litium Qliro Addon, which in tern calls the Build() method and GetDeliveryMethods(). Following is an example code for Accelerator 7.1 to override it.
using Litium.AddOns.Qliro.Api.Models;
using Litium.AddOns.Qliro.Abstractions;
using Litium.Foundation.Modules.ECommerce;
using Litium.Foundation.Modules.ECommerce.Deliveries;
using Litium.Foundation.Security;
using System;
using System.Collections.Generic;
using System.Linq;
using Litium.AddOns.Qliro.Builders;
using Litium.Globalization;
namespace Litium.Accelerator.Payments.Handlers
{
public class CustomQliroShippingMethodsBuilder : QliroShippingMethodsBuilder
{
private readonly ChannelService _channelService;
public CustomQliroShippingMethodsBuilder(ChannelService channelService)
{
_channelService = channelService;
}
public override List<ShippingMethod> Build(ShippingMethodBuildArgs args)
{
return base.Build(args);
}
protected override List<DeliveryMethod> GetDeliveryMethods(ShippingMethodBuildArgs args)
{
var channel = _channelService.Get(args.OrderCarrier.ChannelID);
if (channel == null)
return new List<DeliveryMethod>();
var deliveryMethodIds = channel.CountryLinks?.FirstOrDefault()?.DeliveryMethodSystemIds ?? Enumerable.Empty<Guid>();
return deliveryMethodIds.Select(deliveryMethodId => ModuleECommerce.Instance.DeliveryMethods.Get(deliveryMethodId, SecurityToken.CurrentSecurityToken)).ToList();
}
}
}
- If you are testing locally, you need publicly visible urls for server to server Qliro callbacks.
- You can set the backgroundCallsDomainName attribute in the Qliro addon config, to point the domain to a publicly visible domain.
- Alternatively, specify the full url for AvailableShippingMethodsUrl in the checkoutFlowInfo in Src\Litium.Accelerator\Payments\Widgets\QliroWidget.cs
private ExecutePaymentArgs CreatePaymentArgs(OrderCarrier order, string paymentAccountId)
{
//....
checkoutFlowInfo.SetValue(ConstantsAndKeys.AvailableShippingMethodsUrlKey, "https://somePublicDomain/");
//....
}
- The default URL sent (if nothing is specified) is similar to:
"MerchantOrderAvailableShippingMethodsUrl": "http://sampleDomain.com/PaymentProviderResult.axd/Report/Qliro?QliroNotificationType=AvailableShippingMethods&accountId=Qliro"
Customize shipping options sent to Qliro
You can customize the shipping options sent to Qliro by changing the return value of the Build() method in the above example.
public override List<ShippingMethod> Build(ShippingMethodBuildArgs args)
{
var result = base.Build(args);
//TODO: Customize the result values, for example you can change descriptions, etc.
return result;
}