public async Task <IActionResult> Merchant() { MerchantViewModel model = null; var user = await _userManager.GetUserAsync(User); if (user == null) { throw new ApplicationException($"Unable to load user with ID '{_userManager.GetUserId(User)}'."); } var userMerchant = await _merchantRepository.GetByUser(user.Id); if (userMerchant == null) { return(View("Merchant/Create")); } var subscriptions = await _subscriptionsRepository.GetByUserId(user.Id); if (subscriptions == null || subscriptions.Paid && subscriptions.Expired < DateTime.Now) { await _subscriptionsRepository.CreatePaymentAddress(user.Id); } decimal price = Convert.ToDecimal(_configuration["Subscription:" + subscriptions?.WalletType + ":Price"]); await Subscriptions(price); subscriptions = await _subscriptionsRepository.GetByUserId(user.Id); model = new MerchantViewModel { MerchantId = userMerchant.MerchantId, MerchantSecret = Crypto.GetSha256Hash(userMerchant.MerchantSecret), RedirectUri = userMerchant.RedirectUri, XPubKey = userMerchant.XPubKey, EthereumAddress = userMerchant.EthereumAddress, Status = subscriptions.Expired > DateTime.Now && subscriptions.Paid, Address = subscriptions.Address, Expired = subscriptions.Expired, WalletType = subscriptions.WalletType, Price = price, StatusMessage = StatusMessage }; return(View("Merchant/Index", model)); }