예제 #1
0
        /// <summary>
        /// Создание сессии
        /// </summary>
        /// <param name="paymentInfo">Сведения о платеже</param>
        /// <returns>Id сессии</returns>
        public async Task <string> CreateSession(PaymentInfo paymentInfo)
        {
            var userEmail = httpContextAccessor.HttpContext.User.FindFirstValue(ClaimTypes.Email);

            if (string.IsNullOrEmpty(userEmail) || userEmail != paymentInfo.Email)
            {
                throw new ArgumentException("Указанный Email не совпадает с Email в Вашем профиле");
            }

            var reservedKey = await keystoreService.ReserveKey(paymentInfo.Game);

            var sessionId = Guid.NewGuid().ToString();

            cache.AddPaymentInfo(sessionId, new PaymentInfoCache(paymentInfo, reservedKey));

            return(sessionId);
        }