コード例 #1
0
        public void UpdateFastPaymentStatus(FastPayment fastPayment, FastPaymentDTOStatus newStatus, DateTime statusDate)
        {
            var oldStatus = fastPayment.FastPaymentStatus;

            _fastPaymentManager.UpdateFastPaymentStatus(_uow, fastPayment, newStatus, statusDate);
            Save(fastPayment);
            _logger.LogInformation($"Статус платежа с externalId: {fastPayment.ExternalId} изменён c {oldStatus} на {newStatus}");
        }
コード例 #2
0
        private async Task UpdateFastPaymentStatusAsync(
            IEnumerable <FastPayment> processingFastPayments,
            IServiceScope scope,
            IUnitOfWork uow)
        {
            var orderRequestManager = scope.ServiceProvider.GetRequiredService <IOrderRequestManager>();

            foreach (var payment in processingFastPayments)
            {
                var response = await orderRequestManager.GetOrderInfo(payment.Ticket);

                if ((int)response.Status == (int)payment.FastPaymentStatus)
                {
                    var fastPaymentWithQR     = !string.IsNullOrWhiteSpace(payment.QRPngBase64);
                    var fastPaymentFromOnline = payment.OnlineOrderId.HasValue;
                    if (!_fastPaymentManager.IsTimeToCancelPayment(payment.CreationDate, fastPaymentWithQR, fastPaymentFromOnline))
                    {
                        continue;
                    }

                    _logger.LogInformation($"Отменяем платеж с сессией: {payment.Ticket}");
                    _fastPaymentManager.UpdateFastPaymentStatus(uow, payment, FastPaymentDTOStatus.Rejected, DateTime.Now);
                }
                else
                {
                    var newStatus = response.Status;
                    _logger.LogInformation(
                        $"Обновляем статус платежа с сессией: {payment.Ticket} новый статус: {newStatus}");
                    _fastPaymentManager.UpdateFastPaymentStatus(uow, payment, newStatus, response.StatusDate);
                }

                uow.Save(payment);
                uow.Commit();
                _updatedCount++;
            }
        }