/// <summary>
 /// Request a transaction cancellation from transaction code
 /// </summary>
 /// <param name="credentials">PagSeguro credentials</param>
 /// <param name="transactionCode">Transaction Code</param>
 /// <returns><c cref="T:Uol.PagSeguro.CancelRequestResponse">Result</c></returns>
 public static RequestResponse RequestCancel(Credentials credentials, string transactionCode)
 {
     PagSeguroTrace.Info(string.Format(CultureInfo.InvariantCulture, "CancelService.Register(transactionCode = {0}) - begin", transactionCode));
     try {
         using (var response = HttpUrlConnectionUtil.GetHttpPostConnection(
                    PagSeguroUris.GetCancelUri(credentials).AbsoluteUri, BuildCancelUrl(credentials, transactionCode)))
         {
             using (var reader = XmlReader.Create(response.GetResponseStream()))
             {
                 var cancel = new RequestResponse();
                 CancelSerializer.Read(reader, cancel);
                 PagSeguroTrace.Info(string.Format(CultureInfo.InvariantCulture, "CancelService.createRequest({0}) - end", cancel.ToString()));
                 return(cancel);
             }
         }
     } catch (WebException exception) {
         var pse = HttpUrlConnectionUtil.CreatePagSeguroServiceException((HttpWebResponse)exception.Response);
         PagSeguroTrace.Error(string.Format(CultureInfo.InvariantCulture, "CancelService.createRequest() - error {0}", pse));
         throw pse;
     }
 }
Exemple #2
0
 /// <summary>
 /// Request a transaction cancellation from transaction code
 /// </summary>
 /// <param name="credentials">PagSeguro credentials</param>
 /// <param name="transactionCode">Transaction Code</param>
 /// <returns><c cref="T:Uol.PagSeguro.CancelRequestResponse">Result</c></returns>
 public static RequestResponse RequestCancel(Credentials credentials, string transactionCode)
 {
     PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "CancelService.Register(transactionCode = {0}) - begin", transactionCode));
     try {
         using (var response = HttpURLConnectionUtil.GetHttpPostConnection(
                    PagSeguroConfiguration.CancelUri.AbsoluteUri, BuildCancelURL(credentials, transactionCode)))
         {
             using (XmlReader reader = XmlReader.Create(response.Content.ReadAsStreamAsync().Result))
             {
                 RequestResponse cancel = new RequestResponse();
                 CancelSerializer.Read(reader, cancel);
                 PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "CancelService.createRequest({0}) - end", cancel.ToString()));
                 return(cancel);
             }
         }
     } catch (System.Exception exception) {
         PagSeguroServiceException pse = HttpURLConnectionUtil.CreatePagSeguroServiceException(exception);
         PagSeguroTrace.Error(String.Format(CultureInfo.InvariantCulture, "CancelService.createRequest() - error {0}", pse));
         throw pse;
     }
 }