public static UrlSettings Create(string orderNumberId, IDictionary <string, string> settings) { var urlSettings = new UrlSettings(); // Build notify Url (PayPal will redirect back to this url after processing OK or FAIL) // This key is sent to PayPal using https so it is not likely it will come from other because // only PayPal knows this key to send back to us string acceptSecurityKey = GetMD5Key(orderNumberId + "accepted"); string cancelSecurityKey = GetMD5Key(orderNumberId + "canceled"); string notifyUrl = UriSupport.AbsoluteUrlBySettings(settings[PayPalConstants.Configuration.SuccessUrl]); string acceptUrl = UriSupport.AddQueryString(notifyUrl, "accept", "true"); acceptUrl = UriSupport.AddQueryString(acceptUrl, "hash", acceptSecurityKey); var cancelUrl = UriSupport.AbsoluteUrlBySettings(settings[PayPalConstants.Configuration.CancelUrl]); cancelUrl = UriSupport.AddQueryString(cancelUrl, "accept", "false"); cancelUrl = UriSupport.AddQueryString(cancelUrl, "hash", cancelSecurityKey); urlSettings.NotifyUrl = notifyUrl; urlSettings.AcceptUrl = acceptUrl; urlSettings.CancelUrl = cancelUrl; return(urlSettings); }
/// <summary> /// Gets the URL. /// </summary> /// <param name="entry">The entry.</param> /// <param name="relationRepository">The relation repository.</param> /// <param name="urlResolver">The URL resolver.</param> /// <param name="language">The language.</param> /// <returns>The Url for the <param name="entry"></param>.</returns> /// <exception cref="T:System.Web.HttpException">The Web application is running under IISĀ 7 in Integrated mode.</exception> /// <exception cref="T:System.InvalidOperationException">The current <see cref="T:System.Uri" /> instance is not an absolute instance.</exception> /// <exception cref="T:System.ArgumentException">The specified <see cref="UriPartial.Authority"/> is not valid.</exception> /// <exception cref="T:System.ArgumentNullException">Parent products are <see langword="null" />.</exception> /// <exception cref="T:System.NotSupportedException">The query collection is read-only.</exception> internal static string GetUrl( this EntryContentBase entry, IRelationRepository relationRepository, UrlResolver urlResolver, string language) { ContentReference parentLink = entry.GetParentProducts(relationRepository: relationRepository).FirstOrDefault(); ContentReference productLink = entry is VariationContent ? entry.GetParentProducts(relationRepository : relationRepository) .FirstOrDefault() ?? entry.ContentLink : entry.ContentLink; UrlBuilder urlBuilder = string.IsNullOrEmpty(value: language) ? new UrlBuilder(urlResolver.GetUrl(contentLink: productLink)) : new UrlBuilder( urlResolver.GetUrl(contentLink: productLink, language: language)); if (parentLink != null && entry.Code != null) { urlBuilder.QueryCollection.Add("variationCode", value: entry.Code); } Global.UrlRewriteProvider.ConvertToExternal(url: urlBuilder, null, toEncoding: Encoding.UTF8); string externalUrl = HttpContext.Current == null ? UriSupport.AbsoluteUrlBySettings(urlBuilder.ToString()) : $"{HttpContext.Current.Request.Url.GetLeftPart(part: UriPartial.Authority)}{urlBuilder}"; return(externalUrl); }
private PaymentProcessingResult ProcessPaymentCheckout(IPayment payment, ICart cart) { var merchRef = DateTime.Now.Ticks.ToString(); payment.Properties[DataCashMerchantReferencePropertyName] = merchRef; // A unique reference number for each transaction (Min 6, max 30 alphanumeric character) var notifyUrl = UriSupport.AbsoluteUrlBySettings(Utilities.GetUrlFromStartPageReferenceProperty("DataCashPaymentPage")); notifyUrl = UriUtil.AddQueryString(notifyUrl, "accept", "true"); notifyUrl = UriUtil.AddQueryString(notifyUrl, "hash", Utilities.GetSHA256Key(merchRef + "accepted")); var requestDoc = _requestDocumentCreation.CreateDocumentForPaymentCheckout(cart, payment, notifyUrl); var responseDoc = DocumentHelpers.SendTransaction(requestDoc, _dataCashConfiguration.Config); string redirectUrl; if (DocumentHelpers.IsSuccessful(responseDoc)) { redirectUrl = $"{responseDoc.get("Response.HpsTxn.hps_url")}?HPS_SessionID={responseDoc.get("Response.HpsTxn.session_id")}"; payment.Properties[DataCashReferencePropertyName] = responseDoc.get("Response.datacash_reference"); } else { return(PaymentProcessingResult.CreateUnsuccessfulResult(DocumentHelpers.GetErrorMessage(responseDoc))); } _orderRepository.Save(cart); var message = $"---DataCash--. Redirect end user to {redirectUrl}"; _logger.Information(message); return(PaymentProcessingResult.CreateSuccessfulResult(message, redirectUrl)); }
private SetExpressCheckoutRequestDetailsType SetupExpressCheckoutReqDetailsType(ICart cart, IPayment payment, string orderNumber) { var setExpressChkOutReqDetails = _payPalApiHelper.CreateExpressCheckoutReqDetailsType(payment, _paymentMethodConfiguration); // This key is sent to PayPal using https so it is not likely it will come from other because // only PayPal knows this key to send back to us var acceptSecurityKey = Utilities.GetAcceptUrlHashValue(orderNumber); var cancelSecurityKey = Utilities.GetCancelUrlHashValue(orderNumber); _acceptUrl = UriSupport.AbsoluteUrlBySettings(_paymentMethodConfiguration.SuccessUrl); _cancelUrl = UriSupport.AbsoluteUrlBySettings(_paymentMethodConfiguration.CancelUrl); var acceptUrl = UriSupport.AddQueryString(_acceptUrl, "accept", "true"); acceptUrl = UriSupport.AddQueryString(acceptUrl, "hash", acceptSecurityKey); var cancelUrl = UriSupport.AddQueryString(_cancelUrl, "accept", "false"); cancelUrl = UriSupport.AddQueryString(cancelUrl, "hash", cancelSecurityKey); setExpressChkOutReqDetails.CancelURL = cancelUrl; setExpressChkOutReqDetails.ReturnURL = acceptUrl; setExpressChkOutReqDetails.PaymentDetails = new List <PaymentDetailsType> { _payPalApiHelper.GetPaymentDetailsType(payment, cart, orderNumber, _acceptUrl) }; setExpressChkOutReqDetails.BillingAddress = AddressHandling.ToAddressType(payment.BillingAddress); return(setExpressChkOutReqDetails); }
public override ActionResult Index(ShareThisBlock currentBlock) { var model = new ShareThisBlockViewModel(); PageData page = pageRouteHelper.Page; model.FriendlyUrl = UriSupport.AbsoluteUrlBySettings(urlResolver.GetUrl(page.ContentLink)); model.Settings = currentBlock; return(PartialView(model)); }
public ActionResult Index() { if (PageEditing.PageIsInEditMode) { return(new EmptyResult()); } var currentCart = _orderRepository.LoadCart <ICart>(PrincipalInfo.CurrentPrincipal.GetContactId(), Cart.DefaultName); if (!currentCart.Forms.Any() || !currentCart.GetFirstForm().Payments.Any()) { throw new PaymentException(PaymentException.ErrorType.ProviderError, "", Utilities.Translate("GenericError")); } var payment = currentCart.Forms.SelectMany(f => f.Payments).FirstOrDefault(c => c.PaymentMethodId.Equals(_dibsRequestHelper.DIBSConfiguration.PaymentMethodId)); if (payment == null) { throw new PaymentException(PaymentException.ErrorType.ProviderError, "", Utilities.Translate("PaymentNotSpecified")); } InitializeReponse(); var transactionRequest = new TransactionRequest(Request.Form, _dibsRequestHelper.DIBSConfiguration); if (transactionRequest.IsProcessable()) { var cancelUrl = Utilities.GetUrlFromStartPageReferenceProperty("CheckoutPage"); // get link to Checkout page cancelUrl = UriUtil.AddQueryString(cancelUrl, "success", "false"); cancelUrl = UriUtil.AddQueryString(cancelUrl, "paymentmethod", "dibs"); var gateway = new DIBSPaymentGateway(); var redirectUrl = cancelUrl; if (transactionRequest.IsSuccessful()) { var acceptUrl = Utilities.GetUrlFromStartPageReferenceProperty("DIBSPaymentLandingPage"); redirectUrl = gateway.ProcessSuccessfulTransaction (currentCart, payment, transactionRequest.TransactionId, transactionRequest.OrderId, acceptUrl, cancelUrl); } else { TempData["Message"] = Utilities.Translate("CancelMessage"); redirectUrl = gateway.ProcessUnsuccessfulTransaction(cancelUrl, Utilities.Translate("CancelMessage")); } return(Redirect(redirectUrl)); } var notifyUrl = UriSupport.AbsoluteUrlBySettings(Utilities.GetUrlFromStartPageReferenceProperty("DIBSPaymentPage")); var requestPaymentData = _dibsRequestHelper.CreateRequestPaymentData(payment, currentCart, notifyUrl); return(new RedirectAndPostActionResult(PaymentWindowEntryPoint, requestPaymentData)); }
/// <summary> /// Gets the default asset url. /// </summary> /// <typeparam name="TContentMedia">The type of the content media.</typeparam> /// <param name="assetContainer">The asset container.</param> /// <returns>The Url for the default asset.</returns> /// <exception cref="T:System.Web.HttpException">The Web application is running under IISĀ 7 in Integrated mode.</exception> /// <exception cref="T:System.InvalidOperationException">The current <see cref="T:System.Uri" /> instance is not an absolute instance.</exception> /// <exception cref="T:System.ArgumentException">The specified <see cref="UriPartial.Authority"/> is not valid.</exception> /// <exception cref="T:System.MemberAccessException">The <see cref="T:System.Lazy`1" /> instance is initialized to use the default constructor of the type that is being lazily initialized, and permissions to access the constructor are missing.</exception> /// <exception cref="T:System.MissingMemberException">The <see cref="T:System.Lazy`1" /> instance is initialized to use the default constructor of the type that is being lazily initialized, and that type does not have a public, parameterless constructor.</exception> internal static string GetDefaultAsset <TContentMedia>(this IAssetContainer assetContainer) where TContentMedia : IContentMedia { string url = AssetUrlResolver.Value.GetAssetUrl <TContentMedia>(assetContainer: assetContainer); UrlBuilder urlBuilder = new UrlBuilder(UrlResolver.Value.GetUrl(internalUrl: url)); Global.UrlRewriteProvider.ConvertToExternal(url: urlBuilder, null, toEncoding: Encoding.UTF8); string externalUrl = HttpContext.Current == null ? UriSupport.AbsoluteUrlBySettings(urlBuilder.ToString()) : $"{HttpContext.Current.Request.Url.GetLeftPart(part: UriPartial.Authority)}{urlBuilder}"; return(externalUrl); }
public override ActionResult Index(ShareThisBlock currentBlock) { ShareThisBlockViewModel model = new ShareThisBlockViewModel(); PageData myPageData = pageRouteHelper.Page; var internalUrl = urlResolver.GetUrl(myPageData.PageLink); var url = new UrlBuilder(internalUrl); Global.UrlRewriteProvider.ConvertToExternal(url, null, System.Text.Encoding.UTF8); var friendlyUrl = UriSupport.AbsoluteUrlBySettings(url.ToString()); model.FriendlyUrl = friendlyUrl; return(PartialView(model)); }
public static string GetExternalUrl(this IContent content) { var internalUrl = UrlResolver.Current.GetUrl(content.ContentLink); if (internalUrl == null) { return(null); } var url = new UrlBuilder(internalUrl); EPiServer.Global.UrlRewriteProvider.ConvertToExternal(url, null, Encoding.UTF8); var friendlyUrl = UriSupport.AbsoluteUrlBySettings(url.ToString()); return(friendlyUrl); }
public ActionResult Index() { if (PageEditing.PageIsInEditMode) { return(new EmptyResult()); } // verify that we have a basket with payment var currentCart = _orderRepository.LoadCart <ICart>(PrincipalInfo.CurrentPrincipal.GetContactId(), Cart.DefaultName); if (!currentCart.Forms.Any() || !currentCart.GetFirstForm().Payments.Any()) { throw new PaymentException(PaymentException.ErrorType.ProviderError, "", Utilities.Translate("GenericError")); } // verify payment is epay var payment = currentCart.Forms.SelectMany(f => f.Payments).FirstOrDefault(c => c.PaymentMethodId.Equals(_epayRequestHelper.EpayConfiguration.PaymentMethodId)); if (payment == null) { throw new PaymentException(PaymentException.ErrorType.ProviderError, "", Utilities.Translate("PaymentNotSpecified")); } // Clear cache InitializeReponse(); // Post-Call Epay. var actionResult = PostCheckAndRedirect(currentCart, payment); //Test and redirect if callback from Epay if (actionResult != null) { return(actionResult); } // Pre-Call Epay var notifyUrl = UriSupport.AbsoluteUrlBySettings(Utilities.GetUrlFromStartPageReferenceProperty("EpayPaymentPage")); var requestPaymentData = _epayRequestHelper.CreateRequestPaymentData(payment, currentCart, notifyUrl); return(new RedirectAndPostActionResult(_epayRequestHelper.EpayConfiguration.ProcessingUrl, requestPaymentData)); }
public static string GetExternalUrl(PageData page) { try { var internalUrl = UrlResolver.Current.GetUrl(page.ContentLink); if (internalUrl != null) //can be null for special pages like settings { var url = new UrlBuilder(internalUrl); Global.UrlRewriteProvider.ConvertToExternal(url, null, System.Text.Encoding.UTF8); var friendlyUrl = UriSupport.AbsoluteUrlBySettings(url.ToString()); return(friendlyUrl); } return(null); } catch (Exception ex) { _log.Error("Could not resolve pageUrl. Perhaps SiteDefinition.Current cannot be resolved? Scheduled jobs requires a * binding to handle SiteDefinition.Current", ex); return(null); } }
/// <summary> /// Gets url from start page's reference property. /// </summary> /// <param name="propertyName">The property name.</param> /// <param name="isAbsolute">Whether to return relative or absolute url.</param> /// <returns>The friendly url.</returns> public static string GetUrlFromStartPageReferenceProperty(string propertyName, bool isAbsolute = false) { var url = UrlResolver.Service.GetUrl(ContentReference.StartPage); var startPageData = ContentLoader.Service.Get <PageData>(ContentReference.StartPage); if (startPageData != null) { var contentLink = startPageData.Property[propertyName]?.Value as ContentReference; if (!ContentReference.IsNullOrEmpty(contentLink)) { url = UrlResolver.Service.GetUrl(contentLink); } } if (isAbsolute) { url = UriSupport.AbsoluteUrlBySettings(url); } return(url); }
/// <summary> /// Gets the URL. /// </summary> /// <param name="contentReference">The content reference.</param> /// <param name="language">The language.</param> /// <returns>The Url for the <param name="contentReference"></param>.</returns> /// <exception cref="T:System.Web.HttpException">The Web application is running under IISĀ 7 in Integrated mode.</exception> /// <exception cref="T:System.InvalidOperationException">The current <see cref="T:System.Uri" /> instance is not an absolute instance.</exception> /// <exception cref="T:System.ArgumentException">The specified <see cref="UriPartial.Authority"/> is not valid.</exception> /// <exception cref="T:System.MemberAccessException">The <see cref="T:System.Lazy`1" /> instance is initialized to use the default constructor of the type that is being lazily initialized, and permissions to access the constructor are missing.</exception> /// <exception cref="T:System.MissingMemberException">The <see cref="T:System.Lazy`1" /> instance is initialized to use the default constructor of the type that is being lazily initialized, and that type does not have a public, parameterless constructor.</exception> internal static string GetUrl(this ContentReference contentReference, string language) { if (ContentReference.IsNullOrEmpty(contentLink: contentReference)) { return(string.Empty); } UrlBuilder urlBuilder = string.IsNullOrEmpty(value: language) ? new UrlBuilder(UrlResolver.Value.GetUrl(contentLink: contentReference)) : new UrlBuilder( UrlResolver.Value.GetUrl( contentLink: contentReference, language: language)); Global.UrlRewriteProvider.ConvertToExternal(url: urlBuilder, null, toEncoding: Encoding.UTF8); string externalUrl = HttpContext.Current == null ? UriSupport.AbsoluteUrlBySettings(urlBuilder.ToString()) : $"{HttpContext.Current.Request.Url.GetLeftPart(part: UriPartial.Authority)}{urlBuilder}"; return(externalUrl); }
/// <summary> /// Gets friendly url of the page. /// </summary> /// <param name="pageReference">The page reference.</param> /// <returns>The friendly url of page if UrlRewriteProvider.IsFurlEnabled</returns> public static string GetFriendlyUrl(this PageReference pageReference) { if (pageReference == null) { return(string.Empty); } var page = DataFactory.Instance.GetPage(pageReference); if (UrlRewriteProvider.IsFurlEnabled) { //var urlBuilder = new UrlBuilder(new Uri(page.LinkURL, UriKind.RelativeOrAbsolute)); var url = UriSupport.AddLanguageSelection(page.LinkURL, ContentLanguage.PreferredCulture.Name); UrlBuilder urlBuilder = new UrlBuilder(UriSupport.AbsoluteUrlBySettings(url)); Global.UrlRewriteProvider.ConvertToExternal(urlBuilder, page.PageLink, System.Text.Encoding.UTF8); return(urlBuilder.ToString()); } else { return(page.LinkURL); } }
private void ModifyIContentProperties(LinkItem serverModel, ExtendedEPiLinkModel clientModel) { var mappedHref = serverModel.GetMappedHref(); if (string.IsNullOrEmpty(mappedHref)) { return; } var hrefWithoutHash = mappedHref; var anchorOnPage = ""; var indexOfHash = mappedHref.IndexOf('#'); if (indexOfHash > 0) { hrefWithoutHash = mappedHref.Substring(0, indexOfHash - 1); anchorOnPage = mappedHref.Substring(indexOfHash + 1); } clientModel.Href = hrefWithoutHash; clientModel.AnchorOnPage = anchorOnPage; var contentGuid = PermanentLinkUtility.GetGuid(hrefWithoutHash); var contentReference = PermanentLinkUtility.FindContentReference(contentGuid); IContent content; if (!(contentReference != ContentReference.EmptyReference) || !_contentRepository.TryGet(contentReference, out content)) { return; } clientModel.TypeIdentifier = _uiDescriptors.GetTypeIdentifiers(content.GetType()).FirstOrDefault(); var friendlyUrl = _urlHelper.ContentUrl(content.ContentLink); var absoluteUriBySettings = UriSupport.AbsoluteUrlBySettings(friendlyUrl); clientModel.PublicUrl = indexOfHash > 0 ? string.Format("{0}#{1}", absoluteUriBySettings, anchorOnPage) : absoluteUriBySettings; }
public static string GetBaseUrl() { return(UriSupport.AbsoluteUrlBySettings(UrlResolver.Service.GetUrl(ContentReference.StartPage))); }
public static string GetParticipantInfo(IParticipant participant, string propertyname) { if (participant == null) { return(string.Empty); } { if (String.IsNullOrEmpty(propertyname)) { return(String.Empty); } propertyname = propertyname.ToLower(); switch (propertyname) { case "editurl": var internalUrl = UrlResolver.Current.GetUrl(participant.EventPage); UrlBuilder relativeUrl = new UrlBuilder(internalUrl); Global.UrlRewriteProvider.ConvertToExternal(relativeUrl, null, System.Text.Encoding.UTF8); string url = UriSupport.AbsoluteUrlBySettings(relativeUrl.ToString()); url = EPiServer.UriSupport.AddQueryString(url, "code", participant.Code); url = EPiServer.UriSupport.AddQueryString(url, "email", participant.Email); return(url); case "username": return(participant.Username); case "registrationcode": return(participant.Code); case "email": return(participant.Email); case "price": return(participant.Price.ToString()); case "eventname": case "coursename": return(DataFactory.Instance.Get <EventPageBase>(participant.EventPage).Name); case "submitted": return(participant.DateSubmitted.ToString("yyyy-MM-dd HH:mm")); case "status": return(participant.AttendStatus.ToString()); case "fullname": return(GetParticipantInfo(participant, "FirstName") + " " + GetParticipantInfo(participant, "LastName")); case "datestring": return(GetEventDates(participant.EventPage)); case "coursedatestring": return(string.Format(LocalizationService.Current.GetString("/attend/diploma/datetext"), GetEventDates(participant.EventPage))); default: { try { SerializableXmlDocument xmlDoc = new SerializableXmlDocument(); xmlDoc.LoadXml(participant.XForm); foreach (XmlNode formNode in xmlDoc.SelectNodes("instance/*")) { if (propertyname == formNode.Name.Replace('_', ' ').ToLower()) { return(formNode.InnerText); } } foreach (XmlNode formNode in xmlDoc.SelectNodes("FormData/*")) { if (propertyname == formNode.Name.ToLower()) { return(formNode.InnerText); } } } catch (Exception) { } } break; } return(String.Empty); } }