コード例 #1
0
ファイル: RefundSerializer.cs プロジェクト: couras/dotnet
        /// <summary>
        /// Read a payment refund request result
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="result"></param>
        public static void Read(XmlReader reader, RequestResponse result)
        {
            if (reader.IsEmptyElement)
            {
                XMLParserUtils.SkipNode(reader);
                return;
            }

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Text:
                        result.Response = reader.Value;
                        break;
                }
            }
        }
コード例 #2
0
ファイル: CancelService.cs プロジェクト: couras/dotnet
        /// <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(HttpWebResponse response = HttpURLConnectionUtil.GetHttpPostConnection(
                    PagSeguroConfiguration.CancelUri.AbsoluteUri, BuildCancelURL(credentials, transactionCode)))
                {

                    using (XmlReader reader = XmlReader.Create(response.GetResponseStream()))
                    {

                        RequestResponse cancel = new RequestResponse();
                        CancelSerializer.Read(reader, cancel);
                        PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "CancelService.createRequest({0}) - end", cancel.ToString()));
                        return cancel;
                    }
                }
            } catch (WebException exception) {
                PagSeguroServiceException pse = HttpURLConnectionUtil.CreatePagSeguroServiceException((HttpWebResponse)exception.Response);
                PagSeguroTrace.Error(String.Format(CultureInfo.InvariantCulture, "CancelService.createRequest() - error {0}", pse));
                throw pse;
            }
        }
コード例 #3
0
ファイル: RefundService.cs プロジェクト: couras/dotnet
        /// <summary>
        /// Request a transaction refund 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 RequestRefund(Credentials credentials, string transactionCode, decimal? refundValue = null)
        {
            PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "RefundService.Register(transactionCode = {0}) - begin", transactionCode));

            try {
                using(HttpWebResponse response = HttpURLConnectionUtil.GetHttpPostConnection(
                    PagSeguroConfiguration.RefundUri.AbsoluteUri, BuildRefundURL(credentials, transactionCode, refundValue)))
                {

                    using (XmlReader reader = XmlReader.Create(response.GetResponseStream()))
                    {

                        RequestResponse refund = new RequestResponse();
                        RefundSerializer.Read(reader, refund);
                        PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "RefundService.Register({0}) - end", refund.ToString()));
                        return refund;
                    }
                }
            } catch (WebException exception) {
                PagSeguroServiceException pse = HttpURLConnectionUtil.CreatePagSeguroServiceException((HttpWebResponse)exception.Response);
                PagSeguroTrace.Error(String.Format(CultureInfo.InvariantCulture, "RefundService.Register() - error {0}", pse));
                throw pse;
            }
        }