Beispiel #1
0
        public IActionResult ConfirmPayment(PaymentModel Payment)
        {
            PaymentValidation paymentValidation = new PaymentValidation();
            ValidationResult  result            = paymentValidation.Validate(Payment);

            if (result.IsValid)
            {
                var cart = SessionHelper.GetObjectFromJson <List <ProductModel> >(HttpContext.Session, "cart");

                var ConfirmPayment = new ConfirmPaymentModel();

                ConfirmPayment.Product = cart;
                ConfirmPayment.Payment = Payment;

                if (ConfirmPayment != null)
                {
                    return(View(ConfirmPayment));
                }
            }
            else
            {
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(error.PropertyName, error.ErrorMessage);
                }
            }
            return(View(nameof(Checkout), Payment));
        }
Beispiel #2
0
		internal static void ConfirmPayment()
		{
			Console.WriteLine("Confirm payment");

			var ticketsTask = DataFactory.TicketService.Value.GetByPartitionKeyAsync(Configuration.Year);
			ticketsTask.Wait();

			var tickets = ticketsTask.Result.Where(i => !i.IsPayed).ToList();
			for (var i = 0; i < tickets.Count; i++)
			{
				Console.WriteLine("{0}. {1}", i, tickets[i].AttendeeEMail);
			}

			Console.Write("Chose ticket: ");
			var n = int.Parse(Console.ReadLine());

			var ticket = tickets[n];
			ticket.IsPayed = true;

			var attendeeTask = AppFactory.AttendeeService.Value.GetAttendeeByEmailAsync(ticket.AttendeeEMail);
			attendeeTask.Wait();

			var attendee = attendeeTask.Result;

			var message = new ConfirmPaymentModel
			{
				Email = attendee.EMail,
				FullName = attendee.FullName
			};

			AppFactory.TicketService.Value.SetTicketPayedAsync(attendee.EMail).Wait();
			NotificationFactory.AttendeeNotificationService.Value.SendPaymentConfirmationEmailAsync(message).Wait();
		}
Beispiel #3
0
        public ActionResult ConfirmPromise(long paymentId, long playerSeasonId)
        {
            if (this.CurrentPrincipal == null || this.CurrentPrincipal.IsAuthenticated == false)
            {
                return(this.RedirectToAction("Signin", "User"));
            }
            else
            {
                Payment targetPayment = this.ServiceManager.PaymentService.ConfirmPromise(this.CurrentPrincipal.User.Id, playerSeasonId, paymentId);

                if (targetPayment != null)
                {
                    //ADD CODE HERE FOR SENDING EMAIL TO PLAYER AND KERRI ABOUT PAYMENT
                    EmailService       sendPlayerEmail  = new EmailService();
                    EmailConfiguration emailConfig      = new EmailConfiguration();
                    AMFUserLogin       playerDemoInfo   = this.ServiceManager.UserService.GetByEmail(this.CurrentPrincipal.User.Email);
                    PlayerSeason       playerSeasonInfo = this.ServiceManager.SeasonService.GetPlayerSeasonById(playerSeasonId);

                    sendPlayerEmail.SendThankYouForPaymentEmail(this.CurrentPrincipal.User.Email, emailConfig, playerDemoInfo, playerSeasonInfo);

                    return(this.RedirectToAction("Season"));
                }
                else
                {
                    ConfirmPaymentModel retVal = new ConfirmPaymentModel();

                    PlayerSeason playerSeason = this.ServiceManager.SeasonService.GetPlayerSeasonById(playerSeasonId);
                    retVal.PaymentDetails = playerSeason.Payments.FirstOrDefault(p => p.Id == paymentId);
                    retVal.PlayerInfo     = this.CurrentPrincipal.User;
                    return(this.View("Confirm", retVal));
                }
            }
        }
		public async Task SendPaymentConfirmationEmailAsync(ConfirmPaymentModel model)
		{
			var template = new ConfirmPayment();
			
			var text = template.TransformText();

			var message = new SendGridMessage();
			message.To = new[] { new MailAddress(model.Email, model.FullName) };
			message.Subject = string.Format("Подтверждение оплаты билета на AZUREday {0}", Configuration.Year);
			message.Html = text;
			message.From = new MailAddress(Configuration.SendGridFromEmail, Configuration.SendGridFromName);
			message.ReplyTo = new[] { new MailAddress(Configuration.SendGridFromEmail, Configuration.SendGridFromName) };

			await SendEmail(message);
		}
Beispiel #5
0
        public async Task SendPaymentConfirmationEmailAsync(ConfirmPaymentModel model)
        {
            var template = new ConfirmPayment();

            var text = template.TransformText();

            var message = new SendGridMessage();

            message.AddTo(model.Email, model.FullName);
            message.Subject     = $"Подтверждение оплаты билета на AZUREday {Configuration.Year}";
            message.HtmlContent = text;
            message.From        = new EmailAddress(Configuration.SendGridFromEmail, Configuration.SendGridFromName);
            message.ReplyTo     = new EmailAddress(Configuration.SendGridFromEmail, Configuration.SendGridFromName);

            await SendEmail(message);
        }
Beispiel #6
0
        public ActionResult Confirm(decimal paymentAmount, PaymentPortions paymentPortion, PaymentMethods paymentMethod, string checkNumber, long playerSeasonId)
        {
            if (this.CurrentPrincipal == null || this.CurrentPrincipal.IsAuthenticated == false)
            {
                return(this.RedirectToAction("Signin", "User"));
            }
            else
            {
                ConfirmPaymentModel retVal = new ConfirmPaymentModel();

                retVal.PlayerSeason = this.ServiceManager.SeasonService.GetPlayerSeasonById(playerSeasonId);

                if (retVal.PlayerSeason.PlayerId == this.CurrentPrincipal.User.Id)
                {
                    retVal.PaymentDetails = this.ServiceManager.PaymentService.AddSeasonPayment(this.CurrentPrincipal.User.Id, paymentMethod, paymentAmount, checkNumber, playerSeasonId);
                    retVal.PlayerInfo     = this.CurrentPrincipal.User;
                }

                return(this.View(retVal));
            }
        }
Beispiel #7
0
        public ActionResult CancelPromise(long paymentId, long playerSeasonId)
        {
            if (this.CurrentPrincipal == null || this.CurrentPrincipal.IsAuthenticated == false)
            {
                return(this.RedirectToAction("Signin", "User"));
            }
            else
            {
                if (this.ServiceManager.PaymentService.CancelPromise(this.CurrentPrincipal.User.Id, playerSeasonId, paymentId))
                {
                    return(this.RedirectToAction("Season"));
                }
                else
                {
                    ConfirmPaymentModel retVal = new ConfirmPaymentModel();

                    PlayerSeason playerSeason = this.ServiceManager.SeasonService.GetPlayerSeasonById(playerSeasonId);
                    retVal.PaymentDetails = playerSeason.Payments.FirstOrDefault(p => p.Id == paymentId);
                    retVal.PlayerInfo     = this.CurrentPrincipal.User;
                    return(this.View("Confirm", retVal));
                }
            }
        }
        public async Task <string> PaymentConfirm([FromBody] PaymentResponse response)
        {
            var email   = response.MerchantInternalUserId;
            var tickets = await AppFactory.TicketService.Value.GetTicketsByEmailAsync(email);

            if (tickets != null && tickets.Any())
            {
                if (response.ErrorCode != 0)
                {
                    var ai = new TelemetryClient();

                    var props = new Dictionary <string, string>();
                    props.Add("MerchantInternalPaymentId", response.MerchantInternalPaymentId);
                    props.Add("MerchantInternalUserId", response.MerchantInternalUserId);
                    props.Add("OrderId", response.OrderId.ToString());
                    props.Add("ErrorCode", response.ErrorCode.ToString());
                    props.Add("DebugMessage", response.DebugMessage);
                    props.Add("Sum", response.Sum.ToString("F"));
                    props.Add("OrderSum", response.OrderSum.ToString("F"));

                    ai.TrackEvent("Payment error", props);

                    var attendee = await AppFactory.AttendeeService.Value.GetAttendeeByEmailAsync(email);

                    var message = new ErrorPaymentModel
                    {
                        Email    = attendee.EMail,
                        FullName = attendee.FullName
                    };

                    await Task.WhenAll(
                        NotificationFactory.AttendeeNotificationService.Value.SendPaymentErrorEmailAsync(message)
                        );
                }
                else
                {
                    var attendee = await AppFactory.AttendeeService.Value.GetAttendeeByEmailAsync(email);

                    var message = new ConfirmPaymentModel
                    {
                        Email    = attendee.EMail,
                        FullName = attendee.FullName
                    };

                    var orderSum = response.OrderSum;

                    var tasks = new List <Task>();
                    if ((decimal)tickets.Sum(x => x.Price) <= orderSum)
                    {
                        foreach (var ticket in tickets)
                        {
                            tasks.Add(AppFactory.TicketService.Value.SetTicketsPayedAsync(email, ticket.TicketType));
                        }
                        tasks.Add(NotificationFactory.AttendeeNotificationService.Value.SendPaymentConfirmationEmailAsync(message));
                    }
                    else
                    {
                        if (tickets.Count > 1)
                        {
                            if ((decimal)tickets[0].Price <= orderSum)
                            {
                                tasks.Add(AppFactory.TicketService.Value.SetTicketsPayedAsync(email, tickets[0].TicketType));
                                tasks.Add(NotificationFactory.AttendeeNotificationService.Value.SendPaymentConfirmationEmailAsync(message));

                                orderSum -= (decimal)tickets[0].Price;
                            }

                            if ((decimal)tickets[1].Price <= orderSum)
                            {
                                tasks.Add(AppFactory.TicketService.Value.SetTicketsPayedAsync(email, tickets[1].TicketType));
                            }
                            else
                            {
                                var newPrice = (decimal)tickets[1].Price - orderSum;
                                tasks.Add(AppFactory.TicketService.Value.UpdateTicketPriceAsync(email, tickets[1].TicketType, newPrice));
                            }
                        }
                        else
                        {
                            if ((decimal)tickets[0].Price <= orderSum)
                            {
                                tasks.Add(AppFactory.TicketService.Value.SetTicketsPayedAsync(email, tickets[0].TicketType));
                                tasks.Add(NotificationFactory.AttendeeNotificationService.Value.SendPaymentConfirmationEmailAsync(message));
                            }
                        }
                    }

                    await Task.WhenAll(tasks);
                }
            }
            else
            {
                var ai = new TelemetryClient();

                var props = new Dictionary <string, string>();
                props.Add("MerchantInternalPaymentId", response.MerchantInternalPaymentId);
                props.Add("MerchantInternalUserId", response.MerchantInternalUserId);
                props.Add("OrderId", response.OrderId.ToString());
                props.Add("ErrorCode", response.ErrorCode.ToString());
                props.Add("DebugMessage", response.DebugMessage);
                props.Add("Sum", response.Sum.ToString("F"));
                props.Add("OrderSum", response.OrderSum.ToString("F"));

                ai.TrackEvent("Unable to find ticket", props);
            }

            return(string.Empty);
        }
		public async Task<string> PaymentConfirm([FromBody]PaymentResponse response)
		{
			var email = response.MerchantInternalUserId;
			var ticket = await AppFactory.TicketService.Value.GetTicketByEmailAsync(email);

			if (ticket != null)
			{
				if (response.ErrorCode != 0)
				{
					var ai = new TelemetryClient();

					var props = new Dictionary<string, string>();
					props.Add("MerchantInternalPaymentId", response.MerchantInternalPaymentId);
					props.Add("MerchantInternalUserId", response.MerchantInternalUserId);
					props.Add("OrderId", response.OrderId.ToString());
					props.Add("ErrorCode", response.ErrorCode.ToString());
					props.Add("DebugMessage", response.DebugMessage);
					props.Add("Sum", response.Sum.ToString("F"));
					props.Add("OrderSum", response.OrderSum.ToString("F"));

					ai.TrackEvent("Payment error", props);

					var attendee = await AppFactory.AttendeeService.Value.GetAttendeeByEmailAsync(email);

					var message = new ErrorPaymentModel
					{
						Email = attendee.EMail,
						FullName = attendee.FullName
					};

					await Task.WhenAll(
						AppFactory.TicketService.Value.DeleteTicketAsync(email),
						NotificationFactory.AttendeeNotificationService.Value.SendPaymentErrorEmailAsync(message)
					);
				}
				else
				{
					var attendee = await AppFactory.AttendeeService.Value.GetAttendeeByEmailAsync(email);

					var message = new ConfirmPaymentModel
					{
						Email = attendee.EMail,
						FullName = attendee.FullName
					};

					await Task.WhenAll(
						AppFactory.TicketService.Value.SetTicketPayedAsync(email),
						NotificationFactory.AttendeeNotificationService.Value.SendPaymentConfirmationEmailAsync(message)
					);
				}
			}
			else
			{
				var ai = new TelemetryClient();

				var props = new Dictionary<string, string>();
				props.Add("MerchantInternalPaymentId", response.MerchantInternalPaymentId);
				props.Add("MerchantInternalUserId", response.MerchantInternalUserId);
				props.Add("OrderId", response.OrderId.ToString());
				props.Add("ErrorCode", response.ErrorCode.ToString());
				props.Add("DebugMessage", response.DebugMessage);
				props.Add("Sum", response.Sum.ToString("F"));
				props.Add("OrderSum", response.OrderSum.ToString("F"));

				ai.TrackEvent("Unable to find ticket", props);
			}

			return string.Empty;
		}