public ActionResult Notification() { var response = new BoolResponse { IsValid = false, Message = "" }; response.RecordId = Request.Params["bid"]; // this can hppen in situation when bid is suffixed to eth query string twice breaking the whole code /// so a simple handling fro the same has been put in /// if (response.RecordId.Contains(",")) { var tmpId = response.RecordId.Split(','); response.RecordId = tmpId[0]; } PaymentModel payment = null; var settingResponse = _checkoutApi.PaymentSetting(PaymentMethodTypes.MasterCard.ToString()); var setting = settingResponse.Result; var mcard = new MasterCardApi(setting); if (Request["orderId"] != null) { var refOrderId = Request["transId"]; string orderId = Request.Params["orderId"]; var orderResponse = _orderApi.GetOrdDetail(Sanitizer.GetSafeHtmlFragment(refOrderId)); var order = orderResponse.Result; string paymentId = orderId.Split('-')[1]; payment = order.Payments.FirstOrDefault(x => x.Id == paymentId); var paymentRequest = new PostProcessPaymentRequest { CurrencyCode = order.CurrencyCode, Order = order, OrderTotal = payment.OrderAmount, Payment = payment, }; var paymentResponse = setting.PostProcessPayment(paymentRequest); _checkoutApi.UpdatePayment(refOrderId, paymentResponse.Payment); response.RecordId = order.Id; response.IsValid = paymentResponse.Success; if (!response.IsValid) { response.RecordId = Request.Params["bid"]; if (paymentResponse.Errors.Any()) { response.Message = paymentResponse.Errors[0]; } } else { SiteUtils.ResetBasketCookieAndSession(); } } return(View(CustomViews.PAYMENT_RESPONSE, response)); }
public virtual ActionResult ReOrder(string id) { var result = _orderRepository.GetOrdDetail(Sanitizer.GetSafeHtmlFragment(id)); var model = new List <BasketAddModel>(); if (result.Result != null && result.Result.Items.Any()) { foreach (var item in result.Result.Items) { var line = new BasketAddModel() { StockCode = item.StockCode, Qty = item.Qty, CustomInfo1 = item.CustomInfo1, CustomInfo2 = item.CustomInfo2, CustomInfo3 = item.CustomInfo3, CustomInfo4 = item.CustomInfo4, CustomInfo5 = item.CustomInfo5, ParentProductId = item.ParentProductId.ToString() }; model.Add(line); } } var basket = _basketApi.BulkAddProduct(model); return(JsonSuccess(basket, JsonRequestBehavior.AllowGet)); }
public ActionResult OrderConfirmation(string id) { var response = _orderApi.GetOrdDetail(Sanitizer.GetSafeHtmlFragment(id)); SetDataLayerVariables(response.Result, WebhookEventTypes.CheckoutConfirmation); return(View(CustomViews.ORDER_CONFIRMATION, response.Result)); }
public ActionResult Notification() { var response = new BoolResponse { IsValid = false, Message = "" }; PaymentModel payment = null; var settingResponse = _checkoutApi.PaymentSetting(PaymentMethodTypes.Worldpay.ToString()); var setting = settingResponse.Result; if (Request.QueryString["paymentStatus"] == "AUTHORISED") { //var orderNo = Request.QueryString["orderNo"]; var refOrderId = Request.Params["transId"]; string orderId = Request.Params["orderId"]; var paymentAmount = (Convert.ToDecimal(Request.Params["paymentAmount"]) / 100); var orderResponse = _orderApi.GetOrdDetail(Sanitizer.GetSafeHtmlFragment(refOrderId)); var order = orderResponse.Result; string paymentId = orderId.Split('-')[1]; payment = order.Payments.FirstOrDefault(x => x.Id == paymentId); payment.IsValid = true; payment.Status = PaymentStatus.Paid.GetHashCode(); payment.PaidAmount = paymentAmount; _checkoutApi.UpdatePayment(order.Id, payment); response = new BoolResponse { IsValid = true, RecordId = order.Id }; SetDataLayerVariables(order, WebhookEventTypes.CheckoutPayment); return(View(CustomViews.PAYMENT_RESPONSE, response)); } return(View(CustomViews.PAYMENT_RESPONSE, response)); }
public ActionResult Notification() { var response = new BoolResponse { IsValid = false, Message = "" }; response.RecordId = Request.Params["bid"]; PaymentModel payment = null; var settingRespose = _checkoutApi.PaymentSetting(PaymentMethodTypes.Paypal.ToString()); var setting = settingRespose.Result; if (Request["oid"] != null) { var refOrderId = Request["oid"]; string orderId = Request.Params["oid"]; var orderResponse = _orderApi.GetOrdDetail(Sanitizer.GetSafeHtmlFragment(refOrderId)); var order = orderResponse.Result; string paymentId = Request.Params["payId"]; string token = Request.Params["token"]; string payerId = Request.Params["payerId"]; payment = order.Payments.FirstOrDefault(x => x.Id == paymentId); var paymentRequest = new PostProcessPaymentRequest { CurrencyCode = order.CurrencyCode, Order = order, OrderTotal = payment.OrderAmount, Payment = payment, Token = token, PayerId = payerId }; var paymentResponse = setting.PostProcessPayment(paymentRequest); if (paymentResponse.Success == true) { payment = paymentResponse.Payment; payment.IsValid = true; payment.Status = PaymentStatus.Authorized.GetHashCode(); if (setting.EnableImmediateCapture) { payment.PaidAmount = payment.OrderAmount; payment.Status = PaymentStatus.Paid.GetHashCode(); } _checkoutApi.UpdatePayment(order.Id, payment); SiteUtils.ResetBasketCookieAndSession(); response = new BoolResponse { IsValid = true, RecordId = order.Id }; return(View(CustomViews.PAYMENT_RESPONSE, response)); } // payment.IsValid = false; //payment.Status = PaymentStatus.Authorized.GetHashCode(); // _checkoutApi.UpdatePayment(order.Id, payment); //SiteUtils.ResetBasketCookieAndSession(); // response = new BoolResponse { IsValid = false, RecordId = order.Id }; // return View(CustomViews.PAYMENT_RESPONSE, response); } return(View(CustomViews.PAYMENT_RESPONSE, response)); }
public ActionResult OrderDetail(string id) { var result = _orderRepository.GetOrdDetail(Sanitizer.GetSafeHtmlFragment(id)); result.Result.isB2BEnable = _sessionContext.CurrentSiteConfig.B2BSettings.EnableB2B; result.Result.AllowReorder = _sessionContext.CurrentSiteConfig.B2BSettings.AllowReorder; return(View(CustomViews.ORDER_DETAIL, result.Result)); }
public ActionResult Notification() { var response = new BoolResponse { IsValid = false, Message = "" }; response.RecordId = Request.Params["bid"]; PaymentModel payment = null; var settingRespose = _checkoutApi.PaymentSetting(PaymentMethodTypes.Paypal.ToString()); var setting = settingRespose.Result; if (Request["oid"] != null) { var refOrderId = Request["oid"]; string orderId = Request.Params["oid"]; var orderResponse = _orderApi.GetOrdDetail(Sanitizer.GetSafeHtmlFragment(refOrderId)); var order = orderResponse.Result; string paymentId = Request.Params["payId"]; string token = Request.Params["token"]; string payerId = Request.Params["payerId"]; payment = order.Payments.FirstOrDefault(x => x.Id == paymentId); var paymentRequest = new PostProcessPaymentRequest { CurrencyCode = order.CurrencyCode, Order = order, OrderTotal = payment.OrderAmount, Payment = payment, Token = token, PayerId = payerId }; var paymentResponse = setting.PostProcessPayment(paymentRequest); if (paymentResponse.Success == true) { paymentResponse.Payment.IsValid = true; } _checkoutApi.UpdatePayment(refOrderId, paymentResponse.Payment); response.RecordId = order.Id; response.IsValid = paymentResponse.Success; if (!response.IsValid) { response.RecordId = Request.Params["bid"]; if (paymentResponse.Errors.Any()) { response.Message = paymentResponse.Errors[0]; } } else { SiteUtils.ResetBasketCookie(); } } return(View(CustomViews.PAYMENT_RESPONSE, response)); }
/// <summary> /// Payement response accepted for Cash on Delivery /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult PaymentResponse(string id) { var orderResponse = _orderApi.GetOrdDetail(Sanitizer.GetSafeHtmlFragment(id)); var order = orderResponse.Result; //order.Payment.IsValid = true; //order.Payment.Status = order.Payment.IsValid.GetHashCode(); //_checkoutApi.UpdatePayment(order.Id, order.Payment); var response = new BoolResponse { IsValid = true, RecordId = order.Id }; SetDataLayerVariables(order, WebhookEventTypes.CheckoutPayment); return(View(CustomViews.PAYMENT_RESPONSE, response)); }
/// <summary> /// Klarna create order /// </summary> /// <param name="id">authorizationToken</param> /// <param name="processPaymentRequest"></param> /// <param name="orderId"></param> /// <param name="paymentId"></param> public ActionResult CreateOrder(string id, CheckoutModel processPaymentRequest, string orderId, string paymentId) { var settingResponse = _checkoutApi.PaymentSetting(PaymentMethodTypes.Klarna.ToString()); var setting = settingResponse.Result; var klarna = new KlarnaApi(setting); //var token = klarna.GenerateConsumerToken(processPaymentRequest, id); var orderResp = klarna.CreateOrder(processPaymentRequest, id, orderId, paymentId); var response = new BoolResponse { IsValid = false, Message = "" }; PaymentModel payment = null; if (orderResp.FraudStatus == "ACCEPTED") { var refOrderId = orderResp.RefOrderId; var orderResponse = _orderApi.GetOrdDetail(Sanitizer.GetSafeHtmlFragment(refOrderId)); var order = orderResponse.Result; payment = order.Payments.FirstOrDefault(x => x.Id == orderResp.PaymentId); payment.IsValid = true; payment.Status = PaymentStatus.Paid.GetHashCode(); payment.PaidAmount = (Convert.ToDecimal(orderResp.OrderAmount) / 100); payment.PspResponseCode = orderResp.OrderId; payment.PspResponseMessage = orderResp.FraudStatus; //payment.FraudScore = orderResp.FraudStatus; _checkoutApi.UpdatePayment(order.Id, payment); response = new BoolResponse { IsValid = true, RecordId = order.Id }; SetDataLayerVariables(order, WebhookEventTypes.CheckoutPayment); return(JsonSuccess(new { response = response, notificationUrl = setting.NotificationUrl }, JsonRequestBehavior.AllowGet)); } return(JsonSuccess(new { response = response, notificationUrl = setting.NotificationUrl }, JsonRequestBehavior.AllowGet)); }