public CustomerPayment GetCustomerPaymentByToken(CustomerPaymentTokenizer tokenizer)
        {
            try
            {
                Log.Info($"Consultando o cartões de credito com o token {tokenizer.Id} para o usuário {tokenizer.IdCustomer}");

                var creditCard = MundiPagg.MundiPaggProxy.GetCreditCardByToken(tokenizer);

                if (creditCard == null)
                    return null;

                CustomerPayment payment = new CustomerPayment();
                payment.CreditCardNumber = creditCard.MaskedCreditCardNumber;
                payment.CreditCardBrand = (CreditCardBrandEnum)((int)creditCard.CreditCardBrand);
                payment.InstantBuy = creditCard.InstantBuyKey;
                payment.SecurityCode = tokenizer.SecurityCode;

                return payment;
                
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex);
                throw;
            }
            finally
            {
                Log.Info($"Finalizando a consulta o cartões de credito com o token {tokenizer.Id} para o usuário {tokenizer.IdCustomer}");
            }

        }
 public bool CreateQuickTicket(CustomerTicket ticket, CustomerPayment payment, Customer customer)
 {
     try
     {
         Dictionary<String, Object> extraParamenter = new Dictionary<string, object>();
         extraParamenter.Add("ticket", JsonConvert.SerializeObject(ticket));
         extraParamenter.Add("payment", JsonConvert.SerializeObject(payment));
         Infra.Queue.AzureQueueMessageManager.Enqueue(customer.Id.ToString(), customer.Name, null, Infra.Queue.AzureMessageType.NEW_TRANSACTION_INSTANT_BUY, extraParamenter);
         return true;
     }
     catch (System.Exception ex)
     {
         throw ex;
     }
 }
Пример #3
0
        public IActionResult Get([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                CustomerPayment SingleCustomerPayment = _context.CustomerPayment.Single(m => m.CustomerPaymentId == id);

                if (SingleCustomerPayment == null)
                {
                    return(NotFound());
                }

                return(Ok(SingleCustomerPayment));
            }
            catch (System.InvalidOperationException ex)
            {
                return(NotFound(ex));
            }
        }
        protected override void ItemShowing()
        {
            CustomerPayment item = UpdatingItem as CustomerPayment;

            if (item != null)
            {
                this.txtID.Text        = item.ID;
                this.txtID.Enabled     = false;
                dtSheetDate.Value      = item.SheetDate;
                rdTransfer.Checked     = (item.PaymentMode == PaymentMode.Transfer);
                rdCash.Checked         = item.PaymentMode == PaymentMode.Cash;
                rdCheck.Checked        = item.PaymentMode == PaymentMode.Check;
                txtAmount.DecimalValue = item.Amount;
                txtCheckNum.Text       = item.CheckNum;
                Customer         = (new CompanyBLL(AppSettings.Current.ConnStr)).GetByID(item.CustomerID).QueryObject;
                txtCustomer.Text = Customer != null ? Customer.Name : string.Empty;
                txtMemo.Text     = item.Memo;
                ShowAssigns();
                ShowOperations(item.ID, item.DocumentType, dataGridView1);
                ShowAttachmentHeaders(item.ID, item.DocumentType, this.gridAttachment);
                ShowButtonState();
            }
        }
        internal static CustomerPaymentList getPaymentList(HttpResponseMessage responce)
        {
            var customerPaymentlist = new CustomerPaymentList();
            var jsonObj             = JsonConvert.DeserializeObject <Dictionary <string, object> >(responce.Content.ReadAsStringAsync().Result);

            if (jsonObj.ContainsKey("customerpayments"))
            {
                var paymentsArray = JsonConvert.DeserializeObject <List <object> >(jsonObj["customerpayments"].ToString());
                foreach (var paymentObj in paymentsArray)
                {
                    var payment = new CustomerPayment();
                    payment = JsonConvert.DeserializeObject <CustomerPayment>(paymentObj.ToString());
                    customerPaymentlist.Add(payment);
                }
            }
            if (jsonObj.ContainsKey("page_context"))
            {
                var pageContext = new PageContext();
                pageContext = JsonConvert.DeserializeObject <PageContext>(jsonObj["page_context"].ToString());
                customerPaymentlist.page_context = pageContext;
            }
            return(customerPaymentlist);
        }
Пример #6
0
        public ActionResult CreditPayment(CustomerPayment item)
        {
            item.Customer = Customer.TryFind(item.CustomerId);

            if (!ModelState.IsValid)
            {
                return(PartialView("_CreditPayment", item));
            }

            // Store and Serial
            item.CashSession = GetSession();
            item.Store       = item.CashSession.CashDrawer.Store;

            try {
                item.Serial = (from x in CustomerPayment.Queryable
                               where x.Store.Id == item.Store.Id
                               select x.Serial).Max() + 1;
            } catch {
                item.Serial = 1;
            }

            item.Creator          = CurrentUser.Employee;
            item.CreationTime     = DateTime.Now;
            item.Updater          = item.Creator;
            item.ModificationTime = item.CreationTime;

            using (var scope = new TransactionScope()) {
                item.CreateAndFlush();
            }

            if (Request.IsAjaxRequest())
            {
                return(PartialView("_CreditPaymentSuccesful", item));
            }

            return(View("_CreditPaymentSuccesful", item));
        }
        protected override object GetItemFromInput()
        {
            CustomerPayment info = null;

            if (UpdatingItem == null)
            {
                info         = new CustomerPayment();
                info.ClassID = PaymentType;
            }
            else
            {
                info = UpdatingItem as CustomerPayment;
            }
            if (txtID.Text == _AutoCreate)
            {
                info.ID = string.Empty;
            }
            info.SheetDate = dtSheetDate.Value;
            if (rdTransfer.Checked)
            {
                info.PaymentMode = PaymentMode.Transfer;
            }
            if (rdCheck.Checked)
            {
                info.PaymentMode = PaymentMode.Check;
            }
            if (rdCash.Checked)
            {
                info.PaymentMode = PaymentMode.Cash;
            }
            info.Amount     = txtAmount.DecimalValue;
            info.CheckNum   = txtCheckNum.Text;
            info.CustomerID = Customer != null ? Customer.ID : null;
            info.Memo       = txtMemo.Text;
            return(info);
        }
        private void PayButton_Click(object sender, RoutedEventArgs e)

        {
            if (PayTextBox.Text == "0" || PayTextBox.Text == "")
            {
                MessageBox.Show("Please enter a value greater than 0", "GOLDLINE", MessageBoxButton.OK);
            }
            else if (CustomerIdLabel.Content.ToString() == "" || _selectedCustomer == null)
            {
                MessageBox.Show("Please select a customer", "GOLDLINE", MessageBoxButton.OK);
            }
            else
            {
                CustomerPayment cs = new CustomerPayment(CustomerPayment.GetNextCustomerPaymentId(),
                                                         _selectedCustomer.Id, decimal.Parse(PayTextBox.Text), DateTime.Now, App.CurrentUser.Id);

                MessageBox.Show(CustomerPayment.AddCustomerPayment(cs)
                    ? "Payment was recorded successfully"
                    : "Could not record payment");

                PayTextBox.Text = "";
                ReloadDataGrid();
            }
        }
        public CustomerPaymentShould()
        {
            // constructors to hold data
            _paymentManager = new CustomerPaymentManager();


            _customer = new Customer()
            {
                FirstName  = "Sofia",
                LastName   = "Howard",
                CustomerId = 5
            };

            int number = 4567;

            string paymentTypeName = "Master";

            _customerPayment = new CustomerPayment()
            {
                PaymentTypeName = paymentTypeName,
                Account         = number,
                CustomerId      = _customer.CustomerId
            };
        }
Пример #10
0
        private CustomerPayment SetupOrg(int id)
        {
            var             organization = organizationService.Get(id);
            CustomerPayment viewModel    = null;

            if (organization != null && organization.HeadquartersContactInformation != null)
            {
                OrganizationBudget planTier = subscriptionService.GetPriceTier(organization);

                viewModel = new CustomerPayment
                {
                    OrganizationId   = id,
                    CardAddressCity  = organization.HeadquartersContactInformation.City,
                    CardAddressLine1 = organization.HeadquartersContactInformation.Address1,
                    CardAddressLine2 = organization.HeadquartersContactInformation.Address2,
                    CardAddressState = organization.HeadquartersContactInformation.State.Abbreviation,
                    CardAddressZip   = organization.HeadquartersContactInformation.ZipCode.ToString(),
                    PlanTier         = planTier,
                    CustomerId       = organization.Subscription.CustomerBillingId,
                    HasTrialed       = organization.Subscription.HasTrialed
                };
            }
            return(viewModel);
        }
        public void GetProcessorTest()
        {
            var paymentData = new CustomerPayment
            {
                Amount         = 10,
                CustomerName   = "Test Customer 1",
                Description    = "Test Description 1",
                ForProductType = ProductType.Others
            };

            CheckProcessor <IPhysicalProductPaymentProcessor>(paymentData);

            paymentData.ForProductType = ProductType.Book;
            CheckProcessor <IBookPaymentProcessor>(paymentData);

            paymentData.ForProductType = ProductType.NewSubscription;
            CheckProcessor <IMembershipPaymentProcessor>(paymentData);

            paymentData.ForProductType = ProductType.UpgradeSubscription;
            CheckProcessor <IMembershipUpgradePaymentProcessor>(paymentData);

            paymentData.ForProductType = ProductType.Video;
            CheckProcessor <IVideoSalePaymentProcessor>(paymentData);
        }
Пример #12
0
        public HttpResponseMessage Put(string id, [FromBody] CustomerPayment value)
        {
            this.OrganizationId = value.OrganizationId;
            string errorMessage = String.Empty;

            try
            {
                if (this.UserIsAdminOfOrganization)
                {
                    var customerPayment = subscriptionService.SaveCustomer(id, value);
                    return(Request.CreateResponse(HttpStatusCode.Accepted, value));
                }
            }
            catch (StripeException ex)
            {
                emailHelper.SendStripeError(ex);
                errorMessage = ex.StripeError.Message;
            }
            catch (Exception ex)
            {
                emailHelper.SendErrorEmail(ex);
            }
            return(Request.CreateResponse(HttpStatusCode.BadRequest, errorMessage));
        }
        //pay to customer

        public ActionResult PaymentToCustomer(Guid UID, double totalPay)
        {
            string status = "error";

            try
            {
                var c     = db.Customers.Where(x => x.UID == UID).FirstOrDefault();
                var objCp = new CustomerPayment();



                // Entry in customer Payment

                objCp.UID            = Guid.NewGuid();
                objCp.CustomerId     = c.Id;
                objCp.EntryType      = 5;
                objCp.PaymentMethode = 1;
                objCp.Credit         = Convert.ToDecimal(totalPay);
                objCp.Debit          = 0;
                objCp.EntryDate      = DateTime.Now;
                objCp.CreatedBy      = ActiveUserId;
                objCp.CreatedOn      = DateTime.Now;
                objCp.UpdatedBy      = ActiveUserId;
                objCp.UpdatedOn      = DateTime.Now;
                db.CustomerPayments.Add(objCp);
                db.SaveChanges();

                var objCpl = new CustomerPaymentLog();

                objCpl.UID               = Guid.NewGuid();
                objCpl.CustomerId        = c.Id;
                objCpl.EntryType         = 5;
                objCpl.CustomerPaymentId = objCp.Id;
                objCpl.PaymentMethode    = 1;
                objCpl.CreatedBy         = ActiveUserId;
                objCpl.Credit            = Convert.ToDecimal(totalPay);
                objCpl.Debit             = 0;
                objCpl.CreatedOn         = DateTime.Now;
                objCpl.UpdatedBy         = ActiveUserId;
                objCpl.UpdatedOn         = DateTime.Now;
                db.CustomerPaymentLogs.Add(objCpl);

                db.SaveChanges();


                //return UID and Balance  to js
                var objUpdatedCustomer = db.Customers.Where(cU => cU.UID == UID).Select(s => new
                {
                    UID     = s.UID,
                    CpId    = objCp.Id,
                    Balance = (db.CustomerPayments.Where(x => x.CustomerId == c.Id).Sum(cp => cp.Debit)) - (db.CustomerPayments.Where(x => x.CustomerId == c.Id).Sum(cp => cp.Credit))
                }).FirstOrDefault();

                status = Newtonsoft.Json.JsonConvert.SerializeObject(objUpdatedCustomer);
            }
            catch (Exception ex)
            {
                ApplicationExceptionLogging(ex.Message, ex.StackTrace, "CustomerManagementController", "LoadGridPayments");
            }
            return(Content(status));
        }
        public ActionResult AddCustomer(Customer objCustomer, List <string> SubCategoryName, List <int> SubCategoryId)
        {
            string status = "error";

            try
            {
                if (!Authenticated)
                {
                    status = "Session Expired";
                }
                else
                {
                    if (objCustomer.IsActive == null)
                    {
                        objCustomer.IsActive = false;
                    }
                    if (objCustomer.IsResaler == null)
                    {
                        objCustomer.IsResaler = false;
                    }

                    objCustomer.UID       = Guid.NewGuid();
                    objCustomer.CreatedBy = ActiveUserId;
                    objCustomer.CreatedOn = DateTime.Now;
                    objCustomer.UpdatedBy = ActiveUserId;
                    objCustomer.UpdatedOn = DateTime.Now;

                    db.Customers.Add(objCustomer);
                    if (db.SaveChanges() > 0)
                    {
                        // Discount Entry



                        for (int i = 0; i < SubCategoryName.Count(); i++)
                        {
                            var objDsc = new DiscountOnBrand();
                            if (SubCategoryName[i] == "" || string.IsNullOrEmpty(SubCategoryName[i]))
                            {
                                SubCategoryName[i] = "0";
                            }

                            objDsc.SubCatId   = SubCategoryId[i];
                            objDsc.Discount   = Convert.ToDecimal(SubCategoryName[i]);
                            objDsc.CustomerId = objCustomer.Id;
                            objDsc.CreatedOn  = DateTime.Now;
                            db.DiscountOnBrands.Add(objDsc);
                        }


                        // Entry in Customer Payment

                        var objCp = new CustomerPayment();
                        objCp.UID        = Guid.NewGuid();
                        objCp.CustomerId = objCustomer.Id;
                        if (objCustomer.OpeningBalance == 0)
                        {
                            objCp.Debit  = 0;
                            objCp.Credit = 0;
                        }
                        if (objCustomer.OpeningBalance > 0)
                        {
                            objCp.Debit  = objCustomer.OpeningBalance;
                            objCp.Credit = 0;
                        }
                        if (objCustomer.OpeningBalance < 0)
                        {
                            objCp.Credit = -(objCustomer.OpeningBalance);
                            objCp.Debit  = 0;
                        }
                        objCp.EntryType      = 1;
                        objCp.PaymentMethode = 1;
                        objCp.EntryDate      = DateTime.Now;
                        objCp.CreatedBy      = ActiveUserId;
                        objCp.CreatedOn      = DateTime.Now;
                        objCp.UpdatedBy      = ActiveUserId;
                        objCp.UpdatedOn      = DateTime.Now;
                        db.CustomerPayments.Add(objCp);

                        // Entry in Customer Payment Logs
                        var objCpl = new CustomerPaymentLog();

                        objCpl.UID        = Guid.NewGuid();
                        objCpl.CustomerId = objCustomer.Id;
                        if (objCustomer.OpeningBalance == 0)
                        {
                            objCpl.Debit  = 0;
                            objCpl.Credit = 0;
                        }
                        if (objCustomer.OpeningBalance > 0)
                        {
                            objCpl.Debit  = objCustomer.OpeningBalance;
                            objCpl.Credit = 0;
                        }
                        if (objCustomer.OpeningBalance < 0)
                        {
                            objCpl.Credit = -(objCustomer.OpeningBalance);
                            objCpl.Debit  = 0;
                        }
                        objCpl.EntryType      = 1;
                        objCpl.PaymentMethode = 1;
                        objCpl.CreatedBy      = ActiveUserId;
                        objCpl.CreatedOn      = DateTime.Now;
                        objCpl.UpdatedBy      = ActiveUserId;
                        objCpl.UpdatedOn      = DateTime.Now;
                        db.CustomerPaymentLogs.Add(objCpl);

                        db.SaveChanges();


                        status = Newtonsoft.Json.JsonConvert.SerializeObject(objCustomer);
                    }
                }
            }
            catch (Exception ex)
            {
                ApplicationExceptionLogging(ex.Message, ex.StackTrace, "CustomerManagementController", "AddVendor");
            }
            return(Content(status));
        }
Пример #15
0
        private static CreditCardBrandEnum ConvertCreditCardBrand(CustomerPayment payment)
        {
            var enumValues = System.Enum.GetValues(typeof(CreditCardBrandEnum));

            foreach (var value in enumValues)
            {
                if ((int)value == (int)payment.CreditCardBrand)
                    return (CreditCardBrandEnum)value;

            }

            return default(CreditCardBrandEnum);

        }
Пример #16
0
 public void UpdateCustomerPayment(CustomerPayment payment)
 {
     payment = _db.CustomerPayments.FirstOrDefault(cust => cust.customerPaymentId == payment.customerPaymentId);
     _db.Entry(payment).State = EntityState.Modified;
     _db.SaveChanges();
 }
Пример #17
0
 public static CustomerPayment ApplyInvoicePayment(CustomerPayment pago, ICustomerPaymentRepository paymentRepository)
 {
     return(paymentRepository.ApplyInvoicePayment(pago));
 }
Пример #18
0
 public void Test_DeleteCustomerPayment()
 {
     Assert.IsNull(CustomerPayment.DeleteCustomerPayment(1));
 }
Пример #19
0
 public void Test_GetCustomerPayment()
 {
     Assert.IsTrue(CustomerPayment.GetCustomerPayments().Any());
 }
Пример #20
0
 public void Update(CustomerPayment customerPayment)
 {
     db.Entry(customerPayment).State = EntityState.Modified;
     db.SaveChanges();
 }
Пример #21
0
        /// <summary>
        /// Process the incoming Stripe Event
        /// </summary>
        public void ProcessEvent(string customerId, StripeEvent stripeEvent)
        {
            try
            {
                LoggingFactory.GetLogger().Log($"Start ProcessEvent(EventType={stripeEvent.Type})", EventLogSeverity.Debug);

                EmailTemplateCode emailTemplateCode = EmailTemplateCode.None;

                Customer customer = _customerRepository.Query().FirstOrDefault(p => p.PaymentCustomerId == customerId);
                if (customer == null)
                {
                    LoggingFactory.GetLogger().Log("Message.NotFindCustomerByPaymentCustomerId", EventLogSeverity.Error);
                    throw new Exception("Messages.NotFindCustomerByPaymentCustomerId" + customerId);
                }

                StripeSubscription subscription;

                switch (stripeEvent.Type)
                {
                case "charge.succeeded":
                    var charge = Mapper <StripeCharge> .MapFromJson(stripeEvent.Data.Object.ToString());

                    var payment = new CustomerPayment(customer.Id, charge.BalanceTransactionId, false, Convert.ToDecimal(charge.Amount / 100.0), charge.Created);

                    _customerPaymentRepository.Add(payment);

                    LoggingFactory.GetLogger().Log("Customer payment added", EventLogSeverity.Information);

                    emailTemplateCode = EmailTemplateCode.ChargeSuccessfull;

                    break;

                case "charge.refunded":
                    var refundedCharge = Mapper <StripeCharge> .MapFromJson(stripeEvent.Data.Object.ToString());

                    var stripeEventObject = JObject.Parse(stripeEvent.Data.Object.ToString());
                    var refundsData       = stripeEventObject.SelectToken("refunds.data");
                    StripeApplicationFeeRefund[] refunds = Mapper <StripeApplicationFeeRefund[]> .MapFromJson(refundsData.ToString());

                    StripeApplicationFeeRefund lastRefund = refunds[refunds.Length - 1];
                    var amountRefundedInDollars           = (decimal)(lastRefund.Amount / 100.0);

                    var refundPayment = new CustomerPaymentRefund(customer.Id, refundedCharge.BalanceTransactionId,
                                                                  refundedCharge.Id,
                                                                  amountRefundedInDollars, lastRefund.Created);

                    _customerPaymentRefundRepository.Add(refundPayment);

                    // TODO update refund field in payment record
                    //refundedCharge.Refunded
                    LoggingFactory.GetLogger().Log("Customer payment refunding", EventLogSeverity.Information);

                    emailTemplateCode = EmailTemplateCode.ChargeRefunded;

                    break;

                case "charge.failed":

                    // Update the DB

                    emailTemplateCode = EmailTemplateCode.ChargeFailed;
                    LoggingFactory.GetLogger().Log("Customer payment failed", EventLogSeverity.Information);

                    //TODO:

                    break;

                case "customer.subscription.deleted":

                    // look up user details from the Customer
                    subscription = Mapper <StripeSubscription> .MapFromJson(stripeEvent.ToString());

                    customer.PlanCanceledOn = subscription.CanceledAt ?? DateTime.Now;
                    _customerRepository.Update(customer);

                    //TODO:
                    //- Create log entry for Admins
                    emailTemplateCode = EmailTemplateCode.CustomerSubscriptionDeleted;
                    LoggingFactory.GetLogger().Log("Customer subscription deleted", EventLogSeverity.Information);

                    break;

                case "customer.subscription.updated":

                    // look up user details from the Customer
                    subscription = Mapper <StripeSubscription> .MapFromJson(stripeEvent.ToString());

                    customer.PlanUpdatedOn = subscription.Start ?? DateTime.Now;
                    _customerRepository.Update(customer);

                    //TODO:
                    //- Create log entry for Admins
                    emailTemplateCode = EmailTemplateCode.CustomerSubscriptionUpdated;
                    LoggingFactory.GetLogger().Log("Customer subsciption updated", EventLogSeverity.Information);

                    break;

                case "charge.created":
                    //TODO
                    return;
                }


                if (emailTemplateCode != EmailTemplateCode.None)
                {
                    EmailTemplate emailTemplate =
                        _emailTemplatesRepository.GetTemplateByName(
                            Common.Helpers.Utilities.ToDescriptionString(emailTemplateCode));

                    emailTemplate = EmailTemplateFactory.ParseTemplate(emailTemplate, customer);
                    MailMessage mailMessage = MailMessageMapper.ConvertToMailMessage(emailTemplate);
                    bool        result      = EmailServiceFactory.GetEmailService().SendMail(mailMessage);

                    if (result)
                    {
                        _unitOfWork.Commit();
                        LoggingFactory.GetLogger().Log("Payment information saved", EventLogSeverity.Information);
                    }
                    else
                    {
                        LoggingFactory.GetLogger().Log("There is an error creating Customer payment", EventLogSeverity.Fatal);
                        throw new Exception("There is an error creating Customer payment");
                    }
                }

                LoggingFactory.GetLogger().Log("End ProcessEvent({0})", EventLogSeverity.Debug);
            }
            catch (Exception ex)
            {
                LoggingFactory.GetLogger().Log(ex.InnerException + "  " + ex.Message, EventLogSeverity.Error);
            }
        }
Пример #22
0
 public IHttpActionResult Save(CustomerPayment model)
 {
     return(Ok(_customerPaymentRepository.SavePayment(model)));
 }
Пример #23
0
        public ActionResult Payment(/*DateTime RequiredDate,*/ string BillFirstName, string BillLastName, string BillPhone, string BillCity, string BillAddress, string ShipFirstName, string ShipLastName, string ShipPhone, string ShipCity, string ShipAddress, string PayWay, string CreditCardNo4, string CreditCardNo8, string CreditCardNo12, string CreditCardNo16, string CreditCardMM, string CreditCardYY, int?CreditCardCSC, string IdentityCard)
        {
            CustomerPayment customerPayment;

            if (string.IsNullOrEmpty(CreditCardNo4) && string.IsNullOrEmpty(CreditCardNo8) && string.IsNullOrEmpty(CreditCardNo12) && string.IsNullOrEmpty(CreditCardNo16) && string.IsNullOrEmpty(CreditCardMM) && string.IsNullOrEmpty(CreditCardYY) && CreditCardCSC == null && string.IsNullOrEmpty(IdentityCard))
            {
                if (string.IsNullOrEmpty(BillFirstName) && string.IsNullOrEmpty(BillLastName) && string.IsNullOrEmpty(BillCity) && string.IsNullOrEmpty(BillAddress) && string.IsNullOrEmpty(BillPhone))
                {
                    customerPayment = new CustomerPayment()
                    {
                        OrderDate = DateTime.Now,
                        //RequiredDate = DateTime.Now,
                        BillName    = ShipFirstName + ShipLastName,
                        BillPhone   = ShipPhone,
                        BillCity    = ShipCity,
                        BillAddress = ShipAddress,
                        ShipperID   = 1,
                        ShipName    = ShipFirstName + ShipLastName,
                        ShipPhone   = ShipPhone,
                        ShipAddress = ShipAddress,
                        ShipCity    = ShipCity,
                        PayWay      = "ATM",
                        PayDate     = DateTime.Now,
                        Freight     = 100
                    };
                }
                else
                {
                    customerPayment = new CustomerPayment()
                    {
                        OrderDate = DateTime.Now,
                        //RequiredDate = DateTime.Now,
                        BillName    = BillFirstName + BillLastName,
                        BillPhone   = BillPhone,
                        BillCity    = BillCity,
                        BillAddress = BillAddress,
                        ShipperID   = 1,
                        ShipName    = ShipFirstName + ShipLastName,
                        ShipPhone   = ShipPhone,
                        ShipAddress = ShipAddress,
                        ShipCity    = ShipCity,
                        PayWay      = "ATM",
                        PayDate     = DateTime.Now,
                        Freight     = 100
                    };
                }
            }
            else
            {
                if (string.IsNullOrEmpty(BillFirstName) && string.IsNullOrEmpty(BillLastName) && string.IsNullOrEmpty(BillCity) && string.IsNullOrEmpty(BillAddress) && string.IsNullOrEmpty(BillPhone))
                {
                    customerPayment = new CustomerPayment()
                    {
                        OrderDate = DateTime.Now,
                        //RequiredDate = DateTime.Now,
                        BillName       = ShipFirstName + ShipLastName,
                        BillPhone      = ShipPhone,
                        BillCity       = ShipCity,
                        BillAddress    = ShipAddress,
                        ShipperID      = 1,
                        ShipName       = ShipFirstName + ShipLastName,
                        ShipPhone      = ShipPhone,
                        ShipAddress    = ShipAddress,
                        ShipCity       = ShipCity,
                        PayWay         = "CreditCard",
                        CreditCardNo   = CreditCardNo4 + CreditCardNo8 + CreditCardNo12 + CreditCardNo16,
                        CreditCardCSC  = CreditCardCSC,
                        CreditCardDate = CreditCardMM + CreditCardYY,
                        IdentityCard   = IdentityCard,
                        PayDate        = DateTime.Now,
                        Freight        = 100
                    };
                }
                else
                {
                    customerPayment = new CustomerPayment()
                    {
                        OrderDate = DateTime.Now,
                        //RequiredDate = DateTime.Now,
                        BillName       = BillFirstName + BillLastName,
                        BillPhone      = BillPhone,
                        BillCity       = BillCity,
                        BillAddress    = BillAddress,
                        ShipperID      = 1,
                        ShipName       = ShipFirstName + ShipLastName,
                        ShipPhone      = ShipPhone,
                        ShipAddress    = ShipAddress,
                        ShipCity       = ShipCity,
                        PayWay         = "CreditCard",
                        CreditCardNo   = CreditCardNo4 + CreditCardNo8 + CreditCardNo12 + CreditCardNo16,
                        CreditCardCSC  = CreditCardCSC,
                        CreditCardDate = CreditCardMM + CreditCardYY,
                        IdentityCard   = IdentityCard,
                        PayDate        = DateTime.Now,
                        Freight        = 100
                    };
                }
            }

            PaymentViewModel paymentViewModel = new PaymentViewModel()
            {
                customerPayment = customerPayment
            };
            var CustomerID = _repo.GetCustomerID(User.Identity.Name);

            _repo.Payment(paymentViewModel, CustomerID);

            return(RedirectToAction("OrderDetail", "OrderDetail"));
        }
Пример #24
0
        public ActionResult ViewCreditPayment(int id)
        {
            var item = CustomerPayment.Find(id);

            return(View("ViewCreditPayment", item));
        }
Пример #25
0
        public ActionResult PrintCreditPayment(int id)
        {
            var model = CustomerPayment.Find(id);

            return(PdfTicketView("PrintCreditPayment", model));
        }
Пример #26
0
        public bool CreateQuickTicket(CustomerTicket ticket, CustomerPayment payment, Customer customer)
        {
            try
            {
                Log.Info($"Criando o ticket do cliente com o id {customer.Id}");

                ticket.Status = Enum.StatusEnum.Pending;
                ticket.Id = Guid.NewGuid();

                var result = this.customerTicketService.CreateQuickTicket(ticket, payment, customer);

                if (result)
                {
                    customer.Tickets.Add(ticket);
                    this.customerRepository.Update(customer);
                }

                return result;
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex);
                throw;
            }
            finally
            {
                Log.Info($"Finalizando a criação do ticket do evento para o cliente {customer.Id}");
            }

        }
        private DbInsertStatement GetQuery_InsertQuery(CustomerPayment _obj)
        {
            Dictionary <string, DbFieldEntry> fields = GetFields(_obj);

            return(DbMgr.CreateInsertClause("CustomerPayments", fields));
        }
Пример #28
0
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organizationId}");
                var transactionApi = service.GetBankTransactionsApi();
                var accounts       = service.GetBankAccountsApi().GetBankAccounts(null);
                var parameters     = new Dictionary <object, object>();
                parameters.Add("filter_by", "Status.All");
                parameters.Add("account_id", accounts[0].account_id);
                Console.WriteLine("---------------------- All Transactions ----------------------");
                var transactionList = transactionApi.GetTransactions(parameters);
                var transactions    = transactionList;
                foreach (var trans in transactions)
                {
                    Console.WriteLine("{0},{1},{2}", trans.transaction_id, trans.status, trans.amount);
                }

                Console.WriteLine("---------------------- Specified Transaction ----------------------");
                var transaction = transactionApi.Get(transactions[2].transaction_id);
                Console.WriteLine("{0},{1},{2}", transaction.transaction_id, transaction.transaction_type, transaction.amount);

                Console.WriteLine("---------------------- New Transaction ----------------------");
                var newTransactionInfo = new Transaction()
                {
                    transaction_type = "transfer_fund",
                    from_account_id  = accounts[0].account_id,
                    to_account_id    = accounts[2].account_id,
                    amount           = 10
                };
                var newTransaction = transactionApi.Create(newTransactionInfo);
                Console.WriteLine("{0},{1},{2}", newTransaction.transaction_id, newTransaction.transaction_type, newTransaction.amount);

                Console.WriteLine("---------------------- Updated Transaction ----------------------");
                var updateInfo = new Transaction()
                {
                    amount           = 50,
                    currency_id      = transactionList[0].currency_id,
                    date             = "2014-02-06",
                    description      = "",
                    exchange_rate    = 1,
                    from_account_id  = accounts[0].account_id,
                    reference_number = "",
                    to_account_id    = accounts[2].account_id,
                    transaction_type = "transfer_fund"
                };
                var updatedTrans = transactionApi.Update(newTransaction.transaction_id, updateInfo);
                Console.WriteLine("{0},{1},{2}", updatedTrans.transaction_id, updatedTrans.transaction_type, updatedTrans.amount);

                Console.WriteLine("---------------------- Delete Transaction ----------------------");
                var deltrans = transactionApi.Delete(updatedTrans.transaction_id);
                Console.WriteLine(deltrans);
                var parameters1 = new Dictionary <object, object>();
                parameters1.Add("amount_start", "1");
                parameters1.Add("amount_end", "4000");
                parameters1.Add("date_start", "2014-02-01");
                parameters1.Add("date_end", "2014-02-07");

                var matchingtrans = transactionApi.GetMatchingTransactions(transactions[1].transaction_id, parameters1);

                foreach (var matchingTran in matchingtrans)
                {
                    Console.WriteLine("{0},{1},{2}", matchingTran.transaction_id, matchingTran.transaction_type, matchingTran.amount);
                }
                var parameters3 = new Dictionary <object, object>();
                parameters3.Add("account_id", accounts[1].account_id);
                TransactionsToBeMatched transtomatch = new TransactionsToBeMatched()
                {
                    transactions_to_be_matched = new List <Transaction>()
                    {
                        new Transaction()
                        {
                            transaction_id   = transactions[2].transaction_id,
                            transaction_type = "vendor_payment"
                        },
                        new Transaction()
                        {
                            transaction_id   = transactions[3].transaction_id,
                            transaction_type = "transfer_fund"
                        },
                        new Transaction()
                        {
                            transaction_id   = transactions[1].transaction_id,
                            transaction_type = "expense"
                        }
                    }
                };
                var matchtransaction = transactionApi.MatchATransaction(transactions[0].transaction_id, transtomatch);
                Console.WriteLine(matchtransaction);
                var unmatch = transactionApi.UnmatchTransaction(transactions[0].transaction_id);
                Console.WriteLine(unmatch);
                parameters.Add("sort_column", "statement_date");
                var associatedTransObj = transactionApi.GetAssociatedTransactions(transactions[0].transaction_id, null);
                var associatedTrans    = associatedTransObj.associated_transactions;
                Console.WriteLine(associatedTransObj.imported_transaction_id);
                foreach (var asociatedTran in associatedTrans)
                {
                    Console.WriteLine("{0},{1},{2}", asociatedTran.transaction_id, asociatedTran.transaction_type, asociatedTran.amount);
                }
                var exclude = transactionApi.ExcludeATransaction(transactions[0].transaction_id);
                Console.WriteLine(exclude);
                var restore = transactionApi.RestoreATransaction(transactions[0].transaction_id);
                Console.WriteLine(restore);
                var transacInfo = new Transaction()
                {
                    amount           = 4000,
                    date             = "2013-01-29",
                    description      = "Insurance payment",
                    exchange_rate    = 1,
                    from_account_id  = accounts[1].account_id,
                    reference_number = "Ref-9872",
                    to_account_id    = accounts[3].account_id,
                    transaction_type = "expense"
                };
                var catogarise = transactionApi.CategorizeAnUncategorizedTransaction(transactions[0].transaction_id, transacInfo);
                Console.WriteLine(catogarise);
                var creditrefundInfo = new CreditNote()
                {
                    creditnote_id   = "{credit note id}",
                    date            = "2014-02-07",
                    from_account_id = "{account id from which account the transaction is going to be done}",
                    amount          = 4000
                };
                var catogasCred = transactionApi.CategorizeAsCreditNoteRefunds(transactions[0].transaction_id, creditrefundInfo);
                Console.WriteLine(catogasCred);
                var vendordetails = new VendorPayment()
                {
                    vendor_id = "{vendor id}",
                    amount    = 4000,
                    paid_through_account_id = "{account id}"
                };
                var vendorcat = transactionApi.CategorizeAsVendorpayment(transactions[0].transaction_id, vendordetails);
                Console.WriteLine(vendorcat);
                var customerinfo = new CustomerPayment()
                {
                    customer_id = "{customer id}",
                    date        = "2014-02-08",
                    invoices    = new List <Invoice>()
                    {
                        new Invoice()
                        {
                            invoice_id     = "{invoice id}",
                            amount_applied = 4000
                        }
                    },
                    amount = 4000
                };
                var custpaycat = transactionApi.CategorizeAsCustomerPayments(transactions[0].transaction_id, customerinfo, parameters);
                Console.WriteLine(custpaycat);
                var expenseInfo = new Expense()
                {
                    account_id = accounts[3].account_id,
                    date       = "2013-01-29",
                    paid_through_account_id = accounts[4].account_id,
                    project_id       = "",
                    amount           = 4000,
                    tax_id           = "",
                    is_inclusive_tax = false,
                    is_billable      = false,
                    reference_number = "Ref-123",
                    description      = "Insurance payment",
                };
                var catAsExpens = transactionApi.CategorizeAsExpense(transactions[0].transaction_id, expenseInfo, @"F:\error.png");
                Console.WriteLine(catAsExpens);
                var uncatogorise = transactionApi.UncategorizeACategorizedTransaction(transactions[0].transaction_id);
                Console.WriteLine(uncatogorise);
                var vendorCreditsApi = service.GetVendorCreditsApi();
                var vendorCredits    = vendorCreditsApi.GetVendorCredits(null);
                var refundInfo       = new VendorCreditRefund()
                {
                    vendor_credit_id = vendorCredits[0].vendor_credit_id,
                    date             = "2014-11-25",
                };
                var catAsVendorRefund = transactionApi.CategorizeAsVendorCreditRefund(transactions[0].transaction_id, refundInfo);
                Console.WriteLine(catAsVendorRefund);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
 private DbUpdateStatement GetQuery_UpdateQuery(CustomerPayment _obj)
 {
     return(DbMgr.CreateUpdateClause("CustomerPayments", GetFields(_obj), "CustomerPaymentID", _obj.CustomerPaymentID));
 }
Пример #30
0
 public void Test_UpdateCustomerPayment()
 {
     Assert.IsNull(CustomerPayment.UpdateCustomerPayment(new CustomerPayment(1, 1, 0, new DateTime(), 1)));
 }
 public MembershipUpgradePaymentProcessor(CustomerPayment customerPayment) : base(customerPayment)
 {
 }
Пример #32
0
 public void Test_GetNextCustomerPaymentId()
 {
     Assert.IsNull(CustomerPayment.DeleteCustomerPayment(1));
 }
Пример #33
0
        internal static bool ProcessPayment(CustomerTicket ticket, CustomerPayment payment, out Guid instantBuy)
        {
            var amountTransaction = (long)(ticket.Quantity * ticket.Event.Price);
            var expiration = payment.Expiration.Split('/');
            var expMonth = Convert.ToInt32(expiration.FirstOrDefault());
            var expYear = Convert.ToInt32(expiration.LastOrDefault());

            instantBuy = Guid.Empty;

            try
            {
                Log.Info($"Create transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer}");

                // Cria a transação.
                var transaction = new CreditCardTransaction()
                {
                    AmountInCents = amountTransaction,
                    CreditCard = new CreditCard()
                    {
                        CreditCardBrand = ConvertCreditCardBrand(payment),
                        CreditCardNumber = payment.CreditCardNumber,
                        ExpMonth = expMonth,
                        ExpYear = expYear,
                        HolderName = payment.HolderName,
                        SecurityCode = payment.SecurityCode
                    },
                };

                // Cria requisição.
                var createSaleRequest = new CreateSaleRequest()
                {
                    // Adiciona a transação na requisição.
                    CreditCardTransactionCollection = new Collection<CreditCardTransaction>(new CreditCardTransaction[] { transaction }),
                };

                Log.Info($"Make request for transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer}");

                var serviceClient = new GatewayServiceClient(merchantKey, hostUri);

                // Autoriza a transação e recebe a resposta do gateway.
                var httpResponse = serviceClient.Sale.Create(createSaleRequest);

                Log.Info($"Request Status for transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer} with status {httpResponse.HttpStatusCode}");
                if (httpResponse.Response.CreditCardTransactionResultCollection != null)
                {
                    var transactionStatus = httpResponse.Response.CreditCardTransactionResultCollection.FirstOrDefault().CreditCardTransactionStatus;
                    Log.Info($"Transaction Status for ticket {ticket.Id} with status {transactionStatus.ToString()}");

                    if (transactionStatus == CreditCardTransactionStatusEnum.NotAuthorized)
                        ticket.Status = Enum.StatusEnum.NotAuthorized;

                    if (transactionStatus == CreditCardTransactionStatusEnum.Captured)
                        ticket.Status = Enum.StatusEnum.Authorized;

                    if (payment.KeepSave)
                        instantBuy = httpResponse.Response.CreditCardTransactionResultCollection.FirstOrDefault().CreditCard.InstantBuyKey;
                    
                    return true;

                }

                return false;
            }
            catch (System.Exception ex)
            {
                Log.Error($"Request Error for transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer}", ex);
                throw ex;
            }
            finally
            {
                Log.Info($"End Request for transaction for ticket {ticket.Id} and for customer {ticket.IdCustomer}");
            }

        }
Пример #34
0
        public ActionResult CreditPayment()
        {
            var model = new CustomerPayment { Date = DateTime.Now };

            if (Request.IsAjaxRequest ()) {
                return PartialView ("_CreditPayment", model);
            }

            return View ("_CreditPayment", model);
        }
Пример #35
0
 public void AddCustomerPayment(CustomerPayment payment)
 {
     _db.CustomerPayments.Add(payment);
     _db.SaveChanges();
 }
Пример #36
0
 public IHttpActionResult DeleteCustomerPayment([FromBody] CustomerPayment model)
 {
     return(Ok(_customerPaymentRepository.DeleteCustomerPayment(model)));
 }
Пример #37
0
        public ActionResult CreditPayment(CustomerPayment item)
        {
            item.Customer = Customer.TryFind (item.CustomerId);

            if (!ModelState.IsValid) {
                return PartialView ("_CreditPayment", item);
            }

            // Store and Serial
            item.CashSession = GetSession ();
            item.Store = item.CashSession.CashDrawer.Store;

            try {
                item.Serial = (from x in CustomerPayment.Queryable
                           where x.Store.Id == item.Store.Id
                           select x.Serial).Max () + 1;
            } catch {
                item.Serial = 1;
            }

            item.Creator = CurrentUser.Employee;
            item.CreationTime = DateTime.Now;
            item.Updater = item.Creator;
            item.ModificationTime = item.CreationTime;

            using (var scope = new TransactionScope ()) {
                item.CreateAndFlush ();
            }

            if (Request.IsAjaxRequest ()) {
                return PartialView ("_CreditPaymentSuccesful", item);
            }

            return View ("_CreditPaymentSuccesful", item);
        }