public async Task <ActionResult> Index(string token, CancellationToken cancellationToken)
        {
            if (string.IsNullOrEmpty(token))
            {
                this.ModelState.AddModelError(string.Empty, "Token URL parameter cannot be empty");
                this.ViewBag.Message = "Token URL parameter cannot be empty";
                return(this.View());
            }

            ResolvedSubscription resolvedSubscription = null;

            Microsoft.Marketplace.SaaS.Models.Subscription subscriptionDetails = null;
            Azure.Response <Microsoft.Marketplace.SaaS.Models.SubscriptionPlans> availablePlans = null;
            bool anyPendingOperations = false;

            if (token.ToLowerInvariant() != SampleToken)
            {
                // Get the subscription for the offer from the marketplace purchase identification token
                resolvedSubscription = await this.marketplaceProcessor.GetSubscriptionFromPurchaseIdentificationTokenAsync(token, cancellationToken);

                if (resolvedSubscription == default(ResolvedSubscription))
                {
                    this.ViewBag.Message = "Token did not resolve to a subscription";
                    return(this.View());
                }

                subscriptionDetails = resolvedSubscription.Subscription;

                // Populate the available plans for this subscription from the API
                availablePlans = await this.marketplaceClient.Fulfillment.ListAvailablePlansAsync(
                    resolvedSubscription.Id.Value,
                    null,
                    null,
                    cancellationToken);

                // See if there are pending operations for this subscription
                var pendingOperations = await this.marketplaceClient.Operations.ListOperationsAsync(
                    resolvedSubscription.Id.Value,
                    null,
                    null,
                    cancellationToken);

                anyPendingOperations = pendingOperations?.Value.Operations?.Any(o => o.Status == OperationStatusEnum.InProgress) ?? false;
            }

            var graphApiUser = await this.graphServiceClient.Me.Request().GetAsync();

            var isSampleToken = string.Equals(token, SampleToken, StringComparison.InvariantCultureIgnoreCase);

            var provisioningModel = new AzureSubscriptionProvisionModel
            {
                // Landing page is the only place to capture the customer's contact details
                // It can be present in multiple places:
                //  - the details received from the Graph API
                //  - beneficiary information on the subscription details
                // it is also possible that the Graph API
                NameFromOpenIdConnect = (this.User.Identity as ClaimsIdentity)?.FindFirst("name")?.Value,
                EmailFromClaims       = this.User.Identity.GetUserEmail(),
                EmailFromGraph        = graphApiUser.Mail ?? string.Empty,
                NameFromGraph         = graphApiUser.DisplayName ?? string.Empty,
                UserPrincipalName     = graphApiUser.UserPrincipalName ?? string.Empty,
                PurchaserEmail        = graphApiUser.Mail ?? string.Empty,

                // Get the other potential contact information from the marketplace API
                PurchaserUPN        = isSampleToken ? "*****@*****.**" : subscriptionDetails?.Purchaser?.EmailId,
                PurchaserTenantId   = isSampleToken ? Guid.Empty : subscriptionDetails?.Purchaser?.TenantId ?? Guid.Empty,
                BeneficiaryUPN      = isSampleToken ? "*****@*****.**" : subscriptionDetails?.Beneficiary?.EmailId,
                BeneficiaryTenantId = isSampleToken ? Guid.Empty : subscriptionDetails?.Beneficiary?.TenantId ?? Guid.Empty,

                // Maybe the end users are a completely different set of contacts, start with one
                BusinessUnitContactEmail = this.User.Identity.GetUserEmail(),

                PlanId             = isSampleToken ? "*****@*****.**" : resolvedSubscription.PlanId,
                SubscriptionId     = isSampleToken ? Guid.Empty : resolvedSubscription.Id.Value,
                OfferId            = isSampleToken ? "sample offer" : resolvedSubscription.OfferId,
                SubscriptionName   = isSampleToken ? "sample subscription" : resolvedSubscription.SubscriptionName,
                SubscriptionStatus = isSampleToken ? SubscriptionStatusEnum.PendingFulfillmentStart : subscriptionDetails?.SaasSubscriptionStatus ?? SubscriptionStatusEnum.NotStarted,

                Region            = TargetContosoRegionEnum.NorthAmerica,
                AvailablePlans    = isSampleToken ? new System.Collections.Generic.List <Plan>() : availablePlans?.Value.Plans.ToList(),
                PendingOperations = isSampleToken ? false : anyPendingOperations,
            };

            return(this.View(provisioningModel));
        }