/// <summary> /// Validates the checkout order. /// you may save additional order info into the order, during validations. /// following is a sample which saves the date of birth as additional order info. /// </summary> /// <remarks> /// The method need to return within 3 seconds to be able to cancel placed an order at Klarna. /// </remarks> /// <param name="order">The order.</param> /// <returns>ValidationResult.</returns> public ValidationResult ValidateCheckoutOrder(ILitiumKcoOrder order) { var kcoOrder = order as LitiumKcoOrder; if (!string.IsNullOrEmpty(kcoOrder?.CheckoutOrder?.CheckoutCustomer?.DateOfBirth)) { AddOrUpdateAdditionalOrderInfo(order.OrderCarrier, "DateOfBirth", kcoOrder.CheckoutOrder.CheckoutCustomer.DateOfBirth); } var channel = _channelService.Get(order.OrderCarrier.ChannelID); var language = channel.WebsiteLanguageSystemId.HasValue ? _languageService.Get(channel.WebsiteLanguageSystemId.Value) : null; CultureInfo.CurrentUICulture = language != null ? language.CultureInfo : CultureInfo.CurrentUICulture; var routeRequestLookupInfo = new RouteRequestLookupInfo() { Channel = channel, IsSecureConnection = true, }; _errorPageResolver.TryGet(routeRequestLookupInfo, out var routeRequestInfo); // following result is used by Klarna AddOn to send the validation result back to Klarna. // ReSharper disable once ConvertToLambdaExpression return(new ValidationResult { IsOrderValid = true, RedirectToUrlOnValidationFailure = routeRequestInfo.DataPath, }); }
/// <summary> /// Validates the checkout order. /// you may save additional order info into the order, during validations. /// following is a sample which saves the date of birth as additional order info. /// </summary> /// <remarks> /// The method need to return within 3 seconds to be able to cancel placed an order at Klarna. /// </remarks> /// <param name="order">The order.</param> /// <returns>ValidationResult.</returns> public ValidationResult ValidateCheckoutOrder(ILitiumKcoOrder order) { //var order = kcoOrder as CheckoutOrder; //var customer = order.OrderDetailsRaw["customer"] as JObject; //if (customer != null) //{ // var dateOfBirth = customer["date_of_birth"]; // if (dateOfBirth != null) // { // AddOrUpdateAdditionalOrderInfo(order.OrderCarrier, "DateOfBirth", (string)dateOfBirth); // } //} var channel = _channelService.Get(order.OrderCarrier.ChannelID); var language = channel.WebsiteLanguageSystemId.HasValue ? _languageService.Get(channel.WebsiteLanguageSystemId.Value) : null; CultureInfo.CurrentUICulture = language != null ? language.CultureInfo : CultureInfo.CurrentUICulture; var routeRequestLookupInfo = new RouteRequestLookupInfo() { Channel = channel, IsSecureConnection = true, }; _errorPageResolver.TryGet(routeRequestLookupInfo, out var routeRequestInfo); //following result is used by Klarna AddOn to send the validation result back to Klarna. // ReSharper disable once ConvertToLambdaExpression return(new ValidationResult { IsOrderValid = true, RedirectToUrlOnValidationFailure = routeRequestInfo.DataPath, }); }
public void Refresh() { _checkoutOrder = _klarnaCheckout.FetchKcoOrder(_checkoutOrder.OrderCarrier); }
public void Update(OrderCarrier orderCarrier) { _checkoutOrder = _klarnaCheckout.FetchKcoOrder(orderCarrier); }
public PaymentWidgetOrder(ILitiumKcoApi klarnaCheckout, ILitiumKcoOrder checkoutOrder) { _klarnaCheckout = klarnaCheckout; _checkoutOrder = checkoutOrder; }