public IEnumerable GetRecords()
        {
            CCSynchronizeCards graph = _Graph as CCSynchronizeCards;

            if (graph == null)
            {
                return(GetAllCustomers());
            }

            CCSynchronizeCard syncCards = graph.Caches[typeof(CCSynchronizeCard)].Current as CCSynchronizeCard;

            if (syncCards == null || syncCards.CCProcessingCenterID == null || syncCards.CustomerCCPID == null)
            {
                return(GetAllCustomers());
            }
            else
            {
                string customerId                = syncCards.CustomerCCPID;
                string processingCenterID        = syncCards.CCProcessingCenterID;
                IEnumerable <Customer> customers = GetCustomersWithSameCCPID(processingCenterID, customerId);

                if (!customers.Any())
                {
                    return(GetAllCustomers());
                }
                return(customers);
            }
        }
예제 #2
0
        public bool ValidateImportCard(CCSynchronizeCard card, int cardIndex)
        {
            bool ret = true;

            if (card.BAccountID == null)
            {
                PXProcessing <CCSynchronizeCard> .SetError(cardIndex, CA.Messages.CustomerNotDefined);

                ret = false;
            }

            if (card.PaymentMethodID == null)
            {
                PXProcessing <CCSynchronizeCard> .SetError(cardIndex, Messages.PaymentMethodNotDefined);

                ret = false;
            }

            if (card.CashAccountID != null)
            {
                IEnumerable <CashAccount> availableCA = PXSelectorAttribute.SelectAll <CCSynchronizeCard.cashAccountID>(this.CustomerCardPaymentData.Cache, card)
                                                        .RowCast <CashAccount>();
                bool exists = availableCA.Any(i => i.CashAccountID == card.CashAccountID);

                if (!exists)
                {
                    PXProcessing <CCSynchronizeCard> .SetError(cardIndex,
                                                               PXMessages.LocalizeFormatNoPrefixNLA(AR.Messages.CashAccountIsNotConfiguredForPaymentMethodInAR, card.PaymentMethodID));

                    ret = false;
                }
            }
            return(ret);
        }
예제 #3
0
        public virtual void CCSynchronizeCard_BAccountID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
        {
            CCSynchronizeCard syncCard = e.Row as CCSynchronizeCard;

            if (syncCard == null || !e.ExternalCall || syncCard.BAccountID == null)
            {
                return;
            }

            if (Filter.Current.EnableCustomerPaymentDialog.GetValueOrDefault() == false)
            {
                Filter.Current.EnableCustomerPaymentDialog = true;
                Filter.Current.CustomerName = GetCustomerNameByID(syncCard.BAccountID);
                CustPaymentProfileForDialog.Cache.Clear();
                int insertedCnt = PopulatePaymentProfileForDialog(syncCard.PCCustomerID, syncCard.BAccountID);

                if (insertedCnt > 0)
                {
                    CustPaymentProfileForDialog.AskExt();
                }
            }

            if (Filter.Current.EnableCustomerPaymentDialog.GetValueOrDefault() == true)
            {
                Filter.Current.EnableCustomerPaymentDialog = false;
            }
        }
예제 #4
0
        public void UpdateCCProcessingSyncronizeCardRecord(CCSynchronizeCard item)
        {
            PXCache syncCardCache = Caches[typeof(CCSynchronizeCard)];

            item.Imported = true;
            syncCardCache.Update(item);
            syncCardCache.Persist(PXDBOperation.Update);
        }
예제 #5
0
        private List <CCSynchronizeCard> GetExistedSyncCardEntriesByCustomerCCPID(string customerCCPID, string processingCenterId)
        {
            string customerIdHash = CCSynchronizeCard.GetSha1HashString(customerCCPID);
            PXSelectBase <CCSynchronizeCard> query = new PXSelect <CCSynchronizeCard,
                                                                   Where <CCSynchronizeCard.customerCCPIDHash, Equal <Required <CCSynchronizeCard.customerCCPIDHash> >,
                                                                          And <CCSynchronizeCard.cCProcessingCenterID, Equal <Required <CCSynchronizeCard.cCProcessingCenterID> > > > >(this);
            var ret = query.Select(customerIdHash, processingCenterId).RowCast <CCSynchronizeCard>().ToList();

            return(ret);
        }
예제 #6
0
        public virtual void CCSynchronizeCard_PaymentMethodId_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
        {
            CCSynchronizeCard syncCard = e.Row as CCSynchronizeCard;

            if (syncCard?.CardNumber != null)
            {
                string cardNum = syncCard.CardNumber.Substring(syncCard.CardNumber.IndexOf(maskedCardTmpl) + maskedCardTmpl.Length);
                FormatMaskedCardNum(syncCard, cardNum);
            }
        }
예제 #7
0
        private int GetCardsAllProfiles()
        {
            CreditCardsFilter                 filter                = Filter.Current;
            string                            processingCenter      = filter.ProcessingCenterId;
            CreditCardReceiverFactory         factory               = new CreditCardReceiverFactory(filter);
            CCSynchronizeCardManager          syncronizeCardManager = new CCSynchronizeCardManager(this, processingCenter, factory);
            Dictionary <string, CustomerData> customerDatas         = syncronizeCardManager.GetCustomerProfilesFromService();

            syncronizeCardManager.SetCustomerProfileIds(customerDatas.Select(i => i.Key));
            Dictionary <string, CustomerCreditCard> unsyncCustomerCreditCards = syncronizeCardManager.GetUnsynchronizedPaymentProfiles();
            int unsyncCardCnt = 0;

            foreach (var item in unsyncCustomerCreditCards)
            {
                List <CCSynchronizeCard> alreadyAdded = GetExistedSyncCardEntriesByCustomerCCPID(item.Key, processingCenter);
                CustomerCreditCard       cards        = item.Value;

                foreach (CreditCardData card in cards.CreditCards)
                {
                    if (CheckNotImportedRecordExists(cards.CustomerProfileId, card.PaymentProfileID, alreadyAdded))
                    {
                        continue;
                    }

                    CCSynchronizeCard syncCard     = new CCSynchronizeCard();
                    CustomerData      customerData = customerDatas[cards.CustomerProfileId];
                    string            cardNumber   = card.CardNumber.Trim('X');
                    FormatMaskedCardNum(syncCard, cardNumber);
                    syncCard.CCProcessingCenterID  = processingCenter;
                    syncCard.CustomerCCPID         = cards.CustomerProfileId;
                    syncCard.CustomerCCPIDHash     = CCSynchronizeCard.GetSha1HashString(syncCard.CustomerCCPID);
                    syncCard.PaymentCCPID          = card.PaymentProfileID;
                    syncCard.PCCustomerID          = customerData.CustomerCD;
                    syncCard.PCCustomerDescription = customerData.CustomerName;
                    syncCard.PCCustomerEmail       = customerData.Email;

                    if (card.CardExpirationDate != null)
                    {
                        syncCard.ExpirationDate = card.CardExpirationDate.Value;
                    }

                    if (card.AddressData != null)
                    {
                        AddressData addrData = card.AddressData;
                        syncCard.FirstName = addrData.FirstName;
                        syncCard.LastName  = addrData.LastName;
                    }

                    CustomerCardPaymentData.Insert(syncCard);
                    unsyncCardCnt++;
                }
            }

            return(unsyncCardCnt);
        }
예제 #8
0
 private void FormatMaskedCardNum(CCSynchronizeCard syncCard, string cardNumber)
 {
     if (syncCard.PaymentMethodID == null)
     {
         syncCard.CardNumber = maskedCardTmpl + cardNumber;
     }
     else
     {
         syncCard.CardNumber = syncCard.PaymentMethodID + ":" + maskedCardTmpl + cardNumber;
     }
 }
예제 #9
0
        private bool CheckNotImportedRecordExists(string custCCPID, string paymentCCPID, List <CCSynchronizeCard> checkList)
        {
            bool ret = false;
            CCSynchronizeCard item = checkList.Where(i => i.CustomerCCPID == custCCPID && i.PaymentCCPID == paymentCCPID &&
                                                     i.Imported.GetValueOrDefault() == false).FirstOrDefault();

            if (item != null)
            {
                ret = true;
            }
            return(ret);
        }
예제 #10
0
        protected virtual void viewCustomer()
        {
            CCSynchronizeCard       syncCard      = CustomerCardPaymentData.Current;
            CustomerMaint           customer      = CreateInstance <CustomerMaint>();
            PXSelectBase <Customer> customerQuery = new PXSelect <Customer,
                                                                  Where <Customer.bAccountID, Equal <Required <Customer.bAccountID> > > >(this);

            customer.CurrentCustomer.Current = customerQuery.SelectSingle(syncCard.BAccountID);

            if (customer.CurrentCustomer.Current != null)
            {
                throw new PXRedirectRequiredException(customer, true, string.Empty);
            }
        }
예제 #11
0
        private bool CheckCustomerPaymentProfileExists(CCSynchronizeCard syncCard, int cardIndex)
        {
            var    result            = GetPaymentsProfilesByCustomer(syncCard.CCProcessingCenterID, syncCard.CustomerCCPID);
            string checkPaymentCCPID = syncCard.PaymentCCPID;

            foreach (CustomerPaymentMethodDetail cpmDetail in result.RowCast <CustomerPaymentMethodDetail>())
            {
                if (cpmDetail.Value == checkPaymentCCPID)
                {
                    PXProcessing <CCSynchronizeCard> .SetError(cardIndex, Messages.RecordWithPaymentCCPIDExists);

                    return(true);
                }
            }
            return(false);
        }
예제 #12
0
            public static CustomerPaymentProfile CreateFromSyncCard(CCSynchronizeCard syncCard)
            {
                CustomerPaymentProfile ret = new CustomerPaymentProfile()
                {
                    RecordID                = syncCard.RecordID,
                    CustomerCCPID           = syncCard.CustomerCCPID,
                    PCCustomerDescription   = syncCard.PCCustomerDescription,
                    PCCustomerEmail         = syncCard.PCCustomerEmail,
                    PCCustomerID            = syncCard.PCCustomerID,
                    BAccountID              = syncCard.BAccountID,
                    PaymentProfileFirstName = syncCard.FirstName,
                    PaymentProfileLastName  = syncCard.LastName,
                    PaymentCCPID            = syncCard.PaymentCCPID
                };

                return(ret);
            }
예제 #13
0
        public virtual void CCSynchronizeCard_BAccountID_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e)
        {
            CCSynchronizeCard syncCard = e.Row as CCSynchronizeCard;

            if (syncCard == null)
            {
                return;
            }

            string customerCCPID = syncCard.CustomerCCPID;
            PXSelectBase <CustomerProcessingCenterID> cpcQuery = new PXSelect <CustomerProcessingCenterID,
                                                                               Where <CustomerProcessingCenterID.customerCCPID, Equal <Required <CustomerProcessingCenterID.customerCCPID> > >,
                                                                               OrderBy <Desc <CustomerProcessingCenterID.createdDateTime> > >(this);
            CustomerProcessingCenterID customerPaymentMethod = cpcQuery.SelectSingle(customerCCPID);

            if (customerPaymentMethod != null)
            {
                e.NewValue = customerPaymentMethod.BAccountID;
                return;
            }

            string customerID = syncCard.PCCustomerID;

            if (customerID == null)
            {
                return;
            }

            customerID = DeleteCustomerPrefix(customerID);
            PXSelectBase <Customer> cQuery = new PXSelect <Customer,
                                                           Where <Customer.acctCD, Equal <Required <CCSynchronizeCard.pCCustomerID> > > >(this);
            Customer customer = cQuery.SelectSingle(customerID);

            if (customer != null)
            {
                e.NewValue = customer.BAccountID;
            }
        }
예제 #14
0
        public void CreateCustomerPaymentMethodRecord(CCSynchronizeCard item)
        {
            PXCache customerPaymentMethodCache = Caches[typeof(CustomerPaymentMethod)];
            CustomerPaymentMethod customerPM   = customerPaymentMethodCache.CreateInstance() as CustomerPaymentMethod;

            customerPM.BAccountID           = item.BAccountID;
            customerPM.CustomerCCPID        = item.CustomerCCPID;
            customerPM.Descr                = item.CardNumber;
            customerPM.PaymentMethodID      = item.PaymentMethodID;
            customerPM.CashAccountID        = item.CashAccountID;
            customerPM.CCProcessingCenterID = item.CCProcessingCenterID;

            if (item.ExpirationDate != null)
            {
                customerPaymentMethodCache.SetValueExt <CustomerPaymentMethod.expirationDate>(customerPM, item.ExpirationDate);
            }

            customerPaymentMethodCache.Insert(customerPM);
            customerPaymentMethodCache.Persist(PXDBOperation.Insert);
            customerPM = customerPaymentMethodCache.Current as CustomerPaymentMethod;
            CreateCustomerPaymentMethodDetailRecord(customerPM, item);
            CreateCustomerProcessingCenterRecord(customerPM, item);
        }
예제 #15
0
        private void CreateCustomerPaymentMethodDetailRecord(CustomerPaymentMethod customerPM, CCSynchronizeCard syncCard)
        {
            PXResultset <PaymentMethodDetail> details = GetPaymentMethodDetailParams(customerPM.PaymentMethodID);
            PXCache customerPaymentMethodDetailCache  = Caches[typeof(CustomerPaymentMethodDetail)];
            CustomerPaymentMethodDetail customerPaymentDetails;

            foreach (PaymentMethodDetail detail in details)
            {
                customerPaymentDetails                 = customerPaymentMethodDetailCache.CreateInstance() as CustomerPaymentMethodDetail;
                customerPaymentDetails.DetailID        = detail.DetailID;
                customerPaymentDetails.PMInstanceID    = customerPM.PMInstanceID;
                customerPaymentDetails.PaymentMethodID = customerPM.PaymentMethodID;

                if (customerPaymentDetails.DetailID == CreditCardAttributes.CardNumber)
                {
                    Match match = new Regex("[\\d]+").Match(syncCard.CardNumber);
                    if (match.Success)
                    {
                        string cardNum = match.Value.PadLeft(8, 'X');
                        customerPaymentDetails.Value = cardNum;
                    }
                }

                if (customerPaymentDetails.DetailID == CreditCardAttributes.CCPID)
                {
                    customerPaymentDetails.Value = syncCard.PaymentCCPID;
                }

                customerPaymentMethodDetailCache.Insert(customerPaymentDetails);
                customerPaymentMethodDetailCache.Persist(PXDBOperation.Insert);
            }
        }
예제 #16
0
        private void CreateCustomerProcessingCenterRecord(CustomerPaymentMethod customerPM, CCSynchronizeCard syncCard)
        {
            PXCache customerProcessingCenterCache = Caches[typeof(CustomerProcessingCenterID)];

            customerProcessingCenterCache.ClearQueryCacheObsolete();
            PXSelectBase <CustomerProcessingCenterID> checkRecordExist = new PXSelectReadonly <CustomerProcessingCenterID,
                                                                                               Where <CustomerProcessingCenterID.cCProcessingCenterID, Equal <Required <CreditCardsFilter.processingCenterId> >,
                                                                                                      And <CustomerProcessingCenterID.bAccountID, Equal <Required <CustomerProcessingCenterID.bAccountID> >,
                                                                                                           And <CustomerProcessingCenterID.customerCCPID, Equal <Required <CustomerProcessingCenterID.customerCCPID> > > > > >(this);
            CustomerProcessingCenterID cProcessingCenter = checkRecordExist.SelectSingle(syncCard.CCProcessingCenterID, syncCard.BAccountID, syncCard.CustomerCCPID);

            if (cProcessingCenter == null)
            {
                cProcessingCenter                      = customerProcessingCenterCache.CreateInstance() as CustomerProcessingCenterID;
                cProcessingCenter.BAccountID           = syncCard.BAccountID;
                cProcessingCenter.CCProcessingCenterID = syncCard.CCProcessingCenterID;
                cProcessingCenter.CustomerCCPID        = syncCard.CustomerCCPID;
                customerProcessingCenterCache.Insert(cProcessingCenter);
                customerProcessingCenterCache.Persist(PXDBOperation.Insert);
            }
        }