public override void Update(IBSOrderInformation orderFromIbs, OrderStatusDetail orderStatusDetail) { //eHail Order Thread.Sleep(500); //Call Geo Thread.Sleep(500); //Process Geo Thread.Sleep(500); }
public void when_order_is_paired_and_received_fare_with_preauth_disabled_and_preauth_fails() { // Prepare var accountId = Guid.NewGuid(); var orderId = Guid.NewGuid(); string companyKey = null; var orderAmount = 100.55m; var creditCardId = Guid.NewGuid(); using (var context = new BookingDbContext(DbName)) { context.Save(new AccountDetail { Id = accountId, CreationDate = DateTime.Now, IBSAccountId = 123, DefaultCreditCard = creditCardId }); context.Save(new CreditCardDetails { AccountId = accountId, CreditCardId = creditCardId, Token = "token" }); context.Save(new OrderDetail { Id = orderId, AccountId = accountId, PickupDate = DateTime.Now, CreatedDate = DateTime.Now, IBSOrderId = 12345, CompanyKey = companyKey }); context.Save(new OrderPairingDetail { OrderId = orderId }); } var tip = FareHelper.CalculateTipAmount(orderAmount, ConfigurationManager.ServerData.DefaultTipPercentage); var ibsOrder = new IBSOrderInformation { Fare = Convert.ToDouble(orderAmount) }; var status = new OrderStatusDetail { OrderId = orderId, CompanyKey = companyKey, AccountId = accountId, IBSOrderId = 12345 }; ConfigurationManager.SetPaymentSettings(null, new ServerPaymentSettings { PaymentMode = PaymentMethod.Braintree }); EnsurePreAuthPaymentForTripWasCalled(status, orderAmount + tip); // Act Sut.Update(ibsOrder, status); // Assert PaymentServiceMock.Verify(); Assert.AreEqual(1, Commands.Count); Assert.AreEqual(typeof(ChangeOrderStatus), Commands.First().GetType()); }
public void when_order_on_external_company_has_booking_fees_configured_with_cmt_and_card_is_declined() { // Prepare var creditCardId = Guid.NewGuid(); var accountId = Guid.NewGuid(); var orderId = Guid.NewGuid(); string companyKey = "ext"; var orderAmount = 100.85m; var bookingFees = 40.85m; using (var context = new BookingDbContext(DbName)) { context.RemoveAll <FeesDetail>(); context.SaveChanges(); context.Save(new AccountDetail { Id = accountId, CreationDate = DateTime.Now, IBSAccountId = 123, DefaultCreditCard = creditCardId }); context.Save(new AccountIbsDetail { CompanyKey = companyKey, AccountId = accountId, IBSAccountId = 123 }); context.Save(new CreditCardDetails { AccountId = accountId, CreditCardId = creditCardId, Token = "token" }); context.Save(new OrderDetail { Id = orderId, AccountId = accountId, PickupDate = DateTime.Now, CreatedDate = DateTime.Now, IBSOrderId = 12345, CompanyKey = companyKey, BookingFees = bookingFees }); context.Save(new OrderPairingDetail { OrderId = orderId }); context.Save(new FeesDetail { Market = null, Booking = bookingFees, Id = Guid.NewGuid() }); } var tip = FareHelper.CalculateTipAmount(orderAmount, ConfigurationManager.ServerData.DefaultTipPercentage); var ibsOrder = new IBSOrderInformation { Fare = Convert.ToDouble(orderAmount) }; var status = new OrderStatusDetail { OrderId = orderId, CompanyKey = companyKey, AccountId = accountId, IBSOrderId = 12345 }; ConfigurationManager.SetPaymentSettings(null, new ServerPaymentSettings { PaymentMode = PaymentMethod.Cmt }); ConfigurationManager.SetPaymentSettings(companyKey, new ServerPaymentSettings { PaymentMode = PaymentMethod.Cmt }); EnsurePreAuthForFeeWasCalled(status, bookingFees); EnsurePreAuthPaymentForTripWasCalled(status, orderAmount + tip); // Act Sut.Update(ibsOrder, status); // Wait for commands to be sent properly Thread.Sleep(5000); // Assert PaymentServiceMock.Verify(); Assert.AreEqual(3, Commands.Count); Assert.AreEqual(typeof(ReactToPaymentFailure), Commands.First().GetType()); Assert.AreEqual(typeof(ReactToPaymentFailure), Commands.Skip(1).First().GetType()); Assert.AreEqual(typeof(ChangeOrderStatus), Commands.Skip(2).First().GetType()); }
public void when_order_is_paired_and_received_fare_with_preauth_enabled_and_commit_fails_with_card_declined() { // Prepare var accountId = Guid.NewGuid(); var orderId = Guid.NewGuid(); var creditCardId = Guid.NewGuid(); string companyKey = null; var orderAmount = 100.85m; var preAuthAmount = 50m; using (var context = new BookingDbContext(DbName)) { context.Save(new AccountDetail { Id = accountId, CreationDate = DateTime.Now, IBSAccountId = 123, DefaultCreditCard = creditCardId }); context.Save(new CreditCardDetails { AccountId = accountId, CreditCardId = creditCardId, Token = "token" }); context.Save(new OrderDetail { Id = orderId, AccountId = accountId, PickupDate = DateTime.Now, CreatedDate = DateTime.Now, IBSOrderId = 12345, CompanyKey = companyKey }); context.Save(new OrderPaymentDetail { PaymentId = Guid.NewGuid(), OrderId = orderId, CompanyKey = companyKey, PreAuthorizedAmount = preAuthAmount, FirstPreAuthTransactionId = "asdasdnasd", TransactionId = "asdasdnasd" }); context.Save(new OrderPairingDetail { OrderId = orderId }); } var tip = FareHelper.CalculateTipAmount(orderAmount, ConfigurationManager.ServerData.DefaultTipPercentage); var ibsOrder = new IBSOrderInformation { Fare = Convert.ToDouble(orderAmount) }; var status = new OrderStatusDetail { OrderId = orderId, CompanyKey = companyKey, AccountId = accountId, IBSOrderId = 12345 }; ConfigurationManager.SetPaymentSettings(null, new ServerPaymentSettings { PaymentMode = PaymentMethod.Braintree }); EnsureCommitWasCalled(status, preAuthAmount, orderAmount + tip, orderAmount, tip); EnsureVoidPreAuthWasCalled(status); // Act Sut.Update(ibsOrder, status); // Assert PaymentServiceMock.Verify(); Assert.AreEqual(3, Commands.Count); Assert.AreEqual(typeof(LogCreditCardError), Commands.First().GetType()); Assert.AreEqual(typeof(ReactToPaymentFailure), Commands.Skip(1).First().GetType()); Assert.AreEqual(typeof(ChangeOrderStatus), Commands.Skip(2).First().GetType()); }
public override OrderStatusDetail GetOrderStatus(Guid orderId, IAuthSession session) { var orderStatus = base.GetOrderStatus(orderId, session); if (orderStatus.Status == OrderStatus.Completed) { return(orderStatus); } var ibsInfo = new IBSOrderInformation { VehicleMake = "Lamborghini", VehicleColor = "Red", VehicleModel = "Diablo", VehicleNumber = "93002", VehicleRegistration = "123", VehicleType = "Sport", FirstName = "Tony", LastName = "Apcurium", MobilePhone = "5145551234", DriverId = "99123", TerminalId = "98695", ReferenceNumber = "1209", DriverPhotoUrl = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + HttpContext.Current.Request.ApplicationPath.TrimEnd('/') + "/assets/img/tony.jpg", Status = VehicleStatuses.Common.Waiting }; var order = _orderDao.FindById(orderId); if (order.IBSOrderId.HasValue && order.IBSOrderId != 0) { ibsInfo.IBSOrderId = order.IBSOrderId.Value; } if (order.IBSOrderId.HasValue && (!orderStatus.IBSStatusId.HasValue() || orderStatus.IBSStatusId == VehicleStatuses.Common.Waiting)) { ibsInfo.VehicleLatitude = DefaultTaxiLatitude; ibsInfo.VehicleLongitude = DefaultTaxiLongitude; ibsInfo.Status = VehicleStatuses.Common.Assigned; } else if (orderStatus.IBSStatusId == VehicleStatuses.Common.Assigned && orderStatus.VehicleLatitude == DefaultTaxiLatitude && orderStatus.VehicleLongitude == DefaultTaxiLongitude) { // Move taxi close to user ibsInfo.VehicleLatitude = order.PickupAddress.Latitude - NearbyTaxiDelta; ibsInfo.VehicleLongitude = order.PickupAddress.Longitude - NearbyTaxiDelta; ibsInfo.Status = VehicleStatuses.Common.Assigned; } else if (orderStatus.IBSStatusId == VehicleStatuses.Common.Assigned) { // Move taxi to user position ibsInfo.VehicleLatitude = order.PickupAddress.Latitude; ibsInfo.VehicleLongitude = order.PickupAddress.Longitude; ibsInfo.Status = VehicleStatuses.Common.Arrived; } else if (orderStatus.IBSStatusId == VehicleStatuses.Common.Arrived) { ibsInfo.VehicleLatitude = orderStatus.VehicleLatitude; ibsInfo.VehicleLongitude = orderStatus.VehicleLongitude; ibsInfo.Status = VehicleStatuses.Common.Loaded; } else if (orderStatus.IBSStatusId == VehicleStatuses.Common.Loaded) { ibsInfo.VehicleLatitude = orderStatus.VehicleLatitude; ibsInfo.VehicleLongitude = orderStatus.VehicleLongitude; ibsInfo.Status = VehicleStatuses.Common.Done; } _updater.Update(ibsInfo, orderStatus); return(orderStatus); }