public chargebackRetrievalResponse RetrieveByActionable(bool actionable)
        {
            var xmlResponse = SendRetrievalRequest(
                string.Format(ServiceRoute + "/?actionable={0}", actionable));

            return(ChargebackUtils.DeserializeResponse <chargebackRetrievalResponse>(xmlResponse));
        }
        public chargebackRetrievalResponse RetrieveByArn(string arn)
        {
            var xmlResponse = SendRetrievalRequest(string.Format(ServiceRoute + "/?arn={0}",
                                                                 arn));

            return(ChargebackUtils.DeserializeResponse <chargebackRetrievalResponse>(xmlResponse));
        }
        public chargebackRetrievalResponse RetrieveByCaseId(long caseId)
        {
            var xmlResponse = SendRetrievalRequest(
                string.Format(ServiceRoute + "/{0}", caseId));

            return(ChargebackUtils.DeserializeResponse <chargebackRetrievalResponse>(xmlResponse));
        }
        public chargebackRetrievalResponse RetrieveByActivityDate(DateTime date)
        {
            var queryDate   = date.ToString("yyyy-MM-dd");
            var xmlResponse = SendRetrievalRequest(ServiceRoute + "/?date=" + queryDate);

            return(ChargebackUtils.DeserializeResponse <chargebackRetrievalResponse>(xmlResponse));
        }
        public chargebackRetrievalResponse RetrieveByActivityDateWithImpact(DateTime date, bool financialImpact)
        {
            var queryDate            = date.ToString("yyyy-MM-dd");
            var queryFinancialImpact = financialImpact.ToString();
            var xmlResponse          = SendRetrievalRequest(string.Format(ServiceRoute + "/?date={0}&financialOnly={1}",
                                                                          queryDate, queryFinancialImpact));

            return(ChargebackUtils.DeserializeResponse <chargebackRetrievalResponse>(xmlResponse));
        }
        public chargebackRetrievalResponse RetrieveByCardNumber(string cardNumber, int month, int year)
        {
            var expirationDate      = new DateTime(year, month, 1);
            var queryExpirationDate = expirationDate.ToString("MMyy");
            var xmlResponse         = SendRetrievalRequest(
                string.Format(ServiceRoute + "/?cardNumber={0}&expirationDate={1}",
                              cardNumber, queryExpirationDate));

            return(ChargebackUtils.DeserializeResponse <chargebackRetrievalResponse>(xmlResponse));
        }
        private void ConfigureCommunication()
        {
            _communication.SetHost(Config.Get("host"));
            var encoded = ChargebackUtils.Encode64(Config.Get("username") + ":" + Config.Get("password"), "utf-8");

            _communication.AddToHeader("Authorization", "Basic " + encoded);
            _communication.SetContentType("application/com.vantivcnp.services-v2+xml");
            _communication.SetAccept("application/com.vantivcnp.services-v2+xml");
            if (!String.IsNullOrEmpty(Config.Get("proxyHost")) && !String.IsNullOrEmpty(Config.Get("proxyPort")))
            {
                _communication.SetProxy(Config.Get("proxyHost"), int.Parse(Config.Get("proxyPort")));
            }
        }
Exemple #8
0
        private void ConfigureCommunication()
        {
            _communication.SetHost(Config.Get("host"));
            string encoded = ChargebackUtils.Encode64(
                Config.Get("username") + ":" + Config.Get("password"), "utf-8");

            _communication.AddToHeader("Authorization", "Basic " + encoded);
            if (!String.IsNullOrEmpty(Config.Get("proxyHost")) && !String.IsNullOrEmpty(Config.Get("proxyPort")))
            {
                _communication.SetProxy(Config.Get("proxyHost"), int.Parse(Config.Get("proxyPort")));
            }
            _communication.SetContentType(null);
        }
 private string SendRetrievalRequest(string urlRoute)
 {
     try
     {
         ConfigureCommunication();
         var responseContent = _communication.Get(urlRoute);
         var receivedBytes   = responseContent.GetByteData();
         var xmlResponse     = ChargebackUtils.BytesToString(receivedBytes);
         ChargebackUtils.PrintXml(xmlResponse, Config.Get("printXml"), Config.Get("neuterXml"));
         return(xmlResponse);
     }
     catch (WebException we)
     {
         throw ChargebackRetrievalWebException(we);
     }
 }
        private ChargebackWebException ChargebackRetrievalWebException(WebException we)
        {
            var webErrorResponse = (HttpWebResponse)we.Response;
            var httpStatusCode   = (int)webErrorResponse.StatusCode;
            var rawResponse      = ChargebackUtils.GetResponseXml(webErrorResponse);

            if (!webErrorResponse.ContentType.Contains("application/com.vantivcnp.services-v2+xml"))
            {
                return(new ChargebackWebException(string.Format("Retrieval Failed - HTTP {0} Error", httpStatusCode), httpStatusCode, rawResponse));
            }
            ChargebackUtils.PrintXml(rawResponse, Config.Get("printXml"), Config.Get("neuterXml"));
            var errorResponse = ChargebackUtils.DeserializeResponse <errorResponse>(rawResponse);
            var errorMessages = errorResponse.errors;

            return(new ChargebackWebException(string.Format("Retrieval Failed - HTTP {0} Error", httpStatusCode), httpStatusCode, rawResponse, errorMessages));
        }
        private chargebackUpdateResponse SendUpdateRequest(long caseId, string xmlBody)
        {
            string xmlRequest = Serialize(xmlBody);

            ChargebackUtils.PrintXml(xmlRequest, Config.Get("printXml"), Config.Get("neuterXml"));
            try
            {
                ConfigureCommunication();
                var responseContent = communication.Put(ServiceRoute + "/" + caseId, ChargebackUtils.StringToBytes(xmlRequest));
                var receivedBytes   = responseContent.GetByteData();
                var xmlResponse     = ChargebackUtils.BytesToString(receivedBytes);
                ChargebackUtils.PrintXml(xmlResponse, Config.Get("printXml"), Config.Get("neuterXml"));
                return(ChargebackUtils.DeserializeResponse <chargebackUpdateResponse>(xmlResponse));
            }
            catch (WebException we)
            {
                throw ChargebackUpdateWebException(we);
            }
        }
Exemple #12
0
        private chargebackDocumentUploadResponse HandleResponse(ResponseContent responseContent)
        {
            var contentType   = responseContent.GetContentType();
            var responseBytes = responseContent.GetByteData();

            if (!contentType.Contains("application/com.vantivcnp.services-v2+xml"))
            {
                var stringResponse = ChargebackUtils.BytesToString(responseBytes);
                throw new ChargebackException(
                          string.Format("Unexpected returned Content-Type: {0}. Call Vantiv immediately!" +
                                        "\nAttempting to read the response as raw text:" +
                                        "\n{1}", contentType, stringResponse));
            }
            var xmlResponse = ChargebackUtils.BytesToString(responseBytes);

            ChargebackUtils.PrintXml(xmlResponse, Config.Get("printXml"), Config.Get("neuterXml"));
            var docResponse
                = ChargebackUtils.DeserializeResponse <chargebackDocumentUploadResponse>(xmlResponse);

            return(docResponse);
        }
Exemple #13
0
        public List <byte> RetrieveDocument(long caseId, string documentId)
        {
            try
            {
                ConfigureCommunication();
                var responseContent = _communication.Get(
                    string.Format(ServiceRoute + "/retrieve/{0}/{1}", caseId, documentId));
                var contentType   = responseContent.GetContentType();
                var responseBytes = responseContent.GetByteData();
                if (!"image/tiff".Equals(contentType))
                {
                    var responseString = ChargebackUtils.BytesToString(responseBytes);
                    var docErrorResponse
                        = ChargebackUtils.DeserializeResponse <chargebackDocumentUploadResponse>(responseString);
                    throw new ChargebackDocumentException(docErrorResponse.responseMessage, docErrorResponse.responseCode, responseString);
                }

                return(responseBytes);
            }
            catch (WebException we)
            {
                throw ChargebackDocumentWebException(we, "Retrieve");
            }
        }
Exemple #14
0
 private void ConfigureCommunicationForUpload(string filePath)
 {
     ConfigureCommunication();
     _communication.SetContentType(ChargebackUtils.GetMimeMapping(Path.GetFileName(filePath)));
 }