static void Main(string[] args) { const string password = "******"; //var p = new UniplatServiceWCFMobicom.UniplatServiceWCFMobicom(); var client = new NS.UniplatService();//UniplatServiceClient(); { Console.WriteLine("Sending DebitMoney"); var paymentNumber = DateTime.Now.Ticks.ToString().Substring(1, 10); var reqBeeline = new NS.ReqDebit() { Amount = 1000, Comment = "Test", PartnerCode = "tst", ServiceId = "13632", //"6889", MSISDN = "9099952793", //"9035618208", //"9168036435",//"9099952793",//"9055812453", PaymentNumber = paymentNumber, PaymentId = Guid.NewGuid().ToString() }; var reqMts = new NS.ReqDebit() { Amount = 1500, Comment = "Test", PartnerCode = "tst", ServiceId = "6889", //"6907", MSISDN = "9104501874", //"9521873493", //"9035618208", //"9168036435",//"9099952793",//"9055812453", PaymentNumber = paymentNumber, PaymentId = Guid.NewGuid().ToString() }; var req = reqMts; req.Hash = GetHash(req.PaymentId + req.PartnerCode + req.ServiceId + req.MSISDN + req.PaymentNumber + req.Amount + password); var resp = client.DebitMoney(req); if (resp.ResultCode == 0) { Console.WriteLine("Succsessfull response received"); Console.WriteLine("Send state request?"); int x = 0; while (Console.ReadLine() == "y") //(x ++ < 10) { var reqState = new NS.ReqState() { PaymentId = req.PaymentId, PartnerCode = "tst" }; reqState.Hash = GetHash(reqState.PaymentId + reqState.PartnerCode + password); resp = client.GetDebitState(reqState); Console.WriteLine(resp.ResultCode + " " + resp.ResultComment); } } else { Console.WriteLine("Bad request. Error code: " + resp.ResultCode); } Console.ReadKey(); } }
/// <summary> /// Запиывает в БД запрос ReqState клиента /// </summary> /// <param name="request">Переданный клиентом запрос</param> /// <returns>Добавленная в БД запись</returns> private ClientMessage LogReqState(ReqState request) { var logEntry = _storage.ClientMessages.CreateObject(); logEntry.Id = Guid.NewGuid(); logEntry.CreateTime = DateTime.Now; logEntry.Method = "GetDebitState"; logEntry.Action = "Request"; logEntry.PaymentId = Truncate(request.PaymentId, 50); logEntry.PartnerCode = Truncate(request.PartnerCode, 3); logEntry.Hash = Truncate(request.Hash, 50); _storage.ClientMessages.AddObject(logEntry); return(logEntry); }
public Resp GetDebitState(ReqState request) { //MobicomMessage initialResponse = null; Func <int, string, Resp> createAndSaveDebitStateResp = (i, com) => CreateAndSaveResp(request.PaymentId, i, com, "GetDebitState", null); try { var initialRequest = LogReqState(request); Guid paymentId; if (!Guid.TryParse(request.PaymentId, out paymentId)) { return(createAndSaveDebitStateResp(2, "Incorrect parameter: PaymentId")); } string wrongParameter; if (!request.CheckParametersRegex(out wrongParameter)) { return(createAndSaveDebitStateResp(2, "Incorrect parameter: " + wrongParameter)); } var payment = _storage.Payments.SingleOrDefault(p => p.Id == paymentId && p.Partner.Code == request.PartnerCode); if (payment == null) { return(createAndSaveDebitStateResp(1, "Unknown pair (PaymentId, PartnerCode)")); } if (!request.CheckHashCode(payment.Partner.Password)) { return(createAndSaveDebitStateResp(4, "Incorrect hash-value")); } if (payment.Status != null && payment.Status.IsTerminal) { return(CreateAndSaveResp(request.PaymentId, payment.Status.PartnerCode, payment.Status.PartnerDescription, "GetDebitState", null)); } var mobiRequest = new MobicomStatusRequest(); mobiRequest.version = payment.Merchant.Bank.ProtocolVersion; mobiRequest.Owner = new Owner { id = payment.OwnerId }; mobiRequest.Agregator = new Agregator { id = payment.Merchant.Bank.AgregarorId }; mobiRequest.hash = GetHash(mobiRequest.Owner.id + payment.Merchant.Bank.Password); LogMobicomStatusRequest(mobiRequest, initialRequest); var mobiClient = new mobicomTypeClient(); var response = mobiClient.MobicomStatusRequestOperation(mobiRequest); return(CreateNLogStateResponse(payment, response)); } catch (Exception e) { Trace.WriteLine("Ошибка в GetDebitState: " + e); return(createAndSaveDebitStateResp(13, "UniplatService internal error")); } finally { TrySaveChanges(); } }
public Resp GetDebitState(ReqState request) { return(CreateRandomResp()); }