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 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); } }
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); }
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"); } }