public ActionResult PlaceOrder() { CreateOrderIfRequired(); webShopModel.PaymentCompleted = null; try { MerchantOrder order = OrderHelper.PrepareOrder(Request.Form, webShopModel); if (order != null) { MerchantOrderResponse response = omniKassa.Announce(order); webShopModel = null; SessionVar.Set <WebShopModel>(SESSION_ORDER, null); return(new RedirectResult(response.RedirectUrl)); } } catch (RabobankSdkException ex) { webShopModel.Error = ex.Message; } catch (ArgumentException ex) { webShopModel.Error = ex.Message; } return(View("Index", webShopModel)); }
private void CreateOrderIfRequired() { if (Session[SESSION_ORDER] == null) { webShopModel = new WebShopModel(GetOrder(++orderId)); SessionVar.Set <WebShopModel>(SESSION_ORDER, webShopModel); } }
public HomeController() { if (omniKassa == null) { omniKassa = Endpoint.Create(Environment.SANDBOX, SIGNING_KEY, TOKEN); } webShopModel = SessionVar.Get <WebShopModel>(SESSION_ORDER); if (webShopModel != null) { orderId = webShopModel.OrderId; orderItemId = webShopModel.GetLastItemId(); } }
public static MerchantOrder PrepareOrder(NameValueCollection collection, WebShopModel model) { Decimal totalPrice = model.GetTotalPrice(); if (totalPrice > 0.0m) { Address shippingDetails = CreateShippingDetails(collection); Address billingDetails = CreateBillingDetails(collection); CustomerInformation customerInformation = CreateCustomerInformation(collection); PaymentBrand? paymentBrand = CreatePaymentBrand(collection); PaymentBrandForce? paymentBrandForce = CreatePaymentBrandForce(collection); return(model.PrepareMerchantOrder(totalPrice, customerInformation, shippingDetails, billingDetails, paymentBrand, paymentBrandForce)); } else { model.Error = "Total amount must be greater than zero."; } return(null); }