Ejemplo n.º 1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="credentials"></param>
 /// <param name="notificationCode"></param>
 /// <returns></returns>
 private static string BuildTransactionNotificationUrl(Credentials credentials, string notificationCode)
 {
     QueryStringBuilder transactionNotificationUrl = new QueryStringBuilder("{url}/{notificationCode}?{credential}");
     transactionNotificationUrl.ReplaceValue("{url}", PagSeguroConfiguration.NotificationUri.AbsoluteUri);
     transactionNotificationUrl.ReplaceValue("{notificationCode}", HttpUtility.UrlEncode(notificationCode));
     transactionNotificationUrl.ReplaceValue("{credential}", new QueryStringBuilder().EncodeCredentialsAsQueryString(credentials).ToString());
     return transactionNotificationUrl.ToString();
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="credentials">PagSeguro credentials</param>
        /// <param name="transactionCode">Transaction Code</param>
        /// <returns></returns>
        private static string BuildCancelURL(Credentials credentials, string transactionCode)
        {
            QueryStringBuilder builder = new QueryStringBuilder();

            builder.EncodeCredentialsAsQueryString(credentials);
            builder.Append("transactionCode", transactionCode);

            return builder.ToString();
        }
Ejemplo n.º 3
0
        private static String BuildInstallmentURL(Credentials credentials, Decimal amount, String cardBrand)
        {
            QueryStringBuilder builder = new QueryStringBuilder("{url}?{credentials}&amount={amount}&cardBrand={cardBrand}");

            builder.ReplaceValue("{url}", PagSeguroConfiguration.InstallmentUri.AbsoluteUri);
            builder.ReplaceValue("{credentials}", new QueryStringBuilder().EncodeCredentialsAsQueryString(credentials).ToString());
            builder.ReplaceValue("{amount}", PagSeguroUtil.DecimalFormat(amount));
            builder.ReplaceValue("{cardBrand}", HttpUtility.UrlEncode(cardBrand.ToString()));

            return builder.ToString();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="credentials"></param>
 /// <param name="notificationCode"></param>
 /// <returns></returns>
 private static string BuildTransactionNotificationUrl(Credentials credentials, string notificationCode, bool preApproval)
 {
     QueryStringBuilder transactionNotificationUrl = new QueryStringBuilder("{url}/{notificationCode}?{credential}");
     if (preApproval == true)
         transactionNotificationUrl.ReplaceValue("{url}", PagSeguroConfiguration.CurrentConfig.PreApprovalNotificationUrl.AbsoluteUri);
     else
         transactionNotificationUrl.ReplaceValue("{url}", PagSeguroConfiguration.CurrentConfig.NotificationUrl.AbsoluteUri);
     transactionNotificationUrl.ReplaceValue("{notificationCode}", HttpUtility.UrlEncode(notificationCode));
     transactionNotificationUrl.ReplaceValue("{credential}", new QueryStringBuilder().EncodeCredentialsAsQueryString(credentials).ToString());
     return transactionNotificationUrl.ToString();
 }
Ejemplo n.º 5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="credentials">PagSeguro credentials</param>
        /// <param name="transactionCode">Transaction Code</param>
        /// <param name="refundValue">Refund Value</param>
        /// <returns></returns>
        private static string BuildRefundURL(Credentials credentials, string transactionCode, decimal? refundValue)
        {
            QueryStringBuilder builder = new QueryStringBuilder();

            builder.EncodeCredentialsAsQueryString(credentials);
            builder.Append("transactionCode", transactionCode);
            if (refundValue.HasValue) {
                builder.Append("refundValue", PagSeguroUtil.DecimalFormat(refundValue.Value));
            }

            return builder.ToString();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="credentials"></param>
        /// <param name="payment"></param>
        /// <returns></returns>
        internal static string BuildTransactionUrl(Credentials credentials, Checkout checkout)
        {
            QueryStringBuilder builder = new QueryStringBuilder();
            IDictionary<string, string> data = TransactionParse.GetData(checkout);

            builder.
                EncodeCredentialsAsQueryString(credentials);

            foreach (KeyValuePair<string, string> pair in data)
            {
                builder.Append(pair.Key, pair.Value);
            }

            return builder.ToString();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="credentials"></param>
        /// <param name="reference"></param>
        /// <param name="initialDate"></param>
        /// <param name="finalDate"></param>
        /// <param name="pageNumber"></param>
        /// <param name="resultsPerPage"></param>
        /// <returns></returns>
        private static string BuildSearchUrlByReference(Credentials credentials, String reference, DateTime initialDate, DateTime finalDate, int? pageNumber, int? resultsPerPage)
        {
            QueryStringBuilder builder = new QueryStringBuilder("{url}?reference={reference}&initialDate={initialDate}{finalDate}{page}{maxPageResults}{credential}");

            builder.ReplaceValue("{url}", PagSeguroConfiguration.PreApprovalSearchUri.AbsoluteUri);
            builder.ReplaceValue("{reference}", HttpUtility.UrlEncode(reference));
            builder.ReplaceValue("{initialDate}", PagSeguroUtil.FormatDateXml(initialDate));
            builder.ReplaceValue("{finalDate}", finalDate < DateTime.MaxValue ? "&" + FinalDateParameterName + "=" + PagSeguroUtil.FormatDateXml(finalDate) : "");
            if (pageNumber.HasValue)
            {
                builder.ReplaceValue("{page}", pageNumber > 0 ? "&" + PageNumberParameterName + "=" + pageNumber : "");
            }
            if (resultsPerPage.HasValue)
            {
                builder.ReplaceValue("{maxPageResults}", resultsPerPage > 0 ? "&" + MaxPageResultsParameterName + "=" + resultsPerPage : "");
            }
            builder.ReplaceValue("{credential}", credentials != null ? new QueryStringBuilder().AppendToQuery("&").EncodeCredentialsAsQueryString(credentials).ToString() : "");

            return PagSeguroUtil.RemoveExtraSpaces(builder.ToString());
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="credentials"></param>
        /// <param name="notificationCode"></param>
        /// <returns></returns>
        private static string BuildSearchUrlByNotification(Credentials credentials, string notificationCode)
        {
            QueryStringBuilder searchUrlByNotification;

            searchUrlByNotification = new QueryStringBuilder("{url}/notifications/{notificationCode}?{credential}");
            searchUrlByNotification.ReplaceValue("{url}", PagSeguroConfiguration.PreApprovalSearchUri.AbsoluteUri);
            searchUrlByNotification.ReplaceValue("{notificationCode}", HttpUtility.UrlEncode(notificationCode));

            searchUrlByNotification.ReplaceValue("{credential}", new QueryStringBuilder().EncodeCredentialsAsQueryString(credentials).ToString());
            return searchUrlByNotification.ToString();
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="credentials"></param>
        /// <param name="interval"></param>
        /// <returns></returns>
        private static string BuildSearchUrlByInterval(Credentials credentials, int interval)
        {
            QueryStringBuilder searchUrlByInterval;

            searchUrlByInterval = new QueryStringBuilder("{url}/notifications?{credential}&interval={interval}");
            searchUrlByInterval.ReplaceValue("{url}", PagSeguroConfiguration.PreApprovalSearchUri.AbsoluteUri);
            searchUrlByInterval.ReplaceValue("{interval}", HttpUtility.UrlEncode(interval.ToString()));
            searchUrlByInterval.ReplaceValue("{credential}", new QueryStringBuilder().EncodeCredentialsAsQueryString(credentials).ToString());
            return searchUrlByInterval.ToString();
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        internal static String BuildAuthorizationURL(String code)
        {
            QueryStringBuilder builder = new QueryStringBuilder("{URL}?code={code}");
            builder.ReplaceValue("{URL}", PagSeguroConfiguration.AuthorizarionUri.AbsoluteUri);
            builder.ReplaceValue("{code}", code);

            return builder.ToString();
        }
Ejemplo n.º 11
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="credentials"></param>
 /// <param name="notificationCode"></param>
 /// <returns></returns>
 private static string BuildAuthorizationNotificationUrl(Credentials credentials, string notificationCode)
 {
     QueryStringBuilder builder = new QueryStringBuilder("{url}{notificationCode}?{credential}");
     builder.ReplaceValue("{url}", PagSeguroConfiguration.AuthorizationNotificationUri.AbsoluteUri);
     builder.ReplaceValue("{notificationCode}", HttpUtility.UrlEncode(notificationCode));
     builder.ReplaceValue("{credential}", new QueryStringBuilder().EncodeCredentialsAsQueryString(credentials).ToString());
     return builder.ToString();
 }
Ejemplo n.º 12
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="credentials"></param>
        /// <param name="transactionCode"></param>
        /// <returns></returns>
        private static string BuildSearchUrlByCode(Credentials credentials, string transactionCode, bool preApproval)
        {
            QueryStringBuilder searchUrlByCode;

            if (preApproval == true)
            {
                searchUrlByCode = new QueryStringBuilder("{url}/{preApprovalCode}?{credential}");
                searchUrlByCode.ReplaceValue("{url}", PagSeguroConfiguration.PreApprovalSearchUri.AbsoluteUri);
                searchUrlByCode.ReplaceValue("{preApprovalCode}", HttpUtility.UrlEncode(transactionCode));
            }
            else
            {
                searchUrlByCode = new QueryStringBuilder("{url}/{transactionCode}?{credential}");
                searchUrlByCode.ReplaceValue("{url}", PagSeguroConfiguration.PreApprovalSearchUri.AbsoluteUri);
                searchUrlByCode.ReplaceValue("{transactionCode}", HttpUtility.UrlEncode(transactionCode));
            }

            searchUrlByCode.ReplaceValue("{credential}", new QueryStringBuilder().EncodeCredentialsAsQueryString(credentials).ToString());
            return searchUrlByCode.ToString();
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="credentials"></param>
        /// <param name="preApproval"></param>
        /// <returns></returns>
        internal static string BuildPreApprovalUrl(Credentials credentials, PreApprovalRequest preApproval)
        {
            QueryStringBuilder builder = new QueryStringBuilder();
            IDictionary<string, string> data = PreApprovalParse.GetData(preApproval);

            builder.
                EncodeCredentialsAsQueryString(credentials);

            foreach (KeyValuePair<string, string> pair in data)
            {
                builder.Append(pair.Key, pair.Value);
            }

            return builder.ToString();
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="credentials"></param>
        /// <param name="initialDate"></param>
        /// <param name="finalDate"></param>
        /// <param name="pageNumber"></param>
        /// <param name="resultsPerPage"></param>
        /// <returns></returns>
        internal static String BuildSearchUrlByDate(Credentials credentials, DateTime initialDate, DateTime finalDate, int? pageNumber = null, int? resultsPerPage = null)
        {
            QueryStringBuilder builder = new QueryStringBuilder("{URL}?{credentials}&initialDate={initialDate}{finalDate}{page}{maxPageResults}");
            builder.ReplaceValue("{URL}", PagSeguroConfiguration.AuthorizarionSearchUri.AbsoluteUri);
            builder.ReplaceValue("{initialDate}", PagSeguroUtil.FormatDateXml(initialDate));
            builder.ReplaceValue("{finalDate}", finalDate < DateTime.MaxValue ? "&" + FinalDateParameterName + "=" + PagSeguroUtil.FormatDateXml(finalDate) : "");

            if (pageNumber.HasValue) {
                builder.ReplaceValue("{page}", pageNumber > 0 ? "&" + PageNumberParameterName + "=" + pageNumber : "" );
            }
            if (pageNumber.HasValue)
            {
                builder.ReplaceValue("{maxPageResults}", resultsPerPage > 0 ? "&" + MaxPageResultsParameterName + "=" + resultsPerPage : "");
            }

            builder.ReplaceValue("{credentials}", new QueryStringBuilder().EncodeCredentialsAsQueryString(credentials).ToString());

            return PagSeguroUtil.RemoveExtraSpaces(builder.ToString());
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="credentials"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        internal static String BuildSearchUrlByCode(Credentials credentials, String code)
        {
            QueryStringBuilder builder = new QueryStringBuilder("{URL}{code}?{credentials}");
            builder.ReplaceValue("{URL}", PagSeguroConfiguration.AuthorizarionSearchUri.AbsoluteUri);
            builder.ReplaceValue("{code}", code);
            builder.ReplaceValue("{credentials}", new QueryStringBuilder().EncodeCredentialsAsQueryString(credentials).ToString() );

            return builder.ToString();
        }
Ejemplo n.º 16
0
 private static String BuildSessionURL(Credentials credentials)
 {
     QueryStringBuilder builder = new QueryStringBuilder();
     builder.EncodeCredentialsAsQueryString(credentials);
     return builder.ToString();
 }
Ejemplo n.º 17
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="credentials"></param>
        /// <param name="payment"></param>
        /// <returns></returns>
        internal static string BuildCheckoutUrl(Credentials credentials, PaymentRequest payment)
        {
            QueryStringBuilder builder = new QueryStringBuilder();
            IDictionary<string, string> data = PaymentParse.GetData(payment);

            builder.
                EncodeCredentialsAsQueryString(credentials);
            
            foreach (KeyValuePair<string, string> pair in data)
            {
                builder.Append(pair.Key, pair.Value);
            }

            return builder.ToString();
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="credentials"></param>
        /// <param name="reference"></param>
        /// <returns></returns>
        private static string BuildSearchUrlByReference(Credentials credentials, string reference)
        {
            QueryStringBuilder searchUrlByReference;

            searchUrlByReference = new QueryStringBuilder("{url}?{credentials}&reference={reference}");
            searchUrlByReference.ReplaceValue("{url}", PagSeguroConfiguration.SearchUri.AbsoluteUri);
            searchUrlByReference.ReplaceValue("{reference}", HttpUtility.UrlEncode(reference));
            searchUrlByReference.ReplaceValue("{credentials}", new QueryStringBuilder().EncodeCredentialsAsQueryString(credentials).ToString());

            return searchUrlByReference.ToString();
        }
Ejemplo n.º 19
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="credentials"></param>
 /// <param name="preApprovalCode"></param>
 /// <returns></returns>
 private static string BuildCancelUrl(Credentials credentials, string preApprovalCode)
 {
     QueryStringBuilder searchUrlByCode = new QueryStringBuilder("{url}/{preApprovalCode}?{credential}");
     searchUrlByCode.ReplaceValue("{url}", PagSeguroConfiguration.PreApprovalCancelUri.AbsoluteUri);
     searchUrlByCode.ReplaceValue("{preApprovalCode}", HttpUtility.UrlEncode(preApprovalCode));
     searchUrlByCode.ReplaceValue("{credential}", new QueryStringBuilder().EncodeCredentialsAsQueryString(credentials).ToString());
     return searchUrlByCode.ToString();
 }
Ejemplo n.º 20
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        internal static string buildAuthorizationRequestUrl(Credentials credentials, AuthorizationRequest authorizationRequest)
        {
            QueryStringBuilder builder = new QueryStringBuilder();
            IDictionary<string, string> data = AuthorizationParse.GetData(authorizationRequest);

            builder.
                EncodeCredentialsAsQueryString(credentials);

            foreach (KeyValuePair<string, string> pair in data)
            {
                builder.Append(pair.Key, pair.Value.ToString(CultureInfo.InvariantCulture));
            }

            return HttpUtility.UrlDecode(builder.ToString());
        }
Ejemplo n.º 21
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="credentials"></param>
 /// <param name="initialDate"></param>
 /// <param name="finalDate"></param>
 /// <param name="pageNumber"></param>
 /// <param name="resultsPerPage"></param>
 /// <returns></returns>
 private static string BuildSearchUrlByDate(Credentials credentials, DateTime initialDate, DateTime finalDate, int pageNumber, int resultsPerPage, bool preApproval)
 {
     QueryStringBuilder searchUrlByCode = new QueryStringBuilder("{url}/?initialDate={initialDate}{finalDate}{page}{maxPageResults}{credential}");
     if (preApproval == true)
         searchUrlByCode.ReplaceValue("{url}", PagSeguroConfiguration.PreApprovalSearchUri.AbsoluteUri);
     else
         searchUrlByCode.ReplaceValue("{url}", PagSeguroConfiguration.SearchUri.AbsoluteUri);
     searchUrlByCode.ReplaceValue("{initialDate}", PagSeguroUtil.FormatDateXml(initialDate));
     searchUrlByCode.ReplaceValue("{finalDate}", finalDate < DateTime.MaxValue ? "&" + FinalDateParameterName + "=" + PagSeguroUtil.FormatDateXml(finalDate) : "");
     searchUrlByCode.ReplaceValue("{page}", pageNumber > 0 ? "&" + PageNumberParameterName + "=" + pageNumber : "");
     searchUrlByCode.ReplaceValue("{maxPageResults}", resultsPerPage > 0 ? "&" + MaxPageResultsParameterName + "=" + resultsPerPage : "");
     searchUrlByCode.ReplaceValue("{credential}", credentials != null ? new QueryStringBuilder().AppendToQuery("&").EncodeCredentialsAsQueryString(credentials).ToString() : "");
     return PagSeguroUtil.RemoveExtraSpaces(searchUrlByCode.ToString());
 }
Ejemplo n.º 22
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="credentials"></param>
        /// <param name="initialDate"></param>
        /// <param name="finalDate"></param>
        /// <param name="pageNumber"></param>
        /// <param name="resultsPerPage"></param>
        /// <returns></returns>
        private static string BuildSearchUrlAbandoned(Credentials credentials, DateTime initialDate, DateTime finalDate, int? pageNumber, int? resultsPerPage)
        {
            QueryStringBuilder searchUrlAbandoned = new QueryStringBuilder("{url}/abandoned?initialDate={initialDate}{finalDate}{credential}");

            searchUrlAbandoned.ReplaceValue("{url}", PagSeguroConfiguration.SearchAbandonedUri.AbsoluteUri);
            searchUrlAbandoned.ReplaceValue("{initialDate}", PagSeguroUtil.FormatDateXml(initialDate));
            searchUrlAbandoned.ReplaceValue("{finalDate}", finalDate < DateTime.MaxValue ? "&" + FinalDateParameterName + "=" + PagSeguroUtil.FormatDateXml(finalDate) : "");

            if (pageNumber.HasValue)
                searchUrlAbandoned.AppendToQuery("{page}").ReplaceValue("{page}", pageNumber > 0 ? "&" + PageNumberParameterName + "=" + pageNumber : "");

            if (resultsPerPage.HasValue)
                searchUrlAbandoned.AppendToQuery("{maxPageResults}").ReplaceValue("{maxPageResults}", resultsPerPage > 0 ? "&" + MaxPageResultsParameterName + "=" + resultsPerPage : "");

            searchUrlAbandoned.ReplaceValue("{credential}", credentials != null ? new QueryStringBuilder().AppendToQuery("&").EncodeCredentialsAsQueryString(credentials).ToString() : "");

            return PagSeguroUtil.RemoveExtraSpaces(searchUrlAbandoned.ToString());
        }