public async Task <Guid> Handle(BuySubscriptionRenewalCommand command, CancellationToken cancellationToken)
        {
            var priceList = await PriceListProvider.GetPriceList(_sqlConnectionFactory.GetOpenConnection());

            var subscriptionId = new SubscriptionId(command.SubscriptionId);

            var subscription = await _aggregateStore.Load(new SubscriptionId(command.SubscriptionId));

            if (subscription == null)
            {
                throw new InvalidCommandException(new List <string> {
                    "Subscription for renewal must exist."
                });
            }

            var subscriptionRenewalPayment = SubscriptionRenewalPayment.Buy(
                _payerContext.PayerId,
                subscriptionId,
                SubscriptionPeriod.Of(command.SubscriptionTypeCode),
                command.CountryCode,
                MoneyValue.Of(command.Value, command.Currency),
                priceList);

            _aggregateStore.AppendChanges(subscriptionRenewalPayment);

            return(subscriptionRenewalPayment.Id);
        }
        public Task <Guid> Handle(CreateMeetingFeePaymentCommand command, CancellationToken cancellationToken)
        {
            var meetingFeePayment = MeetingFeePayment.Create(new MeetingFeeId(command.MeetingFeeId));

            _aggregateStore.AppendChanges(meetingFeePayment);

            return(Task.FromResult(meetingFeePayment.Id));
        }
        public async Task <Unit> Handle(ExpireSubscriptionPaymentCommand command, CancellationToken cancellationToken)
        {
            var subscriptionPayment = await _aggregateStore.Load(new SubscriptionPaymentId(command.PaymentId));

            subscriptionPayment.Expire();

            _aggregateStore.AppendChanges(subscriptionPayment);

            return(Unit.Value);
        }
        public async Task <Unit> Handle(ActivatePriceListItemCommand command, CancellationToken cancellationToken)
        {
            var priceListItem = await _aggregateStore.Load(new PriceListItemId(command.PriceListItemId));

            priceListItem.Activate();

            _aggregateStore.AppendChanges(priceListItem);

            return(Unit.Value);
        }
        public async Task <Guid> Handle(CreateSubscriptionCommand command, CancellationToken cancellationToken)
        {
            var subscriptionPayment =
                await _aggregateStore.Load(new SubscriptionPaymentId(command.SubscriptionPaymentId));

            var subscription = Subscription.Create(subscriptionPayment.GetSnapshot());

            _aggregateStore.AppendChanges(subscription);

            return(subscription.Id);
        }
예제 #6
0
        public Task <Guid> Handle(CreateMeetingFeeCommand command, CancellationToken cancellationToken)
        {
            var meetingFee = MeetingFee.Create(
                new PayerId(command.PayerId),
                new MeetingId(command.MeetingId),
                MoneyValue.Of(command.Value, command.Currency));

            _aggregateStore.AppendChanges(meetingFee);

            return(Task.FromResult(meetingFee.Id));
        }
        public async Task <Unit> Handle(MarkMeetingFeeAsPaidCommand command, CancellationToken cancellationToken)
        {
            var meetingFee =
                await _aggregateStore.Load(new MeetingFeeId(command.MeetingFeeId));

            meetingFee.MarkAsPaid();

            _aggregateStore.AppendChanges(meetingFee);

            return(Unit.Value);
        }
        public Task <Guid> Handle(CreatePriceListItemCommand command, CancellationToken cancellationToken)
        {
            var priceListItem = PriceListItem.Create(
                command.CountryCode,
                SubscriptionPeriod.Of(command.SubscriptionPeriodCode),
                PriceListItemCategory.Of(command.CategoryCode),
                MoneyValue.Of(command.PriceValue, command.PriceCurrency));

            _aggregateStore.AppendChanges(priceListItem);

            return(Task.FromResult(priceListItem.Id));
        }
예제 #9
0
        public async Task <Unit> Handle(MarkSubscriptionRenewalPaymentAsPaidCommand command, CancellationToken cancellationToken)
        {
            var subscriptionRenewalPayment =
                await _aggregateStore.Load(
                    new SubscriptionRenewalPaymentId(command.SubscriptionRenewalPaymentId));

            subscriptionRenewalPayment.MarkRenewalAsPaid();

            _aggregateStore.AppendChanges(subscriptionRenewalPayment);

            return(Unit.Value);
        }
        public async Task <Unit> Handle(ChangePriceListItemAttributesCommand command, CancellationToken cancellationToken)
        {
            var priceListItem = await _aggregateStore.Load(new PriceListItemId(command.PriceListItemId));

            priceListItem.ChangeAttributes(
                command.CountryCode,
                SubscriptionPeriod.Of(command.SubscriptionPeriodCode),
                PriceListItemCategory.Of(command.CategoryCode),
                MoneyValue.Of(command.PriceValue, command.PriceCurrency));

            _aggregateStore.AppendChanges(priceListItem);
            return(Unit.Value);
        }
        public async Task <Unit> Handle(RenewSubscriptionCommand command, CancellationToken cancellationToken)
        {
            var subscriptionRenewalPayment =
                await _aggregateStore.Load(new SubscriptionRenewalPaymentId(command.SubscriptionRenewalPaymentId));

            var subscription = await _aggregateStore.Load(new SubscriptionId(command.SubscriptionId));

            subscription.Renew(subscriptionRenewalPayment.GetSnapshot());

            _aggregateStore.AppendChanges(subscription);

            return(Unit.Value);
        }
        public Task <Guid> Handle(CreatePayerCommand request, CancellationToken cancellationToken)
        {
            var payer = Payer.Create(
                request.UserId,
                request.Login,
                request.Email,
                request.FirstName,
                request.LastName,
                request.Name);

            _aggregateStore.AppendChanges(payer);

            return(Task.FromResult(payer.Id));
        }
        public async Task <Guid> Handle(BuySubscriptionCommand command, CancellationToken cancellationToken)
        {
            var priceList = await PriceListProvider.GetPriceList(_sqlConnectionFactory.GetOpenConnection());

            var subscription = SubscriptionPayment.Buy(
                _payerContext.PayerId,
                SubscriptionPeriod.Of(command.SubscriptionTypeCode),
                command.CountryCode,
                MoneyValue.Of(command.Value, command.Currency),
                priceList);

            _aggregateStore.AppendChanges(subscription);

            return(subscription.Id);
        }
        public async Task <Unit> Handle(DeactivatePriceListItemCommand command, CancellationToken cancellationToken)
        {
            var priceListItem = await _aggregateStore.Load(new PriceListItemId(command.PriceListItemId));

            if (priceListItem == null)
            {
                throw new InvalidCommandException(new List <string> {
                    "Pricelist item for deactivation must exist."
                });
            }

            priceListItem.Deactivate();

            _aggregateStore.AppendChanges(priceListItem);

            return(Unit.Value);
        }
예제 #15
0
        public async Task <ProcessPaymentResult> Handle(ProcessPaymentCommand command, CancellationToken cancellationToken)
        {
            _logger.Information("starting acquring bank payment request");
            var bankPayemntResult = await _acuquiryBank.ProcessPayment(new BankPaymentRequest
            {
                Amount          = command.Amount,
                Currency        = command.Currency,
                CardExpiryYear  = command.CardExpiryYear,
                CardExpiryMonth = command.CardExpiryMonth,
                CardNumber      = command.CardNumber,
                CVV             = command.CVV,
                MerchantId      = Guid.NewGuid().ToString()
            });

            var encriptionKey       = Guid.NewGuid().ToString("N");
            var encriptedCardNumber = _cryptoService.Encrypt(command.CardNumber, encriptionKey);
            var encriptedCardMonth  = _cryptoService.Encrypt(command.CardExpiryMonth, encriptionKey);
            var encriptedCardYear   = _cryptoService.Encrypt(command.CardExpiryYear, encriptionKey);
            var encriptedCardCVV    = _cryptoService.Encrypt(command.CVV, encriptionKey);

            var payment = new Payment(encriptedCardNumber,
                                      encriptedCardMonth,
                                      encriptedCardYear,
                                      command.Amount,
                                      command.Currency,
                                      encriptedCardCVV,
                                      encriptionKey,
                                      bankPayemntResult.PaymentIdentifier,
                                      bankPayemntResult.PaymentStatus);


            await _paymentRepository.AppendChanges(payment);


            if (bankPayemntResult.PaymentStatus == PaymentStatus.Success)
            {
                _logger.Information("bank payment successful");
                return(new SuccessResult(payment.Id.ToString()));
            }
            else
            {
                _logger.Error("The Bank was unable to process the payment");
                return(new ErrorResult("The Bank was unable to process the payment"));
            }
        }
        public async Task <UserRegistrationResponse> Handle(
            UserRegistrationCommand command,
            CancellationToken cancellationToken)
        {
            var user = new User(Guid.NewGuid(),
                                command.FirstName,
                                command.LastName,
                                command.Age,
                                command.EmailAddress,
                                command.MobileNumber,
                                command.City,
                                command.Password);

            await _aggregateStore.AppendChanges(user);

            return(new UserRegistrationResponse {
                Id = user.Id
            });
        }
        public async Task <Unit> Handle(ChangePriceListItemAttributesCommand command, CancellationToken cancellationToken)
        {
            var priceListItem = await _aggregateStore.Load(new PriceListItemId(command.PriceListItemId));

            if (priceListItem == null)
            {
                throw new InvalidCommandException(new List <string> {
                    "Pricelist item for changing must exist."
                });
            }

            priceListItem.ChangeAttributes(
                command.CountryCode,
                SubscriptionPeriod.Of(command.SubscriptionPeriodCode),
                PriceListItemCategory.Of(command.CategoryCode),
                MoneyValue.Of(command.PriceValue, command.PriceCurrency));

            _aggregateStore.AppendChanges(priceListItem);
            return(Unit.Value);
        }