Example #1
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);
        }
Example #2
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);
        }