public static void Payment(TransactionInfo transactionInfo) { var reqPay = new RequestPay() { amount = transactionInfo.InputPrice, localIP = AppGlobal.LocalIP, PAN = transactionInfo.Pan, PINBlock = transactionInfo.Pinblock, serial = AppGlobal.Serial, terminalID = AppGlobal.TerminalID, track2Ciphered = transactionInfo.Track2Card }; var cardIssuerBank = AppGlobal.BankCardNumList .FirstOrDefault(w => w.CardNumber == reqPay.PAN.Substring(0, 6)).Name; var PanRecipt = $"{reqPay.PAN.Substring(0, 6)}××××××{reqPay.PAN.Substring(11, 4)}"; var result = HttpHelper.Post("http://37.156.22.197:8080/api/PaymentSrv/PaymentRequest", reqPay); var report = new StiReport(); string ReportName = string.Empty; if (result != null && result.Status != "TransactionFaild") { ReportName = "ReciptSuccess.mrt"; var reportPath = $"{AppDomain.CurrentDomain.BaseDirectory}Recipts\\{ReportName}"; report.Load(reportPath); report.Dictionary.Variables.Add("terminalID", reqPay.terminalID); report.Dictionary.Variables.Add("PAN", PanRecipt); report.Dictionary.Variables.Add("cardIssuerBank", cardIssuerBank); report.Dictionary.Variables.Add("PSPRefNo", result.RefNo ?? string.Empty); report.Dictionary.Variables.Add("systemRefNo", result.ClientRefNo ?? string.Empty); report.Dictionary.Variables.Add("transactionStatus", result.Message); report.Dictionary.Variables.Add("amount", reqPay.amount); } else { ReportName = "ReciptFailed.mrt"; var reportPath = $"{AppDomain.CurrentDomain.BaseDirectory}Recipts\\{ReportName}"; report.Load(reportPath); report.Dictionary.Variables.Add("terminalID", reqPay.terminalID); report.Dictionary.Variables.Add("PAN", PanRecipt); report.Dictionary.Variables.Add("cardIssuerBank", cardIssuerBank); report.Dictionary.Variables.Add("transactionStatus", result != null ? result.Message : "تراکنش ناموفق"); } try { report.Print(false); } catch (Exception) { if (result != null) { result.Message += $"{Environment.NewLine}در حال حاضر امکان چاپ رسید وجود ندارد."; } } }
private string ConvertRequestPayToString(RequestPay requestPay) { var stringBuilder = new StringBuilder(); /*Сразу извиняюсь за подобное, с xml не работал, у нас все в JSON, что успел нахватать за 2 часа, то использовал) палкаи не бить) */ if (requestPay.Key != null) { stringBuilder.Append($"Key={requestPay.Key};"); } if (requestPay.Amount != null) { stringBuilder.Append($"Amount={requestPay.Amount};"); } if (requestPay.Cheque != null) { stringBuilder.Append($"Cheque={requestPay.Cheque};"); } if (requestPay.OrderId != null) { stringBuilder.Append($"OrderId={requestPay.OrderId};"); } if (requestPay.CustomerKey != null) { stringBuilder.Append($"CustomerKey={requestPay.CustomerKey};"); } if (requestPay.CustomFields != null) { stringBuilder.Append($"CustomFields={requestPay.CustomFields};"); } if (requestPay.PayInfo != null) { stringBuilder.Append($"PayInfo={requestPay.PayInfo};"); } if (requestPay.PaytureId != null) { stringBuilder.Append($"PayInfo={requestPay.PayInfo};"); } return(stringBuilder.ToString()); }
public ActionResult Delete(int id) { var data = db.paymenttbl.Where(x => x.payid.Equals(id)).FirstOrDefault(); if (data == null) { return(View(new RequestPay())); } var model = new RequestPay { payid = data.payid, mid = data.mid, name = data.name, phone = data.phone, addr = data.addr, pay = data.payid, paydate = data.paydate, memo = data.memo }; return(View(model)); }
public ActionResult DeleteCheck(RequestPay model) { paymenttbl paymenttbl = new paymenttbl(); paymenttbl.payid = model.payid; paymenttbl.mid = model.mid; paymenttbl.name = model.name; paymenttbl.phone = model.phone; paymenttbl.addr = model.addr; paymenttbl.pay = model.payid; paymenttbl.paydate = model.paydate; paymenttbl.memo = model.memo; db.Entry(paymenttbl).State = System.Data.Entity.EntityState.Deleted; db.paymenttbl.Remove(paymenttbl); db.SaveChanges(); var data = db.paymenttbl.Where(x => x.payid.Equals(paymenttbl.payid)).Select(x => new RequestPay { payid = x.payid, mid = x.mid, name = x.name, phone = x.phone, addr = x.addr, pay = x.payid, paydate = x.paydate, memo = x.memo }).OrderBy(x => x.payid).ToPagedList(1, l_pageSize); var viewModel = new paymenttblsViewModel { RequestPay = data, PageIndex = 1 }; return(View("Index", viewModel)); }
public async Task <ActionResult> Get() { try { /* В полной версии данные запроса принимались бы с фронта * по этому взаимодействие и соеденение данных было бы немного другое */ var payInfo = new PayInfo { PAN = "5218851946955484", EMonth = 12, EYear = 22, CardHolder = "Ivan Ivanov", SecureCode = 123, OrderId = "cd2dc9e4-41fe-da3f-4e78-b7e15c7d58dc", Amount = 12461 }; var requestPay = new RequestPay { Key = "Merchant", Amount = 12517, OrderId = "a3718039-7e6b-373b-315f-53ca1cab5d09" }; var data = ConvertRequestPayToString(requestPay).Replace(";", "&"); var client = new HttpClient(); var response = await client.GetAsync($"{configuration.GetSection("UrlPay").Value}?{data}&PayInfo={ConvertPayInfoToString(payInfo)}"); var result = new ResponsePay { }; if (response.IsSuccessStatusCode) { XDocument doc = XDocument.Parse(response.Content.ReadAsStringAsync().Result); /*Сразу извиняюсь за подобное, с xml не работал, у нас все в JSON, что успел нахватать за 2 часа, то использовал) палкаи не бить) * XML не моя сильная сторона, но за недельку поднатаскаюсь)*/ if (doc.Element("Pay").Attribute("Key") != null) { result.Key = doc.Element("Pay").Attribute("Key").Value; } if (doc.Element("Pay").Attribute("ACSUrl") != null) { result.ACSUrl = doc.Element("Pay").Attribute("ACSUrl").Value; } if (doc.Element("Pay").Attribute("AddInfo") != null) { result.AddInfo = doc.Element("Pay").Attribute("AddInfo").Value; } if (doc.Element("Pay").Attribute("Amount") != null) { result.Amount = doc.Element("Pay").Attribute("Amount").Value; } if (doc.Element("Pay").Attribute("ErrCode") != null) { result.ErrCode = doc.Element("Pay").Attribute("ErrCode").Value; } if (doc.Element("Pay").Attribute("FinalTerminal") != null) { result.FinalTerminal = doc.Element("Pay").Attribute("FinalTerminal").Value; } if (doc.Element("Pay").Attribute("OrderId") != null) { result.OrderId = doc.Element("Pay").Attribute("OrderId").Value; } if (doc.Element("Pay").Attribute("PaReq") != null) { result.PaReq = doc.Element("Pay").Attribute("PaReq").Value; } if (doc.Element("Pay").Attribute("Success") != null) { result.Success = doc.Element("Pay").Attribute("Success").Value; } if (doc.Element("Pay").Attribute("ThreeDSVersion") != null) { result.ThreeDSVersion = doc.Element("Pay").Attribute("ThreeDSVersion").Value; } if (doc.Element("Pay").Attribute("ACSUrl") != null) { result.ACSUrl = doc.Element("Pay").Attribute("ACSUrl").Value; } } return(Ok(new { result })); } catch (Exception ex) { _logger.LogError(ex.Message); return(BadRequest(ex.Message)); } }