3

I noticed that the payment type (e.g. used in http://{{ServiceHost}}/{{ShopsApi}}/GetCartPaymentMethods(cartId='Cart01', paymentType='Creditcard')) is no where configured in Sitecore. It turns out that it's hard-coded in the BaseTranslateItemsToPaymentBlock:

protected virtual string GetPaymentTemplateName(string paymentOptionType)
{
return paymentOptionType == "1" ? "CreditCard" : (paymentOptionType == "2" ? "LoyaltyCard" : (paymentOptionType == "3" ? "GiftCard" : (paymentOptionType == "4" ? "Federated" : string.Empty)));
}

I would expect a Sitecore configuration setting. This is difficult to use at the XC9 API, and Commerce Connect doesn't work well with it. At the moment I cannot retrieve all payment options and next retrieve the payment methods using the PaymentOptionType because that expects (at XC9 side) the above mentioned hard-coded values.

How to solve this?

1 Answer 1

2

Solved it by overriding the base method;

public class TranslateItemsToPaymentMethodsBlock : Sitecore.Commerce.Plugin.Management.TranslateItemsToPaymentMethodsBlock
{
    public TranslateItemsToPaymentMethodsBlock(CommerceCommander commander) : base(commander)
    {
    }

    protected override string GetPaymentTemplateName(string paymentOptionType)
    {
          return paymentOptionType == "5" ? "MyCustomOptionType" : base.GetPaymentTemplateName(paymentOptionType);
    }
}

and configuring XC9 to use the new class:

.ConfigurePipeline<IGetPaymentOptionsPipeline>(d =>
{
   d.Replace<Sitecore.Commerce.Plugin.Management.TranslateItemsToPaymentOptionsBlock, TranslateItemsToPaymentOptionsBlock>();
})

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.