public async Task <PaymentConfiguration> UpdatePaymentConfiguration(PaymentConfiguration paymentConfiguration) { IPaymentGateway paymentGateway = PaymentGatewayConfig.GetPaymentGatewayInstance(ApplicationDomain.Instance, "configure payment"); //// validate the payment configuration before saving. paymentGateway.ValidateConfiguration(paymentConfiguration); // check if branding configuration has been setup else don't create web experience profile. bool isBrandingConfigured = await ApplicationDomain.Instance.PortalBranding.IsConfiguredAsync().ConfigureAwait(false); if (isBrandingConfigured) { // create a web experience profile using the branding for the web store. BrandingConfiguration brandConfig = await ApplicationDomain.Instance.PortalBranding.RetrieveAsync().ConfigureAwait(false); paymentConfiguration.WebExperienceProfileId = paymentGateway.CreateWebExperienceProfile(paymentConfiguration, brandConfig, ApplicationDomain.Instance.PortalLocalization.CountryIso2Code); } // Save the validated & complete payment configuration to repository. PaymentConfiguration paymentConfig = await ApplicationDomain.Instance.PaymentConfigurationRepository.UpdateAsync(paymentConfiguration).ConfigureAwait(false); return(paymentConfig); }