public static Messages.Response EpaymentProcess(Messages.Request request) { float amount = request.Parameters.Value <float>("amount"); string device = request.Parameters.Value <string>("device"); string protocol = request.Parameters.Value <string>("protocol"); string port = request.Parameters.Value <string>("port"); string data = request.Parameters.Value <string>("data"); int pos = request.Parameters.Value <int>("pos"); PaymentRequest paymentRequest = new PaymentRequest(amount); ConcertProtocol concertProtocol = ConcertProtocol.find(protocol); concertProtocol.Terminal = new SerialTerminal(port); Issue issue = concertProtocol.SendPaymentRequest(paymentRequest); if (issue.Type == Issue.SUCCESS) { return(request.Success(issue.Response)); } else { return(request.Failure("", issue.Message)); } }
/// <summary> /// /// </summary> /// <param name="request"></param> /// <returns></returns> private Messages.Response ProcessRequest(Messages.Request request) { Messages.Response response = null; if (Handlers.ContainsKey(request.Name)) { Log.Debug("Route request to {0} ", request.Name); try { Handlers.TryGetValue(request.Name, out Handler handler); response = handler.Invoke(request); } catch (Exception e) { response = request.Failure(e.GetType().Name, e.Message); } } else { Log.Debug("No handler defined for {0}", request.Name); response = request.Unknown(String.Format("Unknown request {0}", request.Name)); } return(response); }