public static SendReceipt GetSendReceiptCommand(OrderDetail order, AccountDetail account, int?orderId, string vehicleNumber, DriverInfos driverInfos, double?fare, double?toll, double?extra, double?surcharge, double?bookingFees, double?tip, double?tax, OrderPaymentDetail orderPayment = null, double?amountSavedByPromotion = null, PromotionUsageDetail promotionUsed = null, CreditCardDetails creditCard = null, SendReceipt.CmtRideLinqReceiptFields cmtRideLinqFields = null) { var command = new SendReceipt { Id = Guid.NewGuid(), OrderId = order.Id, EmailAddress = account.Email, IBSOrderId = orderId ?? 0, PickupDate = order.PickupDate, UtcDropOffDate = order.DropOffDate, VehicleNumber = vehicleNumber, DriverInfos = driverInfos, Fare = fare.GetValueOrDefault(), Extra = extra.GetValueOrDefault(), Tip = tip.GetValueOrDefault(), Tax = tax.GetValueOrDefault(), Toll = toll.GetValueOrDefault(), Surcharge = surcharge.GetValueOrDefault(), BookingFees = bookingFees.GetValueOrDefault(), PickupAddress = order.PickupAddress, DropOffAddress = order.DropOffAddress, ClientLanguageCode = order.ClientLanguageCode, CmtRideLinqFields = cmtRideLinqFields }; if (promotionUsed != null) { command.AmountSavedByPromotion = amountSavedByPromotion.GetValueOrDefault(); command.PromoCode = promotionUsed.Code; command.PromoDiscountType = promotionUsed.DiscountType; command.PromoDiscountValue = promotionUsed.DiscountValue; } if (orderPayment != null) { command.PaymentInfo = new SendReceipt.Payment( orderPayment.Amount, orderPayment.TransactionId, orderPayment.AuthorizationCode, orderPayment.Type == PaymentType.CreditCard ? "Credit Card" : orderPayment.Type.ToString()); if ((orderPayment.CardToken.HasValue()) && (creditCard != null)) { command.PaymentInfo.Last4Digits = creditCard.Last4Digits; command.PaymentInfo.Company = creditCard.CreditCardCompany; command.PaymentInfo.NameOnCard = creditCard.NameOnCard; command.PaymentInfo.ExpirationMonth = creditCard.ExpirationMonth; command.PaymentInfo.ExpirationYear = creditCard.ExpirationYear; } } return(command); }
public object Post(TestEmailAdministrationRequest request) { try { switch (request.TemplateName) { case NotificationService.EmailConstant.Template.AccountConfirmation: _notificationService.SendAccountConfirmationEmail(new Uri("http://www.google.com"), request.EmailAddress, request.Language); break; case NotificationService.EmailConstant.Template.BookingConfirmation: _notificationService.SendBookingConfirmationEmail(12345, "This is a standard note", _pickupAddress, _dropOffAddress, DateTime.Now, _bookingSettings, request.EmailAddress, request.Language, true); break; case NotificationService.EmailConstant.Template.PasswordReset: _notificationService.SendPasswordResetEmail("N3wp@s5w0rd", request.EmailAddress, request.Language); break; case NotificationService.EmailConstant.Template.CancellationFeesReceipt: _notificationService.SendCancellationFeesReceiptEmail(1234, 24.42, "1111", request.EmailAddress, request.Language); break; case NotificationService.EmailConstant.Template.NoShowFeesReceipt: _notificationService.SendNoShowFeesReceiptEmail(1234, 10.00, _pickupAddress, "1111", request.EmailAddress, request.Language); break; case NotificationService.EmailConstant.Template.Receipt: var fareObject = _serverSettings.ServerData.VATIsEnabled ? FareHelper.GetFareFromAmountInclTax(45m, _serverSettings.ServerData.VATPercentage) : FareHelper.GetFareFromAmountInclTax(45m, 0); var toll = 3; var tip = (double)45 * ((double)15 / (double)100); var amountSavedByPromo = 10; var extra = 2; var surcharge = 5; var bookingFees = 7; var tipIncentive = 10; var driverInfos = new DriverInfos { DriverId = "7009", FirstName = "Alex", LastName = "Proteau", MobilePhone = "5551234567", VehicleColor = "Silver", VehicleMake = "DMC", VehicleModel = "Delorean", VehicleRegistration = "OUTATIME", VehicleType = "Time Machine" }; var fare = Convert.ToDouble(fareObject.AmountExclTax); var tax = Convert.ToDouble(fareObject.TaxAmount); _notificationService.SendTripReceiptEmail(Guid.NewGuid(), 12345, "9007", driverInfos, fare, toll, tip, tax, extra, surcharge, bookingFees, fare + toll + tip + tax + bookingFees + extra + tipIncentive - amountSavedByPromo, _payment, _pickupAddress, _dropOffAddress, DateTime.Now.AddMinutes(-15), DateTime.UtcNow, request.EmailAddress, request.Language, amountSavedByPromo, "PROMO10", new SendReceipt.CmtRideLinqReceiptFields { Distance = 13, DriverId = "D1337", DropOffDateTime = DateTime.Now, AccessFee = 0.3, LastFour = "1114", TripId = 9874, RateAtTripStart = 1, RateAtTripEnd = 4, FareAtAlternateRate = 23.45, LastLatitudeOfVehicle = 45.546571, LastLongitudeOfVehicle = -73.586309, Tolls = new[] { new TollDetail { TollName = "Toll 1", TollAmount = 95 }, new TollDetail { TollName = "Toll 2", TollAmount = 5 }, new TollDetail { TollName = "Toll 3", TollAmount = 30 }, new TollDetail { TollName = "Toll 4", TollAmount = 35 } }, TipIncentive = tipIncentive }, true); break; case NotificationService.EmailConstant.Template.PromotionUnlocked: _notificationService.SendPromotionUnlockedEmail("10% Off your next ride", "PROMO123", DateTime.Now.AddMonths(1), request.EmailAddress, request.Language, true); break; case NotificationService.EmailConstant.Template.CreditCardDeactivated: _notificationService.SendCreditCardDeactivatedEmail("Visa", "1234", request.EmailAddress, request.Language, true); break; default: throw new Exception("sendTestEmailErrorNoMatchingTemplate"); } } catch (Exception e) { _logger.LogError(e); throw new HttpError(HttpStatusCode.InternalServerError, e.Message); } return(new HttpResult(HttpStatusCode.OK)); }