Пример #1
0
        /// <summary>
        /// Выполнение платежа
        /// </summary>
        /// <param name="paymentByCard">Сведения о карте и сессии</param>
        public async Task BillPayment(PaymentByCard paymentByCard)
        {
            var paymentInfoCache = cache.GetPaymentInfo(paymentByCard.SessionId);
            var user             = await accountService.GetCurrentUser();

            var order = await orderService.AddOrder(
                user,
                paymentInfoCache,
                new SessionInfo()
            {
                CardNumber = paymentByCard.Card.Number,
                SessionId  = paymentByCard.SessionId
            });

            var earnings = await DistributeMoney(paymentInfoCache);

            await keystoreService.DeleteKey(paymentInfoCache.KeyDto.Id, paymentInfoCache.Game.Id);

            cache.RemovePaymentInfo(paymentByCard.SessionId);
            await smtpService.SendPurchaseNotification(paymentInfoCache);


            await notifierService.SendNotification(new Notification
            {
                Url  = (await accountService.GetUserById(paymentInfoCache.Game.SellerId))?.NotificationUrl,
                Body = new SaleNotification
                {
                    Order         = order,
                    Earnings      = earnings,
                    ValidationKey = GetValidationKey(order, earnings)
                }
            });
        }