public void Handle(ManualRideLinqTripInfoUpdated @event)
        {
            if (@event.EndTime.HasValue)
            {
                var orderStatus = _orderDao.FindOrderStatusById(@event.SourceId);
                var account     = _accountDao.FindById(orderStatus.AccountId);

                if (orderStatus != null)
                {
                    // Check if card declined
                    InitializeCmtServiceClient();

                    var trip = _cmtTripInfoServiceHelper.CheckForTripEndErrors(@event.PairingToken);

                    if (trip != null && trip.ErrorCode == CmtErrorCodes.CardDeclined)
                    {
                        _commandBus.Send(new ReactToPaymentFailure
                        {
                            AccountId       = orderStatus.AccountId,
                            OrderId         = orderStatus.OrderId,
                            IBSOrderId      = orderStatus.IBSOrderId,
                            CreditCardId    = account.DefaultCreditCard.GetValueOrDefault(),
                            TransactionId   = orderStatus.OrderId.ToString().Split('-').FirstOrDefault(), // Use first part of GUID to display to user
                            OverdueAmount   = Convert.ToDecimal(@event.Total),
                            TransactionDate = @event.EventDate
                        });

                        return;
                    }

                    // Since RideLinqCmt payment is processed automatically by CMT, we have to charge booking fees separately
                    _feeService.ChargeBookingFeesIfNecessary(orderStatus);
                }
            }
        }
        public void Handle(ManualRideLinqTripInfoUpdated @event)
        {
            using (var context = _contextFactory.Invoke())
            {
                var orderReport = context.Find <OrderReportDetail>(@event.SourceId);
                orderReport.Payment.MdtFare            = @event.Fare;
                orderReport.Payment.MdtTip             = @event.Tip;
                orderReport.Payment.MdtToll            = @event.Toll;
                orderReport.Payment.Error              = @event.PairingError;
                orderReport.Payment.TotalAmountCharged = @event.Total.HasValue
                    ? (decimal?)Math.Round(@event.Total.Value, 2)
                    : null;

                if (@event.EndTime.HasValue)
                {
                    orderReport.OrderStatus.OrderIsCompleted = true;
                    orderReport.OrderStatus.Status           = OrderStatus.Completed;
                }

                if (@event.PairingError.HasValueTrimmed())
                {
                    orderReport.OrderStatus.OrderIsCancelled = true;
                    orderReport.OrderStatus.Status           = OrderStatus.Canceled;
                }

                context.Save(orderReport);
            }
        }
Esempio n. 3
0
        private void OnManualRideLinqTripInfoUpdated(ManualRideLinqTripInfoUpdated @event)
        {
            if (@event.EndTime.HasValue)
            {
                _status = OrderStatus.Completed;
            }

            if (@event.PairingError.HasValueTrimmed())
            {
                _status = OrderStatus.Canceled;
            }
        }
Esempio n. 4
0
        public void Handle(ManualRideLinqTripInfoUpdated @event)
        {
            var order = _orderDao.FindById(@event.SourceId);

            if (order != null)
            {
                if (@event.EndTime.HasValue)
                {
                    // ManualRideLinq order is done, send receipt

                    order.Fare      = @event.Fare;
                    order.Tip       = @event.Tip;
                    order.Tax       = @event.Tax;
                    order.Toll      = @event.Toll;
                    order.Surcharge = @event.Surcharge;

                    SendTripReceipt(@event.SourceId,
                                    Convert.ToDecimal(@event.Fare ?? 0),
                                    Convert.ToDecimal(@event.Tip ?? 0),
                                    Convert.ToDecimal(@event.Tax ?? 0),
                                    extra: Convert.ToDecimal(@event.Extra ?? 0),
                                    toll: Convert.ToDecimal(@event.Toll ?? 0),
                                    surcharge: Convert.ToDecimal(@event.Surcharge ?? 0),
                                    cmtRideLinqFields: new SendReceipt.CmtRideLinqReceiptFields
                    {
                        DriverId            = @event.DriverId.ToString(),
                        PickUpDateTime      = @event.StartTime,
                        DropOffDateTime     = @event.EndTime,
                        TripId              = @event.TripId,
                        Distance            = @event.Distance,
                        LastFour            = @event.LastFour,
                        AccessFee           = @event.AccessFee,
                        FareAtAlternateRate = @event.FareAtAlternateRate,
                        RateAtTripEnd       = @event.RateAtTripEnd.HasValue ? Convert.ToInt32(@event.RateAtTripEnd) : 0,
                        RateAtTripStart     = @event.RateAtTripStart.HasValue ? Convert.ToInt32(@event.RateAtTripStart) : 0,
                        Tolls = @event.Tolls,
                        LastLatitudeOfVehicle  = @event.LastLatitudeOfVehicle,
                        LastLongitudeOfVehicle = @event.LastLongitudeOfVehicle,
                        TipIncentive           = (order.TipIncentive.HasValue) ? order.TipIncentive.Value : 0
                    });
                }
            }
        }
Esempio n. 5
0
        public void Handle(ManualRideLinqTripInfoUpdated @event)
        {
            using (var context = _contextFactory.Invoke())
            {
                _logger.LogMessage("Trip info updated event received for order {0} (TripId {1}; Pairing token {2}", @event.SourceId, @event.TripId, @event.PairingToken);
                var order = context.Find <OrderDetail>(@event.SourceId);
                if (order != null)
                {
                    if (@event.EndTime.HasValue)
                    {
                        order.Status      = (int)OrderStatus.Completed;
                        order.DropOffDate = @event.EndTime;
                    }
                    else if (@event.PairingError.HasValueTrimmed())
                    {
                        order.Status = (int)OrderStatus.Canceled;
                    }

                    order.Fare      = @event.Fare;
                    order.Tax       = @event.Tax;
                    order.Toll      = @event.Toll;
                    order.Tip       = @event.Tip;
                    order.Surcharge = @event.Surcharge + @event.AccessFee; // add access fees here since it's only for manual ridelinq and we don't want to add a property for it in OrderDetail

                    context.Save(order);
                }

                var orderStatusDetails = context.Find <OrderStatusDetail>(@event.SourceId);
                if (orderStatusDetails != null)
                {
                    if (@event.EndTime.HasValue)
                    {
                        orderStatusDetails.Status = OrderStatus.Completed;
                    }
                    else if (@event.PairingError.HasValueTrimmed())
                    {
                        orderStatusDetails.Status = OrderStatus.Canceled;
                    }

                    context.Save(orderStatusDetails);
                }

                var rideLinqDetails = context.Find <OrderManualRideLinqDetail>(@event.SourceId);
                if (rideLinqDetails == null)
                {
                    _logger.LogMessage("There is no manual RideLinQ details for order {0}", @event.SourceId);
                    return;
                }

                rideLinqDetails.DriverId            = @event.DriverId;
                rideLinqDetails.StartTime           = @event.StartTime;
                rideLinqDetails.EndTime             = @event.EndTime;
                rideLinqDetails.TripId              = @event.TripId;
                rideLinqDetails.Distance            = @event.Distance;
                rideLinqDetails.PairingToken        = @event.PairingToken;
                rideLinqDetails.Extra               = @event.Extra;
                rideLinqDetails.Fare                = @event.Fare;
                rideLinqDetails.FareAtAlternateRate = @event.FareAtAlternateRate;
                rideLinqDetails.Total               = @event.Total;
                rideLinqDetails.Toll                = @event.Toll;
                rideLinqDetails.Tip                    = @event.Tip;
                rideLinqDetails.Tax                    = @event.Tax;
                rideLinqDetails.Surcharge              = @event.Surcharge;
                rideLinqDetails.RateAtTripStart        = @event.RateAtTripStart;
                rideLinqDetails.RateAtTripEnd          = @event.RateAtTripEnd;
                rideLinqDetails.RateChangeTime         = @event.RateChangeTime;
                rideLinqDetails.AccessFee              = @event.AccessFee;
                rideLinqDetails.LastFour               = @event.LastFour;
                rideLinqDetails.PairingError           = @event.PairingError;
                rideLinqDetails.LastLatitudeOfVehicle  = @event.LastLatitudeOfVehicle;
                rideLinqDetails.LastLongitudeOfVehicle = @event.LastLongitudeOfVehicle;

                context.Save(rideLinqDetails);
            }
        }