public ActionResult PaymentFail(string trans_id = "") { Models.PaymentResultModel model = new Models.PaymentResultModel(); string trID = trans_id; model.trans_id = trID; var order = _orderService.GetOrderByAuthorizationTransactionIdAndPaymentMethod(trID, "Payments.TBCBankCard"); if (order == null) { // Incorect request from bank _logger.Error($"Incorrect trans_id = {trans_id} from Bank. order not found."); model.PaymentResultText = "Error process payment"; model.PaymentSucess = false; return(View(model)); } model.OrderId = order.Id; model.PaymentResultText = "Error process payment"; model.PaymentSucess = false; return(View(model)); }
public ActionResult PaymentSuccess(string trans_id = "") { Models.PaymentResultModel model = new Models.PaymentResultModel(); string trID = trans_id; model.trans_id = trID; var order = _orderService.GetOrderByAuthorizationTransactionIdAndPaymentMethod(trID, "Payments.TBCBankCard"); if (order == null) { // Incorect request from bank _logger.Error($"Incorrect trans_id = {trans_id} from Bank. order not found."); model.PaymentResultText = "Error process payment"; model.PaymentSucess = false; return(View(model)); } model.OrderId = order.Id; try { model.total = order.OrderTotal; model.tax = order.OrderTax; model.shipping = order.OrderShippingInclTax; } catch { } try { model.city = order.ShippingAddress.City; model.country = order.ShippingAddress.Country.Name; model.region = order.ShippingAddress.StateProvince.Name; } catch { model.city = "Tbilisi"; model.country = "Georgia"; model.region = "GE"; } foreach (var i in order.OrderItems) { try { model.items.Add(new Models.PaymentResultSubItemModel() { OrderID = order.Id, Category = i.Product.ProductCategories.ToString(), Product = i.Product.Name, quantity = i.Quantity, SKU = i.Product.Sku, UnitPrice = i.Product.Price }); } catch { } } // get Result Frm Bank string lang = _workContext.WorkingLanguage.UniqueSeoCode; string url = _TbcPaymentSettings.ServiceURL; Debug($"Payment URL = {url}"); string certPath = $@"{HttpContext.Request.PhysicalApplicationPath}Plugins\Payments.TBCBankCard\KeyStore\{_TbcPaymentSettings.CertificatePath}"; Code.Merchant merchant = new Code.Merchant(certPath, _TbcPaymentSettings.SecretPass, url, 30000); string bankPaymentResult = ""; Code.StatusResult CheckResult = null; try { bankPaymentResult = merchant.GetTransResult(new Code.CommandParams(lang) { trans_id = trans_id }); CheckResult = new Code.StatusResult(bankPaymentResult); if (CheckResult.RESULT == "OK") { order.PaymentStatus = Core.Domain.Payments.PaymentStatus.Authorized; order.AuthorizationTransactionCode = CheckResult.RESULT; _orderService.UpdateOrder(order); Debug($"Check result: {CheckResult.RESULT}. Code: {CheckResult.RESULT_CODE}"); model.PaymentResultText = CheckResult.GetResultMSG(lang);// "Payment sucessful"; model.PaymentSucess = true; return(View(model)); } else { order.AuthorizationTransactionCode = bankPaymentResult; _orderService.UpdateOrder(order); model.PaymentResultText = CheckResult.GetResultMSG(lang);//"Payment error."; model.PaymentSucess = false; return(View(model)); } } catch (Exception ex) { _logger.Error($"TBC Paysucces error check transaction :{ex.Message}"); model.PaymentResultText = "Error check transaction."; model.PaymentSucess = false; return(View(model)); } }