private bool ProcCenterSupportTokenizing(string procCenterId)
		{
			var query = new PXSelect<CCProcessingCenter,
				Where<CCProcessingCenter.processingCenterID, Equal<Required<CCProcessingCenter.processingCenterID>>>>(this);
			CCProcessingCenter procCenter = query.Select(procCenterId);
			string typeName = procCenter.ProcessingTypeName;
			if (typeName == AuthnetConstants.AIMPluginFullName)
			{
				return false;
			}
			if (typeName == AuthnetConstants.CIMPluginFullName || 
				typeName == AuthnetConstants.APIPluginFullName)
			{
				return true;
			}
			Type type = CCPluginTypeHelper.GetPluginType(procCenter.ProcessingTypeName);
			if (CCPluginTypeHelper.CheckImplementInterface(type, PluginConstants.V1TokenizedInterface))
			{
				return true;
			}
			if (CCProcessingFeatureHelper.IsFeatureSupported(type, CCProcessingFeature.ProfileManagement))
			{
				return true;
			}
			return false;
		}
Beispiel #2
0
        protected virtual void CCProcessingCenter_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            CCProcessingCenter row = e.Row as CCProcessingCenter;

            if (row == null)
            {
                return;
            }
            PXUIFieldAttribute.SetEnabled <CCProcessingCenter.processingTypeName>(sender, row, row.IsActive.GetValueOrDefault());
            PXUIFieldAttribute.SetRequired <CCProcessingCenter.processingTypeName>(sender, row.IsActive.GetValueOrDefault());
            bool isTokenized = CCProcessingFeatureHelper.IsFeatureSupported(row, CCProcessingFeature.HostedForm);

            PXUIFieldAttribute.SetVisible <CCProcessingCenter.allowDirectInput>(sender, row, isTokenized);
            PXUIFieldAttribute.SetVisible <CCProcessingCenter.syncronizeDeletion>(sender, row, isTokenized);
            PXUIFieldAttribute.SetVisible <CCProcessingCenter.syncRetryAttemptsNo>(sender, row, isTokenized);
            PXUIFieldAttribute.SetVisible <CCProcessingCenter.syncRetryDelayMs>(sender, row, isTokenized);
            bool supportsExtendedProfiles = isTokenized && CCProcessingFeatureHelper.IsFeatureSupported(row, CCProcessingFeature.ExtendedProfileManagement);

            PXUIFieldAttribute.SetVisible <CCProcessingCenter.createAdditionalCustomerProfiles>(sender, row, supportsExtendedProfiles);
            PXUIFieldAttribute.SetVisible <CCProcessingCenter.creditCardLimit>(sender, row,
                                                                               supportsExtendedProfiles && row.CreateAdditionalCustomerProfiles == true);
            this.testCredentials.SetEnabled(!string.IsNullOrEmpty(row.ProcessingCenterID) && !string.IsNullOrEmpty(row.ProcessingTypeName));
            this.updateExpirationDate.SetVisible(row.NeedsExpDateUpdate == true);
            this.ProcessingCenter.Cache.AllowDelete = !HasTransactions(row);
            PaymentMethods.AllowInsert = false;
            PaymentMethods.AllowDelete = false;
            SetAllowAcceptFormCheckbox(sender, row);
        }
Beispiel #3
0
        protected virtual void CCProcessingCenter_ProcessingTypeName_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            CCProcessingCenter row = e.Row as CCProcessingCenter;

            if (row == null)
            {
                return;
            }
            bool isTokenized = CCProcessingFeatureHelper.IsFeatureSupported(row, CCProcessingFeature.ProfileManagement);
            bool isHF        = CCProcessingFeatureHelper.IsFeatureSupported(row, CCProcessingFeature.HostedForm);

            sender.SetValue <CCProcessingCenter.allowDirectInput>(row, isTokenized && !isHF);
            foreach (CCProcessingCenterDetail detail in Details.Select())
            {
                Details.Delete(detail);
            }
            this.ImportSettings();

            bool supported = CCProcessingFeatureHelper.IsFeatureSupported(row, CCProcessingFeature.PaymentHostedForm);

            if (supported)
            {
                sender.RaiseExceptionHandling <CCProcessingCenter.useAcceptPaymentForm>(ProcessingCenter.Current, null,
                                                                                        new PXSetPropertyException(Messages.UseAcceptPaymentFormWarning, PXErrorLevel.Warning));
                row.UseAcceptPaymentForm = true;
            }
        }
        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));
        }
            private void CheckWebhook()
            {
                V2SettingsGenerator seetingsGen = new V2SettingsGenerator(_provider);

                if (!CCProcessingFeatureHelper.IsFeatureSupported(_plugin.GetType(), CCProcessingFeature.WebhookManagement))
                {
                    PXTrace.WriteInformation("Skip check webhook. Plugin doesn't implement this feature.");
                    return;
                }

                V2.ICCWebhookProcessor processor = _plugin.CreateProcessor <V2.ICCWebhookProcessor>(seetingsGen.GetSettings());
                if (!processor.WebhookEnabled)
                {
                    PXTrace.WriteInformation("Skip check webhook. This feature is disabled.");
                    return;
                }
                string eCompanyName = V2.CCServiceEndpointHelper.EncodeUrlSegment(CompanyName);
                string eProcCenter  = V2.CCServiceEndpointHelper.EncodeUrlSegment(ProcessingCenterId);
                string url          = V2.CCServiceEndpointHelper.GetEndpointUrl(eCompanyName, eProcCenter);

                if (url == null || url.Contains("localhost"))
                {
                    PXTrace.WriteInformation($"Skip check webhook. Not valid Url: {url}");
                    return;
                }

                bool result = checkUrl.IsMatch(url);

                if (!result)
                {
                    PXTrace.WriteInformation($"Skip check webhook. Not valid Url: {url}");
                    return;
                }

                IEnumerable <V2.Webhook> list = processor.GetAttachedWebhooks();

                V2.Webhook res = list.Where(i => i.Url == url).FirstOrDefault();
                if (res == null)
                {
                    string name = "AcumaticaWebhook";
                    PXTrace.WriteInformation($"Webhook not found. Performing add webhook with name = {name}, url = {url}");
                    V2.Webhook webhook = new V2.Webhook();
                    webhook.Enable = true;
                    webhook.Events = new List <V2.WebhookEvent>()
                    {
                        V2.WebhookEvent.CreateAuthTran,
                        V2.WebhookEvent.CreateAuthCaptureTran,
                    };
                    webhook.Name = name;
                    webhook.Url  = url;
                    processor.AddWebhook(webhook);
                }
            }
        private void ConvertCustomerPaymentMethod(CustomerPaymentMethod cpm, CCProcessingCenter newCCPC)
        {
            if (newCCPC == null)
            {
                throw new PXException(Messages.NotSetProcessingCenter);
            }
            if (!CCProcessingFeatureHelper.IsFeatureSupported(newCCPC, CCProcessingFeature.ProfileManagement))
            {
                throw new PXException(Messages.ProcessingCenterShouldTokenization);
            }
            PaymentMethodUpdater updaterGraph = PXGraph.CreateInstance <PaymentMethodUpdater>();

            updaterGraph.ConvertCustomerPaymentMethod(cpm, newCCPC);
        }
Beispiel #7
0
        private void SetAllowAcceptFormCheckbox(PXCache cache, CCProcessingCenter processingCenter)
        {
            bool enabled = false;

            if (CCProcessingFeatureHelper.IsFeatureSupported(processingCenter, CCProcessingFeature.PaymentHostedForm))
            {
                enabled = true;
            }

            PXUIFieldAttribute.SetEnabled <CCProcessingCenter.useAcceptPaymentForm>(cache, processingCenter, enabled);
            PXUIFieldAttribute.SetVisible <CCProcessingCenter.useAcceptPaymentForm>(cache, processingCenter, enabled);
            if (!enabled)
            {
                cache.SetValueExt <CCProcessingCenter.useAcceptPaymentForm>(processingCenter, enabled);
            }
        }
Beispiel #8
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);
                }
            }
        }
        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 CCProcessingCenter_ProcessingTypeName_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            CCProcessingCenter row = e.Row as CCProcessingCenter;

            if (row == null)
            {
                return;
            }
            bool isTokenized = CCProcessingFeatureHelper.IsFeatureSupported(row, CCProcessingFeature.ProfileManagement);
            bool isHF        = CCProcessingFeatureHelper.IsFeatureSupported(row, CCProcessingFeature.HostedForm);

            sender.SetValue <CCProcessingCenter.allowDirectInput>(row, isTokenized && !isHF);
            foreach (CCProcessingCenterDetail detail in Details.Select())
            {
                Details.Delete(detail);
            }
            this.ImportSettings();
        }
        public virtual IList <ISettingsDetail> ExportSettings(PXGraph callerGraph, string processingCenterID)
        {
            CCProcessingContext context = new CCProcessingContext()
            {
                callerGraph = callerGraph
            };
            CCProcessingCenter processingCenter = _repository.GetCCProcessingCenter(processingCenterID);

            CCProcessingFeatureHelper.CheckProcessing(processingCenter, CCProcessingFeature.Base, context);
            if (context.processingCenter == null)
            {
                throw new PXException(Messages.ERR_CCProcessingCenterNotFound);
            }
            var processor = GetProcessingWrapper(context);
            List <ISettingsDetail> processorSettings = new List <ISettingsDetail>();

            processor.ExportSettings(processorSettings);
            return(processorSettings);
        }
        protected virtual void Filter_NewCCProcessingCenterID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
        {
            Filter filter = e.Row as Filter;

            if (filter == null)
            {
                return;
            }
            if (!string.IsNullOrEmpty(filter.NewCCProcessingCenterID))
            {
                CCProcessingCenter procCenter = PXSelect <CCProcessingCenter,
                                                          Where <CCProcessingCenter.processingCenterID, Equal <Required <CCProcessingCenter.processingCenterID> > > > .Select(this, filter.NewCCProcessingCenterID);

                if (!CCProcessingFeatureHelper.IsFeatureSupported(procCenter, CCProcessingFeature.ProfileManagement))
                {
                    throw new PXSetPropertyException(Messages.ProcessingCenterShouldTokenization);
                }
            }
        }
        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);
                    }
                }
            }
        }
        public virtual bool TestCredentials(PXGraph callerGraph, string processingCenterID)
        {
            CCProcessingContext context = new CCProcessingContext()
            {
                callerGraph = callerGraph
            };
            CCProcessingCenter processingCenter = _repository.GetCCProcessingCenter(processingCenterID);

            CCProcessingFeatureHelper.CheckProcessing(processingCenter, CCProcessingFeature.Base, context);
            if (context.processingCenter == null)
            {
                throw new PXException(Messages.ERR_CCProcessingCenterNotFound);
            }
            var         processor   = GetProcessingWrapper(context);
            APIResponse apiResponse = new APIResponse();

            processor.TestCredentials(apiResponse);
            ProcessAPIResponse(apiResponse);
            return(apiResponse.isSucess);
        }
        protected virtual void CCProcessingCenter_CreateAdditionalCustomerProfile_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
        {
            CCProcessingCenter row = e.Row as CCProcessingCenter;

            if (row == null)
            {
                return;
            }
            if (!CCProcessingFeatureHelper.IsFeatureSupported(row, CCProcessingFeature.ExtendedProfileManagement))
            {
                string errorMessage = PXMessages.LocalizeFormatNoPrefixNLA(
                    AR.Messages.FeatureNotSupportedByProcessing,
                    CCProcessingFeature.ExtendedProfileManagement);
                throw new PXException(errorMessage);
            }
            if (row.CreateAdditionalCustomerProfiles == true && row.CreditCardLimit == null)
            {
                cache.SetDefaultExt <CCProcessingCenter.creditCardLimit>(row);
            }
        }
        public virtual void ValidateSettings(PXGraph callerGraph, string processingCenterID, ISettingsDetail settingDetail)
        {
            CCProcessingContext context = new CCProcessingContext()
            {
                callerGraph = callerGraph
            };
            CCProcessingCenter processingCenter = _repository.GetCCProcessingCenter(processingCenterID);

            CCProcessingFeatureHelper.CheckProcessing(processingCenter, CCProcessingFeature.Base, context);
            if (context.processingCenter == null)
            {
                throw new PXException(Messages.ERR_CCProcessingCenterNotFound);
            }
            var      processor = GetProcessingWrapper(context);
            CCErrors result    = processor.ValidateSettings(settingDetail);

            if (result.source != CCErrors.CCErrorSource.None)
            {
                throw new PXSetPropertyException(result.ErrorMessage, PXErrorLevel.Error);
            }
        }
Beispiel #17
0
        protected virtual bool IsFeatureSupported(string procCenterId, CCProcessingFeature feature)
        {
            bool ret = CCProcessingFeatureHelper.IsFeatureSupported(GetProcessingCenterById(procCenterId), CCProcessingFeature.PaymentHostedForm);

            return(ret);
        }
        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();
        }