Esempio n. 1
0
        /// <summary>
        /// Return an auth token that can be used for other tests
        /// </summary>
        /// <returns></returns>
        private string PerformCreditCardAuth()
        {
            var customerData = new CustomerFields
            {
                Address1 = "123 Main Street",
                Address2 = "Suite 200",
                City     = "St. Louis",
                Country  = "USA",
                Email    = "*****@*****.**",
                Name1    = "George",
                Name2    = "Washington",
                Phone    = "123-333-3333",
                State    = "MO",
                ZipCode  = "63102"
            };

            var transactionData = new CreditCardPayment
            {
                CardExpire = "1218",
                Cvv        = "123",
                CardNumber = "4111111111111111"
            };

            var transaction = new Payment(UserName, Password, Mode, ResponseVersion);

            transaction.ProcessCreditCardAuth(transactionData, customerData, 0);
            var result   = transaction.GetRawResponse();
            var response = new Response(result);

            return(response.GetValue(ResponseFields.ResultToken));
        }
Esempio n. 2
0
        public void Handle(InitiateCreditCardPayment command)
        {
            var payment = new CreditCardPayment(command.PaymentId, command.OrderId, command.TransactionId, command.Amount,
                                                command.Meter, command.Tip, command.CardToken, command.Provider, command.CompanyKey);

            _repository.Save(payment, command.Id.ToString());
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the credit card payment.
        /// </summary>
        /// <returns></returns>
        public Payment GetCreditCardPayment()
        {
            if (string.IsNullOrEmpty(CreditCardNumber.Text))
            {
                return(null);
            }

            var payment = new CreditCardPayment()
            {
                CreditCardNumber       = CreditCardNumber.Text,
                CreditCardSecurityCode = SecurityCode.Text
            };

            int dateValue;

            if (int.TryParse(creditCardMonth.SelectedValue, out dateValue))
            {
                payment.ExpirationMonth = dateValue;
            }
            if (int.TryParse(creditCardYear.SelectedValue, out dateValue))
            {
                payment.ExpirationYear = dateValue;
            }

            return(payment);
        }
    private string PostCreditCardPayment(string tranResp)
    {
      //Credit Card Payment

      var creditCardPayment = new CreditCardPayment
      {
        TransactionID = tranResp,
        CardNumber = oneTimeDonationView.CardNumber,
        CardType = oneTimeDonationView.CardType,//"Visa",
        ExpiryMonth = oneTimeDonationView.ExpiryMonth,//"09",
        ExpiryYear = oneTimeDonationView.ExpiryYear,//"2018",
        CardHolderName = oneTimeDonationView.CarHolderName,
        CardVerificationValue = oneTimeDonationView.SecurityCode,
        PaymentAmount = oneTimeDonationView.DonationAmount //"5.00"//oneTimeDonationInterface.DonationAmount.ToString("N2")
      };
      HttpClient cons = new HttpClient();
      cons.DefaultRequestHeaders.Accept.Clear();
      cons.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
      cons.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", GetEncodedAuthorization());
      StringContent jSonReqCreditCardPayment = new StringContent(JsonConvert.SerializeObject(creditCardPayment), Encoding.UTF8, "application/json");
      //  HttpResponseMessage creditCardResponseMessage = cons.PostAsync("https://secureuat.artezhq.com/api/CreditCardPayments", jSonReqCreditCardPayment).Result;
      HttpResponseMessage creditCardResponseMessage = cons.PostAsync("https://secure.e2rm.com/api/CreditCardPayments", jSonReqCreditCardPayment).Result;
      var ghi = creditCardResponseMessage.Content.ReadAsAsync<CreditCardPaymentResponse>();
      return ghi.Result.PaymentID.ToString();
    }
Esempio n. 5
0
        protected override IPayment CreateConcretePayment()
        {
            IPayment product = new CreditCardPayment();

            // Here is the place for some additional object creation logic.
            return(product);
        }
        public Mediachase.Commerce.Orders.Payment PreProcess(OrderForm orderForm)
        {
            if (orderForm == null)
            {
                throw new ArgumentNullException("orderForm");
            }

            if (!ValidateData())
            {
                return(null);
            }

            var payment = new CreditCardPayment
            {
                CardType               = "Credit card",
                PaymentMethodId        = PaymentMethodId,
                PaymentMethodName      = "GenericCreditCard",
                OrderFormId            = orderForm.OrderFormId,
                OrderGroupId           = orderForm.OrderGroupId,
                Amount                 = orderForm.Total,
                CreditCardNumber       = CreditCardNumber,
                CreditCardSecurityCode = CreditCardSecurityCode,
                ExpirationMonth        = ExpirationMonth,
                ExpirationYear         = ExpirationYear,
                Status                 = PaymentStatus.Pending.ToString(),
                CustomerName           = CreditCardName,
                TransactionType        = TransactionType.Authorization.ToString()
            };

            return(payment);
        }
Esempio n. 7
0
        /// <summary>
        /// This method is called before the order is completed. This method should check all the parameters
        /// and validate the credit card or other parameters accepted.
        /// </summary>
        /// <param name="form"></param>
        /// <returns>bool</returns>
        public Payment PreProcess(OrderForm form)
        {
            CreditCardPayment cardPayment = new CreditCardPayment();

            //if (form.Payments.Count == 0)
            {
                DateTime expiratonDate = new DateTime(int.Parse(creditCardExpireYear.SelectedValue == null ? "0" : creditCardExpireYear.SelectedValue),
                                                      int.Parse(creditCardExpireMonth.SelectedValue == null ? "0" : creditCardExpireMonth.SelectedValue), 1);

                cardPayment.BillingAddressId       = form.BillingAddressId;
                cardPayment.CustomerName           = creditCardName.Text;
                cardPayment.CreditCardNumber       = creditCardNumber.Text;
                cardPayment.ExpirationMonth        = expiratonDate.Month;
                cardPayment.ExpirationYear         = expiratonDate.Year;
                cardPayment.CreditCardSecurityCode = creditCardCSC.Text;
            }

            /*
             * CreditCardPayment ccPayment =
             * info.CreditCardName = creditCardName.Text;
             * info.CreditCardNumber = creditCardNumber.Text;
             * info.CreditCardExpired = new DateTime(int.Parse(creditCardExpireYear.SelectedValue == null ? "0" : creditCardExpireYear.SelectedValue),
             *  int.Parse(creditCardExpireMonth.SelectedValue == null ? "0" : creditCardExpireMonth.SelectedValue), 1).ToString("MMyyyy");
             * info.CreditCardCSC = creditCardCSC.Text;
             * */
            return((Payment)cardPayment);
        }
Esempio n. 8
0
        public CommandResult FinishCreditCardOrder(FinishCreditCardOrderCommand command, Guid UserId)
        {
            var email = new Email(command.Email);

            var payment = new CreditCardPayment(
                command.CardHolderName,
                command.CardNumber,
                command.PaidDate,
                command.ExpireDate,
                command.Total,
                command.TotalPaid,
                command.Payer,
                email);

            var cart = new ShoppingCart(UserId, command.ListOfItems);

            var order = new Order(UserId, cart, payment);

            order.AddNonconformity(payment, cart);

            if (order.IsInvalid)
            {
                return(new CommandResult(false, "Can't finish the order request."));
            }

            _unit.Orders.CreateOrder(order);

            return(new CommandResult(true, "Order finished with success."));
        }
Esempio n. 9
0
        public ICommandResult Handle(CreateCreditCardSubscriptionCommand command)
        {
            // Fail Fast Validations
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possível realizar sua assinatura"));
            }

            // Verificar se Documento já está cadastrado
            if (_studentRepository.DocumentExists(command.Document))
            {
                AddNotification("Document", "Este CPF já está em uso");
            }

            // Verificar se Email já está cadastrado
            if (_studentRepository.DocumentExists(command.Email))
            {
                AddNotification("Email", "Este Email já está em uso");
            }

            //Gerar os VOs
            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentType.CPF);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);

            // gerar as Entidades
            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new CreditCardPayment(command.CardHolderName, command.CardNumber, command.LastTransactionNumber,
                                                     command.PaidDate, command.ExpireDate,
                                                     command.Total, command.TotalPaid,
                                                     command.Payer, new Document(command.PayerDocuments,
                                                                                 command.PayerDocumentsType), address, email);

            // Relacionamentos
            subscription.AddPayments(payment);
            student.AddSubscription(subscription);

            //Agrupar as Validações
            AddNotifications(name, document, email, address, student, subscription, subscription, payment);

            // Checar Notificações
            if (Invalid)
            {
                return(new CommandResult(false, "Não foi possível realizar sua assinatura"));
            }

            //Salvar as informações
            _studentRepository.CreateSubscription(student);

            // Enviar E-mail de boas vindas
            _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo ao Curso", "Sua assinatura foi assinada");
            // Retornar informações

            return(new CommandResult(true, "Assinatura realizada com sucesso"));
        }
Esempio n. 10
0
        public void ReturnSuccessWhenHadNoActiveSubscription()
        {
            var payment = new CreditCardPayment($"{_name.FirstName} {_name.LastName}", "5466584611234", "123", "", DateTime.Now, DateTime.Now.AddDays(5), _doc, _email, "", _address, 100, 100);

            _subscription.AddPayment(payment);
            _customer.AddSubscription(_subscription);
            Assert.IsTrue(_customer.Valid);
        }
Esempio n. 11
0
        public void IsEqualTest()
        {
            CreditCardPayment creditCardPaymentCompare = new CreditCardPayment();

            Assert.AreEqual(_creditCardPayment.IsEqual(creditCardPaymentCompare), true);
            creditCardPaymentCompare.CardNumber = new string[] { "1", "2", "2", "2" };
            Assert.AreEqual(_creditCardPayment.IsEqual(creditCardPaymentCompare), false);
        }
Esempio n. 12
0
        public ICommandResult Handle(CreateCreditCardSubscriptionCommand command)
        {
            //Fail Fast Validation

            if (!command.Validate())
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possivel realizar sua assinatura."));
            }

            if (_studentRepository.DocumentExistis(command.DocumentNumber))
            {
                AddNotification("Document", "CPF já em uso.");
            }

            if (_studentRepository.EmailExists(command.Email))
            {
                AddNotification("Email", "E-mail já em uso.");
            }

            if (command.Valid)
            {
                var name     = new Name(command.FirstName, command.LastName);
                var document = new Document(command.DocumentNumber, EDocumentType.CPF);
                var email    = new Email(command.Email);
                var address  = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);

                var student      = new Student(name, document, email);
                var subscription = new Subscription(DateTime.Now.AddMonths(1));
                var payment      = new CreditCardPayment(
                    command.CardHolderName,
                    command.CardName,
                    command.LastTransactionNumber,
                    command.PaidDate,
                    command.ExpireDate,
                    command.Total,
                    command.TotalPaid,
                    address,
                    new Document(command.PayerDocument, command.PayerDocumentType),
                    command.Payer,
                    email
                    );

                //Relacionamentos
                subscription.AddPayment(payment);
                student.AddSubscription(subscription);

                AddNotifications(name, document, email, address, student, subscription, payment);

                if (Valid)
                {
                    _studentRepository.CreateSubscription(student);
                    _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem Vindo", "Assinatura criada!");
                    return(new CommandResult(true, "Assinatura realizada com sucesso"));
                }
            }
            return(new CommandResult(false, "Não foi possivel realizar sua assinatura."));
        }
Esempio n. 13
0
        /// <summary>
        /// Adds the special field.
        /// </summary>
        /// <param name="info">The info.</param>
        /// <param name="name">The name.</param>
        private void AddSpecialField(CreditCardPayment info, string name)
        {
            var val = Settings[name];

            if (val.Length > 0)
            {
                _icharge.AddSpecialField(name, val);
            }
        }
Esempio n. 14
0
        public void CreditCardPaymentTest()
        {
            CreditCardPayment creditCardPayment = new CreditCardPayment();

            creditCardPayment.FirstName = "first";
            _order.CreditCardPayment    = creditCardPayment;
            Assert.AreEqual(_order.CreditCardPayment.FirstName, "first");
            Assert.AreEqual(_order.CreditCardPayment.IsEqual(creditCardPayment), true);
        }
        public ICommandResult Handle(CreateCreditCardSubscriptionCommand command)
        {
            //Fail Fast validations
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possível realizar sua assinatura"));
            }

            //Verificar se documento já esta cadastrado
            if (_repository.DocumentExists(command.Document))
            {
                AddNotification("Documents", "Este CPF já se encontra cadastrado");
            }
            //Verificar se email já esta cadastrado
            if (_repository.DocumentExists(command.Email))
            {
                AddNotification("Documents", "Este E-mail já se encontra cadastrado");
            }
            //Gerar VO
            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentType.CPF);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.Number, command.Neighborhood, command.State, command.Country, command.ZipCode);

            //Gerar entidades
            var student      = new Student(name, document, email, address);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new CreditCardPayment(command.Owner,
                                                     command.CardNumber,
                                                     command.LastTransactionNumber,
                                                     command.PaidDate,
                                                     command.ExipreDate,
                                                     command.Total,
                                                     command.TotalPaid,
                                                     new Document(command.OwnerDocument, command.OwnerType),
                                                     command.Owner,
                                                     address,
                                                     email);

            //Relacionamentos
            subscription.AddPayment(payment);
            student.AddSubscritpion(subscription);
            //Aplicar Validações
            AddNotifications(name, document, email, address, student, subscription, payment);
            if (Invalid)
            {
                return(new CommandResult(false, "Não foi possível realizar sua assinatura"));
            }
            //Salvar Informações
            _repository.CreateSubscrption(student);
            //Enviar E-mail
            _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo ao Site", "Sua Assinatura foi criada");

            return(new CommandResult(true, "Assinatura Realizada com sucesso"));
        }
Esempio n. 16
0
        /// <summary>
        /// Adds the config field.
        /// </summary>
        /// <param name="info">The info.</param>
        /// <param name="name">The name.</param>
        private void AddConfigField(CreditCardPayment info, string name)
        {
            var val = Settings[name];

            if (val.Length > 0)
            {
                _icharge.Config($"{name}={val}");
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Adds the config field.
        /// </summary>
        /// <param name="info">The info.</param>
        /// <param name="name">The name.</param>
        private void AddConfigField(CreditCardPayment info, string name)
        {
            string val = Settings[name];

            if (val.Length > 0)
            {
                _icharge.Config(String.Format("{0}={1}", name, val));
            }
        }
Esempio n. 18
0
 public void TestInitialize()
 {
     order                   = new Order();
     product                 = new Product("testName", new Category("CPU", 1), "1000", "test", Constant.RESOURCE_PATH + "/CPU/0.jpg", "1");
     creditCardPayment       = new CreditCardPayment();
     order.CreditCardPayment = creditCardPayment;
     order.AddSelectProductToList(product);
     order.UserSelectedProductsQuantity.Add(1);
 }
Esempio n. 19
0
        public ICommandResult Handle(CreateCreditCardSubscriptionCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possível realizar sua assinatura"));
            }

            if (_repository.DocumentExists(command.Document))
            {
                AddNotification("Document", "Este CPF já está em uso");
            }

            if (_repository.EmailExists(command.Email))
            {
                AddNotification("Email", "Este E-mail já está em uso");
            }

            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentType.CPF);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);

            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new CreditCardPayment(
                command.CardHolderName,
                command.CardNumber,
                command.LastTransactionNumber,
                command.PaidDate,
                command.ExpireDate,
                command.Total,
                command.TotalPaid,
                command.Payer,
                new Document(command.PayerDocument, command.PayerDocumentType),
                address,
                email
                );

            subscription.AddPayment(payment);
            student.AddSubscription(subscription);

            AddNotifications(name, document, email, address, student, subscription, payment);

            if (Invalid)
            {
                return(new CommandResult(false, "Não foi possível realizar sua assinatura"));
            }

            _repository.CreateSubscription(student);

            _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo ao balta.io", "Sua assinatura foi criada!");

            return(new CommandResult(true, "Assinatura realizada com sucesso"));
        }
        public void ShouldReturnSuccessWhenAddSubscription()
        {
            var subscription = new Subscription(null);
            var payment      = new CreditCardPayment("User Card", "123", "123", DateTime.Now, DateTime.Now.AddDays(3), 100, 100, "User", _document, _address);

            subscription.AddPayment(payment);
            _student.AddSubscription(subscription);

            Assert.IsTrue(_student.Valid);
        }
Esempio n. 21
0
        public ICommandResult Handle(CreateCreditCardSubscriptionCommand command)
        {
            //CREATE FAIL FAST VALIDATIONS

            //Verify if document has been saved
            if (_repository.DocumentExists(command.Document))
            {
                AddNotification("Document", "Este CPF ja esta em uso");
            }

            //verifify if e-mail has been saved
            if (_repository.EmailExists(command.Email))
            {
                AddNotification("E-mail", "Este E-mail ja esta em uso");
            }

            //Create VO's
            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentType.CPF);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);

            //Create Entities
            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new CreditCardPayment(command.CardHolderName,
                                                     command.CardNumber,
                                                     command.LastTransactionNumber,
                                                     command.PaidDate,
                                                     command.ExpireDate,
                                                     command.Total,
                                                     command.TotalPaid,
                                                     command.Payer,
                                                     new Document(command.Document, EDocumentType.CPF),
                                                     address,
                                                     email
                                                     );

            // Relationships
            subscription.AddPayment(payment);
            student.AddSubscription(subscription);

            //Group validations
            AddNotifications(name, document, email, address, student, subscription, payment);

            //Save information
            _repository.CreateSubscriprion(student);

            //Send welcome e-mail
            _emailService.Send(student.Name.ToString(), student.Email.Address, "Welcome", "Your subscription has been created");

            //return information
            return(new CommandResult(true, "Subscription success"));
        }
Esempio n. 22
0
        public void IsCardNumberEqualTest()
        {
            CreditCardPayment creditCardPaymentCompare = new CreditCardPayment();

            _creditCardPayment.CardNumber       = new string[] { "1", "2", "3", "4" };
            creditCardPaymentCompare.CardNumber = new string[] { "1", "2", "3", "4" };
            PrivateObject target = new PrivateObject(_creditCardPayment);

            Assert.AreEqual(target.Invoke("IsCardNumberEqual", new object[] { creditCardPaymentCompare.CardNumber }), true);
            creditCardPaymentCompare.CardNumber = new string[] { "1", "2", "3", "3" };
            Assert.AreEqual(target.Invoke("IsCardNumberEqual", new object[] { creditCardPaymentCompare.CardNumber }), false);
        }
Esempio n. 23
0
        public ICommandResult Handle(CreateCreditCardSubscriptionCommand command)
        {
            //verificar se o doc ta cadastrado
            if (_repository.DocumentExists(command.Document))
            {
                AddNotification("Document", "Este CPF já esta em uso");
            }

            //verificar se o email ta cadastrado
            if (_repository.DocumentExists(command.Email))
            {
                AddNotification("Email", "Este Email já esta em uso");
            }

            //gerar as VOs
            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentType.CPF);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);

            //gerar as Entidades
            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new CreditCardPayment(
                command.CardHolderName,
                command.CardNumber,
                command.LastTransactionNumber,
                command.PaidDate,
                command.ExpireDate,
                command.Total,
                command.TotalPaid,
                command.Payer,
                new Document(command.PayerDocument, command.PayerDocumentType),
                address,
                email);

            //relacionamentos
            subscription.AddPayment(payment);
            student.AddSubscription(subscription);


            //agrupar validações
            AddNotifications(name, document, email, address, student, subscription, payment);

            //salvar as infos
            _repository.CreateSubscription(student);

            //enviar email boas vindas
            _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo novato!!", "Assinatura Criada");
            //retornar infos
            return(new CommanResult(true, "Assinatura cadastrada com sucesso!"));
        }
        public void TestCreditCardPayment()
        {
            CreditCardPayment creditCardPayment = new CreditCardPayment();

            Assert.AreEqual(creditCardPayment.LastName, string.Empty);
            Assert.AreEqual(creditCardPayment.FirstName, string.Empty);
            Assert.AreEqual(creditCardPayment.CreditCardNumber.Length, 4);
            Assert.AreEqual(creditCardPayment.EffectiveDateYear, Constant.START_YEAR.ToString());
            Assert.AreEqual(creditCardPayment.EffectiveDateMonth, "1");
            Assert.AreEqual(creditCardPayment.SecurityCode, string.Empty);
            Assert.AreEqual(creditCardPayment.Mail, string.Empty);
            Assert.AreEqual(creditCardPayment.Address, string.Empty);
        }
        public ICommandResult Handle(CreateCreditCardSubscriptionCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "não foi possível realizar seu cadastro"));
            }

            //verificar se o documento já existe
            if (_repository.DocumentExists(command.Document))
            {
                AddNotifications(command);
                return(new CommandResult(false, "já existe um cadastro com o documento informado"));
            }

            //verificar se email já existe
            if (_repository.EmailExists(command.Email))
            {
                AddNotifications(command);
                return(new CommandResult(false, "já existe um cadastro com o e-mail informado"));
            }

            //gerar vo's
            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentType.CPF);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);

            //gerar entidades
            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new CreditCardPayment(command.CardHolderName, command.CardNumber, command.LastTransactionNumber, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, address,
                                                     new Document(command.PayerDocument, command.PayerDocumentType), command.Payer, email);

            //relacionamentos
            subscription.AddPayment(payment);
            student.AddSubscription(subscription);

            //aplicar validações
            AddNotifications(name, document, email, address, student, subscription, payment);

            //salvar informações
            _repository.CreateSubscription(student);

            //Enviar email de boas vindas
            _emailService.Send(student.Name.ToString(), student.Email.Address, "bem vindo ao serviceName", "Sua assinatura foi criada!");

            //retornar informações
            return(new CommandResult(true, "Assinatura realizada com sucesso!"));
        }
Esempio n. 26
0
        public ICommandResult Handle(CreateCreditCardSubscriptionCommand command)
        {
            //Verify whether document is already registred
            if (_repository.DocumentExists(command.Document))
            {
                AddNotification("Document", "Este CPF ja esta em uso");
            }

            //Verify whether eamil is already registred
            if (_repository.EmailExists(command.Email))
            {
                AddNotification("Email", "Este Email ja esta em uso");
            }

            //Generate VOs
            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentType.CPF);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);

            //Generate Entities
            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new CreditCardPayment(command.CardHolderName, command.CardNumber, command.LastTransactionNumber,
                                                     command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, command.Payer,
                                                     new Document(command.PaymentNumber, command.PayerDocumentType),
                                                     address, email);

            //Apply Relationship
            subscription.AddPayment(payment);
            student.AddSubcription(subscription);

            //Group Validation
            AddNotifications(name, document, email, address, student, subscription, payment);

            //Check notifications
            if (Invalid)
            {
                return(new CommandResult(false, "Não foi possivel realizar sua assinatura."));
            }

            //Save information
            _repository.CreateSubscription(student);

            //Send Welcome E-mail
            _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo ao guilherme.io", "Sua assinatura foi criada");

            //Return information
            return(new CommandResult(true, "Assinatura realizada com sucesso."));
        }
Esempio n. 27
0
        /// <summary>
        /// Creates the credit card payment.
        /// </summary>
        /// <returns></returns>
        public static Payment CreateCreditCardPayment()
        {
            CreditCardPayment payment = new CreditCardPayment();

            UpdatePaymentMethodInfo(payment);

            payment.CardType               = "Visa";
            payment.CreditCardNumber       = "4012888818888";
            payment.CreditCardSecurityCode = "123";
            payment.ExpirationMonth        = 7;
            payment.ExpirationYear         = DateTime.Now.AddYears(1).Year;
            payment.Amount = 10;
            return(payment);
        }
Esempio n. 28
0
        public CreditCardAuthorizationResult Authorize(CreditCardPayment payment, String description, Project.MVC.Entity.Models.Address billingAddress)
        {
            if (billingAddress == null)
            {
                throw new ArgumentNullException("billingAddress");
            }

            if (payment == null)
            {
                throw new ArgumentNullException("payment");
            }

            var result = new CreditCardAuthorizationResult();

            AuthorizeNetAuthorizationResult authResult = _authorizeNetService
                                                         .Authorize(payment.CreditCardNumber, payment.Expiration.ToString("MM/yy"), payment.CVV, payment.Amount, description, billingAddress);

            if (authResult.Success)
            {
                result.Success = true;

                CreditCardTransaction transaction = new CreditCardTransaction()
                {
                    Amount            = authResult.Amount,
                    AuthorizationCode = authResult.AuthorizationCode,
                    CardLastFour      = payment.CreditCardNumber.Substring(payment.CreditCardNumber.Length - 4),
                    PaymentMethod     = PaymentMethod.CreditCard,
                    TransactionDate   = DateTime.Now,
                    TransactionType   = TransactionType.Authorization
                };

                TransactionDetails transactionDetails = new TransactionDetails()
                {
                    TransactionProcessor = TransactionProcessor.AuthorizeNet,
                    TransactionProcessorTransactionID = authResult.MerchantTransactionID
                };

                transaction.TransactionDetails = transactionDetails;

                result.Transaction = transaction;

                return(result);
            }

            result.Success = false;

            result.Errors.AddRange(authResult.Errors);

            return(result);
        }
Esempio n. 29
0
        public static void Main(string[] args)
        {
            IPaymentStrategy <Cash> cashPayment = new CashPayment();

            cashPayment.Pay(new Cash());

            IPaymentStrategy <CreditCard> creditCardPayment = new CreditCardPayment();

            creditCardPayment.Pay(new CreditCard(CardType.Visa, "4539867398424592"));

            IPaymentStrategy <Paypal> payPalPayment = new PayPalPayment();

            payPalPayment.Pay(new Paypal("*****@*****.**"));
        }
Esempio n. 30
0
        public ICommandResult Handle(CreateCreditCardSubcriptionCommand command)
        {
            command.Validate();
            if (command.Invalid)
            {
                AddNotifications(command);
                return(new CommandResult(false, "Não foi possível realizar sua assinatura."));
            }

            //VERIFICAR SE DOCUMENTO JÁ ESTÁ CADASTRADO
            if (_studentRepository.DocumentExists(command.Document))
            {
                AddNotification("Document", "Esse CPF já está incluso.");
            }

            //VERIFICAR SE E-MAIL JÁ ESTÁ CADASTRADO
            if (_studentRepository.EmailExists(command.Email))
            {
                AddNotification("Email", "Esse e-mail já está incluso.");
            }

            //GERAR OS VOS
            var name     = new Name(command.FirstName, command.LastName);
            var document = new Document(command.Document, EDocumentType.CPF);
            var email    = new Email(command.Email);
            var address  = new Address(command.Street, command.Number, command.Neighborhood, command.City, command.State, command.Country, command.ZipCode);



            //GERAR AS ENTIDADES
            var student      = new Student(name, document, email);
            var subscription = new Subscription(DateTime.Now.AddMonths(1));
            var payment      = new CreditCardPayment(command.CardHolderName, command.CardNumber, command.LastTransactionNumber, command.PaidDate, command.ExpireDate, command.Total, command.TotalPaid, command.Payer, new Document(command.PayerDocument, command.PayerDocumentType), address, email);

            subscription.AddPayment(payment);
            student.AddSubscription(subscription);

            AddNotifications(name, document, email, address, student, subscription, payment);
            if (Invalid)
            {
                return(new CommandResult(false, "Não foi possível realizar a sua assinatura."));
            }

            _studentRepository.CreateSubcription(student);

            _emailService.Send(student.Name.ToString(), student.Email.Address, "Bem vindo ao Fabiostefani.io", "Sua assinatura foi criada");

            return(new CommandResult(true, "Assinatura realizada com sucesso."));
        }
        /// <summary>
        /// Gets the credit card payment.
        /// </summary>
        /// <returns></returns>
        public Payment GetCreditCardPayment()
        {
            if (string.IsNullOrEmpty(CreditCardNumber.Text))
                return null;

            var payment = new CreditCardPayment()
            {
                CreditCardNumber = CreditCardNumber.Text,
                CreditCardSecurityCode = SecurityCode.Text
            };

            int dateValue;
            if (int.TryParse(creditCardMonth.SelectedValue, out dateValue))
                payment.ExpirationMonth = dateValue;
            if (int.TryParse(creditCardYear.SelectedValue, out dateValue))
                payment.ExpirationYear = dateValue;

            return payment;
        }
Esempio n. 32
0
        /// <summary>
        /// Implement PayByCreditCard method
        /// </summary>
        public void PayByCreditCard()
        {
            decimal balance = sale.getBalance();
            decimal amountEnter = Amount;
            decimal amount = (amountEnter > balance ? balance : amountEnter);
            PaymentMethod payment = new CreditCardPayment(amount);

            if (amountEnter <= balance)
            {
                sale.processPayment(payment);
                UpdatePaymentMethodView();
            }
            else
                MessageBox.Show("Your credit card payment cannot be greater than your balance.");
        }
Esempio n. 33
0
        public static CreditCardPayment GetCreditCardPaymentByID(int paymentID, string externalType, int externalID)
        {
            CreditCardPayment payment = new CreditCardPayment();

            DataSet ds = CommonData.ExecuteStoredProcedure(Constants.StoredProcedures.PaymentsGet,
                CommonData.SqlParam("@ExternalType", SqlDbType.VarChar, 100, externalType),
                CommonData.SqlParam("@ExternalID", SqlDbType.Int, 4, externalID),
                CommonData.SqlParam("@PaymentID", SqlDbType.Int, 4, paymentID));

            if (ds != null && ds.Tables["Data"] != null && ds.Tables["Data"].Rows.Count > 0)
            {
                DataRow dr = ds.Tables["Data"].Rows[0];
                payment = CreditCardPayment.ConvertToCreditCardPayment(dr);
            }

            return payment;
        }
        public Mediachase.Commerce.Orders.Payment PreProcess(OrderForm orderForm)
        {
            if (orderForm == null) throw new ArgumentNullException("orderForm");

            if (!ValidateData())
                return null;

            var payment = new CreditCardPayment
                {
                    CardType = "Credit card",
                    PaymentMethodId = PaymentMethodId,
                    PaymentMethodName = "GenericCreditCard",
                    OrderFormId = orderForm.OrderFormId,
                    OrderGroupId = orderForm.OrderGroupId,
                    Amount = orderForm.Total,
                    CreditCardNumber = CreditCardNumber,
                    CreditCardSecurityCode = CreditCardSecurityCode,
                    ExpirationMonth = ExpirationMonth,
                    ExpirationYear = ExpirationYear,
                    Status = PaymentStatus.Pending.ToString(),
                    CustomerName = CreditCardName,
                    TransactionType = TransactionType.Authorization.ToString()
            };

            return payment;
        }