コード例 #1
0
        public static bool IsHFPaymentMethod(PXGraph graph, int?PMInstanceID, bool CheckJustDeletedPM = false)
        {
            CCProcessingCenter processingCenter = GetProcessingCenter(graph, PMInstanceID, CheckJustDeletedPM);

            return(CCProcessingFeatureHelper.IsFeatureSupported(processingCenter, CCProcessingFeature.HostedForm) &&
                   (processingCenter.AllowDirectInput != true));
        }
コード例 #2
0
        public static CCProcessingCenter GetProcessingCenter(PXGraph graph, int?PMInstanceID, bool UsePMFromCacheDeleted)
        {
            if (PMInstanceID == null && !UsePMFromCacheDeleted)
            {
                return(null);
            }

            CCProcessingCenter processingCenter = null;

            if (PMInstanceID != null)
            {
                PXResult <CustomerPaymentMethod, CCProcessingCenter> res =
                    (PXResult <CustomerPaymentMethod, CCProcessingCenter>) PXSelectJoin <
                        CustomerPaymentMethod,
                        InnerJoin <CCProcessingCenter,
                                   On <CCProcessingCenter.processingCenterID, Equal <CustomerPaymentMethod.cCProcessingCenterID> > >,
                        Where <CustomerPaymentMethod.pMInstanceID, Equal <Required <CustomerPaymentMethod.pMInstanceID> > > >
                    .Select(graph, PMInstanceID);

                processingCenter = (CCProcessingCenter)res;
            }

            if (processingCenter == null && UsePMFromCacheDeleted)
            {
                //assuming that payment method was just deleted
                IEnumerator cpmEnumerator = graph.Caches[typeof(CustomerPaymentMethod)].Deleted.GetEnumerator();
                if (cpmEnumerator.MoveNext())
                {
                    CustomerPaymentMethod customerPaymentMethod = (CustomerPaymentMethod)cpmEnumerator.Current;
                    processingCenter = GetProcessingCenter(graph, customerPaymentMethod.CCProcessingCenterID);
                }
            }

            return(processingCenter);
        }
コード例 #3
0
        public CCProcessingCenter GetProcessingCenter()
        {
            ICCPaymentProcessingRepository repo             = GetPaymentProcessingRepository();
            CCProcessingCenter             processingCenter = paymentProcessingRepository.GetCCProcessingCenter(processingCenterId);

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

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

                    foreach (CustomerPaymentMethodDetail deletedDet in detailsView.Cache.Deleted)
                    {
                        if (deletedDet.DetailID == ccpidPMDet.DetailID)
                        {
                            ccpidCPMDet = deletedDet;
                            break;
                        }
                    }
                    if (ccpidCPMDet != null && !string.IsNullOrEmpty(ccpidCPMDet.Value))
                    {
                        cim.DeletePaymentMethod();
                    }
                }
            }
        }
        public virtual bool Authorize(ICCPayment aPmtInfo, bool aCapture, ref int aTranNbr)
        {
            Customer customer;
            CustomerPaymentMethod pmInstance = this.findPMInstance(aPmtInfo.PMInstanceID, out customer);

            if (pmInstance == null)
            {
                throw new PXException(Messages.CreditCardWithID_0_IsNotDefined, aPmtInfo.PMInstanceID);
            }
            CCProcessingCenter procCenter = _repository.FindProcessingCenter(pmInstance.PMInstanceID, null);

            if (procCenter == null)
            {
                throw new PXException(Messages.ERR_CCProcessingCenterIsNotSpecified, pmInstance.Descr);
            }
            if (!(procCenter.IsActive ?? false))
            {
                throw new PXException(Messages.ERR_CCProcessingIsInactive, procCenter.ProcessingCenterID);
            }
            if (!IsValidForProcessing(pmInstance, customer))
            {
                return(false);
            }

            CCTranType tranType = aCapture ? CCTranType.AuthorizeAndCapture : CCTranType.AuthorizeOnly;
            CCProcTran tran     = new CCProcTran();

            tran.Copy(aPmtInfo);
            return(this.DoTransaction(ref aTranNbr, tranType, tran, null, customer.AcctCD, procCenter));
        }
コード例 #6
0
        public object GetPlugin()
        {
            CCProcessingCenter processingCenter = GetProcessingCenter();
            object             plugin           = GetProcessorPlugin(processingCenter);

            return(plugin);
        }
        public virtual bool CaptureOnly(ICCPayment aPmtInfo, string aAuthorizationNbr, ref int aTranNbr)
        {
            Customer customer;
            CustomerPaymentMethod pmInstance = this.findPMInstance(aPmtInfo.PMInstanceID, out customer);

            if (string.IsNullOrEmpty(aAuthorizationNbr))
            {
                throw new PXException(Messages.ERR_CCExternalAuthorizationNumberIsRequiredForCaptureOnlyTrans, aAuthorizationNbr);
            }
            CCProcessingCenter procCenter = _repository.GetCCProcessingCenter(pmInstance.CCProcessingCenterID);

            if (procCenter == null)
            {
                throw new PXException(Messages.ERR_CCProcessingCenterUsedForAuthIsNotValid, pmInstance.CCProcessingCenterID, aTranNbr);
            }
            if (!(procCenter.IsActive ?? false))
            {
                throw new PXException(Messages.ERR_CCProcessingCenterUsedForAuthIsNotActive, procCenter, aTranNbr);
            }
            if (!IsCCValidForProcessing(aPmtInfo.PMInstanceID))
            {
                return(false);
            }
            CCProcTran tran = new CCProcTran();

            tran.Copy(aPmtInfo);
            CCProcTran refTran = new CCProcTran {
                AuthNumber = aAuthorizationNbr
            };

            return(this.DoTransaction(ref aTranNbr, CCTranType.CaptureOnly, tran, refTran, customer.AcctCD, procCenter));
        }
コード例 #8
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();
            }
        }
コード例 #9
0
        protected CCProcessingCenter GetProcessingCenterById(string id)
        {
            CCProcessingCenter procCenter = PXSelect <CCProcessingCenter,
                                                      Where <CCProcessingCenter.processingCenterID, Equal <Required <CCProcessingCenter.processingCenterID> > > > .Select(Base, id);

            return(procCenter);
        }
 public static void CheckProcessing(CCProcessingCenter processingCenter, CCProcessingFeature feature, CCProcessingContext newContext)
 {
     CheckProcessingCenter(processingCenter);
     newContext.processingCenter = processingCenter;
     if (feature != CCProcessingFeature.Base && !CCProcessingFeatureHelper.IsFeatureSupported(processingCenter, feature))
     {
         throw new PXException(Messages.FeatureNotSupportedByProcessing, feature.ToString());
     }
 }
コード例 #11
0
        private static CCProcessingCenter GetProcessingCenterByPMInstance(PXGraph graph, int?pmInstanceID)
        {
            CCProcessingCenter processingCenter = (CCProcessingCenter)PXSelectJoin <CCProcessingCenter,
                                                                                    InnerJoin <CustomerPaymentMethod, On <CCProcessingCenter.processingCenterID, Equal <CustomerPaymentMethod.cCProcessingCenterID> > >,
                                                                                    Where <CustomerPaymentMethod.pMInstanceID, Equal <Required <CustomerPaymentMethod.pMInstanceID> > > >
                                                  .Select(graph, pmInstanceID);

            return(processingCenter);
        }
コード例 #12
0
        private void InitializeContext()
        {
            context = new CCProcessingContext();
            ICCPaymentProcessingRepository repository       = CCPaymentProcessingRepository.GetCCPaymentProcessingRepository();
            CCProcessingCenter             processingCenter = repository.GetCCProcessingCenter(processingCenterId);

            context.processingCenter = processingCenter;
            context.callerGraph      = graph;
        }
        public virtual bool Credit(int?aPMInstanceID, int?aRefTranNbr, string aCuryID, decimal?aAmount, ref int aTranNbr)
        {
            CCProcTran            authTran = _repository.GetCCProcTran(aRefTranNbr);
            Customer              customer;
            CustomerPaymentMethod pmInstance = this.findPMInstance(aPMInstanceID, out customer);

            if (authTran == null)
            {
                throw new PXException(Messages.ERR_CCTransactionToCreditIsNotFound, aRefTranNbr);
            }
            if (!MayBeCredited(authTran))
            {
                throw new PXException(Messages.ERR_CCProcessingTransactionMayNotBeCredited, authTran.TranType);
            }

            if (!IsAuthorized(authTran))
            {
                throw new PXException(Messages.ERR_CCProcessingReferensedTransactionNotAuthorized, aRefTranNbr);
            }
            if (!IsCCValidForProcessing(aPMInstanceID))
            {
                return(false);
            }

            CCProcessingCenter procCenter = _repository.GetCCProcessingCenter(authTran.ProcessingCenterID);

            if (procCenter == null)
            {
                throw new PXException(Messages.ERR_CCProcessingCenterUsedInReferencedTranNotFound, authTran.ProcessingCenterID, aRefTranNbr);
            }

            if (!(procCenter.IsActive ?? false))
            {
                throw new PXException(Messages.ERR_CCProcessingCenterUsedInReferencedTranNotActive, authTran.ProcessingCenterID, aRefTranNbr);
            }
            CCProcTran tran = new CCProcTran
            {
                PMInstanceID = aPMInstanceID,
                DocType      = authTran.DocType,
                RefNbr       = authTran.RefNbr,
                OrigDocType  = authTran.OrigDocType,
                OrigRefNbr   = authTran.OrigRefNbr,
                RefTranNbr   = authTran.TranNbr
            };

            if (aAmount.HasValue)
            {
                tran.CuryID = aCuryID;
                tran.Amount = aAmount;
            }
            else
            {
                tran.CuryID = authTran.CuryID;
                tran.Amount = authTran.Amount;
            }
            return(this.DoTransaction(ref aTranNbr, CCTranType.Credit, tran, authTran, customer.AcctCD, procCenter));
        }
コード例 #14
0
 protected bool IsSupportPaymentHostedForm(string processingCenterId)
 {
     if (processingCenterId != checkedProcessingCenter)
     {
         CCProcessingCenter procCenter = GetProcessingCenterById(processingCenterId);
         checkedProcessingCenterResult = IsFeatureSupported(processingCenterId, CCProcessingFeature.PaymentHostedForm);
         checkedProcessingCenter       = processingCenterId;
     }
     return(checkedProcessingCenterResult);
 }
        protected CCCustomerInformationManager(string processingCenterID, CCProcessingFeature feature)
        {
            _feature    = feature;
            _context    = new CCProcessingContext();
            _repository = CCPaymentProcessingRepository.GetCCPaymentProcessingRepository();
            CCProcessingCenter processingCenter = _repository.GetCCProcessingCenter(processingCenterID);

            CCProcessingFeatureHelper.CheckProcessing(processingCenter, _feature, _context);
            _pluginObject = InitializePlugin(_repository.GetCCProcessingCenter(processingCenterID));
        }
コード例 #16
0
        public static bool?CCProcessingCenterNeedsExpDateUpdate(PXGraph graph, CCProcessingCenter ProcessingCenter)
        {
            if (CCProcessingFeatureHelper.IsFeatureSupported(ProcessingCenter, CCProcessingFeature.ProfileManagement))
            {
                PXResultset <CustomerPaymentMethod> unupdatedCpms = PXSelect <CustomerPaymentMethod, Where <CustomerPaymentMethod.cCProcessingCenterID,
                                                                                                            Equal <Required <CustomerPaymentMethod.cCProcessingCenterID> >, And <CustomerPaymentMethod.expirationDate, IsNull> > > .Select(graph, ProcessingCenter.ProcessingCenterID);

                return(unupdatedCpms.Count != 0);
            }
            return(null);
        }
コード例 #17
0
        public static bool IsFeatureSupported(PXGraph graph, int?PMInstanceID, CCProcessingFeature FeatureName)
        {
            CustomerPaymentMethod current = GetCustomerPaymentMethod(graph, PMInstanceID);

            if (current == null)
            {
                return(false);
            }
            CCProcessingCenter processingCenter = GetProcessingCenter(graph, current.CCProcessingCenterID);

            return(CCProcessingFeatureHelper.IsFeatureSupported(processingCenter, FeatureName));
        }
コード例 #18
0
        public static bool IsHFPaymentMethod(PXGraph graph, int?PMInstanceID)
        {
            CustomerPaymentMethod current = GetCustomerPaymentMethod(graph, PMInstanceID);

            if (current == null)
            {
                return(false);
            }
            CCProcessingCenter processingCenter = GetProcessingCenter(graph, current.CCProcessingCenterID);

            return(CCProcessingFeatureHelper.IsFeatureSupported(processingCenter, CCProcessingFeature.HostedForm) && (processingCenter.AllowDirectInput != true));
        }
コード例 #19
0
		private static bool IsProcessingCenterDeprecated(PXGraph graph, int? pmInstanceID)
		{
			const string DeprecatedProcessingCenterTypeName = "PX.CCProcessing.AuthorizeNetTokenizedProcessing";
			if (pmInstanceID == null)
			{
				return false;
			}
			CCProcessingCenter processingCenter = (CCProcessingCenter)PXSelectJoin<CCProcessingCenter, 
					InnerJoin<CustomerPaymentMethod, On<CCProcessingCenter.processingCenterID, Equal<CustomerPaymentMethod.cCProcessingCenterID>>>,
					Where<CustomerPaymentMethod.pMInstanceID, Equal<Required<CustomerPaymentMethod.pMInstanceID>>>>
				.Select(graph, pmInstanceID);
			return string.Equals(processingCenter?.ProcessingTypeName, DeprecatedProcessingCenterTypeName);
		}
コード例 #20
0
        public static bool IsProcessingCenterNotSupported(PXGraph graph, int?pmInstanceID)
        {
            if (pmInstanceID == null)
            {
                return(false);
            }
            CCProcessingCenter processingCenter = GetProcessingCenterByPMInstance(graph, pmInstanceID);

            if (processingCenter == null)
            {
                return(false);
            }
            return(CCPluginTypeHelper.IsUnsupportedPluginType(processingCenter?.ProcessingTypeName));
        }
        private object InitializePlugin(CCProcessingCenter aProcCenter)
        {
            object plugin = null;

            try
            {
                Type processorType = PXBuildManager.GetType(aProcCenter.ProcessingTypeName, true);
                plugin = Activator.CreateInstance(processorType);
            }
            catch (Exception)
            {
                throw new PXException(Messages.ERR_ProcessingCenterTypeInstanceCreationFailed, aProcCenter.ProcessingTypeName, aProcCenter.ProcessingCenterID);
            }
            return(plugin);
        }
 private static void CheckProcessingCenter(CCProcessingCenter processingCenter)
 {
     if (processingCenter == null)
     {
         throw new PXException(Messages.ERR_CCProcessingCenterNotFound);
     }
     if (processingCenter.IsActive != true)
     {
         throw new PXException(Messages.ERR_CCProcessingCenterIsNotActive);
     }
     if (string.IsNullOrEmpty(processingCenter.ProcessingTypeName))
     {
         throw new PXException(Messages.ERR_ProcessingCenterForCardNotConfigured);
     }
 }
        public virtual bool Credit(ICCPayment aPmtInfo, int aRefTranNbr, ref int aTranNbr)
        {
            Customer customer;
            CustomerPaymentMethod pmInstance = this.findPMInstance(aPmtInfo.PMInstanceID, out customer);
            CCProcTran            authTran   = _repository.GetCCProcTran(aRefTranNbr);

            if (authTran == null)
            {
                throw new PXException(Messages.ERR_CCTransactionToCreditIsNotFound, aRefTranNbr);
            }
            if (!MayBeCredited(authTran))
            {
                throw new PXException(Messages.ERR_CCProcessingTransactionMayNotBeCredited, authTran.TranType);
            }

            if (!IsAuthorized(authTran))
            {
                throw new PXException(Messages.ERR_CCProcessingReferensedTransactionNotAuthorized, aRefTranNbr);
            }

            if (!IsCCValidForProcessing(aPmtInfo.PMInstanceID))
            {
                return(false);
            }

            CCProcessingCenter procCenter = _repository.GetCCProcessingCenter(authTran.ProcessingCenterID);

            if (procCenter == null)
            {
                throw new PXException(Messages.ERR_CCProcessingCenterUsedInReferencedTranNotFound, authTran.ProcessingCenterID, aRefTranNbr);
            }

            if (!(procCenter.IsActive ?? false))
            {
                throw new PXException(Messages.ERR_CCProcessingCenterUsedInReferencedTranNotActive, authTran.ProcessingCenterID, aRefTranNbr);
            }
            CCProcTran tran = new CCProcTran();

            tran.Copy(aPmtInfo);
            tran.RefTranNbr = authTran.TranNbr;

            if (!aPmtInfo.CuryDocBal.HasValue)
            {
                tran.CuryID = authTran.CuryID;
                tran.Amount = authTran.Amount;
            }
            return(this.DoTransaction(ref aTranNbr, CCTranType.Credit, tran, authTran, customer.AcctCD, procCenter));
        }
        public virtual bool Capture(int?aPMInstanceID, int?aAuthTranNbr, string aCuryID, decimal?aAmount, ref int aTranNbr)
        {
            CCProcTran            authTran = _repository.GetCCProcTran(aAuthTranNbr);
            Customer              customer;
            CustomerPaymentMethod pmInstance = this.findPMInstance(aPMInstanceID, out customer);

            if (authTran == null)
            {
                throw new PXException(Messages.ERR_CCAuthorizationTransactionIsNotFound, aAuthTranNbr);
            }
            if (!IsAuthorized(authTran))
            {
                throw new PXException(Messages.ERR_CCProcessingReferensedTransactionNotAuthorized, aAuthTranNbr);
            }

            if (authTran.ExpirationDate.HasValue && authTran.ExpirationDate.Value < PXTimeZoneInfo.Now)
            {
                throw new PXException(Messages.ERR_CCAuthorizationTransactionHasExpired, aAuthTranNbr);
            }
            if (!IsCCValidForProcessing(aPMInstanceID))
            {
                return(false);
            }

            CCProcessingCenter procCenter = _repository.GetCCProcessingCenter(authTran.ProcessingCenterID);

            if (procCenter == null)
            {
                throw new PXException(Messages.ERR_CCProcessingCenterUsedForAuthIsNotValid, authTran.ProcessingCenterID, aAuthTranNbr);
            }
            if (!(procCenter.IsActive ?? false))
            {
                throw new PXException(Messages.ERR_CCProcessingCenterUsedForAuthIsNotActive, procCenter, aAuthTranNbr);
            }
            CCProcTran tran = new CCProcTran
            {
                PMInstanceID = aPMInstanceID,
                RefTranNbr   = aAuthTranNbr,
                DocType      = authTran.DocType,
                RefNbr       = authTran.RefNbr,
                CuryID       = aCuryID,
                Amount       = aAmount,
                OrigDocType  = authTran.OrigDocType,
                OrigRefNbr   = authTran.OrigRefNbr
            };

            return(this.DoTransaction(ref aTranNbr, CCTranType.PriorAuthorizedCapture, tran, authTran, customer.AcctCD, procCenter));
        }
コード例 #25
0
        /// <summary>
        /// Checks whether the payment plug-in type that is configured for the processing center is supported by the processing center
        /// and returns the Type object that corresponds to this plug-in type.
        /// </summary>
        public static Type GetPluginTypeWithCheck(CCProcessingCenter procCenter)
        {
            string typeName = procCenter?.ProcessingTypeName;

            if (typeName == null)
            {
                throw new ArgumentNullException(nameof(CCProcessingCenter.ProcessingTypeName));
            }
            if (IsUnsupportedPluginType(typeName))
            {
                throw new PXException(Messages.TryingToUseNotSupportedPlugin, procCenter.ProcessingCenterID);
            }
            Type pluginType = GetPluginType(typeName);

            return(pluginType);
        }
コード例 #26
0
        public static bool IsFeatureSupported(CCProcessingCenter ccProcessingCenter, CCProcessingFeature feature)
        {
            bool ret = false;

            if (ccProcessingCenter != null && !string.IsNullOrEmpty(ccProcessingCenter.ProcessingTypeName))
            {
                try
                {
                    Type procType = CCPluginTypeHelper.GetPluginTypeWithCheck(ccProcessingCenter);
                    ret = IsFeatureSupported(procType, feature);
                }
                catch
                {}
            }
            return(ret);
        }
コード例 #27
0
        public static bool IsProcessingCenterNotSupported(PXGraph graph, string procCenterId)
        {
            if (procCenterId == null)
            {
                return(false);
            }
            CCProcessingCenter processingCenter = PXSelect <CCProcessingCenter,
                                                            Where <CCProcessingCenter.processingCenterID, Equal <Required <CCProcessingCenter.processingCenterID> > > >
                                                  .Select(graph, procCenterId);

            if (processingCenter == null)
            {
                return(false);
            }
            return(CCPluginTypeHelper.IsUnsupportedPluginType(processingCenter.ProcessingTypeName));
        }
コード例 #28
0
        public IEnumerable GetRecords()
        {
            PXSelectBase <CCProcessingCenter> query      = new PXSelectReadonly <CCProcessingCenter>(_Graph);
            ICCPaymentProcessingRepository    repository = CCPaymentProcessingRepository.GetCCPaymentProcessingRepository();

            foreach (CCProcessingCenter item in query.Select())
            {
                string             processingCenterId = item.ProcessingCenterID;
                CCProcessingCenter processingCenter   = repository.GetCCProcessingCenter(processingCenterId);

                if (CCProcessingFeatureHelper.IsFeatureSupported(processingCenter, feature))
                {
                    yield return(item);
                }
            }
        }
        public virtual bool RecordCredit(ICCPayment aPmtInfo, string aRefPCTranNbr, string aExtTranRef, string aExtAuthNbr, out int?aTranNbr)
        {
            aTranNbr = null;
            if (!IsCCValidForProcessing(aPmtInfo.PMInstanceID))
            {
                return(false);
            }
            CCProcTran tran = new CCProcTran();

            tran.Copy(aPmtInfo);
            CCProcTran origCCTran = null;

            if (!String.IsNullOrEmpty(aRefPCTranNbr))
            {
                origCCTran = _repository.FindReferencedCCProcTran(aPmtInfo.PMInstanceID, aRefPCTranNbr);
            }

            if (origCCTran != null && (aPmtInfo.PMInstanceID == origCCTran.PMInstanceID))
            {
                //Override Orig Doc Ref by those from orig CC Tran if any
                tran.RefTranNbr         = origCCTran.TranNbr;
                tran.ProcessingCenterID = origCCTran.ProcessingCenterID;
            }
            else
            {
                CCProcessingCenter procCenter = _repository.FindProcessingCenter(aPmtInfo.PMInstanceID, aPmtInfo.CuryID);
                if (procCenter == null || string.IsNullOrEmpty(procCenter.ProcessingTypeName))
                {
                    throw new PXException(Messages.ERR_ProcessingCenterForCardNotConfigured);
                }
                CashAccount cashAccount = _repository.GetCashAccount(procCenter.CashAccountID);
                if (cashAccount.CuryID != aPmtInfo.CuryID)
                {
                    throw new PXException(Messages.ProcessingCenterCurrencyDoesNotMatch, aPmtInfo.CuryID, cashAccount.CuryID);
                }
                tran.ProcessingCenterID = procCenter.ProcessingCenterID;
                tran.RefPCTranNumber    = aRefPCTranNbr;
            }
            tran.PCTranNumber = aExtTranRef;
            tran.AuthNumber   = aExtAuthNbr;
            tran.TranType     = CCTranTypeCode.GetTypeCode(CCTranType.Credit);
            FillRecordedTran(tran);
            tran = _repository.InsertCCProcTran(tran);
            _repository.Save();
            aTranNbr = tran.TranNbr;
            return(true);
        }
        public virtual bool Void(int?aPMInstanceID, int?aRefTranNbr, ref int aTranNbr)
        {
            CCProcTran            refTran = _repository.GetCCProcTran(aRefTranNbr);
            Customer              customer;
            CustomerPaymentMethod pmInstance = this.findPMInstance(aPMInstanceID, out customer);

            if (refTran == null)
            {
                throw new PXException(Messages.ERR_CCTransactionToVoidIsNotFound, aRefTranNbr);
            }
            if (!MayBeVoided(refTran))
            {
                throw new PXException(Messages.ERR_CCProcessingTransactionMayNotBeVoided, refTran.TranType);
            }
            if (!IsAuthorized(refTran))
            {
                throw new PXException(Messages.ERR_CCProcessingReferensedTransactionNotAuthorized, aRefTranNbr);
            }
            if (!IsCCValidForProcessing(aPMInstanceID))
            {
                return(false);
            }
            CCProcessingCenter procCenter = _repository.GetCCProcessingCenter(refTran.ProcessingCenterID);

            if (procCenter == null)
            {
                throw new PXException(Messages.ERR_CCProcessingCenterUsedInReferencedTranNotFound, refTran.ProcessingCenterID, aRefTranNbr);
            }
            if (!(procCenter.IsActive ?? false))
            {
                throw new PXException(Messages.ERR_CCProcessingCenterUsedInReferencedTranNotFound, procCenter, aRefTranNbr);
            }

            CCProcTran tran = new CCProcTran
            {
                PMInstanceID = aPMInstanceID,
                RefTranNbr   = aRefTranNbr,
                DocType      = refTran.DocType,
                RefNbr       = refTran.RefNbr,
                CuryID       = refTran.CuryID,
                Amount       = refTran.Amount,
                OrigDocType  = refTran.OrigDocType,
                OrigRefNbr   = refTran.OrigRefNbr
            };

            return(this.DoTransaction(ref aTranNbr, CCTranType.Void, tran, refTran, customer.AcctCD, procCenter));
        }