Exemple #1
0
        public override TransactionResponse CommitTransaction(TransactionRequest request)
        {
            string dataToSend = buildTransactionRequestString(request);

            var webRequest = new NVPWebRequest(singlePaymentApi);

            webRequest.SendRequest(dataToSend, Encoding.ASCII);

            NVPWebResponse response;

            try
            {
                response = new NVPWebResponse(webRequest.Response);
            }
            catch (Exception e)
            {
                ErrorLogger.Log(e);

                //502 bad gateway error fix (occuring sometimes)
                PayzaTransactionResponse successfulResponse = new PayzaTransactionResponse(this);
                return(successfulResponse);
            }

            return(new PayzaTransactionResponse(this, response.Content));
        }
Exemple #2
0
        private TransactionResponse CommitTransactionMassPay(TransactionRequest request)
        {
            string dataToSend = buildTransactionRequestString(request);

            var webRequest = new NVPWebRequest(singlePaymentApiMassPay);

            webRequest.SendRequest(dataToSend, Encoding.ASCII);

            var response = new NVPWebResponse(webRequest.Response);

            return(new EgoPayTransactionResponse(this, response.Content));
        }
Exemple #3
0
        public static JObject SendRequest(string service, string values)
        {
            try
            {
                var request = new NVPWebRequest(APIEndpoint + service);
                request.SendRequest(values, Encoding.ASCII);

                var rawResponse = new NVPWebResponse(request.Response).RawContent;
                return(JObject.Parse(rawResponse));
            }
            catch (Exception ex)
            {
                ErrorLogger.Log(ex);
                throw new MsgException("Unable to connect to S4DS API");
            }
        }
Exemple #4
0
        public override TransactionResponse CommitTransaction(TransactionRequest request)
        {
            try
            {
                string dataToSend = buildTransactionRequestString(request);

                var webRequest = new NVPWebRequest(apiUrl);
                webRequest.SendRequest(dataToSend);

                var webResponse = new NVPWebResponse(webRequest.Response).RawContent;

                JObject response = JObject.Parse(webResponse);
                return(new PayeerTransactionResponse(this, response));
            }
            catch (Exception ex)
            {
                ErrorLogger.Log(ex);
                return(new PayeerTransactionResponse(this, null, true));
            }
        }
Exemple #5
0
        public override TransactionResponse CommitTransaction(TransactionRequest request)
        {
            using (WebClient client = new WebClient())
            {
                try
                {
                    string queryString = String.Empty;
                    string dataToSend  = buildTransactionRequestString(request, ref queryString);

                    var webRequest = new NVPWebRequest("http://sapamacash.com/api/b2c?" + queryString);
                    webRequest.SendRequest(dataToSend);
                    var responseString = new NVPWebResponse(webRequest.Response).RawContent;

                    return(new MPesaSapamaTransactionResponse(this, JObject.Parse(responseString)));
                }
                catch (WebException ex)
                {
                    ErrorLogger.Log(ex);
                    var resp = new StreamReader(ex.Response.GetResponseStream()).ReadToEnd();
                    throw new MsgException(resp);
                }
            }
        }