public void BillInquiry() { var binding = new WSHttpBinding(SecurityMode.None, true); var request = XElement.Parse(GetContentFromFile("BillInquiry.xml")); var sign = new EfawateerSigner("ARKAIM-TEST"); var time = DateTime.Now.ToString("s"); request.Element("MsgHeader").Element("TmStp").Value = time; request.Element("MsgFooter").Element("Security").Element("Signature").Value = sign.SignData(request.Element("MsgBody").ToString()); var client = new BillInquiryClient(binding, new EndpointAddress(UriContext.BillInquiry)); var upload = client.Inquire(Guid.NewGuid().ToString(), GetToken(), request); Debug.WriteLine("BillInquiry " + upload); }
public PaymentResult BillInquiryRequest(int cyberplatOperatorId, StringList parametersList) { var billerCode = ExpandBillerCodeFromCyberplatOpertaroId(cyberplatOperatorId); var token = Authenticate(); var request = GetRequestContent(Bilinqrq); var signer = new EfawateerSigner(_certificate); var now = DateTime.Now; var time = now.ToString("s"); var guid = GenerateGuid(); request.Element("MsgHeader").Element("TmStp").Value = time; request.Element("MsgHeader").Element("TrsInf").Element("SdrCode").Value = _customerCode; var billInfo = request.Element("MsgBody"); var accInfo = billInfo.Element("AcctInfo"); accInfo.Element("BillerCode").Value = billerCode.ToString(CultureInfo.InvariantCulture); if (!parametersList.ContainsKey("BillingNo") || parametersList["BillingNo"].Contains("#")) { accInfo.Element("BillingNo").Remove(); } else { accInfo.Element("BillingNo").Value = parametersList["BillingNo"]; } billInfo.Element("ServiceType").Value = parametersList.Get("ServiceType"); var dateRange = billInfo.Element("DateRange"); dateRange.Element("StartDt").Value = now.AddDays(-_startdt).ToString("s"); dateRange.Element("EndDt").Value = time; Audit("BillInquiryRequest request:" + request); request.Element("MsgFooter").Element("Security").Element("Signature").Value = signer.SignData(request.Element("MsgBody").ToString()); var service = new BillInquiryClient(new WSHttpBinding(SecurityMode.None, true) { ReceiveTimeout = new TimeSpan(0, 0, 0, 0, _timeout) }, new EndpointAddress(_inquiryUrl)); var response = service.Inquire(guid, token, request); Audit("BillInquiryRequest response:" + response); var errorCode = Convert.ToInt32(response.Element("MsgHeader").Element("Result").Element("ErrorCode").Value); if (errorCode != 0) { return new PaymentResult { Params = parametersList, Error = errorCode } } ; errorCode = 0; if (response.Element("MsgBody") == null) { errorCode = 10; } else if (response.Element("MsgBody").Element("BillsRec") == null) { errorCode = 11; } else { var billRec = response.Element("MsgBody").Element("BillsRec").Element("BillRec"); if (billRec.Element("OpenDate") != null) { var openDate = DateTime.Parse(billRec.Element("OpenDate").Value); if (openDate > now) { errorCode = 12; } //throw new Exception("Невозможно выполнить оплату счет в будущем (OpenDate)"); } else { var dueDate = DateTime.Parse(billRec.Element("DueDate").Value); if (dueDate > now) { errorCode = 13; } //throw new Exception("Невозможно выполнить оплату счет в будущем (DueDate)"); } if (billRec.Element("ExpiryDate") != null) { var expiryDate = DateTime.Parse(billRec.Element("ExpiryDate").Value); if (expiryDate < now) { errorCode = 14; } //throw new Exception("Невозможно выполнить оплату счет в прошлом (ExpiryDate)"); } if (billRec.Element("CloseDate") != null) { var closeDate = DateTime.Parse(billRec.Element("CloseDate").Value); if (closeDate < now) { errorCode = 15; } //throw new Exception("Невозможно выполнить оплату счет в прошлом (CloseDate)"); } if (errorCode == 0) { var dueAmt = billRec.Element("DueAmount").Value; var inqRefNo = string.Empty; if (billRec.Element("InqRefNo") != null) { inqRefNo = billRec.Element("InqRefNo").Value; } var pmtConst = billRec.Element("PmtConst"); var lower = pmtConst.Element("Lower").Value; var upper = pmtConst.Element("Upper").Value; var allowPart = pmtConst.Element("AllowPart").Value; parametersList.Add("INQREFNO", inqRefNo); if (parametersList.ContainsKey("DueAmt")) { parametersList.Remove("DueAmt"); } parametersList.Add("DueAmt", dueAmt); parametersList.Add("AllowPart", allowPart); parametersList.Add("LOWERAMOUNT", lower); parametersList.Add("UPPERAMOUNT", upper); } } return(new PaymentResult { Params = parametersList, Error = errorCode }); }