Esempio n. 1
0
        public async Task BuySubscription_Test()
        {
            await PriceListHelper.AddPriceListItems(PaymentsModule);

            var subscriptionPaymentId = await PaymentsModule.ExecuteCommandAsync(
                new BuySubscriptionCommand(
                    SubscriptionPeriod.Month.Code,
                    "PL",
                    60,
                    "PLN"));

            var subscriptionPayments = await GetEventually(
                new GetSubscriptionPaymentsProbe(
                    PaymentsModule,
                    ExecutionContext.UserId,
                    x => true),
                10000);

            var subscriptionPayment = subscriptionPayments.Single(x => x.PaymentId == subscriptionPaymentId);

            Assert.That(subscriptionPayment.Status, Is.EqualTo(SubscriptionPaymentStatus.WaitingForPayment.Code));

            await PaymentsModule.ExecuteCommandAsync(
                new MarkSubscriptionPaymentAsPaidCommand(subscriptionPaymentId));

            var subscription = await GetEventually(
                new GetPayerSubscriptionProbe(
                    PaymentsModule,
                    ExecutionContext.UserId),
                10000);

            Assert.That(subscription.Period, Is.EqualTo(SubscriptionPeriod.Month.Code));
            Assert.That(subscription.Status, Is.EqualTo(SubscriptionStatus.Active.Code));
        }
        public async Task SubscriptionPayment_Expiration_Test()
        {
            SystemClock.Set(new DateTime(2020, 6, 15, 10, 0, 0));

            await PriceListHelper.AddPriceListItems(PaymentsModule);

            await PaymentsModule.ExecuteCommandAsync(
                new BuySubscriptionCommand(
                    "Month",
                    "PL",
                    60,
                    "PLN"));

            var subscriptionPayments = await GetEventually(
                new GetSubscriptionPaymentsProbe(
                    PaymentsModule,
                    ExecutionContext.UserId,
                    x => true),
                10000);

            Assert.That(subscriptionPayments[0].Status, Is.EqualTo(SubscriptionPaymentStatus.WaitingForPayment.Code));

            SystemClock.Set(new DateTime(2020, 6, 15, 10, 21, 0));

            await PaymentsModule.ExecuteCommandAsync(
                new ExpireSubscriptionPaymentsCommand());

            await GetEventually(
                new GetSubscriptionPaymentsProbe(
                    PaymentsModule,
                    ExecutionContext.UserId,
                    x => x.Any(y => y.Status == SubscriptionPaymentStatus.Expired.Code)),
                10000);
        }
Esempio n. 3
0
        public async Task CreatePaymentRegister_Test()
        {
            var meetingGroupProposalId = Guid.NewGuid();
            var registerId             = await PaymentsModule.ExecuteCommandAsync(
                new CreatePaymentRegisterCommand(Guid.NewGuid(), meetingGroupProposalId));

            var paymentRegister = await PaymentsModule.ExecuteQueryAsync(new GetMeetingGroupPaymentRegisterQuery(registerId));

            Assert.That(paymentRegister.Id, Is.EqualTo(registerId));
        }
        public async Task CreatePayer_Test()
        {
            var payerId = await PaymentsModule.ExecuteCommandAsync(
                new CreatePayerCommand(Guid.NewGuid(),
                                       PayerSampleData.Id, PayerSampleData.Login, PayerSampleData.Email, PayerSampleData.FirstName,
                                       PayerSampleData.LastName, PayerSampleData.Name));

            var payer = await PaymentsModule.ExecuteQueryAsync(new GetPayerQuery(payerId));

            Assert.That(payer.Id, Is.EqualTo(PayerSampleData.Id));
            Assert.That(payer.Login, Is.EqualTo(PayerSampleData.Login));
            Assert.That(payer.Name, Is.EqualTo(PayerSampleData.Name));
            Assert.That(payer.FirstName, Is.EqualTo(PayerSampleData.FirstName));
            Assert.That(payer.LastName, Is.EqualTo(PayerSampleData.LastName));
            Assert.That(payer.Email, Is.EqualTo(PayerSampleData.Email));
        }
Esempio n. 5
0
        public async Task CreateMeetingPayment_Test()
        {
            PayerId   payerId   = new PayerId(Guid.NewGuid());
            MeetingId meetingId = new MeetingId(Guid.NewGuid());
            decimal   value     = 100;
            string    currency  = "EUR";
            await PaymentsModule.ExecuteCommandAsync(new CreateMeetingPaymentCommand(Guid.NewGuid(),
                                                                                     payerId, meetingId, value, currency));

            var payment = await PaymentsModule.ExecuteQueryAsync(new GetMeetingPaymentQuery(meetingId.Value, payerId.Value));

            Assert.That(payment.PayerId, Is.EqualTo(payerId.Value));
            Assert.That(payment.MeetingId, Is.EqualTo(meetingId.Value));
            Assert.That(payment.FeeValue, Is.EqualTo(value));
            Assert.That(payment.FeeCurrency, Is.EqualTo(currency));
        }
Esempio n. 6
0
        public async Task Create_Then_Pay_MeetingFee_Test()
        {
            var payerId   = Guid.NewGuid();
            var meetingId = Guid.NewGuid();

            var meetingFeeId = await PaymentsModule.ExecuteCommandAsync(new CreateMeetingFeeCommand(
                                                                            Guid.NewGuid(),
                                                                            payerId,
                                                                            meetingId,
                                                                            100,
                                                                            "PLN"));

            var meetingFees = await GetEventually(new GetMeetingFeesProbe(PaymentsModule, meetingId, x => x != null), 5000);

            Assert.That(meetingFees[0].Status, Is.EqualTo(MeetingFeeStatus.WaitingForPayment.Code));

            var meetingFeePaymentId = await PaymentsModule.ExecuteCommandAsync(new CreateMeetingFeePaymentCommand(meetingFeeId));

            await PaymentsModule.ExecuteCommandAsync(new MarkMeetingFeePaymentAsPaidCommand(meetingFeePaymentId));

            meetingFees = await GetEventually(new GetMeetingFeesProbe(PaymentsModule, meetingId, x => x.Any(y => y.Status == MeetingFeePaymentStatus.Paid.Code)), 10000);

            Assert.That(meetingFees[0].Status, Is.EqualTo(MeetingFeeStatus.Paid.Code));
        }
Esempio n. 7
0
        public async Task RegisterPayment_Test()
        {
            var meetingGroupProposalId = Guid.NewGuid();

            var registerId = await PaymentsModule.ExecuteCommandAsync(
                new CreatePaymentRegisterCommand(Guid.NewGuid(), meetingGroupProposalId));

            var startDate = new DateTime(2020, 1, 1);
            var endDate   = new DateTime(2020, 1, 31);

            await PaymentsModule.ExecuteCommandAsync(new RegisterPaymentCommand(registerId, startDate, endDate));

            var payments = await PaymentsModule.ExecuteQueryAsync(new GetMeetingGroupPaymentsQuery(registerId));

            Assert.That(payments[0].MeetingGroupPaymentRegisterId, Is.EqualTo(registerId));
            Assert.That(payments[0].PaymentTermStartDate, Is.EqualTo(startDate));
            Assert.That(payments[0].PaymentTermEndDate, Is.EqualTo(endDate));
            Assert.That(payments[0].PayerId, Is.EqualTo(ExecutionContext.UserId));

            var paymentRegisteredNotification = await GetLastOutboxMessage <PaymentRegisteredNotification>();

            Assert.That(paymentRegisteredNotification.DomainEvent.DateTo, Is.EqualTo(endDate));
            Assert.That(paymentRegisteredNotification.DomainEvent.MeetingGroupPaymentRegisterId.Value, Is.EqualTo(registerId));
        }
Esempio n. 8
0
        public async Task Subscription_Buy_ThenRenew_ThenExpire_Test()
        {
            await PriceListHelper.AddPriceListItems(PaymentsModule);

            DateTime referenceDate = new DateTime(2020, 6, 15);

            SystemClock.Set(referenceDate);

            var subscriptionPaymentId = await PaymentsModule.ExecuteCommandAsync(
                new BuySubscriptionCommand(
                    "Month",
                    "PL",
                    60,
                    "PLN"));

            var subscriptionPayments = await GetEventually(
                new GetSubscriptionPaymentsProbe(PaymentsModule, ExecutionContext.UserId,
                                                 x => true),
                10000);

            var subscriptionPayment = subscriptionPayments.Single(x => x.PaymentId == subscriptionPaymentId);

            Assert.That(subscriptionPayment.Status, Is.EqualTo(SubscriptionPaymentStatus.WaitingForPayment.Code));

            await PaymentsModule.ExecuteCommandAsync(
                new MarkSubscriptionPaymentAsPaidCommand(subscriptionPaymentId));

            subscriptionPayments = await GetEventually(
                new GetSubscriptionPaymentsProbe(PaymentsModule, ExecutionContext.UserId,
                                                 x => x.Any(y => y.Status == SubscriptionPaymentStatus.Paid.Code &&
                                                            y.SubscriptionId.HasValue)),
                10000);

            subscriptionPayment = subscriptionPayments.Single(x => x.PaymentId == subscriptionPaymentId);

            var subscriptionId = subscriptionPayment.SubscriptionId.GetValueOrDefault();

            var subscription = await GetEventually(
                new GetSubscriptionDetailsProbe(
                    PaymentsModule,
                    subscriptionId,
                    x => x.SubscriptionId == subscriptionId &&
                    x.Status == SubscriptionStatus.Active.Code &&
                    x.Period == SubscriptionPeriod.Month.Code), 5000);

            Assert.That(subscriptionPayments[0].Status, Is.EqualTo(SubscriptionPaymentStatus.Paid.Code));
            Assert.That(subscription.ExpirationDate, Is.EqualTo(referenceDate.AddMonths(1)));

            var subscriptionRenewalPaymentId = await PaymentsModule.ExecuteCommandAsync(
                new BuySubscriptionRenewalCommand(
                    subscriptionId,
                    "HalfYear",
                    "PL",
                    320,
                    "PLN"));

            subscriptionPayments = await GetEventually(
                new GetSubscriptionPaymentsProbe(PaymentsModule, ExecutionContext.UserId,
                                                 x => true),
                10000);

            var renewalPayment = subscriptionPayments
                                 .Single(x => x.PaymentId == subscriptionRenewalPaymentId);

            Assert.That(renewalPayment.Status, Is.EqualTo(SubscriptionRenewalPaymentStatus.WaitingForPayment.Code));

            await PaymentsModule.ExecuteCommandAsync(
                new MarkSubscriptionRenewalPaymentAsPaidCommand(subscriptionRenewalPaymentId));

            subscriptionPayments = await GetEventually(
                new GetSubscriptionPaymentsProbe(PaymentsModule, ExecutionContext.UserId,
                                                 x => x.Any(y => y.PaymentId == subscriptionRenewalPaymentId)),
                10000);

            renewalPayment = subscriptionPayments
                             .Single(x => x.PaymentId == subscriptionRenewalPaymentId);

            subscription = await GetEventually(
                new GetSubscriptionDetailsProbe(
                    PaymentsModule,
                    subscriptionId,
                    x => x.SubscriptionId == subscriptionId &&
                    x.Period == SubscriptionPeriod.GetName(SubscriptionPeriod.HalfYear.Code) &&
                    x.Status == SubscriptionStatus.Active.Code
                    ), 5000);

            Assert.That(renewalPayment.Status, Is.EqualTo(SubscriptionRenewalPaymentStatus.Paid.Code));
            Assert.That(subscription.ExpirationDate, Is.EqualTo(referenceDate.AddMonths(7)));

            SystemClock.Set(referenceDate.AddMonths(7).AddDays(1));

            await PaymentsModule.ExecuteCommandAsync(new ExpireSubscriptionsCommand());

            subscription = await GetEventually(
                new GetSubscriptionDetailsProbe(
                    PaymentsModule,
                    subscriptionId,
                    x => x.SubscriptionId == subscriptionId &&
                    x.Status == SubscriptionStatus.Expired.Code),
                10000);

            Assert.That(subscription, Is.Not.Null);
        }