コード例 #1
0
        public chargebackRetrievalResponse RetrieveByArn(string arn)
        {
            var xmlResponse = SendRetrievalRequest(string.Format(ServiceRoute + "/?arn={0}",
                                                                 arn));

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

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

            return(ChargebackUtils.DeserializeResponse <chargebackRetrievalResponse>(xmlResponse));
        }
コード例 #4
0
        public chargebackRetrievalResponse RetrieveByActionable(bool actionable)
        {
            var xmlResponse = SendRetrievalRequest(
                string.Format(ServiceRoute + "/?actionable={0}", actionable));

            return(ChargebackUtils.DeserializeResponse <chargebackRetrievalResponse>(xmlResponse));
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        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));
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        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);
            }
        }
コード例 #9
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);
        }
コード例 #10
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");
            }
        }