public KlarnaCreateCheckoutOrderResponse CreateKlarnaCheckoutOrder(KlarnaCreateCheckoutOrderRequest request) { var res = _client.CreateCheckoutOrder(MakeCheckoutOrderRequest(request)); KlarnaCreateCheckoutOrderResponse response = new KlarnaCreateCheckoutOrderResponse { KlarnaOrderId = res.KlarnaOrderId, VeritixOrderId = res.VeritixOrderId, HtmlSnippet = res.HtmlSnippet, ErrorMessage = res.ErrorMessage, KlarnaOrderStatus = res.IsSuccess ? "Created" : "Failed" }; return(response); }
private CheckoutOrderRequest MakeCheckoutOrderRequest(KlarnaCreateCheckoutOrderRequest request) { var ci = new CultureInfo(request.Locale); var ri = new RegionInfo(ci.LCID); CheckoutOrderRequest req = new CheckoutOrderRequest { OrderData = new CheckoutOrder { Locale = request.Locale.ToLower(), PurchaseCountry = ri.Name.ToLower(), PurchaseCurrency = ri.ISOCurrencySymbol.ToLower(), MerchantReference1 = request.OrderId, OrderAmount = int.Parse(request.ShoppingCart.Total.ToString("0.00").Replace(".", "").Replace(",", "")), OrderTaxAmount = int.Parse(request.ShoppingCart.Tax.ToString("0.00").Replace(".", "").Replace(",", "")), OrderLines = new List <OrderLine>() { new OrderLine { Name = "Tickets", Quantity = 1, UnitPrice = int.Parse(request.ShoppingCart.Total.ToString("0.00").Replace(".", "").Replace(",", "")), TaxRate = int.Parse(request.ShoppingCart.TaxRate.ToString("0.00").Replace(".", "").Replace(",", "")), TotalAmount = int.Parse(request.ShoppingCart.Total.ToString("0.00").Replace(".", "").Replace(",", "")), TotalTaxAmount = int.Parse(request.ShoppingCart.Tax.ToString("0.00").Replace(".", "").Replace(",", "")), TotalDiscountAmount = 0, } }, MerchantUrls = new CheckoutMerchantUrls { Terms = _context.Properties["Klarna.MerchantUrl.Terms"], Checkout = _context.Properties["Klarna.MerchantUrl.Checkout"], Confirmation = _context.Properties["Klarna.MerchantUrl.Confirmation"], Push = _context.Properties["Klarna.MerchantUrl.Push"] }, CheckoutOptions = new CheckoutOptions { AllowSeparateShippingAddress = false, //ColorButton = "#FF9900", //ColorButtonText = "#FF9900", //ColorCheckbox = "#FF9900", //ColorCheckboxCheckmark = "#FF9900", //ColorHeader = "#FF9900", //ColorLink = "#FF9900", //DateOfBirthMandatory = false, //ShippingDetails = "bar", //AllowedCustomerTypes = new List<string>() { "person", "organization" } }, BillingCheckoutAddress = new CheckoutAddressInfo { StreetAddress = "My StreetAddress", StreetAddress2 = "My StreetAddress2", StreetName = "My StreetName", City = "My City", Country = "SE", } } }; return(req); }