protected virtual PaymentMethodDetail FindCCPID(PaymentMethod pm)
        {
            PaymentMethodDetail res = PXSelect <PaymentMethodDetail, Where <PaymentMethodDetail.paymentMethodID, Equal <Required <PaymentMethodDetail.paymentMethodID> >,
                                                                            And <PaymentMethodDetail.isCCProcessingID, Equal <True> > > > .Select(this, pm.PaymentMethodID);

            return(res);
        }
        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();
        }
        protected virtual void PaymentTypeInstanceDetail_Value_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
        {
            PaymentTypeInstanceDetail row = e.Row as PaymentTypeInstanceDetail;
            PaymentMethodDetail       def = this.FindTemplate(row);

            if (def != null)
            {
                if (def.IsIdentifier ?? false)
                {
                    string id = CustomerPaymentMethodMaint.IDObfuscator.MaskID(row.Value, def.DisplayMask);
                    if (this.PaymentTypeInstance.Current.Descr != id)
                    {
                        PaymentTypeInstance parent = this.PaymentTypeInstance.Current;
                        parent.Descr = String.Format("{0}:{1}", parent.PaymentMethodID, id);
                        this.PaymentTypeInstance.Update(parent);
                    }
                }
                //bool isExpirationDate = def.IsExpirationDate ?? false;
                bool isExpirationDate = false;
                if (isExpirationDate)
                {
                    PaymentTypeInstance parent = this.PaymentTypeInstance.Current;
                    try
                    {
                        parent.ExpirationDate = ParseExpiryDate(row.Value);
                    }
                    catch (FormatException)
                    {
                        parent.ExpirationDate = null;
                        this.Details.Cache.RaiseExceptionHandling <PaymentTypeInstanceDetail.value>(row, row.Value, new PXSetPropertyException(Messages.ERR_IncorrectFormatOfPTInstanceExpiryDate));
                    }
                    this.PaymentTypeInstance.Update(parent);
                }
            }
        }
コード例 #4
0
        protected virtual void PaymentMethodDetail_RowInserting(PXCache cache, PXRowInsertingEventArgs e)
        {
            if (errorKey)
            {
                errorKey = false;
                e.Cancel = true;
            }
            else
            {
                PaymentMethodDetail row = (PaymentMethodDetail)e.Row;
                string detID            = row.DetailID;
                string UseFor           = row.UseFor;

                bool isExist = false;
                foreach (PaymentMethodDetail it in this.Details.Select())
                {
                    if ((it.DetailID == detID) && (UseFor == it.UseFor))
                    {
                        isExist = true;
                    }
                }

                if (isExist)
                {
                    cache.RaiseExceptionHandling <PaymentMethodDetail.detailID>(e.Row, detID, new PXException(Messages.DuplicatedPaymentMethodDetail));
                    e.Cancel = true;
                }
            }
        }
        protected virtual PaymentMethodDetail FindTemplate(PaymentTypeInstanceDetail aDet)
        {
            PaymentMethodDetail res = PXSelect <PaymentMethodDetail, Where <PaymentMethodDetail.paymentMethodID, Equal <Required <PaymentMethodDetail.paymentMethodID> >,
                                                                            And <PaymentMethodDetail.detailID, Equal <Required <PaymentMethodDetail.detailID> >,
                                                                                 And <PaymentMethodDetail.useFor, Equal <PaymentMethodDetailUsage.useForAPCards> > > > > .Select(this, aDet.PaymentMethodID, aDet.DetailID);

            return(res);
        }
コード例 #6
0
        protected virtual void PaymentMethodDetail_DetailID_ExceptionHandling(PXCache cache, PXExceptionHandlingEventArgs e)
        {
            PaymentMethodDetail a = e.Row as PaymentMethodDetail;

            if (a.DetailID != null)
            {
                errorKey = true;
            }
        }
コード例 #7
0
        protected virtual void fillCreditCardDefaults()
        {
            this.addDefaultsToDetails(CreditCardAttributes.AttributeName.CCPID, Messages.CCPID);
            PaymentMethodDetail det = this.addDefaultsToDetails(CreditCardAttributes.AttributeName.CardNumber, Messages.CardNumber);

            det.DisplayMask = CreditCardAttributes.MaskDefaults.DefaultIdentifier;
            this.addDefaultsToDetails(CreditCardAttributes.AttributeName.ExpirationDate, Messages.ExpirationDate);
            this.addDefaultsToDetails(CreditCardAttributes.AttributeName.NameOnCard, Messages.NameOnCard);
            this.addDefaultsToDetails(CreditCardAttributes.AttributeName.CCVCode, Messages.CCVCode);
        }
コード例 #8
0
        private PaymentMethodDetail addDefaultsToDetails(CreditCardAttributes.AttributeName aAttr, string aDescr)
        {
            PaymentMethodDetail det = new PaymentMethodDetail();

            ImportDefaults(det, aAttr);
            det.Descr  = aDescr;
            det.UseFor = PaymentMethodDetailUsage.UseForARCards;
            det        = (PaymentMethodDetail)this.Details.Cache.Insert(det);
            return(det);
        }
        protected virtual void PaymentTypeInstanceDetail_RowDeleted(PXCache cache, PXRowDeletedEventArgs e)
        {
            PaymentTypeInstanceDetail row = (PaymentTypeInstanceDetail)e.Row;
            PaymentMethodDetail       def = this.FindTemplate(row);

            if (def.IsIdentifier ?? false)
            {
                this.PaymentTypeInstance.Current.Descr = null;
            }
        }
コード例 #10
0
		protected virtual PaymentMethodDetail FindSameTypeTemplate(PaymentMethod targetPM, PaymentMethodDetail baseDetail)
		{
			PaymentMethodDetail res = PXSelect<PaymentMethodDetail, Where<PaymentMethodDetail.paymentMethodID, Equal<Required<PaymentMethodDetail.paymentMethodID>>,
				And<PaymentMethodDetail.useFor, Equal<PaymentMethodDetailUsage.useForARCards>,
				And<PaymentMethodDetail.isIdentifier, Equal<Required<PaymentMethodDetail.isIdentifier>>,
				And<PaymentMethodDetail.isExpirationDate, Equal<Required<PaymentMethodDetail.isExpirationDate>>,
				And<PaymentMethodDetail.isOwnerName, Equal<Required<PaymentMethodDetail.isOwnerName>>,
				And<PaymentMethodDetail.isCCProcessingID, Equal<Required<PaymentMethodDetail.isCCProcessingID>>>>>>>>>.
					Select(this, targetPM.PaymentMethodID, baseDetail.IsIdentifier, baseDetail.IsExpirationDate, baseDetail.IsOwnerName, baseDetail.IsCCProcessingID);
			return res;
		}
        protected virtual bool ValidateDetail(PaymentTypeInstanceDetail aRow)
        {
            PaymentMethodDetail iTempl = this.FindTemplate(aRow);

            if (iTempl != null && ((iTempl.IsRequired ?? false) || (iTempl.IsIdentifier ?? false)) && String.IsNullOrEmpty(aRow.Value))
            {
                this.Details.Cache.RaiseExceptionHandling <PaymentTypeInstanceDetail.value>(aRow, aRow.Value, new PXSetPropertyException(Messages.ERR_RequiredValueNotEnterd));
                return(false);
            }
            return(true);
        }
コード例 #12
0
 private static void ImportDefaults(PaymentMethodDetail aData, CreditCardAttributes.AttributeName aAttr)
 {
     aData.DetailID         = CreditCardAttributes.GetID(aAttr);
     aData.EntryMask        = CreditCardAttributes.GetMask(aAttr);
     aData.ValidRegexp      = CreditCardAttributes.GetValidationRegexp(aAttr);
     aData.IsIdentifier     = aAttr == CreditCardAttributes.AttributeName.CardNumber;
     aData.IsExpirationDate = aAttr == CreditCardAttributes.AttributeName.ExpirationDate;
     aData.IsOwnerName      = (aAttr == CreditCardAttributes.AttributeName.NameOnCard);
     aData.IsRequired       = (aAttr == CreditCardAttributes.AttributeName.CCPID);
     aData.IsEncrypted      = (aAttr == CreditCardAttributes.AttributeName.ExpirationDate) || (aAttr == CreditCardAttributes.AttributeName.CardNumber) || (aAttr == CreditCardAttributes.AttributeName.CCVCode);
     aData.IsCCProcessingID = (aAttr == CreditCardAttributes.AttributeName.CCPID);
     aData.OrderIndex       = (short)((int)aAttr + 1);
 }
        protected virtual void PaymentTypeInstanceDetail_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            PaymentTypeInstanceDetail row = (PaymentTypeInstanceDetail)e.Row;

            if (row != null)
            {
                PaymentMethodDetail iTempl = this.FindTemplate(row);
                bool isRequired            = (iTempl != null) && (iTempl.IsRequired ?? false);
                PXDefaultAttribute.SetPersistingCheck <PaymentTypeInstanceDetail.value>(cache, row, (isRequired) ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);
                bool showDecripted = !(iTempl.IsEncrypted ?? false);
                PXRSACryptStringAttribute.SetDecrypted <PaymentTypeInstanceDetail.value>(cache, row, showDecripted);
            }
        }
        protected virtual void PaymentTypeInstanceDetail_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
        {
            var row = (PaymentTypeInstanceDetail)e.Row;

            if (row == null)
            {
                return;
            }

            PaymentMethodDetail iTempl = this.FindTemplate(row);

            PXDefaultAttribute.SetPersistingCheck <PaymentTypeInstanceDetail.value>(cache, row, iTempl?.IsRequired == true ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);
        }
コード例 #15
0
        protected virtual void PaymentMethodDetail_RowInserted(PXCache cache, PXRowInsertedEventArgs e)
        {
            PaymentMethodDetail row = (PaymentMethodDetail)e.Row;

            if ((bool)row.IsIdentifier || (bool)row.IsExpirationDate || (bool)row.IsOwnerName)
            {
                bool needRefresh;
                ResetUniqueFlags(row, out needRefresh);
                if (needRefresh)
                {
                    this.Details.View.RequestRefresh();
                }
            }
        }
コード例 #16
0
        private PaymentMethodDetail addDefaultsToDetails(CreditCardAttributes.AttributeName aAttr, string aDescr)
        {
            PaymentMethodDetail det = new PaymentMethodDetail();

            ImportDefaults(det, aAttr);
            det.Descr  = aDescr;
            det.UseFor = PaymentMethodDetailUsage.UseForARCards;
            det        = (PaymentMethodDetail)this.Details.Cache.Insert(det);
            if (PXDBLocalizableStringAttribute.IsEnabled)
            {
                PXDBLocalizableStringAttribute.DefaultTranslationsFromMessage(this.Details.Cache, det, "Descr", aDescr);
            }
            return(det);
        }
コード例 #17
0
        protected virtual void PaymentMethodDetail_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            bool enableID           = false;
            PaymentMethodDetail row = e.Row as PaymentMethodDetail;

            if (row == null || (row != null && string.IsNullOrEmpty(row.DetailID)))
            {
                enableID = true;
            }
            PXUIFieldAttribute.SetEnabled <PaymentMethodDetail.detailID>(cache, e.Row, enableID);

            bool isID = (row != null) && (row.IsIdentifier ?? false);

            PXUIFieldAttribute.SetEnabled <PaymentMethodDetail.displayMask>(cache, e.Row, isID);
        }
        protected virtual void PaymentTypeInstanceDetail_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            var row = (PaymentTypeInstanceDetail)e.Row;

            if (row == null)
            {
                return;
            }

            PaymentMethodDetail iTempl = this.FindTemplate(row);

            PXUIFieldAttribute.SetRequired <PaymentTypeInstanceDetail.value>(cache, iTempl?.IsRequired == true);
            bool showDecripted = !(iTempl.IsEncrypted ?? false);

            PXRSACryptStringAttribute.SetDecrypted <PaymentTypeInstanceDetail.value>(cache, row, showDecripted);
        }
コード例 #19
0
        protected virtual void ResetUniqueFlags(PaymentMethodDetail aRow, out bool needRefresh)
        {
            needRefresh = false;
            const int IDFlag         = 0x1;
            const int ExpDateFlag    = 0x2;
            const int NameOnCardFlag = 0x4;
            int       state          = 0;

            state |= (bool)aRow.IsIdentifier ? IDFlag : 0;
            state |= (bool)aRow.IsExpirationDate ? ExpDateFlag : 0;
            state |= (bool)aRow.IsOwnerName ? NameOnCardFlag : 0;
            if (state != 0)
            {
                foreach (PaymentMethodDetail iDet in this.Details.Select())
                {
                    if (Object.ReferenceEquals(aRow, iDet))
                    {
                        continue;
                    }
                    if (aRow.UseFor != iDet.UseFor)
                    {
                        continue;
                    }
                    bool needUpdate = false;
                    if ((bool)iDet.IsIdentifier && ((state & IDFlag) != 0))
                    {
                        iDet.IsIdentifier = false;
                        needUpdate        = true;
                    }
                    if ((state & ExpDateFlag) != 0 && (bool)iDet.IsExpirationDate)
                    {
                        iDet.IsExpirationDate = false;
                        needUpdate            = true;
                    }
                    if ((state & NameOnCardFlag) != 0 && (bool)iDet.IsOwnerName)
                    {
                        iDet.IsOwnerName = false;
                        needUpdate       = true;
                    }
                    if (needUpdate)
                    {
                        this.Details.Update(iDet);
                        needRefresh = true;
                    }
                }
            }
        }
コード例 #20
0
        protected virtual void CCProcessingCenterPmntMethod_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            CCProcessingCenterPmntMethod row = (CCProcessingCenterPmntMethod)e.Row;
            CCProcessingCenter           processingCenter = PXSelect <CCProcessingCenter,
                                                                      Where <CCProcessingCenter.processingCenterID, Equal <Required <CCProcessingCenter.processingCenterID> > > > .Select(this, row.ProcessingCenterID);

            if (processingCenter != null)
            {
                if (CCProcessingFeatureHelper.IsFeatureSupported(processingCenter, CCProcessingFeature.ProfileManagement))
                {
                    PaymentMethodDetail ccpid = PXSelect <PaymentMethodDetail, Where <PaymentMethodDetail.paymentMethodID, Equal <Current <PaymentMethod.paymentMethodID> >,
                                                                                      And <PaymentMethodDetail.isCCProcessingID, Equal <True> > > > .Select(this);

                    if (ccpid == null)
                    {
                        throw new PXException(Messages.CCPaymentProfileIDNotSetUp);
                    }
                }
            }
        }
コード例 #21
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();
        }
        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
		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);
		}