Hi, Are there a hook or event I can use to add custom order validation? let’s say an age limit to stop the order after the buy-button is pressed but before Klarna get any order data?
Litium versionen: 6.2
Hi, Are there a hook or event I can use to add custom order validation? let’s say an age limit to stop the order after the buy-button is pressed but before Klarna get any order data?
Litium versionen: 6.2
When the shoppingCart.PlaceOrder()
method is executing the
Litium.Foundation.Modules.ECommerce.Plugins.Orders.IPreOrderValidator.Validate(OrderCarrier, CheckoutFlowInfo)
method. The IPreOrderValidator
default behavior is to validate the order with all the implementations of
Litium.Foundation.Modules.ECommerce.Plugins.Orders.IPreOrderValidationRule
that may throw an exception of
Litium.Foundation.Modules.ECommerce.Plugins.Orders.PreOrderValidationException
if the order not is valid.
This can be used to prohibit the order for age restriction or if a secondary validation is checking all products exists in inventory with the ERP system.
This is used in accelerator and you can find the accelerator implementations in the folder Litium.Accelerator\Validations
I suppose you are using the Klarna checkout, and that is rendered from Klarna.
There is a Validation method, but that cannot be used as a reliable way because it automatically assumes the order is validated if reply does not come withing certain amount of time.
If the items are age restricted, you can use the Klarna checkout inbuilt feature in the Klarna account itself, to restrict buyers to be over 18 years.
You can also selectively use the DateOfBirthMandatory feature in KCO, together with above settings, as described here:
https://docs.litium.com/documentation/add-ons/payments/klarna/develop
Yes it’s Klarna and It is not only age restriction, I need a lot of custom logic. So I think I need to implement the Klarna Validation callback check to at least mitigate the problem.
Dose the Litium plugin for Klarna come with this endpoint setup that I can modify? Or do I need to implement it?
In Accelerator project you have KlarnaPaymentWidgetConfigV2
and KlarnaPaymentWidgetConfigV3
that both implement the ValidateCheckoutOrder
that Klarna is calling before creating the actual order. You can change the validation logic there for respective Klarna V2 or Klarna V3 depend on what you are using in your project.
As described in the remarks for that method the result for the validation method need to be returned within 3 seconds.
The method need to return within 3 seconds to be able to cancel placed an order at Klarna.