Exemple #1
0
        /// <inheritdoc />
        /// <summary>
        /// Handles the specified payment made message.
        /// </summary>
        /// <param name="paymentMadeMessage">The payment made message.</param>
        public void Handle(TransactionMadeMessage paymentMadeMessage)
        {
            string paymentId     = paymentMadeMessage.Transaction.Id;
            string autoAllocate  = paymentMadeMessage.PaymentViewModel.AutoAllocate;
            string appointmentId = paymentMadeMessage.PaymentViewModel.AppointmentId;

            string message = "PaymentMadeMessage " +
                             "PaymentId=" + paymentId + " " +
                             "AutoAllocate=" + autoAllocate + " " +
                             "AppointmentId=" + appointmentId;

            loggingService.Info(GetType(), message);

            int?id = GetAppointmentId(autoAllocate, appointmentId);

            if (id.HasValue == false)
            {
                loggingService.Info(GetType(), "Payment not handled");
                return;
            }

            CustomerModel customerModel = customerProvider.GetCustomerModel(paymentMadeMessage.UmbracoContext);

            int customerId = customerModel.Id;

            UpdateAppointment(id.Value, customerId, paymentId);
        }
        /// <summary>
        /// Translates the specified transaction.
        /// </summary>
        /// L<param name="paymentMadeMessage">The payment made message.</param>
        /// <returns></returns>L
        /// <inheritdoc />
        public TransactionModel Translate(TransactionMadeMessage paymentMadeMessage)
        {
            TransactionType transactionType = paymentMadeMessage.Transaction.Type;

            return(new TransactionModel
            {
                Amount = paymentMadeMessage.Transaction.Amount ?? 0,
                CardType = paymentMadeMessage.Transaction.CreditCard.CardType.ToString(),
                MaskedCardNumber = paymentMadeMessage.Transaction.CreditCard.MaskedNumber,
                CreatedTime = DateTime.UtcNow,
                TransactionId = paymentMadeMessage.Transaction.Id,
                CreatedUser = paymentMadeMessage.CreatedUser,
                PaymemtProvider = paymentMadeMessage.PaymentProvider.ToUpper().Substring(0),
                Environment = paymentMadeMessage.Environment.ToUpper().Substring(0),
                TransactionType = transactionType.ToString().ToUpper().Substring(0)
            });
        }
Exemple #3
0
        /// <inheritdoc />
        /// <summary>
        /// Handles the specified transaction made message.
        /// </summary>
        /// <param name="paymentMadeMessage">The payment made message.</param>
        public void Handle(TransactionMadeMessage paymentMadeMessage)
        {
            string transactionId = paymentMadeMessage.Transaction.Id;

            string message = "TransactionMadeMessage " + "TransactionId=" + transactionId + " ";

            loggingService.Info(GetType(), message);

            CustomerModel customerModel = customerProvider.GetCustomerModel(paymentMadeMessage.UmbracoContext);

            TransactionModel model = paymentTranslator.Translate(paymentMadeMessage);

            model.CustomerId = customerModel.Id;

            databaseProvider.InsertTransaction(model);

            ///// do we want to send a confirmation email??

            if (string.IsNullOrEmpty(paymentMadeMessage.EmailTemplateName) == false &&
                string.IsNullOrEmpty(paymentMadeMessage.PaymentViewModel.EmailAddress) == false)
            {
                Dictionary <string, string> dictionary = new Dictionary <string, string>
                {
                    { "PaymentId", transactionId },
                    { "AppointmentId", paymentMadeMessage.PaymentViewModel.AppointmentId },
                    { "PaymentAmount", paymentMadeMessage.PaymentViewModel.Amount.ToString(CultureInfo.InvariantCulture) },
                };

                loggingService.Info(GetType(), "Sending Email");

                MailResponse mailResponse = mailProvider.SendEmail(
                    paymentMadeMessage.UmbracoContext,
                    paymentMadeMessage.EmailTemplateName,
                    paymentMadeMessage.PaymentViewModel.EmailAddress,
                    null,
                    dictionary);

                //// TODO : we need to log the mail response!
            }
        }