public async Task <string> MicosoftCloudAgreement(Microsoft.Store.PartnerCenter.Models.Customers.Customer newCustomer) { //BrandingConfiguration branding = await ApplicationDomain.Instance.PortalBranding.RetrieveAsync().ConfigureAwait(false); ResourceCollection <AgreementMetaData> agreements = await ApplicationDomain.Instance.PartnerCenterClient.AgreementDetails.GetAsync().ConfigureAwait(false); // Obtain reference to the Microsoft Cloud Agreement. AgreementMetaData microsoftCloudAgreement = agreements.Items.FirstOrDefault(agr => agr.AgreementType == Microsoft.Store.PartnerCenter.Models.Agreements.AgreementType.MicrosoftCloudAgreement); // Attest that the customer has accepted the Microsoft Cloud Agreement (MCA). await ApplicationDomain.Instance.PartnerCenterClient.Customers[newCustomer.Id].Agreements.CreateAsync( new Agreement { DateAgreed = DateTime.UtcNow, PrimaryContact = new Microsoft.Store.PartnerCenter.Models.Agreements.Contact { Email = newCustomer.BillingProfile.Email, //customerRegistrationInfoPersisted.Email, FirstName = newCustomer.BillingProfile.DefaultAddress.FirstName, //customerRegistrationInfoPersisted.FirstName, LastName = newCustomer.BillingProfile.DefaultAddress.LastName, //customerRegistrationInfoPersisted.LastName, PhoneNumber = newCustomer.BillingProfile.DefaultAddress.PhoneNumber, //customerRegistrationInfoPersisted.Phone }, TemplateId = microsoftCloudAgreement.TemplateId, Type = Microsoft.Store.PartnerCenter.Models.Agreements.AgreementType.MicrosoftCloudAgreement, //Ahsan UserId = "631c1b48-e58c-46d4-a947-e7cea8b3d796", //branding.AgreementUserId }).ConfigureAwait(false); return(newCustomer.CompanyProfile.TenantId); }
public async Task <SubscriptionsSummary> ProcessOrderForUnAuthenticatedCustomer(string customerId, string paymentId, string payerId) { DateTime startTime = DateTime.Now; customerId.AssertNotEmpty(nameof(customerId)); paymentId.AssertNotEmpty(nameof(paymentId)); payerId.AssertNotEmpty(nameof(payerId)); BrandingConfiguration branding = await ApplicationDomain.Instance.PortalBranding.RetrieveAsync().ConfigureAwait(false); CustomerViewModel customerRegistrationInfoPersisted = await ApplicationDomain.Instance.CustomerRegistrationRepository.RetrieveAsync(customerId).ConfigureAwait(false); Customer newCustomer = new Customer() { CompanyProfile = new CustomerCompanyProfile() { Domain = customerRegistrationInfoPersisted.DomainName, }, BillingProfile = new CustomerBillingProfile() { Culture = customerRegistrationInfoPersisted.BillingCulture, Language = customerRegistrationInfoPersisted.BillingLanguage, Email = customerRegistrationInfoPersisted.Email, CompanyName = customerRegistrationInfoPersisted.CompanyName, DefaultAddress = new Address() { FirstName = customerRegistrationInfoPersisted.FirstName, LastName = customerRegistrationInfoPersisted.LastName, AddressLine1 = customerRegistrationInfoPersisted.AddressLine1, AddressLine2 = customerRegistrationInfoPersisted.AddressLine2, City = customerRegistrationInfoPersisted.City, State = customerRegistrationInfoPersisted.State, Country = customerRegistrationInfoPersisted.Country, PostalCode = customerRegistrationInfoPersisted.ZipCode, PhoneNumber = customerRegistrationInfoPersisted.Phone, } } }; // Register customer newCustomer = await ApplicationDomain.Instance.PartnerCenterClient.Customers.CreateAsync(newCustomer).ConfigureAwait(false); ResourceCollection <AgreementMetaData> agreements = await ApplicationDomain.Instance.PartnerCenterClient.AgreementDetails.GetAsync().ConfigureAwait(false); // Obtain reference to the Microsoft Cloud Agreement. AgreementMetaData microsoftCloudAgreement = agreements.Items.FirstOrDefault(agr => agr.AgreementType == AgreementType.MicrosoftCloudAgreement); // Attest that the customer has accepted the Microsoft Cloud Agreement (MCA). await ApplicationDomain.Instance.PartnerCenterClient.Customers[newCustomer.Id].Agreements.CreateAsync( new Agreement { DateAgreed = DateTime.UtcNow, PrimaryContact = new PartnerCenter.Models.Agreements.Contact { Email = customerRegistrationInfoPersisted.Email, FirstName = customerRegistrationInfoPersisted.FirstName, LastName = customerRegistrationInfoPersisted.LastName, PhoneNumber = customerRegistrationInfoPersisted.Phone }, TemplateId = microsoftCloudAgreement.TemplateId, Type = AgreementType.MicrosoftCloudAgreement, UserId = branding.AgreementUserId }); string newCustomerId = newCustomer.CompanyProfile.TenantId; CustomerViewModel customerViewModel = new CustomerViewModel() { AddressLine1 = newCustomer.BillingProfile.DefaultAddress.AddressLine1, AddressLine2 = newCustomer.BillingProfile.DefaultAddress.AddressLine2, City = newCustomer.BillingProfile.DefaultAddress.City, State = newCustomer.BillingProfile.DefaultAddress.State, ZipCode = newCustomer.BillingProfile.DefaultAddress.PostalCode, Country = newCustomer.BillingProfile.DefaultAddress.Country, Phone = newCustomer.BillingProfile.DefaultAddress.PhoneNumber, Language = newCustomer.BillingProfile.Language, FirstName = newCustomer.BillingProfile.DefaultAddress.FirstName, LastName = newCustomer.BillingProfile.DefaultAddress.LastName, Email = newCustomer.BillingProfile.Email, CompanyName = newCustomer.BillingProfile.CompanyName, MicrosoftId = newCustomer.CompanyProfile.TenantId, UserName = newCustomer.BillingProfile.Email, Password = newCustomer.UserCredentials.Password, AdminUserAccount = newCustomer.UserCredentials.UserName + "@" + newCustomer.CompanyProfile.Domain }; IPaymentGateway paymentGateway = PaymentGatewayConfig.GetPaymentGatewayInstance(ApplicationDomain.Instance, "ProcessingOrder"); OrderViewModel orderToProcess = await paymentGateway.GetOrderDetailsFromPaymentAsync(payerId, paymentId, string.Empty, string.Empty).ConfigureAwait(false); // Assign the actual customer Id orderToProcess.CustomerId = newCustomerId; CommerceOperations commerceOperation = new CommerceOperations(ApplicationDomain.Instance, newCustomerId, paymentGateway); await commerceOperation.PurchaseAsync(orderToProcess).ConfigureAwait(false); SubscriptionsSummary summaryResult = await GetSubscriptionSummaryAsync(newCustomerId).ConfigureAwait(false); // Remove the persisted customer registration info. await ApplicationDomain.Instance.CustomerRegistrationRepository.DeleteAsync(customerId).ConfigureAwait(false); // Capture the request for the customer summary for analysis. Dictionary <string, string> eventProperties = new Dictionary <string, string> { { "CustomerId", orderToProcess.CustomerId } }; // Track the event measurements for analysis. Dictionary <string, double> eventMetrics = new Dictionary <string, double> { { "ElapsedMilliseconds", DateTime.Now.Subtract(startTime).TotalMilliseconds } }; ApplicationDomain.Instance.TelemetryService.Provider.TrackEvent("api/order/NewCustomerProcessOrder", eventProperties, eventMetrics); summaryResult.CustomerViewModel = customerViewModel; return(summaryResult); }
/// <summary> /// Initializes a new instance of the <see cref="PSAgreementMetaData" /> class. /// </summary> /// <param name="agreementMetaData">The base agreement meta data for this instance.</param> public PSAgreementMetaData(AgreementMetaData agreementMetaData) { this.CopyFrom(agreementMetaData); }