public void Ensure_order_can_only_be_cancelled_when_orderStatus_is_not_cancelled_yet() { /* * if OrderStatus hasn't status of "cancelled" * then OrderStatus.CanCancelOrder should return true */ var order = new Order(); foreach (OrderStatus os in Enum.GetValues(typeof(OrderStatus))) { foreach (PaymentStatus ps in Enum.GetValues(typeof(PaymentStatus))) { foreach (ShippingStatus ss in Enum.GetValues(typeof(ShippingStatus))) { order.OrderStatus = os; order.PaymentStatus = ps; order.ShippingStatus = ss; if (os != OrderStatus.Cancelled) { Assert.IsTrue(_orderProcessingService.CanCancelOrder(order)); } else { Assert.IsFalse(_orderProcessingService.CanCancelOrder(order)); } } } } }
public void Ensure_order_can_only_be_cancelled_when_orderStatus_is_not_cancelled_yet() { var order = new Order(); foreach (OrderStatus os in Enum.GetValues(typeof(OrderStatus))) { foreach (PaymentStatus ps in Enum.GetValues(typeof(PaymentStatus))) { foreach (ShippingStatus ss in Enum.GetValues(typeof(ShippingStatus))) { order.OrderStatus = os; order.PaymentStatus = ps; order.ShippingStatus = ss; if (os != OrderStatus.Cancelled) { _orderProcessingService.CanCancelOrder(order).ShouldBeTrue(); } else { _orderProcessingService.CanCancelOrder(order).ShouldBeFalse(); } } } } }
public async System.Threading.Tasks.Task <IActionResult> OrderRefreshAsync(int orderId = 0) { if (orderId > 0) { Order lastOrder = (await _orderService.GetOrderByIdAsync(orderId)); if (lastOrder != null) { if (lastOrder.PaymentMethodSystemName.ToLower().Equals("payments.param")) { if (lastOrder.PaymentStatus == PaymentStatus.Pending) { if (_orderProcessingService.CanCancelOrder(lastOrder)) { await _orderProcessingService.DeleteOrderAsync(lastOrder); await _orderProcessingService.ReOrderAsync(lastOrder); return(RedirectToRoute("Checkout")); } } } } return(RedirectToRoute("OrderDetails", new { orderId = orderId })); } return(RedirectToRoute("Cart")); }
/// <summary> /// Cancel Order /// </summary> /// <returns>Return to either homepage or order details page</returns> public IActionResult CancelOrder() { var orderReferenceId = _webHelper.QueryString <string>("reference_id"); if (!(_paymentPluginManager.LoadPluginBySystemName("Payments.Sezzle") is SezzlePaymentProcessor processor) || !_paymentPluginManager.IsPluginActive(processor)) { throw new NopException("Sezzle Standard module cannot be loaded"); } Guid orderNumberGuid = Guid.Empty; try { orderNumberGuid = new Guid(orderReferenceId); } catch { return(RedirectToAction("Index", "Home", new { area = string.Empty })); } var order = _orderService.GetOrderByGuid(orderNumberGuid); if (order == null) { return(RedirectToAction("Index", "Home", new { area = string.Empty })); } else if (_orderProcessingService.CanCancelOrder(order)) { _orderProcessingService.CancelOrder(order, true); return(RedirectToRoute("OrderDetails", new { orderId = order.Id })); } return(RedirectToAction("Index", "Home", new { area = string.Empty })); }
private void UpdateOrderStatus(Order order, string status) { status = status.ToLower(); switch (status) { case "failed": case "revoked": { //mark order as canceled if ((order.PaymentStatus == PaymentStatus.Paid || order.PaymentStatus == PaymentStatus.Authorized) && _orderProcessingService.CanCancelOrder(order)) { _orderProcessingService.CancelOrder(order, true); } } break; case "ok": { //mark order as paid if (_orderProcessingService.CanMarkOrderAsPaid(order) && status.ToUpper() == "PAID") { _orderProcessingService.MarkOrderAsPaid(order); } } break; } }
public virtual IActionResult CancelOrder(IFormCollection form) { string id = Request.Query["id"]; if (!string.IsNullOrEmpty(id)) { //return RedirectToRoute("OrderDetails", new { orderId = id }); if (int.TryParse(id, out int orderId)) { // Get order that was canceled Order order = _orderService.GetOrderById(orderId); if (order != null) { if (order.OrderStatus == OrderStatus.Pending && _orderProcessingService.CanCancelOrder(order)) { // Reorder items - place order items in shopping cart. _orderProcessingService.ReOrder(order); // Delete the order to avoid customer confusion _orderProcessingService.DeleteOrder(order); } // Redirect customer to shopping cart return(RedirectToRoute("ShoppingCart")); } } } return(RedirectToAction("Index", "Home", new { area = "" })); }
/// <summary> /// Cancel /// </summary> /// <param name="order">Order</param> private void MarkOrderAsCancelled(Core.Domain.Orders.Order order) { if (_orderProcessingService.CanCancelOrder(order)) { _orderProcessingService.CancelOrder(order, true); } }
public IActionResult CancelOrder() { var order = _orderService.SearchOrders(storeId: _storeContext.CurrentStore.Id, customerId: _workContext.CurrentCustomer.Id, pageSize: 1).FirstOrDefault(); Order cancelOrder = null; if (order != null) { cancelOrder = _orderService.GetOrderByGuid(order.OrderGuid); /*if (Guid.TryParse(order.Id, out Guid orderGuid)) * { * cancelOrder = _orderService.GetOrderByGuid(orderGuid); * }*/ if (cancelOrder != null) { if (_orderProcessingService.CanCancelOrder(cancelOrder)) { _orderProcessingService.CancelOrder(cancelOrder, false); } } return(RedirectToRoute("OrderDetails", new { orderId = order.Id })); } return(RedirectToRoute("HomePage")); }
public ActionResult IPNHandler(FormCollection form) { var processor = GetPaymentProcessor(); TransactionStatus txnStatus; if (processor.VerifyIpn(form, out txnStatus)) { var val = GetValue(Constants.OK_INVOICE_KEY, form); int orderId; if (!String.IsNullOrEmpty(val) && Int32.TryParse(val, out orderId)) { var order = _orderService.GetOrderById(orderId); if (_orderProcessingService.CanMarkOrderAsPaid(order) && txnStatus == TransactionStatus.Completed) { _orderProcessingService.MarkOrderAsPaid(order); } else if ((order.PaymentStatus == PaymentStatus.Paid || order.PaymentStatus == PaymentStatus.Authorized) && _orderProcessingService.CanCancelOrder(order) && txnStatus != TransactionStatus.Completed) { _orderProcessingService.CancelOrder(order, true); } var sb = new StringBuilder(); sb.AppendLine("OkPay IPN:"); sb.Append(PreparationOrderNote(form)); sb.AppendLine("New transaction status: " + txnStatus); order.OrderNotes.Add(new OrderNote { Note = sb.ToString(), DisplayToCustomer = false, CreatedOnUtc = DateTime.UtcNow }); _orderService.UpdateOrder(order); } else { var sb = new StringBuilder(); sb.AppendLine("OkPay error: failed order identifier"); sb.AppendLine("Transaction status: " + txnStatus); sb.Append(PreparationOrderNote(form)); _logger.Error("OkPay IPN failed.", new NopException(sb.ToString())); } } else { var sb = new StringBuilder(); sb.AppendLine("Transaction status: " + txnStatus); sb.Append(PreparationOrderNote(form)); _logger.Error("OkPay IPN failed.", new NopException(sb.ToString())); } return(Content("")); }
private ActionResult UpdateOrderStatus(Order order, string status) { status = status.ToUpper(); var textToResponse = "Your order has been paid"; switch (status) { case "CANCELED": { //mark order as canceled if ((order.PaymentStatus == PaymentStatus.Paid || order.PaymentStatus == PaymentStatus.Authorized) && _orderProcessingService.CanCancelOrder(order)) { _orderProcessingService.CancelOrder(order, true); } textToResponse = "Your order has been canceled"; } break; case "AUTHORIZED": { //mark order as authorized if (_orderProcessingService.CanMarkOrderAsAuthorized(order)) { _orderProcessingService.MarkAsAuthorized(order); } textToResponse = "Your order has been authorized"; } break; case "PAID": { //mark order as paid if (_orderProcessingService.CanMarkOrderAsPaid(order) && status.ToUpper() == "PAID") { _orderProcessingService.MarkOrderAsPaid(order); } } break; default: { return(GetResponse("Unsupported status")); } } return(GetResponse(textToResponse, true)); }
//NOP 3.823 public ActionResult Cancel(int orderId) { var order = _orderService.GetOrderById(orderId); if (order == null || order.Deleted || _workContext.CurrentCustomer.Id != order.CustomerId) { return(new HttpUnauthorizedResult()); } //Add some more validation check if (_orderProcessingService.CanCancelOrder(order)) { _orderProcessingService.CancelOrder(order, true); } return(RedirectToRoute("CustomerOrders")); }
private void OrderCanceled(Order order) { if (_orderProcessingService.CanCancelOrder(order)) { _orderProcessingService.CancelOrder(order, false); } order.OrderNotes.Add(new OrderNote { Note = $"Order id {order.Id}. PayU order canceled.", DisplayToCustomer = false, CreatedOnUtc = DateTime.UtcNow }); _orderService.UpdateOrder(order); }
// customer can cancel order from his account 11-6-2018 public ActionResult Cancel(int orderId) { var order = _orderService.GetOrderById(orderId); //I comment this two lines if (order == null || order.Deleted || _workContext.CurrentCustomer.Id != order.CustomerId) { return(Challenge()); } //Add some more validation check if (_orderProcessingService.CanCancelOrder(order)) { _orderProcessingService.CancelOrder(order, true); } return(RedirectToRoute("CustomerOrders")); }
public IActionResult QuickCheckoutWebhook() { try { //validate request var isValid = _serviceManager.ValidateWebhookRequest(Request.Form); if (!isValid) { return(BadRequest()); } var orderGuid = Guid.Parse(Request.Form["transaction_id"]); var order = _orderService.GetOrderByGuid(orderGuid); if (order == null && _serviceManager.GetPaymentFlowType() == PaymentFlowType.Inline) { //order isn't placed //try save the Skrill transaction_id for further processing if (int.TryParse(Request.Form["nop_customer_id"].ToString(), out var customerId)) { var customer = _customerService.GetCustomerById(customerId); if (customer != null) { //status 2 - payment transaction was successful if (Request.Form["status"].ToString().ToLower() == "2" && Request.Form.TryGetValue("mb_transaction_id", out var transactionId)) { _genericAttributeService.SaveAttribute(customer, Defaults.PaymentTransactionIdAttribute, transactionId.ToString()); } } } } else { if (order == null) { return(Ok()); } //add order note var details = Request.Form.Aggregate(string.Empty, (message, parameter) => $"{message}{parameter.Key}: {parameter.Value}; "); _orderService.InsertOrderNote(new OrderNote { OrderId = order.Id, Note = $"Webhook details: {Environment.NewLine}{details}", DisplayToCustomer = false, CreatedOnUtc = DateTime.UtcNow }); //check transaction status switch (Request.Form["status"].ToString().ToLower()) { //order cancelled case "-3": case "-2": case "-1": if (Enum.TryParse <FailedReasonCode>(Request.Form["failed_reason_code"], out var failedReason)) { _orderService.InsertOrderNote(new OrderNote { OrderId = order.Id, Note = $"Order cancelled. Reason: {failedReason}", DisplayToCustomer = false, CreatedOnUtc = DateTime.UtcNow }); } if (_orderProcessingService.CanCancelOrder(order)) { _orderProcessingService.CancelOrder(order, true); } break; //order pending case "0": order.OrderStatus = OrderStatus.Pending; _orderService.UpdateOrder(order); _orderProcessingService.CheckOrderStatus(order); break; //order processed case "2": if (_orderProcessingService.CanMarkOrderAsPaid(order)) { if (Request.Form.TryGetValue("mb_transaction_id", out var transactionId)) { order.CaptureTransactionId = transactionId; } _orderService.UpdateOrder(order); _orderProcessingService.MarkOrderAsPaid(order); } break; } } } catch { } return(Ok()); }
/// <summary> /// Gets a value indicating whether cancel is allowed /// </summary> /// <param name="order">Order</param> /// <returns>A value indicating whether cancel is allowed</returns> public bool CanCancelOrder(Order order) { return(_orderProcessingService.CanCancelOrder(order)); }
//public IActionResult PayGateNotifyHandler(IFormCollection form) public void PayGateNotifyHandler(IFormCollection form) { /** * Enable IPN if it is set */ if (_payGatePaymentSettings.EnableIpn) { Response.WriteAsync("OK"); var reference = Request.Query["pgnopcommerce"]; bool isPaid; _logger.Information("PayGateNotifyHandler start. Order no.: " + reference); //var order = _orderService.GetOrderById(Int32.Parse(Request.Query["pgnopcommerce"])); var order = _orderService.GetOrderById(Int32.Parse(Request.Form["USER1"])); _logger.Information("PayGateNotifyHandler: Order Payment Status: " + order.PaymentStatus); isPaid = order.PaymentStatus == PaymentStatus.Paid ? true : false; if (!isPaid) { var sBuilder = new StringBuilder(); var query_status = PaymentStatus.Pending; var payrequestId = ""; var transactionStatus = ""; var testMode = _payGatePaymentSettings.TestMode; var paygateId = "10011072130"; var encryptionKey = "secret"; if (!testMode) { paygateId = _payGatePaymentSettings.PayGateID; encryptionKey = _payGatePaymentSettings.EncryptionKey; } //Validate checksum for the posted form fields var formData = new NameValueCollection(); var formDataJS = ""; string[] keys = Request.Form.Keys.ToArray(); for (int i = 0; i < keys.Length; i++) { formData[keys[i]] = Request.Form[keys[i]]; formDataJS += keys[i] + "=" + formData[keys[i]] + "&"; } _logger.Information("PayGateNotifyHandler: POST: " + formDataJS); var checksum = formData["CHECKSUM"]; var checkstring = ""; for (var i = 0; i < formData.Count - 1; i++) { checkstring += formData[i]; } checkstring += encryptionKey; var ourChecksum = new PayGateHelper().CalculateMD5Hash(checkstring); if (ourChecksum.Equals(checksum, StringComparison.OrdinalIgnoreCase)) { var trans_status = formData["TRANSACTION_STATUS"]; transactionStatus = trans_status; var query_status_desc = ""; payrequestId = formData["PAY_REQUEST_ID"]; switch (trans_status) { case "1": query_status = PaymentStatus.Paid; query_status_desc = "Approved"; break; case "2": query_status = PaymentStatus.Voided; query_status_desc = "Declined"; break; case "4": query_status = PaymentStatus.Voided; query_status_desc = "Cancelled By Customer with back button on payment page"; break; case "0": query_status = PaymentStatus.Voided; query_status_desc = "Not Done"; break; default: break; } sBuilder.AppendLine("PayGate Notify Handler"); sBuilder.AppendLine("PayGate Query Data"); sBuilder.AppendLine("======================="); sBuilder.AppendLine("PayGate Transaction_Id: " + formData["TRANSACTION_ID"]); sBuilder.AppendLine("PayGate Status Desc: " + query_status_desc); sBuilder.AppendLine(""); //order note order.OrderNotes.Add(new OrderNote { Note = sBuilder.ToString(),//sbbustring.Format("Order status has been changed to {0}", PaymentStatus.Paid), DisplayToCustomer = false, CreatedOnUtc = DateTime.UtcNow }); _orderService.UpdateOrder(order); //load settings for a chosen store scope var storeScope = this.GetActiveStoreScopeConfiguration(_storeService, _workContext); var payGatePaymentSettings = _settingService.LoadSetting <PayGatePaymentSettings>(storeScope); //mark order as paid if (query_status == PaymentStatus.Paid) { if (_orderProcessingService.CanMarkOrderAsPaid(order)) { order.AuthorizationTransactionId = payrequestId; _orderService.UpdateOrder(order); _orderProcessingService.MarkOrderAsPaid(order); } RedirectToRoute("CheckoutCompleted", new { orderId = order.Id }); } else { order.AuthorizationTransactionId = payrequestId; OrderNote note = new OrderNote(); note.CreatedOnUtc = DateTime.Now; note.DisplayToCustomer = true; note.Note = "Payment failed with the following description: " + transactionStatus; if (_orderProcessingService.CanCancelOrder(order)) { _orderProcessingService.CancelOrder(order, false); } order.OrderNotes.Add(note); _orderService.UpdateOrder(order); RedirectToRoute("OrderDetails", new { orderId = order.Id.ToString().Trim() }); } } else { _logger.Error("PayGateNotifyHandler: Checksum mismatch: " + ourChecksum + " : " + checksum); } } } }
public IActionResult s2sHandler() { string errorCode = "", errorDesc = ""; string strRequest = Request.QueryString.ToString().Replace("?", ""); Dictionary <string, string> values; var processor = _paymentPluginManager.LoadPluginBySystemName("Payments.GestPay") as GestPayPaymentProcessor; if (processor == null || !_paymentPluginManager.IsPluginActive(processor)) { throw new NopException("GestPay module cannot be loaded"); } processor.GetResponseDetails(strRequest, out values); if (values != null && values.Count > 0) { if (values.Count == 4) { return(RedirectToRoute("Plugin.Payments.GestPay.AcceptPaymenyByLink", new { a = values["a"], status = values["Status"], paymentId = values["paymentID"], paymentToken = values["paymentToken"] })); } var shopLogin = values["a"]; var encString = values["b"]; string shopTransactionId = "", authorizationCode = "", bankTransactionId = ""; string transactionResult = "", buyerName = "", buyerEmail = "", riskified = "", authorizationcode = "", threeDSAuthenticationLevel = ""; var acceptedThreeDSAuthLevels = new List <string> { "1H", "1F", "2F", "2C", "2E" }; var checkAmount = decimal.Zero; var sb = new StringBuilder(); sb.AppendLine("GestPay s2s:"); if (processor.IsShopLoginChecked(shopLogin) && encString != null) { var endpoint = _gestPayPaymentSettings.UseSandbox ? WSCryptDecryptSoapClient.EndpointConfiguration.WSCryptDecryptSoap12Test : WSCryptDecryptSoapClient.EndpointConfiguration.WSCryptDecryptSoap12; var objDecrypt = new WSCryptDecryptSoapClient(endpoint); string xmlResponse = objDecrypt.DecryptAsync(shopLogin, encString, _gestPayPaymentSettings.ApiKey).Result.OuterXml; XmlDocument XMLReturn = new XmlDocument(); XMLReturn.LoadXml(xmlResponse.ToLower()); //_logger.Information(xmlResponse.ToLower()); //Id transazione inviato errorCode = XMLReturn.SelectSingleNode("/gestpaycryptdecrypt/errorcode")?.InnerText; errorDesc = XMLReturn.SelectSingleNode("/gestpaycryptdecrypt/errordescription")?.InnerText; //authorizationCode = XMLReturn.SelectSingleNode("/gestpaycryptdecrypt/authorizationcode")?.InnerText; shopTransactionId = XMLReturn.SelectSingleNode("/gestpaycryptdecrypt/shoptransactionid")?.InnerText; //_____ Messaggio OK _____// if (errorCode == "0") { //Codice autorizzazione authorizationCode = XMLReturn.SelectSingleNode("/gestpaycryptdecrypt/authorizationcode")?.InnerText; //Codice transazione bankTransactionId = XMLReturn.SelectSingleNode("/gestpaycryptdecrypt/banktransactionid")?.InnerText; //Ammontare della transazione var amount = XMLReturn.SelectSingleNode("/gestpaycryptdecrypt/amount")?.InnerText; //Risultato transazione transactionResult = XMLReturn.SelectSingleNode("/gestpaycryptdecrypt/transactionresult")?.InnerText; //Nome dell'utente buyerName = XMLReturn.SelectSingleNode("/gestpaycryptdecrypt/buyer/buyername")?.InnerText; //Email utilizzata nella transazione buyerEmail = XMLReturn.SelectSingleNode("/gestpaycryptdecrypt/buyer/buyeremail")?.InnerText; //__________ ?validare il totale? __________// riskified = XMLReturn.SelectSingleNode("/gestpaycryptdecrypt/riskresponsedescription")?.InnerText; // 3DS authentication level (1H,1F,2F,2C,2E) threeDSAuthenticationLevel = XMLReturn.SelectSingleNode("/gestpaycryptdecrypt/threeds/authenticationresult/authenticationlevel")?.InnerText?.ToUpper(); try { checkAmount = decimal.Parse(amount, new CultureInfo("en-US")); } catch (Exception exc) { _logger.Error("GestPay s2s. Error getting Amount", exc); } sb.AppendLine("GestPay success."); } else { sb.AppendLine("GestPay failed."); _logger.Error("GestPay S2S. Transaction not found", new NopException(sb.ToString())); } } //________ Inizio composizione messaggio dal server _________// foreach (var kvp in values) { sb.AppendLine(kvp.Key + ": " + kvp.Value); } //Recupero lo stato del pagamento var newPaymentStatus = GestPayHelper.GetPaymentStatus(transactionResult, ""); sb.AppendLine("New payment status: " + newPaymentStatus); sb.AppendLine("Riskified = " + riskified); sb.AppendLine("3DS Level = " + threeDSAuthenticationLevel); //Cerco di recuperare l'ordine var orderNumberGuid = Guid.Empty; try { orderNumberGuid = new Guid(shopTransactionId); } catch { } var order = _orderService.GetOrderByGuid(orderNumberGuid); //_________ aggiorno lo stato dell'ordine _________// if (order != null) { switch (newPaymentStatus) { case PaymentStatus.Pending: { } break; case PaymentStatus.Authorized: { if (_orderProcessingService.CanMarkOrderAsAuthorized(order)) { _orderProcessingService.MarkAsAuthorized(order); } } break; case PaymentStatus.Paid: { if (_orderProcessingService.CanMarkOrderAsPaid(order)) { order.AuthorizationTransactionId = bankTransactionId; order.AuthorizationTransactionCode = authorizationCode; _orderService.UpdateOrder(order); if (!_gestPayPaymentSettings.EnableGuaranteedPayment || acceptedThreeDSAuthLevels.Contains(threeDSAuthenticationLevel)) { _orderProcessingService.MarkOrderAsPaid(order); } } } break; case PaymentStatus.Refunded: { if (_orderProcessingService.CanRefundOffline(order)) { _orderProcessingService.RefundOffline(order); } } break; case PaymentStatus.Voided: { /*_ Visto che non si può impostare il pagamento ad Annullato * _orderProcessingService.CanVoidOffline allora cancello l'ordine. * C'è da decidere se avvisare o meno l'utente _*/ if (_orderProcessingService.CanCancelOrder(order)) { _orderProcessingService.CancelOrder(order, true); } } break; } //__________________ salvo i valori restituiti __________________// sb.AppendLine("GestPay response:"); //Codice Errore sb.AppendLine("ErrorCode: " + errorCode); //Descrizione Errore sb.AppendLine("ErrorDesc: " + errorDesc); sb.AppendLine("TrxResult: " + transactionResult); sb.AppendLine("BankTrxID: " + bankTransactionId); sb.AppendLine("AuthCode: " + authorizationCode); sb.AppendLine("Amount: " + checkAmount); if (!Math.Round(checkAmount, 2).Equals(Math.Round(order.OrderTotal, 2))) { //__________ ?validare il totale? __________// sb.AppendLine(String.Format("Amount difference: {0}-{1}", Math.Round(checkAmount, 2), Math.Round(order.OrderTotal, 2))); } sb.AppendLine("BuyerName: " + buyerName); sb.AppendLine("BuyerEmail: " + buyerEmail); //Inserisco la nota sull'ordine var orderNote = new OrderNote { OrderId = order.Id, Note = sb.ToString(), DisplayToCustomer = false, CreatedOnUtc = DateTime.UtcNow }; _orderService.InsertOrderNote(orderNote); } else { _logger.Error("GestPay S2S. Order is not found", new NopException(sb.ToString())); } } else { _logger.Error("GestPay S2S failed.", new NopException(strRequest)); } //_________ Imposto il risultato __________// var s2SResponse = "KO"; if (errorCode == "0") { s2SResponse = "OK"; } //nothing should be rendered to visitor return(Content(String.Format("<html>{0}</html>", s2SResponse))); }
public void ProcessPostBackModel(PostBackModel model) { if (model == null) { return; } var orderId = GetOrderId(model.ORDERID); var requestFields = new SortedDictionary <string, string>(); var keyValueCollection = (Request.RequestType == "POST") ? Request.Form : Request.QueryString; var sb = new StringBuilder("Ogone Postback Fields:\r\n"); foreach (string key in keyValueCollection) { if (!key.ToUpper().Equals("SHASIGN")) { requestFields.Add(key, keyValueCollection[key]); } sb.AppendFormat("{0}={1};\r\n", key, keyValueCollection[key]); } var order = _orderService.GetOrderById(orderId); if (order == null) { _logger.InsertLog(LogLevel.Error, "Invalid order id", string.Format("Ogone Postback Error. Order id {0} not found.", orderId)); return; } AddOrderNote(order, sb.ToString(), false); var processor = _paymentService.LoadPaymentMethodBySystemName("Payments.Ogone") as OgonePaymentProcessor; if (processor == null || !processor.IsPaymentMethodActive(_paymentSettings) || !processor.PluginDescriptor.Installed) { throw new NopException("Ogone Payment module cannot be loaded"); } if (processor.VerifyHashDigest(requestFields, model.SHASIGN) == false) { AddOrderNote(order, "Ogone Postback Error. SHA-digest verification failed", false); return; } var paymentStatus = OgoneHelper.GetPaymentStatus(model.STATUS.ToString(), model.NCERROR); switch (paymentStatus) { case PaymentStatus.Authorized: if (_orderProcessingService.CanMarkOrderAsAuthorized(order)) { _orderProcessingService.MarkAsAuthorized(order); } break; case PaymentStatus.Paid: if (_orderProcessingService.CanMarkOrderAsPaid(order)) { _orderProcessingService.MarkOrderAsPaid(order); } break; case PaymentStatus.Pending: break; case PaymentStatus.Voided: if (_orderProcessingService.CanCancelOrder(order)) { _orderProcessingService.CancelOrder(order, notifyCustomer: true); } break; } }