예제 #1
0
        public override async ValueTask <(Guid, OrderProposalStatus)> CreateOrderProposal(OrderProposal responseOrderProposal, StoreBookingFlowContext flowContext, OrderStateContext stateContext, OrderTransaction databaseTransaction)
        {
            if (!responseOrderProposal.TotalPaymentDue.Price.HasValue)
            {
                throw new OpenBookingException(new OpenBookingError(), "Price must be set on TotalPaymentDue");
            }

            var version      = Guid.NewGuid();
            var customerType = flowContext.Customer == null ? CustomerType.None : (flowContext.Customer.GetType() == typeof(Organization) ? CustomerType.Organization : CustomerType.Person);
            var result       = await FakeDatabase.AddOrder(
                flowContext.OrderId.ClientId,
                flowContext.OrderId.uuid,
                flowContext.BrokerRole == BrokerType.AgentBroker?BrokerRole.AgentBroker : flowContext.BrokerRole == BrokerType.ResellerBroker?BrokerRole.ResellerBroker : BrokerRole.NoBroker,
                flowContext.Broker.Name,
                flowContext.Broker.Url,
                flowContext.Broker.Telephone,
                flowContext.SellerId.SellerIdLong ?? null, // Small hack to allow use of FakeDatabase when in Single Seller mode
                customerType == CustomerType.None?null : flowContext.Customer.Email,
                customerType,
                customerType == CustomerType.None?null : (customerType == CustomerType.Organization ? flowContext.Customer.Name : null),
                customerType == CustomerType.None?null : flowContext.Customer.Identifier.HasValue?flowContext.Customer.Identifier.Value.ToString() : null,
                customerType == CustomerType.None?null : (customerType == CustomerType.Organization ? null : flowContext.Customer.GivenName),
                customerType == CustomerType.None?null : (customerType == CustomerType.Organization ? null : flowContext.Customer.FamilyName),
                customerType == CustomerType.None?null : (customerType == CustomerType.Organization ? null : flowContext.Customer.Telephone),
                flowContext.Payment?.Identifier,
                flowContext.Payment?.Name,
                flowContext.Payment?.PaymentProviderId,
                flowContext.Payment?.AccountId,
                responseOrderProposal.TotalPaymentDue.Price.Value,
                databaseTransaction.FakeDatabaseTransaction,
                version,
                ProposalStatus.AwaitingSellerConfirmation);

            if (!result)
            {
                throw new OpenBookingException(new OrderAlreadyExistsError());
            }

            return(version, OrderProposalStatus.AwaitingSellerConfirmation);
        }
예제 #2
0
        public override async ValueTask CreateOrder(Order responseOrder, StoreBookingFlowContext flowContext, OrderStateContext stateContext, OrderTransaction databaseTransaction)
        {
            if (_appSettings.FeatureFlags.PaymentReconciliationDetailValidation && responseOrder.TotalPaymentDue.Price > 0 && ReconciliationMismatch(flowContext))
            {
                throw new OpenBookingException(new InvalidPaymentDetailsError(), "Payment reconciliation details do not match");
            }

            var customerType = flowContext.Customer == null ? CustomerType.None : (flowContext.Customer.IsOrganization ? CustomerType.Organization : CustomerType.Person);
            var result       = await FakeDatabase.AddOrder(
                flowContext.OrderId.ClientId,
                flowContext.OrderId.uuid,
                flowContext.BrokerRole == BrokerType.AgentBroker?BrokerRole.AgentBroker : flowContext.BrokerRole == BrokerType.ResellerBroker?BrokerRole.ResellerBroker : BrokerRole.NoBroker,
                flowContext.Broker.Name,
                flowContext.Broker.Url,
                flowContext.Broker.Telephone,
                flowContext.SellerId.SellerIdLong ?? null, // Small hack to allow use of FakeDatabase when in Single Seller mode
                customerType == CustomerType.None?null : flowContext.Customer.Email,
                customerType,
                customerType == CustomerType.None?null : (customerType == CustomerType.Organization ? flowContext.Customer.Name : null),
                customerType == CustomerType.None?null : flowContext.Customer.Identifier.HasValue?flowContext.Customer.Identifier.Value.ToString() : null,
                customerType == CustomerType.None?null : (customerType == CustomerType.Organization ? null : flowContext.Customer.GivenName),
                customerType == CustomerType.None?null : (customerType == CustomerType.Organization ? null : flowContext.Customer.FamilyName),
                customerType == CustomerType.None?null : (customerType == CustomerType.Organization ? null : flowContext.Customer.Telephone),
                flowContext.Payment?.Identifier,
                flowContext.Payment?.Name,
                flowContext.Payment?.PaymentProviderId,
                flowContext.Payment?.AccountId,
                responseOrder.TotalPaymentDue.Price.Value,
                databaseTransaction.FakeDatabaseTransaction,
                null,
                null);

            if (!result)
            {
                throw new OpenBookingException(new OrderAlreadyExistsError());
            }
        }