public static void SyncDeletePMI(PXGraph graph, PXSelectBase <CustomerPaymentMethod> customerPaymentMethodView, PXSelectBase <CustomerPaymentMethodDetail> detailsView)
        {
            IEnumerator cpmEnumerator = customerPaymentMethodView.Cache.Deleted.GetEnumerator();

            if (cpmEnumerator.MoveNext())
            {
                CustomerPaymentMethod current          = (CustomerPaymentMethod)cpmEnumerator.Current;
                CCProcessingCenter    processingCenter = CCProcessingUtils.getProcessingCenter(graph, current.CCProcessingCenterID);
                if (!string.IsNullOrEmpty(current.CCProcessingCenterID) && processingCenter.SyncronizeDeletion == true)
                {
                    CCCustomerInformationManager cim = new CCCustomerInformationManager(current.CCProcessingCenterID, CCProcessingFeature.Tokenization,
                                                                                        new ProcessingContext()
                    {
                        aCustomerID = current.BAccountID, aPMInstanceID = current.PMInstanceID
                    });
                    CustomerPaymentMethodDetail ccpidCPMDet = null;
                    PaymentMethodDetail         ccpidPMDet  = PXSelect <PaymentMethodDetail,
                                                                        Where <PaymentMethodDetail.paymentMethodID, Equal <Optional <CustomerPaymentMethod.paymentMethodID> >,
                                                                               And <PaymentMethodDetail.useFor, Equal <PaymentMethodDetailUsage.useForARCards>, And <PaymentMethodDetail.isCCProcessingID, Equal <True> > > > > .Select(graph, current.PaymentMethodID);

                    foreach (CustomerPaymentMethodDetail deletedDet in detailsView.Cache.Deleted)
                    {
                        if (deletedDet.DetailID == ccpidPMDet.DetailID)
                        {
                            ccpidCPMDet = deletedDet;
                            break;
                        }
                    }
                    if (ccpidCPMDet != null && !string.IsNullOrEmpty(ccpidCPMDet.Value))
                    {
                        cim.DeletePaymentMethod();
                    }
                }
            }
        }
 public void GetCreatePaymentProfileForm <TPaymentMethodType>(PXGraph graph,
                                                              PXSelectBase <TPaymentMethodType> customerPaymentMethodView,
                                                              TPaymentMethodType currentCustomerPaymentMethod)
     where TPaymentMethodType : CustomerPaymentMethod, new()
 {
     CCCustomerInformationManager.GetCreatePaymentProfileForm(graph, customerPaymentMethodView, currentCustomerPaymentMethod);
 }
Example #3
0
        public static void GetManagePaymentProfileForm(PXGraph graph, ICCPaymentProfile paymentProfile)
        {
            if (graph == null || paymentProfile == null)
            {
                return;
            }
            CustomerPaymentMethodDetail ccpID = PXSelectJoin <CustomerPaymentMethodDetail, InnerJoin <PaymentMethodDetail,
                                                                                                      On <CustomerPaymentMethodDetail.paymentMethodID, Equal <PaymentMethodDetail.paymentMethodID>, And <CustomerPaymentMethodDetail.detailID, Equal <PaymentMethodDetail.detailID>,
                                                                                                                                                                                                         And <PaymentMethodDetail.useFor, Equal <PaymentMethodDetailUsage.useForARCards> > > > >,
                                                              Where <PaymentMethodDetail.isCCProcessingID, Equal <True>, And <CustomerPaymentMethodDetail.pMInstanceID,
                                                                                                                              Equal <Required <CustomerPaymentMethod.pMInstanceID> > > > > .SelectWindowed(graph, 0, 1, paymentProfile.PMInstanceID);

            if (ccpID != null && !string.IsNullOrEmpty(ccpID.Value))
            {
                ProcessingCardsPluginFactory pluginFactory    = GetProcessingCardsPluginFactory(paymentProfile.CCProcessingCenterID);
                CCCustomerInformationManager cim              = GetCustomerInformationManager(pluginFactory);
                CCProcessingCenter           processingCenter = pluginFactory.GetProcessingCenter();
                CCProcessingContext          context          = new CCProcessingContext()
                {
                    processingCenter = pluginFactory.GetProcessingCenter(),
                    aCustomerID      = paymentProfile.BAccountID,
                    aPMInstanceID    = paymentProfile.PMInstanceID,
                    callerGraph      = graph
                };
                CardProcessingReadersProvider readersProvider = new CardProcessingReadersProvider(context);
                cim.SetReadersProvider(readersProvider);
                cim.GetManagePaymentProfileForm();
            }
        }
 public void GetOrCreatePaymentProfile <TPaymentMethodType, TDetialsType>(PXGraph graph
                                                                          , PXSelectBase <TPaymentMethodType> customerPaymentMethodView
                                                                          , PXSelectBase <TDetialsType> detailsView)
     where TPaymentMethodType : CustomerPaymentMethod, new()
     where TDetialsType : CustomerPaymentMethodDetail, new()
 {
     CCCustomerInformationManager.GetOrCreatePaymentProfile(graph, customerPaymentMethodView, detailsView);
 }
 public void GetNewPaymentProfiles <TPaymentMethodType, TDetialsType>(PXGraph graph,
                                                                      PXSelectBase <TPaymentMethodType> customerPaymentMethodView,
                                                                      PXSelectBase <TDetialsType> detailsView,
                                                                      TPaymentMethodType currentCustomerPaymentMethod)
     where TPaymentMethodType : CustomerPaymentMethod, new()
     where TDetialsType : CustomerPaymentMethodDetail, new()
 {
     CCCustomerInformationManager.GetNewPaymentProfiles(graph, customerPaymentMethodView, detailsView, currentCustomerPaymentMethod);
 }
Example #6
0
        public static void GetPaymentProfile(PXGraph graph, ICCPaymentProfileAdapter payment, ICCPaymentProfileDetailAdapter paymentDetail)
        {
            string CCPID = null;

            foreach (Tuple <ICCPaymentProfileDetail, ICCPaymentMethodDetail> det in paymentDetail.Select())
            {
                ICCPaymentProfileDetail ppd = det.Item1;
                ICCPaymentMethodDetail  pmd = det.Item2;
                if (pmd.IsCCProcessingID == true)
                {
                    CCPID = ppd.Value;
                    break;
                }
            }
            if (string.IsNullOrEmpty(CCPID))
            {
                throw new PXException(Messages.CreditCardTokenIDNotFound);
            }
            ICCPaymentProfile paymentProfile   = payment.Current;
            string            custProcCenterID = paymentProfile.CCProcessingCenterID;
            int?bAccountId   = paymentProfile.BAccountID;
            int?pmInstanceId = paymentProfile.PMInstanceID;
            ProcessingCardsPluginFactory  pluginFactory   = GetProcessingCardsPluginFactory(custProcCenterID);
            CCCustomerInformationManager  cim             = GetCustomerInformationManager(pluginFactory);
            CardProcessingReadersProvider readersProvider = new CardProcessingReadersProvider(new CCProcessingContext()
            {
                processingCenter = pluginFactory.GetProcessingCenter(),
                aCustomerID      = bAccountId,
                aPMInstanceID    = pmInstanceId,
                callerGraph      = graph
            });

            cim.SetReadersProvider(readersProvider);
            CreditCardData cardData = cim.GetPaymentProfile();

            if (cardData == null)
            {
                throw new PXException(Messages.CreditCardNotFoundInProcCenter, CCPID, paymentProfile.CCProcessingCenterID);
            }
            foreach (Tuple <ICCPaymentProfileDetail, ICCPaymentMethodDetail> det in paymentDetail.Select())
            {
                ICCPaymentProfileDetail ppd = det.Item1;
                ICCPaymentMethodDetail  pmd = det.Item2;
                if (pmd.IsCCProcessingID != true && pmd.IsIdentifier == true && !string.IsNullOrEmpty(cardData.CardNumber))
                {
                    ppd.Value = cardData.CardNumber;
                    paymentDetail.Cache.Update(ppd);
                }
            }
            if (cardData.CardExpirationDate != null)
            {
                payment.Cache.SetValueExt(paymentProfile, nameof(paymentProfile.ExpirationDate), cardData.CardExpirationDate);
                payment.Cache.Update(paymentProfile);
            }
        }
Example #7
0
        public static void GetCreatePaymentProfileForm(PXGraph graph, ICCPaymentProfileAdapter paymentProfileAdapter)
        {
            if (graph == null || paymentProfileAdapter == null)
            {
                return;
            }
            ICCPaymentProfile            ccPaymentProfile = paymentProfileAdapter.Current;
            PXCache                      cache            = paymentProfileAdapter.Cache;
            ProcessingCardsPluginFactory pluginFactory    = GetProcessingCardsPluginFactory(ccPaymentProfile.CCProcessingCenterID);
            CCCustomerInformationManager cim     = GetCustomerInformationManager(pluginFactory);
            CCProcessingContext          context = new CCProcessingContext()
            {
                processingCenter = pluginFactory.GetProcessingCenter(),
                aCustomerID      = ccPaymentProfile.BAccountID,
                aPMInstanceID    = ccPaymentProfile.PMInstanceID,
                callerGraph      = graph
            };
            CardProcessingReadersProvider readersProvider = new CardProcessingReadersProvider(context);

            cim.SetReadersProvider(readersProvider);
            string id = ccPaymentProfile.CustomerCCPID;

            if (id == null)
            {
                id = cim.CreateCustomerProfile();
                ICCPaymentProfile cpm = cache.CreateCopy(ccPaymentProfile) as ICCPaymentProfile;
                cpm.CustomerCCPID = id;
                cache.Update(cpm);
            }
            var processingCenter = pluginFactory.GetProcessingCenter();

            if (processingCenter.CreateAdditionalCustomerProfiles == true)
            {
                int customerProfileCount = CCProcessingHelper.CustomerProfileCountPerCustomer(graph,
                                                                                              ccPaymentProfile.BAccountID,
                                                                                              ccPaymentProfile.CCProcessingCenterID); // Total customer profile count per customer

                var cardLimit = processingCenter.CreditCardLimit;
                if (cardLimit != null && cardLimit > 0)
                {
                    int allPaymentProfileCount = cim.GetAllPaymentProfiles().Count();
                    if (CCProcessingHelper.IsCreditCardCountEnough(allPaymentProfileCount, cardLimit.Value))
                    {
                        context.PrefixForCustomerCD = CCProcessingHelper.BuildPrefixForCustomerCD(customerProfileCount, processingCenter);
                        id = cim.CreateCustomerProfile();
                        ICCPaymentProfile cpm = cache.CreateCopy(ccPaymentProfile) as ICCPaymentProfile;
                        cpm.CustomerCCPID = id;
                        cache.Update(cpm);
                    }
                }
            }
            cim.GetCreatePaymentProfileForm();
        }
        public static void GetCreatePaymentProfileForm <TPaymentMethodType>(PXGraph graph,
                                                                            PXSelectBase <TPaymentMethodType> customerPaymentMethodView,
                                                                            TPaymentMethodType currentCustomerPaymentMethod)
            where TPaymentMethodType : CustomerPaymentMethod, new()
        {
            if (graph == null || customerPaymentMethodView == null || currentCustomerPaymentMethod == null)
            {
                return;
            }
            CCCustomerInformationManager cim = new CCCustomerInformationManager(currentCustomerPaymentMethod.CCProcessingCenterID, CCProcessingFeature.HostedForm)
            {
                CustomerID   = currentCustomerPaymentMethod.BAccountID,
                PMInstanceID = currentCustomerPaymentMethod.PMInstanceID,
                CallerGraph  = graph
            };

            string id = currentCustomerPaymentMethod.CustomerCCPID;

            if (currentCustomerPaymentMethod.CustomerCCPID == null)
            {
                id = cim.CreateCustomerProfile();
                TPaymentMethodType cpm = (TPaymentMethodType)customerPaymentMethodView.Cache.CreateCopy(currentCustomerPaymentMethod);
                cpm.CustomerCCPID = id;
                customerPaymentMethodView.Update(cpm);
            }
            var processingCenter = cim._context.processingCenter;

            if (processingCenter.CreateAdditionalCustomerProfiles == true)
            {
                int customerProfileCount = CCProcessingHelper.CustomerProfileCountPerCustomer(graph,
                                                                                              currentCustomerPaymentMethod.BAccountID,
                                                                                              currentCustomerPaymentMethod.CCProcessingCenterID); // Total customer profile count per customer

                var cardLimit = processingCenter.CreditCardLimit;
                if (cardLimit != null && cardLimit > 0)
                {
                    int allPaymentProfileCount = cim.GetAllPaymentProfiles().Count();
                    if (CCProcessingHelper.IsCreditCardCountEnough(allPaymentProfileCount, cardLimit.Value))
                    {
                        cim.PrefixForCustomerCD = CCProcessingHelper.BuildPrefixForCustomerCD(customerProfileCount, processingCenter);
                        id = cim.CreateCustomerProfile();
                        TPaymentMethodType cpm = (TPaymentMethodType)customerPaymentMethodView.Cache.CreateCopy(currentCustomerPaymentMethod);
                        cpm.CustomerCCPID = id;
                        customerPaymentMethodView.Update(cpm);
                    }
                }
            }
            cim.GetCreatePaymentProfileForm();
        }
        public static void GetPaymentProfile(PXGraph graph, PXSelectBase <CustomerPaymentMethod> customerPaymentMethodView, PXSelectBase <CustomerPaymentMethodDetail> detailsView)
        {
            string CCPID = null;

            foreach (PXResult <CustomerPaymentMethodDetail, PaymentMethodDetail> det in detailsView.Select())
            {
                CustomerPaymentMethodDetail cpmd = (CustomerPaymentMethodDetail)det;
                PaymentMethodDetail         pmd  = (PaymentMethodDetail)det;
                if (pmd.IsCCProcessingID == true)
                {
                    CCPID = cpmd.Value;
                    break;
                }
            }
            if (String.IsNullOrEmpty(CCPID))
            {
                throw new PXException(Messages.CreditCardTokenIDNotFound);
            }
            CCCustomerInformationManager cim = new CCCustomerInformationManager(customerPaymentMethodView.Current.CCProcessingCenterID, CCProcessingFeature.ProfileManagement)
            {
                CustomerID   = customerPaymentMethodView.Current.BAccountID,
                PMInstanceID = customerPaymentMethodView.Current.PMInstanceID,
                CallerGraph  = graph
            };
            CreditCardData cardData = cim.GetPaymentProfile();

            if (cardData == null)
            {
                throw new PXException(Messages.CreditCardNotFoundInProcCenter, CCPID, customerPaymentMethodView.Current.CCProcessingCenterID);
            }
            foreach (PXResult <CustomerPaymentMethodDetail, PaymentMethodDetail> det in detailsView.Select())
            {
                CustomerPaymentMethodDetail cpmd = (CustomerPaymentMethodDetail)det;
                PaymentMethodDetail         pmd  = (PaymentMethodDetail)det;
                if (pmd.IsCCProcessingID != true && pmd.IsIdentifier == true && !string.IsNullOrEmpty(cardData.CardNumber))
                {
                    cpmd.Value = cardData.CardNumber;
                    detailsView.Update(cpmd);
                }
            }
            if (cardData.CardExpirationDate != null)
            {
                CustomerPaymentMethod cpm = (CustomerPaymentMethod)customerPaymentMethodView.Cache.CreateCopy(customerPaymentMethodView.Current);
                customerPaymentMethodView.Cache.SetValueExt <CustomerPaymentMethod.expirationDate>(cpm, cardData.CardExpirationDate);
                customerPaymentMethodView.Update(cpm);
            }
        }
        public static void SyncExistingPMI(PXGraph graph, PXSelectBase <CustomerPaymentMethod> customerPaymentMethodView, PXSelectBase <CustomerPaymentMethodDetail> detailsView)
        {
            string CCPID = null;

            foreach (PXResult <CustomerPaymentMethodDetail, PaymentMethodDetail> det in detailsView.Select())
            {
                CustomerPaymentMethodDetail cpmd = (CustomerPaymentMethodDetail)det;
                PaymentMethodDetail         pmd  = (PaymentMethodDetail)det;
                if (pmd.IsCCProcessingID == true)
                {
                    CCPID = cpmd.Value;
                    break;
                }
            }
            if (String.IsNullOrEmpty(CCPID))
            {
                throw new PXException(Messages.CreditCardTokenIDNotFound);
            }
            CCCustomerInformationManager cim = new CCCustomerInformationManager(customerPaymentMethodView.Current.CCProcessingCenterID, CCProcessingFeature.Tokenization,
                                                                                new ProcessingContext()
            {
                aCustomerID   = customerPaymentMethodView.Current.BAccountID,
                aPMInstanceID = customerPaymentMethodView.Current.PMInstanceID,
                callerGraph   = graph
            });
            SyncPMResponse response = cim.GetPaymentMethod();

            if (response.PMList.Count == 0)
            {
                throw new PXException(Messages.CreditCardNotFoundInProcCenter, CCPID, customerPaymentMethodView.Current.CCProcessingCenterID);
            }
            foreach (PXResult <CustomerPaymentMethodDetail, PaymentMethodDetail> det in detailsView.Select())
            {
                CustomerPaymentMethodDetail cpmd = (CustomerPaymentMethodDetail)det;
                PaymentMethodDetail         pmd  = (PaymentMethodDetail)det;
                if (pmd.IsCCProcessingID != true && response.PMList.First().Value.ContainsKey(cpmd.DetailID))
                {
                    cpmd.Value = response.PMList.First().Value[cpmd.DetailID];
                    detailsView.Update(cpmd);
                }
            }
        }
Example #11
0
        public static void DeletePaymentProfile(PXGraph graph, ICCPaymentProfileAdapter payment, ICCPaymentProfileDetailAdapter paymentDetail)
        {
            IEnumerator cpmEnumerator = payment.Cache.Deleted.GetEnumerator();

            if (cpmEnumerator.MoveNext())
            {
                ICCPaymentProfile            current          = (ICCPaymentProfile)cpmEnumerator.Current;
                ProcessingCardsPluginFactory pluginFactory    = GetProcessingCardsPluginFactory(current.CCProcessingCenterID);
                CCProcessingCenter           processingCenter = pluginFactory.GetProcessingCenter();
                if (!string.IsNullOrEmpty(current.CCProcessingCenterID) && processingCenter.SyncronizeDeletion == true)
                {
                    CCCustomerInformationManager  cim             = GetCustomerInformationManager(pluginFactory);
                    CardProcessingReadersProvider readersProvider = new CardProcessingReadersProvider(new CCProcessingContext()
                    {
                        processingCenter = pluginFactory.GetProcessingCenter(),
                        aCustomerID      = current.BAccountID,
                        aPMInstanceID    = current.PMInstanceID,
                        callerGraph      = pluginFactory.GetPaymentProcessingRepository().Graph
                    });
                    cim.SetReadersProvider(readersProvider);
                    ICCPaymentProfileDetail ccpidCPMDet = null;
                    PaymentMethodDetail     ccpidPMDet  = PXSelect <PaymentMethodDetail,
                                                                    Where <PaymentMethodDetail.paymentMethodID, Equal <Optional <CustomerPaymentMethod.paymentMethodID> >,
                                                                           And <PaymentMethodDetail.useFor, Equal <PaymentMethodDetailUsage.useForARCards>, And <PaymentMethodDetail.isCCProcessingID, Equal <True> > > > > .Select(graph, current.PaymentMethodID);

                    foreach (ICCPaymentProfileDetail deletedDet in paymentDetail.Cache.Deleted)
                    {
                        if (deletedDet.DetailID == ccpidPMDet.DetailID)
                        {
                            ccpidCPMDet = deletedDet;
                            break;
                        }
                    }
                    if (ccpidCPMDet != null && !string.IsNullOrEmpty(ccpidCPMDet.Value))
                    {
                        cim.DeletePaymentProfile();
                    }
                }
            }
        }
        public static void CreatePaymentMethodHF <TPaymentMethodType>(PXGraph graph, PXSelectBase <TPaymentMethodType> customerPaymentMethodView, TPaymentMethodType currentCutomerPaymenMethod)
            where TPaymentMethodType : CustomerPaymentMethod, new()
        {
            if (graph == null || customerPaymentMethodView == null || currentCutomerPaymenMethod == null)
            {
                return;
            }
            CCCustomerInformationManager cim = new CCCustomerInformationManager(currentCutomerPaymenMethod.CCProcessingCenterID, CCProcessingFeature.HostedForm,
                                                                                new ProcessingContext()
            {
                aCustomerID = currentCutomerPaymenMethod.BAccountID, aPMInstanceID = currentCutomerPaymenMethod.PMInstanceID, callerGraph = graph
            });

            if (currentCutomerPaymenMethod.CustomerCCPID == null)
            {
                string             id  = cim.CreateCustomer();
                TPaymentMethodType cpm = (TPaymentMethodType)customerPaymentMethodView.Cache.CreateCopy(currentCutomerPaymenMethod);
                cpm.CustomerCCPID = id;
                customerPaymentMethodView.Update(cpm);
            }
            cim.CreatePaymentMethodHostedForm();
        }
        public static void ManagePaymentMethodHF <TPaymentMethodType>(PXGraph graph, TPaymentMethodType currentCutomerPaymenMethod)
            where TPaymentMethodType : CustomerPaymentMethod, new()
        {
            if (graph == null || currentCutomerPaymenMethod == null)
            {
                return;
            }
            CustomerPaymentMethodDetail ccpID = PXSelectJoin <CustomerPaymentMethodDetail, InnerJoin <PaymentMethodDetail,
                                                                                                      On <CustomerPaymentMethodDetail.paymentMethodID, Equal <PaymentMethodDetail.paymentMethodID>, And <CustomerPaymentMethodDetail.detailID, Equal <PaymentMethodDetail.detailID>,
                                                                                                                                                                                                         And <PaymentMethodDetail.useFor, Equal <PaymentMethodDetailUsage.useForARCards> > > > >,
                                                              Where <PaymentMethodDetail.isCCProcessingID, Equal <True>, And <CustomerPaymentMethodDetail.pMInstanceID,
                                                                                                                              Equal <Required <CustomerPaymentMethod.pMInstanceID> > > > > .SelectWindowed(graph, 0, 1, currentCutomerPaymenMethod.PMInstanceID);

            if (ccpID != null && !string.IsNullOrEmpty(ccpID.Value))
            {
                CCCustomerInformationManager cim = new CCCustomerInformationManager(currentCutomerPaymenMethod.CCProcessingCenterID, CCProcessingFeature.HostedForm,
                                                                                    new ProcessingContext()
                {
                    aCustomerID = currentCutomerPaymenMethod.BAccountID, aPMInstanceID = currentCutomerPaymenMethod.PMInstanceID, callerGraph = graph
                });
                cim.ManagePaymentMethodHostedForm();
            }
        }
Example #14
0
 public virtual void GetOrCreatePaymentProfile(PXGraph graph, ICCPaymentProfileAdapter paymentProfileAdapter, ICCPaymentProfileDetailAdapter profileDetailAdapter)
 {
     CCCustomerInformationManager.GetOrCreatePaymentProfile(graph, paymentProfileAdapter, profileDetailAdapter);
 }
Example #15
0
 public virtual TranProfile GetOrCreatePaymentProfileByTran(PXGraph graph, ICCPaymentProfileAdapter payment, string tranId)
 {
     return(CCCustomerInformationManager.GetOrCreatePaymentProfileByTran(graph, payment, tranId));
 }
Example #16
0
 public virtual void DeletePaymentProfile(PXGraph graph, ICCPaymentProfileAdapter payment, ICCPaymentProfileDetailAdapter paymentDetail)
 {
     CCCustomerInformationManager.DeletePaymentProfile(graph, payment, paymentDetail);
 }
Example #17
0
 public virtual PXResultset <CustomerPaymentMethodDetail> GetAllCustomersCardsInProcCenter(PXGraph graph, int?BAccountID, string CCProcessingCenterID)
 {
     return(CCCustomerInformationManager.GetAllCustomersCardsInProcCenter(graph, BAccountID, CCProcessingCenterID));
 }
Example #18
0
 public virtual void GetNewPaymentProfiles(PXGraph graph, ICCPaymentProfileAdapter payment, ICCPaymentProfileDetailAdapter paymentDetail)
 {
     CCCustomerInformationManager.GetNewPaymentProfiles(graph, payment, paymentDetail);
 }
Example #19
0
        public static TranProfile GetOrCreatePaymentProfileByTran(PXGraph graph, ICCPaymentProfileAdapter adapter, string tranId)
        {
            ICCPaymentProfile            paymentProfile   = adapter.Current;
            ProcessingCardsPluginFactory pluginFactory    = GetProcessingCardsPluginFactory(paymentProfile.CCProcessingCenterID);
            CCProcessingCenter           processingCenter = pluginFactory.GetProcessingCenter();
            CCCustomerInformationManager cim = GetCustomerInformationManager(pluginFactory);

            CardProcessingReadersProvider readersProvider = new CardProcessingReadersProvider(new CCProcessingContext()
            {
                processingCenter = processingCenter,
                aCustomerID      = paymentProfile.BAccountID,
                aPMInstanceID    = paymentProfile.PMInstanceID,
                callerGraph      = graph
            });

            cim.SetReadersProvider(readersProvider);

            Customer    customer = new PXSelect <Customer, Where <Customer.bAccountID, Equal <Required <Customer.bAccountID> > > >(graph).Select(paymentProfile.BAccountID);
            TranProfile ret      = null;

            if (paymentProfile.CustomerCCPID == null)
            {
                ret = cim.GetOrCreateCustomerProfileFromTransaction(tranId, new CreateTranPaymentProfileParams()
                {
                    LocalCustomerId = customer.AcctCD
                });
                return(ret);
            }
            var cardLimit = processingCenter.CreditCardLimit;

            if (processingCenter.CreateAdditionalCustomerProfiles == true && cardLimit != null && cardLimit > 0)
            {
                int customerProfileCount = CCProcessingHelper.CustomerProfileCountPerCustomer(graph,
                                                                                              paymentProfile.BAccountID,
                                                                                              paymentProfile.CCProcessingCenterID);

                int allPaymentProfileCount = cim.GetAllPaymentProfiles().Count();
                if (CCProcessingHelper.IsCreditCardCountEnough(allPaymentProfileCount, cardLimit.Value))
                {
                    var prefix = CCProcessingHelper.BuildPrefixForCustomerCD(customerProfileCount, processingCenter);
                    ret = cim.GetOrCreateCustomerProfileFromTransaction(tranId, new CreateTranPaymentProfileParams()
                    {
                        LocalCustomerId = prefix + customer.AcctCD
                    });
                }
                else
                {
                    ret = cim.GetOrCreateCustomerProfileFromTransaction(tranId, new CreateTranPaymentProfileParams()
                    {
                        PCCustomerId = paymentProfile.CustomerCCPID
                    });
                }
            }
            else
            {
                ret = cim.GetOrCreateCustomerProfileFromTransaction(tranId, new CreateTranPaymentProfileParams()
                {
                    PCCustomerId = paymentProfile.CustomerCCPID
                });
            }
            return(ret);
        }
 public virtual void DeletePaymentProfile(PXGraph graph, PXSelectBase <CustomerPaymentMethod> customerPaymentMethodView, PXSelectBase <CustomerPaymentMethodDetail> detailsView)
 {
     CCCustomerInformationManager.DeletePaymentProfile(graph, customerPaymentMethodView, detailsView);
 }
        public static void GetNewPaymentProfiles <TPaymentMethodType, TDetialsType>(PXGraph graph,
                                                                                    PXSelectBase <TPaymentMethodType> customerPaymentMethodView,
                                                                                    PXSelectBase <TDetialsType> detailsView,
                                                                                    TPaymentMethodType currentCustomerPaymentMethod)
            where TPaymentMethodType : CustomerPaymentMethod, new()
            where TDetialsType : CustomerPaymentMethodDetail, new()
        {
            if (graph == null || customerPaymentMethodView == null || detailsView == null || currentCustomerPaymentMethod == null)
            {
                return;
            }
            CCCustomerInformationManager cim = new CCCustomerInformationManager(currentCustomerPaymentMethod.CCProcessingCenterID, CCProcessingFeature.HostedForm)
            {
                CustomerID   = currentCustomerPaymentMethod.BAccountID,
                PMInstanceID = currentCustomerPaymentMethod.PMInstanceID,
                CallerGraph  = graph
            };

            int            attempt = 1;
            CreditCardData newCard = null;

            //AuthorizeNet sometimes failes to process new card in time when using Hosted Form Method
            while ((attempt <= (cim._context.processingCenter.SyncRetryAttemptsNo ?? 0) + 1) && newCard == null)
            {
                Thread.Sleep(cim._context.processingCenter.SyncRetryDelayMs ?? 0);
                List <CreditCardData> newCards = null;

                try
                {
                    newCards = cim.GetMissingPaymentProfiles().ToList();
                }
                catch (Exception e)
                {
                    throw new PXException(e.Message + ". " + Messages.FailedToSyncCC);
                }

                TPaymentMethodType customerPaymentMethod = customerPaymentMethodView.Current;

                if (newCards != null && newCards.Count > 1)
                {
                    newCards.Sort(new InterfaceExtensions.CreditCardDataComparer());
                    newCard = newCards[0];
                }
                else if (newCards != null && newCards.Count == 1)
                {
                    newCard = newCards[0];
                }

                if (newCard != null)
                {
                    foreach (PXResult <TDetialsType, PaymentMethodDetail> det in detailsView.Select())
                    {
                        TDetialsType        cpmd = det;
                        PaymentMethodDetail pmd  = (PaymentMethodDetail)det;
                        if (pmd.IsCCProcessingID == true)
                        {
                            cpmd.Value = newCard.PaymentProfileID;
                            detailsView.Update(cpmd);
                        }
                        else if (pmd.IsIdentifier == true)
                        {
                            cpmd.Value = newCard.CardNumber;
                            detailsView.Update(cpmd);
                        }
                    }
                    //getting unmasked expiration date
                    newCard = cim.GetPaymentProfile();
                    if (newCard.CardExpirationDate != null)
                    {
                        customerPaymentMethodView.Cache.SetValueExt <CustomerPaymentMethod.expirationDate>(customerPaymentMethod, newCard.CardExpirationDate);
                        customerPaymentMethodView.Update(customerPaymentMethod);
                    }
                }
                attempt++;
            }
            if (newCard == null)
            {
                throw new PXException(Messages.FailedToSyncCC);
            }
        }
Example #22
0
        public static void GetNewPaymentProfiles(PXGraph graph,
                                                 ICCPaymentProfileAdapter payment,
                                                 ICCPaymentProfileDetailAdapter paymentDetail
                                                 )
        {
            if (graph == null || payment == null || paymentDetail == null)
            {
                return;
            }
            ICCPaymentProfile             currentPaymentProfile = payment.Current;
            ProcessingCardsPluginFactory  pluginFactory         = GetProcessingCardsPluginFactory(currentPaymentProfile.CCProcessingCenterID);
            CCCustomerInformationManager  cim             = GetCustomerInformationManager(pluginFactory);
            CardProcessingReadersProvider readersProvider = new CardProcessingReadersProvider(new CCProcessingContext()
            {
                processingCenter = pluginFactory.GetProcessingCenter(),
                aCustomerID      = currentPaymentProfile.BAccountID,
                aPMInstanceID    = currentPaymentProfile.PMInstanceID,
                callerGraph      = graph
            });

            cim.SetReadersProvider(readersProvider);

            int            attempt = 1;
            CreditCardData newCard = null;
            //AuthorizeNet sometimes failes to process new card in time when using Hosted Form Method
            CCProcessingCenter procCenter = pluginFactory.GetProcessingCenter();

            while ((attempt <= (procCenter.SyncRetryAttemptsNo ?? 0) + 1) && newCard == null)
            {
                Thread.Sleep(procCenter.SyncRetryDelayMs ?? 0);
                List <CreditCardData> newCards = null;

                try
                {
                    newCards = cim.GetMissingPaymentProfiles().ToList();
                }
                catch (Exception e)
                {
                    throw new PXException(e.Message + ". " + Messages.FailedToSyncCC);
                }

                ICCPaymentProfile customerPaymentMethod = payment.Current;

                if (newCards != null && newCards.Count > 1)
                {
                    newCards.Sort(new InterfaceExtensions.CreditCardDataComparer());
                    newCard = newCards[0];
                }
                else if (newCards != null && newCards.Count == 1)
                {
                    newCard = newCards[0];
                }

                if (newCard != null)
                {
                    foreach (Tuple <ICCPaymentProfileDetail, ICCPaymentMethodDetail> det in paymentDetail.Select())
                    {
                        ICCPaymentProfileDetail cpmd = det.Item1;
                        ICCPaymentMethodDetail  pmd  = det.Item2;
                        if (pmd.IsCCProcessingID == true)
                        {
                            cpmd.Value = newCard.PaymentProfileID;
                            paymentDetail.Cache.Update(cpmd);
                        }
                        else if (pmd.IsIdentifier == true)
                        {
                            cpmd.Value = newCard.CardNumber;
                            paymentDetail.Cache.Update(cpmd);
                        }
                    }
                    //getting unmasked expiration date
                    newCard = cim.GetPaymentProfile();
                    if (newCard.CardExpirationDate != null)
                    {
                        payment.Cache.SetValueExt <CustomerPaymentMethod.expirationDate>(customerPaymentMethod, newCard.CardExpirationDate);
                        payment.Cache.Update(customerPaymentMethod);
                    }
                }
                attempt++;
            }
            if (newCard == null)
            {
                throw new PXException(Messages.FailedToSyncCC);
            }
        }
Example #23
0
        public static void GetOrCreatePaymentProfile(PXGraph graph
                                                     , ICCPaymentProfileAdapter payment
                                                     , ICCPaymentProfileDetailAdapter paymentDetail)
        {
            ICCPaymentProfile paymentProfile = payment.Current;
            bool isHF         = CCProcessingHelper.IsHFPaymentMethod(graph, payment.Current.PMInstanceID);
            bool isConverting = false;

            if (paymentProfile is CustomerPaymentMethod)
            {
                isConverting = ((CustomerPaymentMethod)paymentProfile).Selected == true;
            }
            isHF = isHF && !isConverting;
            ICCPaymentProfileDetail CCPIDDet = null;
            bool isIDFilled        = false;
            bool isOtherDetsFilled = false;

            foreach (Tuple <ICCPaymentProfileDetail, ICCPaymentMethodDetail> det in paymentDetail.Select())
            {
                ICCPaymentProfileDetail ppd = det.Item1;
                ICCPaymentMethodDetail  pmd = det.Item2;
                if (pmd.IsCCProcessingID == true)
                {
                    isIDFilled = ppd.Value != null;
                    CCPIDDet   = ppd;
                }
                else
                {
                    isOtherDetsFilled = ppd.Value != null || isOtherDetsFilled;
                }
            }
            if (CCPIDDet == null)
            {
                //something's very wrong
                throw new PXException(Messages.NOCCPID, payment.Current.Descr);
            }
            if (isIDFilled && isOtherDetsFilled)
            {
                return;
            }

            bool tryGetProfile = isIDFilled && !isOtherDetsFilled;

            if ((isIDFilled || isOtherDetsFilled) && !isHF || tryGetProfile)
            {
                var currCpm = payment.Current;
                ProcessingCardsPluginFactory pluginFactory    = GetProcessingCardsPluginFactory(currCpm.CCProcessingCenterID);
                CCCustomerInformationManager cim              = GetCustomerInformationManager(pluginFactory);
                CCProcessingCenter           processingCenter = pluginFactory.GetProcessingCenter();
                CCProcessingContext          context          = new CCProcessingContext()
                {
                    processingCenter        = pluginFactory.GetProcessingCenter(),
                    aCustomerID             = currCpm.BAccountID,
                    aPMInstanceID           = currCpm.PMInstanceID,
                    callerGraph             = graph,
                    expirationDateConverter = s => CustomerPaymentMethodMaint.ParseExpiryDate(graph, currCpm, s)
                };
                CardProcessingReadersProvider readersProvider = new CardProcessingReadersProvider(context);
                cim.SetReadersProvider(readersProvider);
                string id = currCpm.CustomerCCPID;
                if (currCpm.CustomerCCPID == null)
                {
                    id = cim.CreateCustomerProfile();
                    paymentProfile.CustomerCCPID = id;
                    payment.Cache.Update(paymentProfile);
                }

                if (processingCenter.CreateAdditionalCustomerProfiles == true && !tryGetProfile)
                {
                    int customerProfileCount = CCProcessingHelper.CustomerProfileCountPerCustomer(graph,
                                                                                                  currCpm.BAccountID,
                                                                                                  currCpm.CCProcessingCenterID); // Total customer profile count per customer

                    var cardLimit = processingCenter.CreditCardLimit;
                    if (cardLimit != null && cardLimit > 0)
                    {
                        int allPaymentProfileCount = cim.GetAllPaymentProfiles().Count();
                        if (CCProcessingHelper.IsCreditCardCountEnough(allPaymentProfileCount, cardLimit.Value))
                        {
                            context.PrefixForCustomerCD = CCProcessingHelper.BuildPrefixForCustomerCD(customerProfileCount, processingCenter);
                            id = cim.CreateCustomerProfile();
                            paymentProfile.CustomerCCPID = id;
                            payment.Cache.Update(paymentProfile);
                        }
                    }
                }

                if (isOtherDetsFilled)
                {
                    string newPMId = cim.CreatePaymentProfile();
                    CCPIDDet.Value = newPMId;
                    CCPIDDet       = paymentDetail.Cache.Update(CCPIDDet) as ICCPaymentProfileDetail;
                }
                CreditCardData cardData = cim.GetPaymentProfile();
                if (cardData != null && !string.IsNullOrEmpty(cardData.PaymentProfileID))
                {
                    foreach (Tuple <ICCPaymentProfileDetail, ICCPaymentMethodDetail> det in paymentDetail.Select())
                    {
                        ICCPaymentProfileDetail ppd = det.Item1;
                        ICCPaymentMethodDetail  pmd = det.Item2;
                        if (ppd.DetailID == CCPIDDet.DetailID)
                        {
                            continue;
                        }
                        string detailValue = null;
                        if (pmd.IsCCProcessingID != true && pmd.IsIdentifier == true && !string.IsNullOrEmpty(cardData.CardNumber))
                        {
                            detailValue = cardData.CardNumber;
                        }
                        ppd.Value = detailValue;
                        paymentDetail.Cache.Update(ppd);
                    }
                    if (cardData.CardExpirationDate != null)
                    {
                        payment.Cache.SetValueExt(paymentProfile, nameof(paymentProfile.ExpirationDate), cardData.CardExpirationDate);
                        payment.Cache.Update(paymentProfile);
                    }
                }
                else
                {
                    throw new PXException(Messages.CouldntGetPMIDetails, payment.Current.Descr);
                }
            }
        }
Example #24
0
        private static CCCustomerInformationManager GetCustomerInformationManager(ProcessingCardsPluginFactory pluginFactory)
        {
            CCCustomerInformationManager cim = new CCCustomerInformationManager(pluginFactory);

            return(cim);
        }
        public static void SyncPaymentMethodsHF <TPaymentMethodType, TDetialsType>(PXGraph graph, PXSelectBase <TPaymentMethodType> customerPaymentMethodView,
                                                                                   PXSelectBase <TDetialsType> detailsView, TPaymentMethodType currentCustomerPaymentMethod)
            where TPaymentMethodType : CustomerPaymentMethod, new()
            where TDetialsType : CustomerPaymentMethodDetail, new()
        {
            if (graph == null || customerPaymentMethodView == null || detailsView == null || currentCustomerPaymentMethod == null)
            {
                return;
            }
            CCCustomerInformationManager cim = new CCCustomerInformationManager(currentCustomerPaymentMethod.CCProcessingCenterID, CCProcessingFeature.HostedForm,
                                                                                new ProcessingContext()
            {
                aCustomerID = currentCustomerPaymentMethod.BAccountID, aPMInstanceID = currentCustomerPaymentMethod.PMInstanceID, callerGraph = graph
            });
            int    attempt = 1;
            string newPMID = string.Empty;

            //AuthorizeNet sometimes failes to process new card in time when using Hosted Form Method
            while ((attempt <= (cim.Context.processingCenter.SyncRetryAttemptsNo ?? 0) + 1) && string.IsNullOrEmpty(newPMID))
            {
                Thread.Sleep(cim.Context.processingCenter.SyncRetryDelayMs ?? 0);
                SyncPMResponse     syncResponse          = cim.SynchronizePaymentMethods();
                TPaymentMethodType customerPaymentMethod = customerPaymentMethodView.Current;
                if (syncResponse.PMList != null && syncResponse.PMList.Count > 0)
                {
                    var sortedPMDict = new SortedDictionary <string, Dictionary <string, string> >(syncResponse.PMList, new strComparer());
                    PXResultset <CustomerPaymentMethodDetail> otherCards = GetAllCustomersCardsInProcCenter(graph, customerPaymentMethod.BAccountID, currentCustomerPaymentMethod.CCProcessingCenterID);
                    foreach (string pmID in sortedPMDict.Keys)
                    {
                        bool detailExists = false;
                        foreach (CustomerPaymentMethodDetail detail in otherCards)
                        {
                            if (detail.Value == pmID)
                            {
                                detailExists = true;
                                break;
                            }
                        }
                        if (!detailExists)
                        {
                            newPMID = pmID;
                            break;
                        }
                    }
                    if (!string.IsNullOrEmpty(newPMID))
                    {
                        //Authorize.Net does not return unmasked dates when all customer cards are requested, only when a single card is requested by id
                        Dictionary <string, string> resultDict = new Dictionary <string, string>();
                        resultDict = sortedPMDict[newPMID];
                        string expirationDate = String.Empty;
                        if (CCProcessingUtils.isFeatureSupported(graph, customerPaymentMethod.PMInstanceID, CCProcessingFeature.UnmaskedExpirationDate) &&
                            sortedPMDict[newPMID].TryGetValue(((ICreditCardDataReader)cim._processingGraph).Key_CardExpiryDate, out expirationDate))
                        {
                            DateTime?expDate = CustomerPaymentMethodMaint.ParseExpiryDate(graph, customerPaymentMethod, expirationDate);
                            if (expDate == null)
                            {
                                string CCPID = resultDict.Where(kvp => kvp.Value == newPMID).First().Key;
                                foreach (TDetialsType det in detailsView.Select())
                                {
                                    if (det.DetailID == CCPID)
                                    {
                                        det.Value = newPMID;
                                        detailsView.Update(det);
                                    }
                                }
                                SyncPMResponse customerPaymentProfile = cim.GetPaymentMethod();
                                if (customerPaymentProfile.PMList != null && syncResponse.PMList.Count > 0)
                                {
                                    resultDict = customerPaymentProfile.PMList.FirstOrDefault().Value;
                                }
                            }
                        }
                        foreach (TDetialsType det in detailsView.Select())
                        {
                            if (resultDict.ContainsKey(det.DetailID))
                            {
                                det.Value = resultDict[det.DetailID];
                                detailsView.Update(det);
                            }
                        }
                    }
                }
                attempt++;
            }
            if (string.IsNullOrEmpty(newPMID))
            {
                throw new PXException(Messages.FailedToSyncCC);
            }
        }
Example #26
0
 public virtual void GetCreatePaymentProfileForm(PXGraph graph, ICCPaymentProfileAdapter ccPaymentProfileAdapter)
 {
     CCCustomerInformationManager.GetCreatePaymentProfileForm(graph, ccPaymentProfileAdapter);
 }
        public static void SyncNewPMI <TPaymentMethodType, TDetialsType>(PXGraph graph, PXSelectBase <TPaymentMethodType> customerPaymentMethodView, PXSelectBase <TDetialsType> detailsView)
            where TPaymentMethodType : CustomerPaymentMethod, new()
            where TDetialsType : CustomerPaymentMethodDetail, new()
        {
            bool isHF         = CCProcessingUtils.isHFPaymentMethod(graph, customerPaymentMethodView.Current.PMInstanceID);
            bool isConverting = customerPaymentMethodView.Current.Selected == true;

            isHF = isHF && !isConverting;
            TDetialsType CCPIDDet          = null;
            bool         isIDFilled        = false;
            bool         isOtherDetsFilled = false;

            foreach (PXResult <TDetialsType, PaymentMethodDetail> det in detailsView.Select())
            {
                TDetialsType        cpmd = det;
                PaymentMethodDetail cmd  = det;
                if (cmd.IsCCProcessingID == true)
                {
                    isIDFilled = cpmd.Value != null;
                    CCPIDDet   = (TDetialsType)detailsView.Cache.CreateCopy(cpmd);
                }
                else
                {
                    isOtherDetsFilled = cpmd.Value != null || isOtherDetsFilled;
                }
            }
            if (CCPIDDet == null)
            {
                //something's very wrong
                throw new PXException(Messages.NOCCPID, customerPaymentMethodView.Current.Descr);
            }
            if (isIDFilled && isOtherDetsFilled)
            {
                return;
            }

            if ((isIDFilled || isOtherDetsFilled) && !isHF || isIDFilled && !isOtherDetsFilled)
            {
                CCCustomerInformationManager cim = new CCCustomerInformationManager(customerPaymentMethodView.Current.CCProcessingCenterID, CCProcessingFeature.Tokenization,
                                                                                    new ProcessingContext()
                {
                    aCustomerID   = customerPaymentMethodView.Current.BAccountID,
                    aPMInstanceID = customerPaymentMethodView.Current.PMInstanceID,
                    callerGraph   = graph
                });
                if (customerPaymentMethodView.Current.CustomerCCPID == null)
                {
                    string             id  = cim.CreateCustomer();
                    TPaymentMethodType cpm = (TPaymentMethodType)customerPaymentMethodView.Cache.CreateCopy(customerPaymentMethodView.Current);
                    cpm.CustomerCCPID = id;
                    customerPaymentMethodView.Update(cpm);
                }
                if (isOtherDetsFilled)
                {
                    string newPMId = cim.CreatePaymentMethod();
                    CCPIDDet.Value = newPMId;
                    CCPIDDet       = detailsView.Update(CCPIDDet);
                }
                SyncPMResponse syncResponse = cim.GetPaymentMethod();
                if (syncResponse.PMList.ContainsKey(CCPIDDet.Value))
                {
                    foreach (PXResult <TDetialsType, PaymentMethodDetail> det in detailsView.Select())
                    {
                        TDetialsType cpmd = det;
                        if (cpmd.DetailID == CCPIDDet.DetailID)
                        {
                            continue;
                        }
                        string detailValue;
                        if (!syncResponse.PMList[CCPIDDet.Value].TryGetValue(cpmd.DetailID, out detailValue))
                        {
                            detailValue = null;
                        }
                        TDetialsType newcpmd = (TDetialsType)detailsView.Cache.CreateCopy(cpmd);
                        newcpmd.Value = detailValue;
                        detailsView.Update(newcpmd);
                    }
                }
                else
                {
                    throw new PXException(Messages.CouldntGetPMIDetails, customerPaymentMethodView.Current.Descr);
                }
            }
        }
Example #28
0
 public virtual void GetManagePaymentProfileForm(PXGraph graph, ICCPaymentProfile paymentProfile)
 {
     CCCustomerInformationManager.GetManagePaymentProfileForm(graph, paymentProfile);
 }
        public static void GetOrCreatePaymentProfile <TPaymentMethodType, TDetialsType>(PXGraph graph
                                                                                        , PXSelectBase <TPaymentMethodType> customerPaymentMethodView
                                                                                        , PXSelectBase <TDetialsType> detailsView)
            where TPaymentMethodType : CustomerPaymentMethod, new()
            where TDetialsType : CustomerPaymentMethodDetail, new()
        {
            bool isHF         = CCProcessingHelper.IsHFPaymentMethod(graph, customerPaymentMethodView.Current.PMInstanceID);
            bool isConverting = customerPaymentMethodView.Current.Selected == true;

            isHF = isHF && !isConverting;
            TDetialsType CCPIDDet          = null;
            bool         isIDFilled        = false;
            bool         isOtherDetsFilled = false;

            foreach (PXResult <TDetialsType, PaymentMethodDetail> det in detailsView.Select())
            {
                TDetialsType        cpmd = det;
                PaymentMethodDetail cmd  = det;
                if (cmd.IsCCProcessingID == true)
                {
                    isIDFilled = cpmd.Value != null;
                    CCPIDDet   = (TDetialsType)detailsView.Cache.CreateCopy(cpmd);
                }
                else
                {
                    isOtherDetsFilled = cpmd.Value != null || isOtherDetsFilled;
                }
            }
            if (CCPIDDet == null)
            {
                //something's very wrong
                throw new PXException(Messages.NOCCPID, customerPaymentMethodView.Current.Descr);
            }
            if (isIDFilled && isOtherDetsFilled)
            {
                return;
            }

            if ((isIDFilled || isOtherDetsFilled) && !isHF || isIDFilled && !isOtherDetsFilled)
            {
                CCCustomerInformationManager cim =
                    new CCCustomerInformationManager(customerPaymentMethodView.Current.CCProcessingCenterID,
                                                     CCProcessingFeature.ProfileManagement)
                {
                    CustomerID           = customerPaymentMethodView.Current.BAccountID,
                    PMInstanceID         = customerPaymentMethodView.Current.PMInstanceID,
                    CallerGraph          = graph,
                    String2DateConverter =
                        s => CustomerPaymentMethodMaint.ParseExpiryDate(graph, customerPaymentMethodView.Current, s),
                };

                var    currentCustomerPaymentMethod = customerPaymentMethodView.Current;
                string id = currentCustomerPaymentMethod.CustomerCCPID;
                if (currentCustomerPaymentMethod.CustomerCCPID == null)
                {
                    id = cim.CreateCustomerProfile();
                    TPaymentMethodType cpm = (TPaymentMethodType)customerPaymentMethodView.Cache.CreateCopy(currentCustomerPaymentMethod);
                    cpm.CustomerCCPID = id;
                    customerPaymentMethodView.Update(cpm);
                }
                var processingCenter = cim._context.processingCenter;
                if (processingCenter.CreateAdditionalCustomerProfiles == true)
                {
                    int customerProfileCount = CCProcessingHelper.CustomerProfileCountPerCustomer(graph,
                                                                                                  currentCustomerPaymentMethod.BAccountID,
                                                                                                  currentCustomerPaymentMethod.CCProcessingCenterID); // Total customer profile count per customer

                    var cardLimit = processingCenter.CreditCardLimit;
                    if (cardLimit != null && cardLimit > 0)
                    {
                        int allPaymentProfileCount = cim.GetAllPaymentProfiles().Count();
                        if (CCProcessingHelper.IsCreditCardCountEnough(allPaymentProfileCount, cardLimit.Value))
                        {
                            cim.PrefixForCustomerCD = CCProcessingHelper.BuildPrefixForCustomerCD(customerProfileCount, processingCenter);
                            id = cim.CreateCustomerProfile();
                            TPaymentMethodType cpm = (TPaymentMethodType)customerPaymentMethodView.Cache.CreateCopy(currentCustomerPaymentMethod);
                            cpm.CustomerCCPID = id;
                            customerPaymentMethodView.Update(cpm);
                        }
                    }
                }


                if (isOtherDetsFilled)
                {
                    string newPMId = cim.CreatePaymentProfile();
                    CCPIDDet.Value = newPMId;
                    CCPIDDet       = detailsView.Update(CCPIDDet);
                }
                CreditCardData cardData = cim.GetPaymentProfile();
                if (cardData != null && !string.IsNullOrEmpty(cardData.PaymentProfileID))
                {
                    foreach (PXResult <TDetialsType, PaymentMethodDetail> det in detailsView.Select())
                    {
                        TDetialsType        cpmd = det;
                        PaymentMethodDetail pmd  = (PaymentMethodDetail)det;
                        if (cpmd.DetailID == CCPIDDet.DetailID)
                        {
                            continue;
                        }
                        string detailValue = null;
                        if (pmd.IsCCProcessingID != true && pmd.IsIdentifier == true && !string.IsNullOrEmpty(cardData.CardNumber))
                        {
                            detailValue = cardData.CardNumber;
                        }
                        TDetialsType newcpmd = (TDetialsType)detailsView.Cache.CreateCopy(cpmd);
                        newcpmd.Value = detailValue;
                        detailsView.Update(newcpmd);
                    }
                    if (cardData.CardExpirationDate != null)
                    {
                        TPaymentMethodType cpm = (TPaymentMethodType)customerPaymentMethodView.Cache.CreateCopy(customerPaymentMethodView.Current);
                        customerPaymentMethodView.Cache.SetValueExt <CustomerPaymentMethod.expirationDate>(cpm, cardData.CardExpirationDate);
                        customerPaymentMethodView.Update(cpm);
                    }
                }
                else
                {
                    throw new PXException(Messages.CouldntGetPMIDetails, customerPaymentMethodView.Current.Descr);
                }
            }
        }
 public virtual void GetNewPaymentProfiles(PXGraph graph,
                                           ICustomerPaymentMethodAdapter customerPaymentMethodAdapter,
                                           ICustomerPaymentMethodDetailAdapter customerPaymentMethodDetailAdapter)
 {
     CCCustomerInformationManager.GetNewPaymentProfiles(graph, customerPaymentMethodAdapter, customerPaymentMethodDetailAdapter);
 }