public void PrepaidValidationToAll() { var binding = new WSHttpBinding(SecurityMode.None, true); var client = new BillersListClient(binding, new EndpointAddress(UriContext.BillersList)); var list = client.GetBillersList(Guid.NewGuid().ToString(), GetToken()); var billers = list.Element("MsgBody").Element("BilrsRec").Elements().Select(element => new { code = element.Element("BillerCode").Value, services = element.Element("Services").Elements().Where(w => w.Element("PrepaidCats") == null).Select(s => s.Element("ServiceType").Value) }).OrderBy(o => o.code);//.ToLookup(k=>k.code, k=>k.services); var request = XElement.Parse(GetContentFromFile("PrepaidValidation.xml")); var sign = new EfawateerSigner("ARKAIM-TEST"); foreach (var biller in billers) { var time = DateTime.Now.ToString("s"); var guid = Guid.NewGuid().ToString(); request.Element("MsgHeader").Element("TmStp").Value = time; request.Element("MsgHeader").Element("GUID").Value = guid; request.Element("MsgBody").Element("BillingInfo").Element("AcctInfo").Element("BillerCode").Value = biller.code; foreach (var serviceType in biller.services) { request.Element("MsgBody") .Element("BillingInfo") .Element("ServiceTypeDetails") .Element("ServiceType") .Value = serviceType; //"Prepaid"; request.Element("MsgFooter").Element("Security").Element("Signature").Value = sign.SignData(request.Element("MsgBody").ToString()); var validator = new PrepaidValidationClient(binding, new EndpointAddress(UriContext.PrepaidValidation)); var upload = validator.Validate(guid, GetToken(), request); Debug.WriteLine(string.Format("-----------{0}--------------", biller.code)); Debug.WriteLine("request:\r\n " + request.Element("MsgBody")); Debug.WriteLine("response:\r\n " + upload.Element("MsgBody")); } } }
public void PrepaidValidation() { var binding = new WSHttpBinding(SecurityMode.None, true); var request = XElement.Parse(GetContentFromFile("PrepaidValidation.xml")); var sign = new EfawateerSigner("ARKAIM-TEST"); var time = DateTime.Now.ToString("s"); var guid = Guid.NewGuid().ToString(); request.Element("MsgHeader").Element("TmStp").Value = time; request.Element("MsgHeader").Element("GUID").Value = guid; request.Element("MsgBody").Element("BillingInfo").Element("AcctInfo").Element("BillerCode").Value = "21"; request.Element("MsgBody").Element("BillingInfo").Element("ServiceTypeDetails").Element("ServiceType").Value = "Prepaid"; request.Element("MsgFooter").Element("Security").Element("Signature").Value = sign.SignData(request.Element("MsgBody").ToString()); var client = new PrepaidValidationClient(binding, new EndpointAddress(UriContext.PrepaidValidation)); var upload = client.Validate(guid, GetToken(), request); Debug.WriteLine("PrepaidValidation " + upload); }
public PaymentResult PrepaidValidationRequest(int cyberplatOperatorId, StringList parametersList) { var billerCode = ExpandBillerCodeFromCyberplatOpertaroId(cyberplatOperatorId); var token = Authenticate(); var request = GetRequestContent(Prepadvalrq); var signer = new EfawateerSigner(_certificate); var time = DateTime.Now.ToString("s"); var guid = GenerateGuid(); request.Element("MsgHeader").Element("TmStp").Value = time; request.Element("MsgHeader").Element("TrsInf").Element("SdrCode").Value = _customerCode; request.Element("MsgHeader").Element("GUID").Value = guid; var billInfo = request.Element("MsgBody").Element("BillingInfo"); var accInfo = billInfo.Element("AcctInfo"); accInfo.Element("BillerCode").Value = billerCode.ToString(); if (!parametersList.ContainsKey("BillingNo") || parametersList["BillingNo"].Contains("#")) { accInfo.Element("BillingNo").Remove(); } else { accInfo.Element("BillingNo").Value = parametersList["BillingNo"]; } var serviceTypeDetails = billInfo.Element("ServiceTypeDetails"); serviceTypeDetails.Element("ServiceType").Value = parametersList["ServiceType"]; if (!parametersList.ContainsKey("PrepaidCat")) { serviceTypeDetails.Element("PrepaidCat").Remove(); } else { serviceTypeDetails.Element("PrepaidCat").Value = parametersList["PrepaidCat"]; } if (!parametersList.ContainsKey("DueAmt")) { billInfo.Element("DueAmt").Remove(); } else { billInfo.Element("DueAmt").Value = parametersList["DueAmt"]; } Audit("Validation request:" + request); request.Element("MsgFooter").Element("Security").Element("Signature").Value = signer.SignData(request.Element("MsgBody").ToString()); var service = new PrepaidValidationClient(new WSHttpBinding(SecurityMode.None, true) { ReceiveTimeout = new TimeSpan(0, 0, 0, 0, _timeout) }, new EndpointAddress(_validationUrl)); var response = service.Validate(guid, token, request); Audit("Validation response:" + response); billInfo = response.Element("MsgBody").Element("BillingInfo"); var errorCode = Convert.ToInt32(billInfo.Element("Result").Element("ErrorCode").Value); if (errorCode == 0) { var validationCode = billInfo.Element("ValidationCode").Value; if (parametersList.ContainsKey("ValidationCode")) { parametersList.Remove("ValidationCode"); } parametersList.Add("ValidationCode", validationCode); } return(new PaymentResult { Params = parametersList, Error = errorCode }); }