public string BuildRepeatRequestUrl(string orderId) { var request = new PayseraRequest { ProjectId = projectId, OrderId = orderId, RepeatRequest = true, Version = AppSettings.Version }; return(BuildRequestUrl(request)); }
public string BuildRequestUrl(PayseraRequest request) { // If request don't provide some data we are trying get it either from client initialization or from application settings if (string.IsNullOrEmpty(request.ProjectId)) { request.ProjectId = projectId; } if (string.IsNullOrEmpty(request.Version)) { request.Version = AppSettings.Version; } if (string.IsNullOrEmpty(request.AcceptUrl)) { request.AcceptUrl = AppSettings.AcceptUrl; } if (string.IsNullOrEmpty(request.CancelUrl)) { request.CancelUrl = AppSettings.CancelUrl; } if (string.IsNullOrEmpty(request.CallbackUrl)) { request.CallbackUrl = AppSettings.CallbackUrl; } var validationResult = request.Validate(); if (validationResult.HasError) { var errorsOfRequestObject = validationResult.Errors.Select(x => x.ErrorMessage); var combinedMessage = errorsOfRequestObject.Aggregate((i, j) => i + "\n" + j); throw new ArgumentException("request", combinedMessage); } var data = request.ToBase64String(); var sign = CryptoUtility.CalculateMd5(data + signPassword); var requestQueryParams = new NameValueCollection { { "data", data }, { "sign", sign } }; var requestQuery = requestQueryParams.ToQueryString(); var paymentUrl = AppSettings.PayUrl; if (string.IsNullOrEmpty(paymentUrl)) { paymentUrl = "https://www.mokejimai.lt/pay/"; } return(string.Format("{0}?{1}", paymentUrl, requestQuery)); }