protected virtual void CCProcessingCenterPmntMethod_RowInserting(PXCache cache, PXRowInsertingEventArgs e)
        {
            if (errorKey)
            {
                errorKey = false;
                e.Cancel = true;
            }
            else
            {
                CCProcessingCenterPmntMethod row = e.Row as CCProcessingCenterPmntMethod;
                string detID   = row.ProcessingCenterID;
                bool   isExist = false;
                foreach (CCProcessingCenterPmntMethod it in this.ProcessingCenters.Select())
                {
                    if (!Object.ReferenceEquals(it, row) && it.ProcessingCenterID == row.ProcessingCenterID)
                    {
                        isExist = true;
                    }
                }

                if (isExist)
                {
                    cache.RaiseExceptionHandling <CCProcessingCenterPmntMethod.processingCenterID>(e.Row, detID, new PXException(Messages.ProcessingCenterIsAlreadyAssignedToTheCard));
                    e.Cancel = true;
                }
            }
        }
        protected virtual void CCProcessingCenterPmntMethod_ProcessingCenterID_ExceptionHandling(PXCache cache, PXExceptionHandlingEventArgs e)
        {
            CCProcessingCenterPmntMethod row = e.Row as CCProcessingCenterPmntMethod;

            if (row.ProcessingCenterID != null)
            {
                errorKey = true;
            }
        }
Example #3
0
        protected virtual void CCProcessingCenterPmntMethod_RowDeleted(PXCache cache, PXRowDeletedEventArgs e)
        {
            CCProcessingCenterPmntMethod row = (CCProcessingCenterPmntMethod)e.Row;

            if (row.IsDefault == true)
            {
                CheckDefaultFlag(cache, null);
            }
        }
Example #4
0
        protected virtual void CCProcessingCenterPmntMethod_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e)
        {
            CCProcessingCenterPmntMethod row    = (CCProcessingCenterPmntMethod)e.Row;
            CCProcessingCenterPmntMethod oldRow = (CCProcessingCenterPmntMethod)e.OldRow;

            if (row.IsDefault != oldRow.IsDefault)
            {
                CheckDefaultFlag(cache, row);
            }
        }
        protected virtual void CCProcessingCenterPmntMethod_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            CCProcessingCenterPmntMethod row = e.Row as CCProcessingCenterPmntMethod;

            if (row == null)
            {
                return;
            }
            PXUIFieldAttribute.SetEnabled <CCProcessingCenterPmntMethod.paymentMethodID>(sender, null, false);
            PXUIFieldAttribute.SetEnabled <CCProcessingCenterPmntMethod.isActive>(sender, null, false);
            PXUIFieldAttribute.SetEnabled <CCProcessingCenterPmntMethod.isDefault>(sender, null, false);
        }
Example #6
0
        private void CheckDefaultFlag(PXCache cache, CCProcessingCenterPmntMethod row)
        {
            PXResultset <CCProcessingCenterPmntMethod> currDefaultProcCenter = DefaultProcCenter.Select();

            if (row != null && row.IsDefault == true)
            {
                foreach (CCProcessingCenterPmntMethod procPmtMethod in currDefaultProcCenter)
                {
                    if (Object.ReferenceEquals(procPmtMethod, row))
                    {
                        continue;
                    }
                    ProcessingCenters.SetValueExt <CCProcessingCenterPmntMethod.isDefault>(procPmtMethod, false);
                }
                ProcessingCenters.View.RequestRefresh();
            }
        }
        protected virtual void CCProcessingCenterPmntMethod_RowInserting(PXCache cache, PXRowInsertingEventArgs e)
        {
            if (errorKey)
            {
                errorKey = false;
                e.Cancel = true;
            }
            else
            {
                CCProcessingCenterPmntMethod row = e.Row as CCProcessingCenterPmntMethod;
                string detID   = row.ProcessingCenterID;
                bool   isExist = false;

                foreach (CCProcessingCenterPmntMethod it in this.ProcessingCenters.Select())
                {
                    if (!Object.ReferenceEquals(it, row) && it.ProcessingCenterID == row.ProcessingCenterID)
                    {
                        isExist = true;
                    }
                }

                if (isExist)
                {
                    cache.RaiseExceptionHandling <CCProcessingCenterPmntMethod.processingCenterID>(e.Row, detID, new PXException(Messages.ProcessingCenterIsAlreadyAssignedToTheCard));
                    e.Cancel = true;
                }
                else
                {
                    CCProcessingCenter procCenter = GetProcessingCenterById(row.ProcessingCenterID);
                    bool supported = CCProcessingFeatureHelper.IsFeatureSupported(procCenter, CCProcessingFeature.PaymentHostedForm);

                    if (supported)
                    {
                        if (row.IsDefault == false)
                        {
                            WebDialogResult result = ProcessingCenters.Ask(Messages.DefaultProcessingCenterConfirmation, MessageButtons.YesNo);
                            if (result == WebDialogResult.Yes)
                            {
                                row.IsDefault = true;
                            }
                        }
                    }
                }
            }
        }
        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);
                    }
                }
            }
        }
		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 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();
        }
Example #11
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();
        }