/// <summary> /// Retrieves the transaction service profile. /// </summary> /// <param name="context">The request context.</param> /// <returns>The transaction service profile.</returns> private static TransactionServiceProfile GetTransactionServiceProfile(Microsoft.Dynamics.Commerce.Runtime.RequestContext context) { GetTransactionServiceProfileDataRequest request = new GetTransactionServiceProfileDataRequest(); Microsoft.Dynamics.Commerce.Runtime.RequestContext getTransactionServiceProfileRequestContext; // Transaction service profile is associated with channel // Decide what context is to be used to retrieve it if (context.GetPrincipal().IsChannelAgnostic) { // If the context is channel agnostic (no channel information), then use any channel available to retrieve the profile GetChannelIdServiceRequest getChannelRequest = new GetChannelIdServiceRequest(); GetChannelIdServiceResponse getChannelResponse = context.Execute <GetChannelIdServiceResponse>(getChannelRequest); long anyChannelId = getChannelResponse.ChannelId; var anonymousIdentity = new CommerceIdentity() { ChannelId = anyChannelId }; getTransactionServiceProfileRequestContext = new Microsoft.Dynamics.Commerce.Runtime.RequestContext(context.Runtime); getTransactionServiceProfileRequestContext.SetPrincipal(new CommercePrincipal(anonymousIdentity)); } else { // If the request has channel information, then use current context to retrieve the transaction service profile getTransactionServiceProfileRequestContext = context; } return(getTransactionServiceProfileRequestContext.Execute <SingleEntityDataServiceResponse <TransactionServiceProfile> >(request).Entity); }
/// <summary> /// Initializes a new instance of the <see cref="TransactionServiceClientFactory"/> class. /// </summary> /// <param name="context">The request context.</param> public TransactionServiceClientFactory(Microsoft.Dynamics.Commerce.Runtime.RequestContext context) { ThrowIf.Null(context, "context"); this.dataAreaId = context.GetChannelConfiguration() != null ? context.GetChannelConfiguration().InventLocationDataAreaId : string.Empty; var getTransactionServiceProfileDataRequest = new GetTransactionServiceProfileDataRequest(); this.transactionServiceProfile = context.Runtime.Execute <SingleEntityDataServiceResponse <TransactionServiceProfile> >(getTransactionServiceProfileDataRequest, context).Entity; this.transactionServiceProfile = GetTransactionServiceProfile(context); this.SetRealTimeServiceProfileConfigSettings(context); this.requestLanguageId = this.transactionServiceProfile.LanguageId; this.ValidateTransactionProfile(); }
private void SetRealTimeServiceProfileConfigSettings(Microsoft.Dynamics.Commerce.Runtime.RequestContext context) { this.transactionServiceProfile.SigningCertificateThumbprint = context.Runtime.Configuration.RealtimeService.Certificate.Thumbprint; this.transactionServiceProfile.StoreName = context.Runtime.Configuration.RealtimeService.Certificate.StoreName; this.transactionServiceProfile.StoreLocation = context.Runtime.Configuration.RealtimeService.Certificate.StoreLocation; }