public static void DoDateUpdateProcess(CustomerPaymentMethod cpm)
        {
            CustomerPaymentMethodMaint cpmGraph = PXGraph.CreateInstance <CustomerPaymentMethodMaint>();

            cpmGraph.CustomerPaymentMethod.Current = cpm;
            CCCustomerInformationManager.SyncExistingPMI(cpmGraph, cpmGraph.CustomerPaymentMethod, cpmGraph.DetailsAll);
            cpm.ExpirationDate = cpmGraph.CustomerPaymentMethod.Current.ExpirationDate;
            if (cpm.ExpirationDate == null)
            {
                string formatString   = CCProcessingUtils.GetExpirationDateFormat(cpmGraph, cpm.CCProcessingCenterID);
                string responseString = null;
                foreach (PXResult <CustomerPaymentMethodDetail, PaymentMethodDetail> details in cpmGraph.DetailsAll.Select())
                {
                    PaymentMethodDetail         pmDetail  = details;
                    CustomerPaymentMethodDetail cpmDetail = details;
                    if (pmDetail.IsExpirationDate == true)
                    {
                        responseString = cpmDetail.Value;
                        break;
                    }
                }
                throw new PXException(Messages.ExpDateParseFailed, InterfaceConstants.ExpDateFormatDesc, responseString, formatString);
            }
            cpmGraph.Save.Press();
        }
        //=Payments.GetARPaymentInfo('102000', 'FEDWRE', '1', 'C000213')
        //                           ^-Cash Account
        //                                     ^-Payment Method
        //                                               ^- Detail ID
        //                                                    ^- Customer ID
        public string GetARPaymentInfo(
            string accountCD,
            string paymentMethodID,
            string detailID,
            string pMInstanceID)
        {
            int actualPMInstanceID;

            if (!int.TryParse(pMInstanceID, out actualPMInstanceID))
            {
                throw new PXArgumentException("pMInstanceID", Messages.ValueMInstanceIdError);
            }

            CustomerPaymentMethodDetail detail = PXSelectJoin <CustomerPaymentMethodDetail,
                                                               InnerJoin <PaymentMethod, On <PaymentMethod.paymentMethodID, Equal <CustomerPaymentMethodDetail.paymentMethodID> >,
                                                                          InnerJoin <PaymentMethodDetail, On <PaymentMethodDetail.paymentMethodID, Equal <CustomerPaymentMethodDetail.paymentMethodID>,
                                                                                                              And <PaymentMethodDetail.detailID, Equal <CustomerPaymentMethodDetail.detailID>,
                                                                                                                   And <Where <PaymentMethodDetail.useFor, Equal <PaymentMethodDetailUsage.useForARCards> > > > >,
                                                                                     InnerJoin <PaymentMethodAccount, On <PaymentMethodAccount.paymentMethodID, Equal <PaymentMethod.paymentMethodID> >,
                                                                                                InnerJoin <CashAccount, On <CashAccount.cashAccountID, Equal <PaymentMethodAccount.cashAccountID> >,
                                                                                                           InnerJoin <Account, On <Account.accountID, Equal <CashAccount.accountID> > > > > > >,
                                                               Where <Account.accountCD, Equal <Required <Account.accountCD> >,
                                                                      And <PaymentMethod.paymentMethodID, Equal <Required <PaymentMethod.paymentMethodID> >,
                                                                           And <CustomerPaymentMethodDetail.detailID, Equal <Required <CustomerPaymentMethodDetail.detailID> >,
                                                                                And <CustomerPaymentMethodDetail.pMInstanceID, Equal <Required <CustomerPaymentMethodDetail.pMInstanceID> > > > > > >
                                                 .Select(PXGraph.CreateInstance <CustomerPaymentMethodMaint>(),
                                                         accountCD,
                                                         paymentMethodID,
                                                         detailID,
                                                         pMInstanceID);

            return(detail != null ? detail.Value : string.Empty);
        }
        protected V2.TranProfile GetCustomerProfileFromDoc(ICCPayment pDoc)
        {
            V2.TranProfile ret = null;
            if (pDoc.PMInstanceID > 0)
            {
                var query = new PXSelectJoin <CustomerPaymentMethod,
                                              InnerJoin <CustomerPaymentMethodDetail, On <CustomerPaymentMethodDetail.pMInstanceID, Equal <CustomerPaymentMethod.pMInstanceID> >,
                                                         InnerJoin <PaymentMethodDetail, On <PaymentMethodDetail.detailID, Equal <CustomerPaymentMethodDetail.detailID> > > >,
                                              Where <CustomerPaymentMethod.pMInstanceID, Equal <Required <CustomerPaymentMethod.pMInstanceID> >,
                                                     And <PaymentMethodDetail.isCCProcessingID, Equal <True> > > >(Base);
                PXResultset <CustomerPaymentMethod> result = query.Select(pDoc.PMInstanceID);

                foreach (PXResult <CustomerPaymentMethod, CustomerPaymentMethodDetail> item in result)
                {
                    CustomerPaymentMethod       cpm    = (CustomerPaymentMethod)item;
                    CustomerPaymentMethodDetail cpmDet = (CustomerPaymentMethodDetail)item;
                    ret = new V2.TranProfile()
                    {
                        CustomerProfileId = cpm.CustomerCCPID, PaymentProfileId = cpmDet.Value
                    };
                    break;
                }
            }
            return(ret);
        }
Пример #4
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();
            }
        }
Пример #5
0
        public static bool IsCCPIDFilled(PXGraph graph, int?PMInstanceID)
        {
            if (PMInstanceID == null || PMInstanceID.Value < 0)
            {
                return(false);
            }

            CustomerPaymentMethod cpm = PXSelect <CustomerPaymentMethod, Where <CustomerPaymentMethod.pMInstanceID,
                                                                                Equal <Required <CustomerPaymentMethod.pMInstanceID> > > > .Select(graph, PMInstanceID);

            if (cpm == null)
            {
                return(false);
            }

            PXResultset <PaymentMethodDetail> paymentMethodDetail = PXSelectJoin <PaymentMethodDetail, LeftJoin <CustomerPaymentMethodDetail,
                                                                                                                 On <CustomerPaymentMethodDetail.paymentMethodID, Equal <PaymentMethodDetail.paymentMethodID>,
                                                                                                                     And <CustomerPaymentMethodDetail.detailID, Equal <PaymentMethodDetail.detailID>,
                                                                                                                          And <PaymentMethodDetail.useFor, Equal <PaymentMethodDetailUsage.useForARCards>,
                                                                                                                               And <CustomerPaymentMethodDetail.pMInstanceID, Equal <Required <CustomerPaymentMethod.pMInstanceID> > > > > > >,
                                                                                  Where <PaymentMethodDetail.isCCProcessingID, Equal <True>,
                                                                                         And <PaymentMethodDetail.paymentMethodID, Equal <Required <PaymentMethodDetail.paymentMethodID> > > > > .Select(graph, PMInstanceID, cpm.PaymentMethodID);

            PaymentMethodDetail         pmIDDetail  = paymentMethodDetail.Count > 0 ? paymentMethodDetail[0].GetItem <PaymentMethodDetail>() : null;
            CustomerPaymentMethodDetail ccpIDDetail = paymentMethodDetail.Count > 0 ? paymentMethodDetail[0].GetItem <CustomerPaymentMethodDetail>() : null;

            if (IsTokenizedPaymentMethod(graph, PMInstanceID) && pmIDDetail == null)
            {
                throw new PXException(Messages.PaymentMethodNotConfigured);
            }
            return(ccpIDDetail != null && !string.IsNullOrEmpty(ccpIDDetail.Value));
        }
        protected int?GetInstanceId(V2.TranProfile input)
        {
            int?    instanceID = PaymentTranExtConstants.NewPaymentProfile;
            PXCache cpmCache   = Base.Caches[typeof(CustomerPaymentMethod)];

            cpmCache.ClearQueryCacheObsolete();
            PXSelectBase <CustomerPaymentMethod> query = new PXSelectReadonly2 <CustomerPaymentMethod,
                                                                                InnerJoin <CustomerPaymentMethodDetail, On <CustomerPaymentMethod.pMInstanceID, Equal <CustomerPaymentMethodDetail.pMInstanceID> >,
                                                                                           InnerJoin <PaymentMethodDetail, On <CustomerPaymentMethodDetail.detailID, Equal <PaymentMethodDetail.detailID>,
                                                                                                                               And <CustomerPaymentMethodDetail.paymentMethodID, Equal <PaymentMethodDetail.paymentMethodID> > > > >,
                                                                                Where <CustomerPaymentMethod.cCProcessingCenterID, Equal <Required <CustomerPaymentMethod.cCProcessingCenterID> >,
                                                                                       And <CustomerPaymentMethod.customerCCPID, Equal <Required <CustomerPaymentMethod.customerCCPID> >,
                                                                                            And <PaymentMethodDetail.isCCProcessingID, Equal <True>, And <PaymentMethodDetail.useFor, Equal <PaymentMethodDetailUsage.useForARCards> > > > > >(Base);

            PXResultset <CustomerPaymentMethod> queryResult = query.Select(SelectedProcessingCenter, input.CustomerProfileId);

            foreach (PXResult <CustomerPaymentMethod, CustomerPaymentMethodDetail> item in queryResult)
            {
                CustomerPaymentMethodDetail checkCpmd = (CustomerPaymentMethodDetail)item;

                if (checkCpmd.Value == input.PaymentProfileId)
                {
                    instanceID = checkCpmd.PMInstanceID;
                    break;
                }
            }
            CustomerPaymentMethod cpm = NewCpm.Select();

            if (cpm != null && cpm.PMInstanceID != null && cpm.PMInstanceID >= 0)
            {
                instanceID = cpm.PMInstanceID.Value;
            }
            return(instanceID);
        }
        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();
                    }
                }
            }
        }
Пример #8
0
        public PXResultset <CustomerPaymentMethodDetail, PaymentMethodDetail> Select(params object[] argumetns)
        {
            PXResultset <T> resultSet = dataView.Select(argumetns);
            PXResultset <CustomerPaymentMethodDetail, PaymentMethodDetail> retResultSet = new PXResultset <CustomerPaymentMethodDetail, PaymentMethodDetail>();

            foreach (PXResult <T, PaymentMethodDetail> result in resultSet)
            {
                CustomerPaymentMethodDetail cpmd = result;
                PaymentMethodDetail         pmd  = (PaymentMethodDetail)result;
                retResultSet.Add(new PXResult <CustomerPaymentMethodDetail, PaymentMethodDetail>(cpmd, pmd));
            }
            return(retResultSet);
        }
        public virtual IEnumerable newCpmd()
        {
            PXCache cache = Base.Caches[typeof(CustomerPaymentMethodDetail)];

            foreach (object item in cache.Cached)
            {
                CustomerPaymentMethodDetail cpm = item as CustomerPaymentMethodDetail;
                if (cache.GetStatus(item) == PXEntryStatus.Inserted)
                {
                    yield return(item);
                }
            }
            yield break;
        }
Пример #10
0
        private static PXResult <CustomerPaymentMethodDetail, PaymentMethodDetail> HasSavedPaymentProfile(PXResultset <CustomerPaymentMethodDetail> items)
        {
            PXResult <CustomerPaymentMethodDetail, PaymentMethodDetail> ret = null;

            foreach (PXResult <CustomerPaymentMethodDetail, PaymentMethodDetail> item in items)
            {
                CustomerPaymentMethodDetail det = item;
                PaymentMethodDetail         pmd = item;
                if (pmd.IsCCProcessingID == true && !string.IsNullOrEmpty(det.Value))
                {
                    ret = item;
                    break;
                }
            }
            return(ret);
        }
        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);
            }
        }
Пример #12
0
        private void FilterPaymentsProfilesFromService(Dictionary <string, CustomerCreditCard> paymentProfiles, PXResult <CustomerPaymentMethod, CustomerPaymentMethodDetail> line)
        {
            CustomerPaymentMethod       paymentMethod       = line;
            CustomerPaymentMethodDetail paymentMethodDetail = line;
            string checkCustomerProfileId = paymentMethod.CustomerCCPID;
            string checkPaymentProfileId  = paymentMethodDetail.Value;

            if (checkCustomerProfileId != null && paymentProfiles.ContainsKey(checkCustomerProfileId))
            {
                CustomerCreditCard customerCreditCard = paymentProfiles[checkCustomerProfileId];
                int index = customerCreditCard.CreditCards.FindIndex(i => i.PaymentProfileID == checkPaymentProfileId);

                if (index != -1)
                {
                    customerCreditCard.CreditCards.RemoveAt(index);
                }
            }
        }
        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);
                }
            }
        }
 protected virtual void UpdateCvvVerificationStatus(CCProcTran aTran)
 {
     if (aTran.TranStatus == CCTranStatusCode.Approved &&
         aTran.CVVVerificationStatus == CVVVerificationStatusCode.Match &&
         (aTran.TranType == CCTranTypeCode.AuthorizeAndCapture || aTran.TranType == CCTranTypeCode.Authorize))
     {
         CustomerPaymentMethod pmInstance = _repository.GetCustomerPaymentMethod(aTran.PMInstanceID);
         if (!pmInstance.CVVVerifyTran.HasValue)
         {
             pmInstance.CVVVerifyTran = aTran.TranNbr;
             CustomerPaymentMethodDetail cvvDetail = _repository.GetCustomerPaymentMethodDetail(aTran.PMInstanceID, CreditCardAttributes.CVV);
             if (cvvDetail != null)
             {
                 _repository.DeletePaymentMethodDetail(cvvDetail);
             }
             _repository.UpdateCustomerPaymentMethod(pmInstance);
             _repository.Save();
         }
     }
 }
Пример #15
0
        void ICreditCardDataReader.ReadData(Dictionary <string, string> aData)
        {
            PXResultset <CustomerPaymentMethodDetail> PMDselect = null;

            PMDselect = PXSelectJoin <CustomerPaymentMethodDetail,
                                      InnerJoin <PaymentMethodDetail, On <CustomerPaymentMethodDetail.detailID, Equal <PaymentMethodDetail.detailID>,
                                                                          And <CustomerPaymentMethodDetail.paymentMethodID, Equal <PaymentMethodDetail.paymentMethodID> > > >,
                                      Where <CustomerPaymentMethodDetail.pMInstanceID, Equal <Required <CustomerPaymentMethodDetail.pMInstanceID> > > >
                        .Select(_graph, _pminstanceID);

            if (PMDselect != null)
            {
                foreach (PXResult <CustomerPaymentMethodDetail, PaymentMethodDetail> dets in PMDselect)
                {
                    PaymentMethodDetail         pmd  = dets;
                    CustomerPaymentMethodDetail cpmd = dets;
                    if (pmd.IsCCProcessingID == true)
                    {
                        aData[CreditCardAttributes.CCPID] = cpmd.Value;
                    }
                    if (pmd.IsIdentifier == true)
                    {
                        aData[CreditCardAttributes.CardNumber] = cpmd.Value;
                    }
                    if (pmd.IsExpirationDate == true)
                    {
                        aData[CreditCardAttributes.ExpirationDate] = cpmd.Value;
                    }
                    if (pmd.IsCVV == true)
                    {
                        aData[CreditCardAttributes.CVV] = cpmd.Value;
                    }
                    if (pmd.IsOwnerName == true)
                    {
                        aData[CreditCardAttributes.NameOnCard] = cpmd.Value;
                    }
                }
            }
        }
        protected int?CreatePaymentProfile(V2.TranProfile input)
        {
            var cpmSelect  = NewCpm;
            var cpmdSelect = NewCpmd;
            var pmdSelect  = PaymentMethodDet;

            foreach (PaymentMethodDetail item in pmdSelect.Select())
            {
                CustomerPaymentMethodDetail cpmd = new CustomerPaymentMethodDetail();
                cpmd.PaymentMethodID = SelectedPaymentMethod;
                cpmd.DetailID        = item.DetailID;
                if (item.IsCCProcessingID == true)
                {
                    cpmd.Value = input.PaymentProfileId;
                }
                cpmdSelect.Insert(cpmd);
            }

            CCCustomerInformationManagerGraph infoManagerGraph = PXGraph.CreateInstance <CCCustomerInformationManagerGraph>();
            GenericCCPaymentProfileAdapter <CustomerPaymentMethod> cpmAdapter = new GenericCCPaymentProfileAdapter <CustomerPaymentMethod>(cpmSelect);
            var cpmdAdapter = new GenericCCPaymentProfileDetailAdapter <CustomerPaymentMethodDetail, PaymentMethodDetail>(cpmdSelect, pmdSelect);

            infoManagerGraph.GetPaymentProfile(Base, cpmAdapter, cpmdAdapter);
            var   cardIdent         = pmdSelect.Select().RowCast <PaymentMethodDetail>().Where(i => i.IsIdentifier == true).First();
            var   detailWithCardNum = cpmdSelect.Select().RowCast <CustomerPaymentMethodDetail>().Where(i => i.DetailID == cardIdent.DetailID).First();
            Match match             = new Regex("[\\d]+").Match(detailWithCardNum.Value);

            CustomerPaymentMethod cpm = cpmSelect.Select();

            if (match.Success)
            {
                cpm.Descr = SelectedPaymentMethod + ":" + maskedCardTmpl + match.Value;
            }

            cpmSelect.Cache.Persist(PXDBOperation.Insert);
            cpmdSelect.Cache.Persist(PXDBOperation.Insert);
            return(cpm.PMInstanceID);
        }
        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();
            }
        }
		private void DoConvert(CustomerPaymentMethod cpm, CCProcessingCenter newCCPC)
		{
			CCProcessingCenterPmntMethod newProcessingCenterPM = PXSelect<CCProcessingCenterPmntMethod,
				Where<CCProcessingCenterPmntMethod.paymentMethodID, Equal<Required<CCProcessingCenterPmntMethod.paymentMethodID>>,
				And<CCProcessingCenterPmntMethod.processingCenterID, Equal<Required<CCProcessingCenterPmntMethod.processingCenterID>>>>>.Select(this, cpm.PaymentMethodID, newCCPC.ProcessingCenterID);
			if (newProcessingCenterPM == null)
			{
				newProcessingCenterPM = (CCProcessingCenterPmntMethod)ProcessingCenterPM.Cache.CreateInstance();
				newProcessingCenterPM.PaymentMethodID = cpm.PaymentMethodID;
				newProcessingCenterPM.ProcessingCenterID = newCCPC.ProcessingCenterID;
				ProcessingCenterPM.Insert(newProcessingCenterPM);
			}

			CustomerPaymentMethod currCPM = (CustomerPaymentMethod)CustomerPM.Cache.CreateCopy(cpm);
			var oldCCProcessingCenterID = currCPM.CCProcessingCenterID;
			currCPM.CCProcessingCenterID = newCCPC.ProcessingCenterID;
			if (currCPM.CustomerCCPID == null)
			{
				CustomerPM.Cache.SetDefaultExt<CustomerPaymentMethod.customerCCPID>(currCPM);
			}
			currCPM.Selected = true;
			currCPM = CustomerPM.Update(currCPM);
			CustomerPM.Current = currCPM;

			PXResultset<PaymentMethodDetail> oldDetails = PMDetails.Select(currCPM.PaymentMethodID);
			foreach (PaymentMethodDetail oldDetail in oldDetails)
			{
				PaymentMethodDetail newDetail = (PaymentMethodDetail)PMDetails.Cache.CreateCopy(oldDetail);
				newDetail.ValidRegexp = null;
				PMDetails.Update(newDetail);
			}

			PaymentMethod CurrPM = PM.Select();
			PaymentMethodDetail CCPID = FindCCPID(CurrPM);

			if (CCPID == null)
			{
				using (PXTransactionScope ts = new PXTransactionScope())
				{
					PaymentMethodDetail res;
					CCPID = (PaymentMethodDetail)PMDetails.Cache.CreateInstance();
					CCPID.PaymentMethodID = currCPM.PaymentMethodID;
					CCPID.UseFor = PaymentMethodDetailUsage.UseForARCards;
					CCPID.DetailID = "CCPID";
					CCPID.Descr = Messages.PaymentProfileID;
					CCPID.IsCCProcessingID = true;
					CCPID.IsRequired = true;
					res = PMDetails.Insert(CCPID);
					if (res == null)
					{
						throw new PXException(Messages.CouldNotInsertPMDetail);
					}
					else
					{
						PMDetails.Cache.Persist(PXDBOperation.Insert);
					}
					ts.Complete();
				}
			}

			CCProcessingCenter procCenter = PXSelect<CCProcessingCenter,
				Where<CCProcessingCenter.processingCenterID, Equal<Required<CCProcessingCenter.processingCenterID>>>>
					.Select(this, oldCCProcessingCenterID);
			bool oldProcCenterSupportTokenizing = ProcCenterSupportTokenizing(oldCCProcessingCenterID);
			bool newProcCenterSupportTokenizing = ProcCenterSupportTokenizing(newCCPC.ProcessingCenterID);

			if (!oldProcCenterSupportTokenizing && newProcCenterSupportTokenizing)
			{
				CustomerPaymentMethodDetail newCCPIDPM = PXSelect<CustomerPaymentMethodDetail,
					Where<CustomerPaymentMethodDetail.pMInstanceID, Equal<Required<CustomerPaymentMethodDetail.pMInstanceID>>,
						And<CustomerPaymentMethodDetail.paymentMethodID, Equal<Required<CustomerPaymentMethodDetail.paymentMethodID>>,
						And<CustomerPaymentMethodDetail.detailID, Equal<Required<CustomerPaymentMethodDetail.detailID>>>>>>
							.Select(this, currCPM.PMInstanceID, currCPM.PaymentMethodID, CCPID.DetailID);
				if (newCCPIDPM != null)
				{
					newCCPIDPM.Value = null;
					CustomerPMDetails.Update(newCCPIDPM);
				}
				else
				{
					newCCPIDPM = new CustomerPaymentMethodDetail
					{
						PMInstanceID = currCPM.PMInstanceID,
						PaymentMethodID = currCPM.PaymentMethodID,
						DetailID = CCPID.DetailID
					};
					CustomerPMDetails.Insert(newCCPIDPM);
				}
				var graph = PXGraph.CreateInstance<CCCustomerInformationManagerGraph>();
				ICCPaymentProfileAdapter paymentProfile = new GenericCCPaymentProfileAdapter<CustomerPaymentMethod>(CustomerPM);
				ICCPaymentProfileDetailAdapter profileDetail = new GenericCCPaymentProfileDetailAdapter<CustomerPaymentMethodDetail,
					PaymentMethodDetail>(CustomerPMDetails, PMDetails);
				DateTime expiredDate;
				if (CheckCardIsExpired(currCPM, out expiredDate))
				{
					Customer cust =  new PXSelect<Customer, 
						Where<Customer.bAccountID, Equal<Required<Customer.bAccountID>>>>(this)
							.SelectSingle(currCPM.BAccountID);
					throw new PXException(AR.Messages.ERR_CCCreditCardHasExpired, expiredDate.ToString("d"), cust.AcctCD);
				}
				graph.GetOrCreatePaymentProfile(this, paymentProfile, profileDetail);
			}

			if (newProcCenterSupportTokenizing)
			{
				if (currCPM.CustomerCCPID == null)
				{
					currCPM.CustomerCCPID = cpm.CustomerCCPID;
				}
				CustomerProcessingCenterID newCustomerProcessingCenterID = new CustomerProcessingCenterID
				{
					CCProcessingCenterID = newCCPC.ProcessingCenterID,
					BAccountID = cpm.BAccountID,
					CustomerCCPID = currCPM.CustomerCCPID
				};
				AddCustomerProcessingCenterIfNeeded(newCustomerProcessingCenterID);
			}
			currCPM = CustomerPM.Update(currCPM);
		}
 public void DeletePaymentMethodDetail(CustomerPaymentMethodDetail detail)
 {
     _cpmDetailRepository.DeletePaymentMethodDetail(detail);
 }
Пример #20
0
        public void ConvertCustomerPaymentMethod(CustomerPaymentMethod cpm, CCProcessingCenter newCCPC)
        {
            CCProcessingCenterPmntMethod newProcessingCenterPM = PXSelect <CCProcessingCenterPmntMethod,
                                                                           Where <CCProcessingCenterPmntMethod.paymentMethodID, Equal <Required <CCProcessingCenterPmntMethod.paymentMethodID> >,
                                                                                  And <CCProcessingCenterPmntMethod.processingCenterID, Equal <Required <CCProcessingCenterPmntMethod.processingCenterID> > > > > .Select(this, cpm.PaymentMethodID, newCCPC.ProcessingCenterID);

            if (newProcessingCenterPM == null)
            {
                newProcessingCenterPM = (CCProcessingCenterPmntMethod)ProcessingCenterPM.Cache.CreateInstance();
                newProcessingCenterPM.PaymentMethodID    = cpm.PaymentMethodID;
                newProcessingCenterPM.ProcessingCenterID = newCCPC.ProcessingCenterID;
                ProcessingCenterPM.Insert(newProcessingCenterPM);
            }

            CustomerPaymentMethod currCPM = (CustomerPaymentMethod)CustomerPM.Cache.CreateCopy(cpm);

            currCPM.CCProcessingCenterID = newCCPC.ProcessingCenterID;
            CustomerPM.Cache.SetDefaultExt <CustomerPaymentMethod.customerCCPID>(currCPM);

            currCPM.Selected   = true;
            currCPM            = CustomerPM.Update(currCPM);
            CustomerPM.Current = currCPM;

            PXResultset <PaymentMethodDetail> oldDetails = PMDetails.Select(currCPM.PaymentMethodID);

            foreach (PaymentMethodDetail oldDetail in oldDetails)
            {
                PaymentMethodDetail newDetail = (PaymentMethodDetail)PMDetails.Cache.CreateCopy(oldDetail);
                newDetail.ValidRegexp = null;
                PMDetails.Update(newDetail);
            }

            PaymentMethod       CurrPM = PM.Select();
            PaymentMethodDetail CCPID  = FindCCPID(CurrPM);

            if (CCPID == null)
            {
                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    PaymentMethodDetail res;
                    CCPID = (PaymentMethodDetail)PMDetails.Cache.CreateInstance();
                    CCPID.PaymentMethodID  = currCPM.PaymentMethodID;
                    CCPID.UseFor           = PaymentMethodDetailUsage.UseForARCards;
                    CCPID.DetailID         = "CCPID";
                    CCPID.Descr            = "Payment Profile ID";
                    CCPID.IsCCProcessingID = true;
                    CCPID.IsRequired       = true;
                    res = PMDetails.Insert(CCPID);
                    if (res == null)
                    {
                        throw new PXException(Messages.CouldNotInsertPMDetail);
                    }
                    else
                    {
                        PMDetails.Cache.Persist(PXDBOperation.Insert);
                    }
                    ts.Complete();
                }
            }

            CustomerPaymentMethodDetail newCCPIDPM = PXSelect <CustomerPaymentMethodDetail, Where <CustomerPaymentMethodDetail.pMInstanceID, Equal <Required <CustomerPaymentMethodDetail.pMInstanceID> >,
                                                                                                   And <CustomerPaymentMethodDetail.paymentMethodID, Equal <Required <CustomerPaymentMethodDetail.paymentMethodID> >,
                                                                                                        And <CustomerPaymentMethodDetail.detailID, Equal <Required <CustomerPaymentMethodDetail.detailID> > > > > > .Select(this, currCPM.PMInstanceID, currCPM.PaymentMethodID, CCPID.DetailID);

            if (newCCPIDPM != null)
            {
                newCCPIDPM.Value = null;
                CustomerPMDetails.Update(newCCPIDPM);
            }
            else
            {
                newCCPIDPM = new CustomerPaymentMethodDetail();
                newCCPIDPM.PMInstanceID    = currCPM.PMInstanceID;
                newCCPIDPM.PaymentMethodID = currCPM.PaymentMethodID;
                newCCPIDPM.DetailID        = CCPID.DetailID;
                CustomerPMDetails.Insert(newCCPIDPM);
            }

            CustomerPaymentMethodMaint.SyncNewPMI(this, CustomerPM, CustomerPMDetails);
            currCPM.Converted = true;
            currCPM           = CustomerPM.Update(currCPM);
            this.Save.Press();
        }
Пример #21
0
        public static void GetOrCreatePaymentProfile(PXGraph graph
                                                     , ICustomerPaymentMethodAdapter customerPaymentMethodAdapter
                                                     , ICustomerPaymentMethodDetailAdapter customerPaymentMethodDetailAdapter)
        {
            bool isHF         = CCProcessingHelper.IsHFPaymentMethod(graph, customerPaymentMethodAdapter.Current.PMInstanceID);
            bool isConverting = customerPaymentMethodAdapter.Current.Selected == true;

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

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

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

                var currentCustomerPaymentMethod = customerPaymentMethodAdapter.Current;
                cim.String2DateConverter = s => CustomerPaymentMethodMaint.ParseExpiryDate(graph, customerPaymentMethodAdapter.Current, s);
                string id = currentCustomerPaymentMethod.CustomerCCPID;
                if (currentCustomerPaymentMethod.CustomerCCPID == null)
                {
                    id = cim.CreateCustomerProfile();
                    CustomerPaymentMethod cpm = customerPaymentMethodAdapter.Current.CreateCopy(customerPaymentMethodAdapter.Cache);
                    cpm.CustomerCCPID = id;
                    customerPaymentMethodAdapter.Cache.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();
                            CustomerPaymentMethod cpm = customerPaymentMethodAdapter.Current.CreateCopy(customerPaymentMethodAdapter.Cache);
                            cpm.CustomerCCPID = id;
                            customerPaymentMethodAdapter.Cache.Update(cpm);
                        }
                    }
                }

                if (isOtherDetsFilled)
                {
                    string newPMId = cim.CreatePaymentProfile();
                    CCPIDDet.Value = newPMId;
                    CCPIDDet       = customerPaymentMethodDetailAdapter.Cache.Update(CCPIDDet) as CustomerPaymentMethodDetail;
                }
                CreditCardData cardData = cim.GetPaymentProfile();
                if (cardData != null && !string.IsNullOrEmpty(cardData.PaymentProfileID))
                {
                    foreach (PXResult <CustomerPaymentMethodDetail, PaymentMethodDetail> det in customerPaymentMethodDetailAdapter.Select())
                    {
                        CustomerPaymentMethodDetail 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;
                        }
                        CustomerPaymentMethodDetail newcpmd = (CustomerPaymentMethodDetail)cpmd.CreateCopy(customerPaymentMethodDetailAdapter.Cache);
                        newcpmd.Value = detailValue;
                        customerPaymentMethodDetailAdapter.Cache.Update(newcpmd);
                    }
                    if (cardData.CardExpirationDate != null)
                    {
                        CustomerPaymentMethod cpm = customerPaymentMethodAdapter.Current.CreateCopy(customerPaymentMethodAdapter.Cache);
                        customerPaymentMethodAdapter.Cache.SetValueExt <CustomerPaymentMethod.expirationDate>(cpm, cardData.CardExpirationDate);
                        customerPaymentMethodAdapter.Cache.Update(cpm);
                    }
                }
                else
                {
                    throw new PXException(Messages.CouldntGetPMIDetails, customerPaymentMethodAdapter.Current.Descr);
                }
            }
        }
        public void ConvertCustomerPaymentMethod(CustomerPaymentMethod cpm, CCProcessingCenter newCCPC)
        {
            CCProcessingCenterPmntMethod newProcessingCenterPM = PXSelect <CCProcessingCenterPmntMethod,
                                                                           Where <CCProcessingCenterPmntMethod.paymentMethodID, Equal <Required <CCProcessingCenterPmntMethod.paymentMethodID> >,
                                                                                  And <CCProcessingCenterPmntMethod.processingCenterID, Equal <Required <CCProcessingCenterPmntMethod.processingCenterID> > > > > .Select(this, cpm.PaymentMethodID, newCCPC.ProcessingCenterID);

            if (newProcessingCenterPM == null)
            {
                newProcessingCenterPM = (CCProcessingCenterPmntMethod)ProcessingCenterPM.Cache.CreateInstance();
                newProcessingCenterPM.PaymentMethodID    = cpm.PaymentMethodID;
                newProcessingCenterPM.ProcessingCenterID = newCCPC.ProcessingCenterID;
                ProcessingCenterPM.Insert(newProcessingCenterPM);
            }

            CustomerPaymentMethod currCPM = (CustomerPaymentMethod)CustomerPM.Cache.CreateCopy(cpm);
            var oldCCProcessingCenterID   = currCPM.CCProcessingCenterID;

            currCPM.CCProcessingCenterID = newCCPC.ProcessingCenterID;
            if (currCPM.CustomerCCPID == null)
            {
                CustomerPM.Cache.SetDefaultExt <CustomerPaymentMethod.customerCCPID>(currCPM);
            }
            currCPM.Selected   = true;
            currCPM            = CustomerPM.Update(currCPM);
            CustomerPM.Current = currCPM;

            PXResultset <PaymentMethodDetail> oldDetails = PMDetails.Select(currCPM.PaymentMethodID);

            foreach (PaymentMethodDetail oldDetail in oldDetails)
            {
                PaymentMethodDetail newDetail = (PaymentMethodDetail)PMDetails.Cache.CreateCopy(oldDetail);
                newDetail.ValidRegexp = null;
                PMDetails.Update(newDetail);
            }

            PaymentMethod       CurrPM = PM.Select();
            PaymentMethodDetail CCPID  = FindCCPID(CurrPM);

            if (CCPID == null)
            {
                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    PaymentMethodDetail res;
                    CCPID = (PaymentMethodDetail)PMDetails.Cache.CreateInstance();
                    CCPID.PaymentMethodID  = currCPM.PaymentMethodID;
                    CCPID.UseFor           = PaymentMethodDetailUsage.UseForARCards;
                    CCPID.DetailID         = "CCPID";
                    CCPID.Descr            = Messages.PaymentProfileID;
                    CCPID.IsCCProcessingID = true;
                    CCPID.IsRequired       = true;
                    res = PMDetails.Insert(CCPID);
                    if (res == null)
                    {
                        throw new PXException(Messages.CouldNotInsertPMDetail);
                    }
                    else
                    {
                        PMDetails.Cache.Persist(PXDBOperation.Insert);
                    }
                    ts.Complete();
                }
            }

            CCProcessingCenter procCenter = PXSelect <CCProcessingCenter,
                                                      Where <CCProcessingCenter.processingCenterID, Equal <Required <CCProcessingCenter.processingCenterID> > > >
                                            .Select(this, oldCCProcessingCenterID);

            bool doesOldProcCenterSupportTokenizing = CCProcessingFeatureHelper.IsFeatureSupported(procCenter, CCProcessingFeature.ProfileManagement);
            bool doesNewProcCenterSupportTokenizing = CCProcessingFeatureHelper.IsFeatureSupported(newCCPC, CCProcessingFeature.ProfileManagement);

            if (!doesOldProcCenterSupportTokenizing && doesNewProcCenterSupportTokenizing)
            {
                CustomerPaymentMethodDetail newCCPIDPM = PXSelect <CustomerPaymentMethodDetail,
                                                                   Where <CustomerPaymentMethodDetail.pMInstanceID, Equal <Required <CustomerPaymentMethodDetail.pMInstanceID> >,
                                                                          And <CustomerPaymentMethodDetail.paymentMethodID, Equal <Required <CustomerPaymentMethodDetail.paymentMethodID> >,
                                                                               And <CustomerPaymentMethodDetail.detailID, Equal <Required <CustomerPaymentMethodDetail.detailID> > > > > >
                                                         .Select(this, currCPM.PMInstanceID, currCPM.PaymentMethodID, CCPID.DetailID);

                if (newCCPIDPM != null)
                {
                    newCCPIDPM.Value = null;
                    CustomerPMDetails.Update(newCCPIDPM);
                }
                else
                {
                    newCCPIDPM = new CustomerPaymentMethodDetail
                    {
                        PMInstanceID    = currCPM.PMInstanceID,
                        PaymentMethodID = currCPM.PaymentMethodID,
                        DetailID        = CCPID.DetailID
                    };
                    CustomerPMDetails.Insert(newCCPIDPM);
                }
                var graph = PXGraph.CreateInstance <CCCustomerInformationManagerGraph>();
                graph.GetOrCreatePaymentProfile(this, new GenericCustomerPaymentMethodAdaper <CustomerPaymentMethod>(CustomerPM),
                                                new GenericCustomerPaymentMethodDetailAdapter <CustomerPaymentMethodDetail>(CustomerPMDetails));
            }

            if (doesNewProcCenterSupportTokenizing)
            {
                if (currCPM.CustomerCCPID == null)
                {
                    currCPM.CustomerCCPID = cpm.CustomerCCPID;
                }
                CustomerProcessingCenterID newCustomerProcessingCenterID = new CustomerProcessingCenterID
                {
                    CCProcessingCenterID = newCCPC.ProcessingCenterID,
                    BAccountID           = cpm.BAccountID,
                    CustomerCCPID        = currCPM.CustomerCCPID
                };
                AddCustomerProcessingCenterIfNeeded(newCustomerProcessingCenterID);
            }
            currCPM = CustomerPM.Update(currCPM);
            this.Save.Press();
        }
Пример #23
0
        public static void GetNewPaymentProfiles(PXGraph graph,
                                                 ICustomerPaymentMethodAdapter customerPaymentMethodAdapter,
                                                 ICustomerPaymentMethodDetailAdapter customerPaymentMethodDetailAdapter
                                                 )
        {
            if (graph == null || customerPaymentMethodAdapter == null || customerPaymentMethodDetailAdapter == null)
            {
                return;
            }
            CustomerPaymentMethod        currentCustomerPaymentMethod = customerPaymentMethodAdapter.Current;
            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);
                }

                CustomerPaymentMethod customerPaymentMethod = customerPaymentMethodAdapter.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 <CustomerPaymentMethodDetail, PaymentMethodDetail> det in customerPaymentMethodDetailAdapter.Select())
                    {
                        CustomerPaymentMethodDetail cpmd = det;
                        PaymentMethodDetail         pmd  = (PaymentMethodDetail)det;
                        if (pmd.IsCCProcessingID == true)
                        {
                            cpmd.Value = newCard.PaymentProfileID;
                            customerPaymentMethodDetailAdapter.Cache.Update(cpmd);
                        }
                        else if (pmd.IsIdentifier == true)
                        {
                            cpmd.Value = newCard.CardNumber;
                            customerPaymentMethodDetailAdapter.Cache.Update(cpmd);
                        }
                    }
                    //getting unmasked expiration date
                    newCard = cim.GetPaymentProfile();
                    if (newCard.CardExpirationDate != null)
                    {
                        customerPaymentMethodAdapter.Cache.SetValueExt <CustomerPaymentMethod.expirationDate>(customerPaymentMethod, newCard.CardExpirationDate);
                        customerPaymentMethodAdapter.Cache.Update(customerPaymentMethod);
                    }
                }
                attempt++;
            }
            if (newCard == null)
            {
                throw new PXException(Messages.FailedToSyncCC);
            }
        }
 public void DeletePaymentMethodDetail(CustomerPaymentMethodDetail detail)
 {
     _graph.Caches[typeof(CustomerPaymentMethodDetail)].Delete(detail);
 }