Esempio n. 1
0
        public virtual async Task TopUpAsync(Guid id, TopUpInput input)
        {
            var account = await _repository.GetAsync(id);

            if (account.UserId != CurrentUser.GetId())
            {
                throw new UnauthorizedTopUpException(account.Id);
            }

            if (account.GetPendingTopUpPaymentId().HasValue)
            {
                throw new TopUpIsAlreadyInProgressException();
            }

            var configuration = _accountGroupConfigurationProvider.Get(account.AccountGroupName);

            await _distributedEventBus.PublishAsync(new CreatePaymentEto
            {
                TenantId      = CurrentTenant.Id,
                UserId        = CurrentUser.GetId(),
                PaymentMethod = input.PaymentMethod,
                Currency      = configuration.Currency,
                PaymentItems  = new List <CreatePaymentItemEto>(new[]
                {
                    new CreatePaymentItemEto
                    {
                        ItemType = PrepaymentConsts.TopUpPaymentItemType,
                        ItemKey  = account.Id.ToString(),
                        OriginalPaymentAmount = input.Amount
                    }
                })
            });
        }
Esempio n. 2
0
 public virtual Task TopUpAsync(Guid id, TopUpInput input)
 {
     return(_service.TopUpAsync(id, input));
 }