public override async ValueTask <Lease> CreateLease( OrderQuote responseOrderQuote, StoreBookingFlowContext flowContext, OrderStateContext stateContext, OrderTransaction databaseTransaction) { if (_appSettings.FeatureFlags.PaymentReconciliationDetailValidation && ReconciliationMismatch(flowContext)) { throw new OpenBookingException(new InvalidPaymentDetailsError(), "Payment reconciliation details do not match"); } // Note if no lease support, simply return null always here instead if (flowContext.Stage != FlowStage.C1 && flowContext.Stage != FlowStage.C2) { return(null); } // TODO: Make the lease duration configurable var leaseExpires = DateTimeOffset.UtcNow + new TimeSpan(0, 5, 0); var brokerRole = BrokerTypeToBrokerRole(flowContext.BrokerRole ?? BrokerType.NoBroker); var result = await FakeDatabase.AddLease( flowContext.OrderId.ClientId, flowContext.OrderId.uuid, brokerRole, 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 flowContext.Customer?.Email, leaseExpires, databaseTransaction.FakeDatabaseTransaction); if (!result) { throw new OpenBookingException(new OrderAlreadyExistsError()); } return(new Lease { LeaseExpires = leaseExpires }); }