本文整理汇总了C#中Uol.PagSeguro.Domain.Credentials类的典型用法代码示例。如果您正苦于以下问题:C# Credentials类的具体用法?C# Credentials怎么用?C# Credentials使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Credentials类属于Uol.PagSeguro.Domain命名空间,在下文中一共展示了Credentials类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CancelPreApproval
/// <summary>
/// CancelPreApproval
/// </summary>
/// <param name="credentials">PagSeguro credentials</param>
/// <param name="preApprovalCode">PreApproval code</param>
/// <returns>The PreApprovalRequestResponse wich contains the response</returns>
public static bool CancelPreApproval(Credentials credentials, string preApprovalCode)
{
PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "PreApprovalService.CancelPreApproval({0}) - begin", preApprovalCode));
try
{
using (HttpWebResponse response = HttpURLConnectionUtil.GetHttpGetConnection(BuildCancelUrl(credentials, preApprovalCode)))
{
if (HttpStatusCode.OK.Equals(response.StatusCode))
{
using (XmlReader reader = XmlReader.Create(response.GetResponseStream()))
{
PreApprovalRequestResponse paymentResponse = new PreApprovalRequestResponse(PagSeguroConfiguration.PreApprovalCancelUri);
PreApprovalSerializer.Read(reader, paymentResponse);
PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "PreApprovalService.CancelPreApproval({0}) - end {1}", preApprovalCode, paymentResponse.Status));
return paymentResponse.Status.Equals("OK", StringComparison.CurrentCultureIgnoreCase);
}
}
else
{
PagSeguroServiceException pse = HttpURLConnectionUtil.CreatePagSeguroServiceException(response);
PagSeguroTrace.Error(String.Format(CultureInfo.InvariantCulture, "PreApprovalService.CancelPreApproval({0}) - error {1}", preApprovalCode, pse));
throw pse;
}
}
}
catch (WebException exception)
{
PagSeguroServiceException pse = HttpURLConnectionUtil.CreatePagSeguroServiceException((HttpWebResponse)exception.Response);
PagSeguroTrace.Error(String.Format(CultureInfo.InvariantCulture, "PreApprovalService.CancelPreApproval({0}) - error {1}", preApprovalCode, pse));
throw pse;
}
}
示例2: GetInstallments
/// <summary>
/// Request a direct payment session
/// </summary>
/// <param name="credentials">PagSeguro credentials</param>
/// <returns><c cref="T:Uol.PagSeguro.CancelRequestResponse">Result</c></returns>
public static Installments GetInstallments(Credentials credentials, Decimal amount, String cardBrand)
{
PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "InstallmentService.GetInstallments() - begin"));
try
{
using (HttpWebResponse response = HttpURLConnectionUtil.GetHttpGetConnection(
BuildInstallmentURL(credentials, amount, cardBrand)))
{
using (XmlReader reader = XmlReader.Create(response.GetResponseStream()))
{
Installments result = new Installments();
InstallmentsSerializer.Read(reader, result);
PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "InstallmentService.Register({0}) - end", result.ToString()));
return result;
}
}
}
catch (ArgumentException exception)
{
PagSeguroServiceException pse = new PagSeguroServiceException(exception.Message);
PagSeguroTrace.Error(String.Format(CultureInfo.InvariantCulture, "InstallmentService.Register() - error {0}", exception.Message));
throw pse;
}
catch (WebException exception)
{
PagSeguroServiceException pse = HttpURLConnectionUtil.CreatePagSeguroServiceException((HttpWebResponse)exception.Response);
PagSeguroTrace.Error(String.Format(CultureInfo.InvariantCulture, "InstallmentService.Register() - error {0}", pse));
throw pse;
}
}
示例3: CreateAuthorizationRequest
/// <summary>
/// Creates a new authorization request
/// </summary>
/// <param name="credentials">PagSeguro credentials. Required</param>
/// <param name="authorizationRequest">PagSeguro AuthorizationRequest</param>
/// <param name="onlyAuthorizationCode"></param>
/// <returns></returns>
public static String CreateAuthorizationRequest(Credentials credentials, AuthorizationRequest authorizationRequest, Boolean onlyAuthorizationCode)
{
PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "AuthorizationService.CreateAuthorizationRequest() - begin"));
try
{
using (HttpWebResponse response = HttpURLConnectionUtil.GetHttpPostConnection(
PagSeguroConfiguration.AuthorizarionRequestUri.AbsoluteUri, buildAuthorizationRequestUrl(credentials, authorizationRequest)))
{
using (XmlReader reader = XmlReader.Create(response.GetResponseStream()))
{
AuthorizationResponse authorization = new AuthorizationResponse();
AuthorizationSerializer.Read(reader, authorization);
if (onlyAuthorizationCode) {
return authorization.Code;
} else {
return BuildAuthorizationURL(authorization.Code);
}
}
}
}
catch (WebException pse)
{
throw pse;
}
catch (PagSeguroServiceException pse)
{
throw pse;
}
}
示例4: SearchByCode
/// <summary>
/// Finds a transaction with a matching transaction code
/// </summary>
/// <param name="credentials">PagSeguro credentials</param>
/// <param name="transactionCode">Transaction code</param>
/// <returns cref="T:Uol.PagSeguro.Transaction"><c>Transaction</c></returns>
public static Transaction SearchByCode(Credentials credentials, string transactionCode, bool preApproval)
{
PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "TransactionSearchService.SearchByCode(transactionCode={0}) - begin", transactionCode));
try
{
using (HttpWebResponse response = HttpURLConnectionUtil.GetHttpGetConnection(BuildSearchUrlByCode(credentials, transactionCode, preApproval)))
{
using (XmlReader reader = XmlReader.Create(response.GetResponseStream()))
{
Transaction transaction = new Transaction();
TransactionSerializer.Read(reader, transaction, preApproval);
PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "TransactionSearchService.SearchByCode(transactionCode={0}) - end {1}", transactionCode, transaction));
return transaction;
}
}
}
catch (WebException exception)
{
PagSeguroServiceException pse = HttpURLConnectionUtil.CreatePagSeguroServiceException((HttpWebResponse)exception.Response);
PagSeguroTrace.Error(String.Format(CultureInfo.InvariantCulture, "TransactionSearchService.SearchByCode(transactionCode={0}) - error {1}", transactionCode, pse));
throw pse;
}
}
示例5: CreateCheckout
/// <summary>
/// Create a new transaction checkout
/// </summary>
/// <param name="credentials">PagSeguro credentials</param>
/// <param name="checkout"></param>
/// <returns cref="T:Uol.PagSeguro.Transaction"><c>Transaction</c></returns>
public static Transaction CreateCheckout(Credentials credentials, Checkout checkout)
{
PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "TransactionService.Register() - begin"));
try
{
using (HttpWebResponse response = HttpURLConnectionUtil.GetHttpPostConnection(
PagSeguroConfiguration.TransactionsUri.AbsoluteUri, BuildTransactionUrl(credentials, checkout)))
{
using (XmlReader reader = XmlReader.Create(response.GetResponseStream()))
{
Transaction transaction = new Transaction();
TransactionSerializer.Read(reader, transaction);
PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "TransactionService.Register() - end {0}", transaction));
return transaction;
}
}
}
catch (WebException exception)
{
PagSeguroServiceException pse = HttpURLConnectionUtil.CreatePagSeguroServiceException((HttpWebResponse)exception.Response);
PagSeguroTrace.Error(String.Format(CultureInfo.InvariantCulture, "TransactionService.Register() - error {0}", pse));
throw pse;
}
}
示例6: SearchByCode
/// <summary>
/// Finds a authorization with a matching authorization code
/// </summary>
/// <param name="credentials">PagSeguro credentials. Required.</param>
/// <param name="code">Authorization code. Required</param>
/// <returns>Authorization Summary</returns>
public static AuthorizationSummary SearchByCode(Credentials credentials, String code)
{
PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "AuthorizationSearchService.SearchByCode({0}) - begin", code));
try
{
using (HttpWebResponse response = HttpURLConnectionUtil.GetHttpGetConnection(BuildSearchUrlByCode(credentials, code)))
{
using (XmlReader reader = XmlReader.Create(response.GetResponseStream()))
{
AuthorizationSummary authorization = new AuthorizationSummary();
AuthorizationSummarySerializer.Read(reader, authorization);
return authorization;
}
}
}
catch (WebException exception)
{
throw exception;
}
catch (PagSeguroServiceException pse)
{
throw pse;
}
}
示例7: CreateSession
/// <summary>
/// Request a direct payment session
/// </summary>
/// <param name="credentials">PagSeguro credentials</param>
/// <returns><c cref="T:Uol.PagSeguro.CancelRequestResponse">Result</c></returns>
public static Session CreateSession(Credentials credentials)
{
PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "SessionService.Register() - begin"));
try
{
using (HttpWebResponse response = HttpURLConnectionUtil.GetHttpPostConnection(
PagSeguroConfiguration.SessionUri.AbsoluteUri, BuildSessionURL(credentials)))
{
using (XmlReader reader = XmlReader.Create(response.GetResponseStream()))
{
Session result = new Session();
SessionSerializer.Read(reader, result);
PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "SessionService.Register({0}) - end", result.ToString()));
return result;
}
}
}
catch (WebException exception)
{
PagSeguroServiceException pse = HttpURLConnectionUtil.CreatePagSeguroServiceException((HttpWebResponse)exception.Response);
PagSeguroTrace.Error(String.Format(CultureInfo.InvariantCulture, "SessionService.Register() - error {0}", pse));
throw pse;
}
}
示例8: CheckTransaction
/// <summary>
/// Returns a transaction from a notification code
/// </summary>
/// <param name="credentials">PagSeguro credentials</param>
/// <param name="notificationCode">Transaction notification code</param>
/// <returns><c cref="T:Uol.PagSeguro.Transaction">Transaction</c></returns>
public static Transaction CheckTransaction(Credentials credentials, string notificationCode)
{
PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "NotificationService.CheckTransaction(notificationCode={0}) - begin", notificationCode));
try
{
using (HttpWebResponse response = HttpURLConnectionUtil.GetHttpGetConnection(BuildTransactionNotificationUrl(credentials,notificationCode)))
{
using (XmlReader reader = XmlReader.Create(response.GetResponseStream()))
{
Transaction transaction = new Transaction();
TransactionSerializer.Read(reader, transaction);
PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "NotificationService.CheckTransaction(notificationCode={0}) - end {1}", notificationCode, transaction));
return transaction;
}
}
}
catch (WebException exception)
{
PagSeguroServiceException pse = HttpURLConnectionUtil.CreatePagSeguroServiceException((HttpWebResponse)exception.Response);
PagSeguroTrace.Error(
String.Format(CultureInfo.InvariantCulture, "NotificationService.CheckTransaction(notificationCode={0}) - error {1}", notificationCode, pse));
throw pse;
}
}
示例9: CreateCheckoutRequest
/// <summary>
/// createCheckoutRequest is the actual implementation of the Register method
/// This separation serves as test hook to validate the Uri
/// against the code returned by the service
/// </summary>
/// <param name="credentials">PagSeguro credentials</param>
/// <param name="payment">Payment request information</param>
/// <returns>The Uri to where the user needs to be redirected to in order to complete the payment process</returns>
public static Uri CreateCheckoutRequest(Credentials credentials, PaymentRequest payment)
{
PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "PaymentService.Register({0}) - begin", payment));
try
{
using (HttpWebResponse response = HttpURLConnectionUtil.GetHttpPostConnection(
PagSeguroConfiguration.PaymentUri.AbsoluteUri, BuildCheckoutUrl(credentials, payment)))
{
if (HttpStatusCode.OK.Equals(response.StatusCode))
{
using (XmlReader reader = XmlReader.Create(response.GetResponseStream()))
{
PaymentRequestResponse paymentResponse = new PaymentRequestResponse(PagSeguroConfiguration.PaymentRedirectUri);
PaymentSerializer.Read(reader, paymentResponse);
PagSeguroTrace.Info(String.Format(CultureInfo.InvariantCulture, "PaymentService.Register({0}) - end {1}", payment, paymentResponse.PaymentRedirectUri));
return paymentResponse.PaymentRedirectUri;
}
}
else
{
PagSeguroServiceException pse = HttpURLConnectionUtil.CreatePagSeguroServiceException(response);
PagSeguroTrace.Error(String.Format(CultureInfo.InvariantCulture, "PaymentService.Register({0}) - error {1}", payment, pse));
throw pse;
}
}
}
catch (WebException exception)
{
PagSeguroServiceException pse = HttpURLConnectionUtil.CreatePagSeguroServiceException((HttpWebResponse)exception.Response);
PagSeguroTrace.Error(String.Format(CultureInfo.InvariantCulture, "PaymentService.Register({0}) - error {1}", payment, pse));
throw pse;
}
}
示例10: BuildTransactionNotificationUrl
/// <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();
}
示例11: BuildCancelURL
/// <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();
}
示例12: BuildTransactionNotificationUrl
/// <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();
}
示例13: BuildInstallmentURL
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();
}
示例14: BuildRefundURL
/// <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();
}
示例15: BuildTransactionUrl
/// <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();
}