public static IHostedPaymentFormProcessingWrapper GetPaymentFormProcessingWrapper(object pluginObject, ICardProcessingReadersProvider provider, CCProcessingContext context) { CCProcessingHelper.CheckHttpsConnection(); var isV1Interface = CCProcessingHelper.IsV1ProcessingInterface(pluginObject.GetType()); if (isV1Interface) { throw new PXException(Messages.TryingToUseNotSupportedPlugin); } var v2ProcessingInterface = CCProcessingHelper.IsV2ProcessingInterface(pluginObject); if (v2ProcessingInterface != null) { V2HostedFormProcessor wrapper = new V2HostedFormProcessor(v2ProcessingInterface); wrapper.ProcessingCenterId = context?.processingCenter.ProcessingCenterID; wrapper.CompanyName = context?.callerGraph.Accessinfo.CompanyName; ISetCardProcessingReadersProvider setProviderBehaviour = wrapper as ISetCardProcessingReadersProvider; if (setProviderBehaviour == null) { throw new PXException(NotLocalizableMessages.ERR_CardProcessingReadersProviderSetting); } setProviderBehaviour.SetProvider(provider); return(wrapper); } throw new PXException(V1.Messages.UnknownPluginType, pluginObject.GetType().Name); }
protected virtual IEnumerable loadCards(PXAdapter adapter) { CreditCardsFilter filter = Filter.Current; filter.EnableCustomerPaymentDialog = false; CCProcessingHelper.CheckHttpsConnection(); if (!ValidateLoadCardsAction()) { int rowCnt = CustomerCardPaymentData.Select().Count; if (rowCnt == 0 || !adapter.ExternalCall || Filter.Ask(CA.Messages.RelodCardDataDialogMsg, MessageButtons.YesNo) == WebDialogResult.Yes) { PXLongOperation.StartOperation(this, delegate { int newCardsCnt = GetCardsAllProfiles(); if (newCardsCnt > 0) { this.Persist(); } }); } } return(adapter.Get()); }
void ICustomerDataReader.ReadData(Dictionary <string, string> aData) { PXResult <Customer, CR.Address, CR.Contact> result = null; if (_customerID != 0) { result = (PXResult <Customer, CR.Address, CR.Contact>) PXSelectJoin <Customer, LeftJoin <CR.Address, On <CR.Address.addressID, Equal <Customer.defBillAddressID> >, LeftJoin <CR.Contact, On <CR.Contact.contactID, Equal <Customer.defBillContactID> > > >, Where <Customer.bAccountID, Equal <Required <Customer.bAccountID> > > > .Select(_graph, _customerID); } else if (!string.IsNullOrEmpty(_customerCD)) { result = (PXResult <Customer, CR.Address, CR.Contact>) PXSelectJoin <Customer, LeftJoin <CR.Address, On <CR.Address.addressID, Equal <Customer.defBillAddressID> >, LeftJoin <CR.Contact, On <CR.Contact.contactID, Equal <Customer.defBillContactID> > > >, Where <Customer.acctCD, Equal <Required <Customer.acctCD> > > > .Select(_graph, _customerCD); } PXResult <CustomerPaymentMethod> pmResult = PXSelect <CustomerPaymentMethod, Where <CustomerPaymentMethod.pMInstanceID, Equal <Required <CustomerPaymentMethod.pMInstanceID> > > > .Select(_graph, _pminstanceID); if (result != null) { CustomerPaymentMethod customerPaymentMethod = pmResult; Customer customer = result; Address billAddress = null; Address address = PXSelect <Address, Where <Address.addressID, Equal <Required <Address.addressID> > > > .Select(_graph, customerPaymentMethod.BillAddressID); billAddress = address ?? result; Contact billContact = null; Contact contact = PXSelect <Contact, Where <CR.Contact.contactID, Equal <Required <Contact.contactID> > > > .Select(_graph, customerPaymentMethod.BillContactID); billContact = contact ?? result; aData[key_CustomerCD] = (_prefixForCustomerCD ?? String.Empty) + (customer.AcctCD ?? String.Empty); aData[key_CustomerName] = customer.AcctName; if (pmResult != null && !string.IsNullOrEmpty(((CustomerPaymentMethod)pmResult).CustomerCCPID)) { aData[Key_Customer_CCProcessingID] = ((CustomerPaymentMethod)pmResult).CustomerCCPID; } aData[key_Country] = billAddress?.CountryID; aData[key_State] = billAddress?.State; aData[key_City] = billAddress?.City; aData[key_Address] = CCProcessingHelper.ExtractStreetAddress(billAddress); aData[key_PostalCode] = billAddress?.PostalCode; aData[key_Customer_FirstName] = billContact?.FirstName; aData[key_Customer_LastName] = billContact?.LastName; aData[key_Phone] = billContact?.Phone1; aData[key_Fax] = billContact?.Fax; aData[key_Email] = billContact?.EMail; } }
protected virtual void CCProcessingCenter_RowSelecting(PXCache sender, PXRowSelectingEventArgs e) { CCProcessingCenter row = e.Row as CCProcessingCenter; if (row == null) { return; } row.NeedsExpDateUpdate = CCProcessingHelper.CCProcessingCenterNeedsExpDateUpdate(this, row); }
private PXResultset <CCSynchronizeCard> GetSyncCardsByProcCenter(string procCenterId) { CCProcessingHelper.CheckHttpsConnection(); PXSelectBase <CCSynchronizeCard> select = new PXSelect <CCSynchronizeCard, Where <CCSynchronizeCard.cCProcessingCenterID, Equal <Required <CCSynchronizeCard.cCProcessingCenterID> >, And <CCSynchronizeCard.imported, Equal <False> > > >(this); PXResultset <CCSynchronizeCard> result = select.Select(procCenterId); return(result); }
public static void GetCreatePaymentProfileForm(PXGraph graph, ICCPaymentProfileAdapter paymentProfileAdapter) { if (graph == null || paymentProfileAdapter == null) { return; } ICCPaymentProfile ccPaymentProfile = paymentProfileAdapter.Current; PXCache cache = paymentProfileAdapter.Cache; ProcessingCardsPluginFactory pluginFactory = GetProcessingCardsPluginFactory(ccPaymentProfile.CCProcessingCenterID); CCCustomerInformationManager cim = GetCustomerInformationManager(pluginFactory); CCProcessingContext context = new CCProcessingContext() { processingCenter = pluginFactory.GetProcessingCenter(), aCustomerID = ccPaymentProfile.BAccountID, aPMInstanceID = ccPaymentProfile.PMInstanceID, callerGraph = graph }; CardProcessingReadersProvider readersProvider = new CardProcessingReadersProvider(context); cim.SetReadersProvider(readersProvider); string id = ccPaymentProfile.CustomerCCPID; if (id == null) { id = cim.CreateCustomerProfile(); ICCPaymentProfile cpm = cache.CreateCopy(ccPaymentProfile) as ICCPaymentProfile; cpm.CustomerCCPID = id; cache.Update(cpm); } var processingCenter = pluginFactory.GetProcessingCenter(); if (processingCenter.CreateAdditionalCustomerProfiles == true) { int customerProfileCount = CCProcessingHelper.CustomerProfileCountPerCustomer(graph, ccPaymentProfile.BAccountID, ccPaymentProfile.CCProcessingCenterID); // Total customer profile count per customer var cardLimit = processingCenter.CreditCardLimit; if (cardLimit != null && cardLimit > 0) { int allPaymentProfileCount = cim.GetAllPaymentProfiles().Count(); if (CCProcessingHelper.IsCreditCardCountEnough(allPaymentProfileCount, cardLimit.Value)) { context.PrefixForCustomerCD = CCProcessingHelper.BuildPrefixForCustomerCD(customerProfileCount, processingCenter); id = cim.CreateCustomerProfile(); ICCPaymentProfile cpm = cache.CreateCopy(ccPaymentProfile) as ICCPaymentProfile; cpm.CustomerCCPID = id; cache.Update(cpm); } } } cim.GetCreatePaymentProfileForm(); }
public static void GetCreatePaymentProfileForm <TPaymentMethodType>(PXGraph graph, PXSelectBase <TPaymentMethodType> customerPaymentMethodView, TPaymentMethodType currentCustomerPaymentMethod) where TPaymentMethodType : CustomerPaymentMethod, new() { if (graph == null || customerPaymentMethodView == null || currentCustomerPaymentMethod == null) { return; } CCCustomerInformationManager cim = new CCCustomerInformationManager(currentCustomerPaymentMethod.CCProcessingCenterID, CCProcessingFeature.HostedForm) { CustomerID = currentCustomerPaymentMethod.BAccountID, PMInstanceID = currentCustomerPaymentMethod.PMInstanceID, CallerGraph = graph }; string id = currentCustomerPaymentMethod.CustomerCCPID; if (currentCustomerPaymentMethod.CustomerCCPID == null) { id = cim.CreateCustomerProfile(); TPaymentMethodType cpm = (TPaymentMethodType)customerPaymentMethodView.Cache.CreateCopy(currentCustomerPaymentMethod); cpm.CustomerCCPID = id; customerPaymentMethodView.Update(cpm); } var processingCenter = cim._context.processingCenter; if (processingCenter.CreateAdditionalCustomerProfiles == true) { int customerProfileCount = CCProcessingHelper.CustomerProfileCountPerCustomer(graph, currentCustomerPaymentMethod.BAccountID, currentCustomerPaymentMethod.CCProcessingCenterID); // Total customer profile count per customer var cardLimit = processingCenter.CreditCardLimit; if (cardLimit != null && cardLimit > 0) { int allPaymentProfileCount = cim.GetAllPaymentProfiles().Count(); if (CCProcessingHelper.IsCreditCardCountEnough(allPaymentProfileCount, cardLimit.Value)) { cim.PrefixForCustomerCD = CCProcessingHelper.BuildPrefixForCustomerCD(customerProfileCount, processingCenter); id = cim.CreateCustomerProfile(); TPaymentMethodType cpm = (TPaymentMethodType)customerPaymentMethodView.Cache.CreateCopy(currentCustomerPaymentMethod); cpm.CustomerCCPID = id; customerPaymentMethodView.Update(cpm); } } } cim.GetCreatePaymentProfileForm(); }
private static ICardTransactionProcessingWrapper GetTransactionProcessingWrapper(object pluginObject) { bool isV1Interface = CCProcessingHelper.IsV1ProcessingInterface(pluginObject.GetType()); if (isV1Interface) { throw new PXException(Messages.TryingToUseNotSupportedPlugin); } var v2ProcessingInterface = CCProcessingHelper.IsV2ProcessingInterface(pluginObject); if (v2ProcessingInterface != null) { return(new V2CardTransactionProcessor(v2ProcessingInterface)); } throw new PXException(V1.Messages.UnknownPluginType, pluginObject.GetType().Name); }
private static IExtendedProfileProcessingWrapper GetExtendedProfileProcessingWrapper(object pluginObject) { CCProcessingHelper.CheckHttpsConnection(); bool isV1Interface = CCProcessingHelper.IsV1ProcessingInterface(pluginObject.GetType()); if (isV1Interface) { throw new PXException(Messages.TryingToUseNotSupportedPlugin); } var v2ProcessingInterface = CCProcessingHelper.IsV2ProcessingInterface(pluginObject); if (v2ProcessingInterface != null) { return(new V2ExtendedProfileProcessor(v2ProcessingInterface)); } throw new PXException(V1.Messages.UnknownPluginType, pluginObject.GetType().Name); }
public virtual IEnumerable SyncCCPaymentMethods(PXAdapter adapter) { string methodName = GetClassMethodName(); PXTrace.WriteInformation($"{methodName} started."); CustomerPaymentMethod currentPaymentMethod = CustomerPaymentMethod.Current; PXTrace.WriteInformation($"{methodName}. CCProcessingCenterID:{currentPaymentMethod.CCProcessingCenterID}; UserName:{this.Base.Accessinfo.UserName}"); IEnumerable ret = adapter.Get(); bool isCancel = false; System.Web.HttpRequest request = System.Web.HttpContext.Current.Request; var cancelStr = request.Form.Get("__CLOSECCHFORM"); bool.TryParse(cancelStr, out isCancel); if (isCancel) { return(ret); } if (currentPaymentMethod.CCProcessingCenterID == null) { CustomerPaymentMethod.Cache.SetDefaultExt <CustomerPaymentMethod.cCProcessingCenterID>(currentPaymentMethod); CustomerPaymentMethod.Cache.SetDefaultExt <CustomerPaymentMethod.customerCCPID>(currentPaymentMethod); } var graph = PXGraph.CreateInstance <CCCustomerInformationManagerGraph>(); ICCPaymentProfileAdapter paymentProfile = new GenericCCPaymentProfileAdapter <CustomerPaymentMethod>(CustomerPaymentMethod); ICCPaymentProfileDetailAdapter profileDetail = new GenericCCPaymentProfileDetailAdapter <CustomerPaymentMethodDetail, PaymentMethodDetail>(CustomerPaymentMethodDetail, PaymentMethodDetail); bool isIDFilled = CCProcessingHelper.IsCCPIDFilled(this.Base, CustomerPaymentMethod.Current.PMInstanceID); if (!isIDFilled) { graph.GetNewPaymentProfiles(this.Base, paymentProfile, profileDetail); } else { graph.GetPaymentProfile(this.Base, paymentProfile, profileDetail); } this.Base.Persist(); return(ret); }
public virtual void Persist(Action @base) { bool isCPMDeleting = CustomerPaymentMethod.Cache.Deleted.Count() != 0; bool isDetailsInserting = CustomerPaymentMethodDetail.Cache.Inserted.Count() != 0; var graph = PXGraph.CreateInstance <CCCustomerInformationManagerGraph>(); ICCPaymentProfileAdapter paymentProfile = new GenericCCPaymentProfileAdapter <CustomerPaymentMethod>(CustomerPaymentMethod); ICCPaymentProfileDetailAdapter paymentProfileDetail = new GenericCCPaymentProfileDetailAdapter <CustomerPaymentMethodDetail, PaymentMethodDetail>(CustomerPaymentMethodDetail, PaymentMethodDetail); if (!isCPMDeleting && isDetailsInserting && !string.IsNullOrEmpty(CustomerPaymentMethod.Current.CCProcessingCenterID) && CCProcessingHelper.IsTokenizedPaymentMethod(this.Base, CustomerPaymentMethod.Current.PMInstanceID, true)) { graph.GetOrCreatePaymentProfile(this.Base, paymentProfile, paymentProfileDetail); } //assuming only one record can be deleted from promary view of this graph at a time else if (isCPMDeleting && CCProcessingHelper.IsTokenizedPaymentMethod(this.Base, null, true)) { graph.DeletePaymentProfile(this.Base, paymentProfile, paymentProfileDetail); } @base(); }
public virtual void ARExpiredCardFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { ARExpiredCardFilter row = e.Row as ARExpiredCardFilter; if (row == null) { return; } PXUIFieldAttribute.SetEnabled <CustomerPaymentMethod.selected>(this.Cards.Cache, null, true); if (row.TokenizedPMs == null) { string pmString = CCProcessingHelper.GetTokenizedPMsString(this); sender.SetValue <ARExpiredCardFilter.tokenizedPMs>(row, pmString); } else { if (row.TokenizedPMs != String.Empty) { Filter.Cache.RaiseExceptionHandling <ARExpiredCardFilter.customerClassID>(e.Row, ((ARExpiredCardFilter)e.Row).CustomerClassID, new PXSetPropertyException(Messages.NotAllCardsShown, PXErrorLevel.Warning, row.TokenizedPMs)); } } }
public static void DeletePaymentProfile(PXGraph graph, PXSelectBase <CustomerPaymentMethod> customerPaymentMethodView, PXSelectBase <CustomerPaymentMethodDetail> detailsView) { IEnumerator cpmEnumerator = customerPaymentMethodView.Cache.Deleted.GetEnumerator(); if (cpmEnumerator.MoveNext()) { CustomerPaymentMethod current = (CustomerPaymentMethod)cpmEnumerator.Current; CCProcessingCenter processingCenter = CCProcessingHelper.GetProcessingCenter(graph, current.CCProcessingCenterID); if (!string.IsNullOrEmpty(current.CCProcessingCenterID) && processingCenter.SyncronizeDeletion == true) { CCCustomerInformationManager cim = new CCCustomerInformationManager(current.CCProcessingCenterID, CCProcessingFeature.ProfileManagement) { CustomerID = current.BAccountID, PMInstanceID = current.PMInstanceID }; cim.CallerGraph = cim.ReadingGraph; 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.DeletePaymentProfile(); } } } }
public static void GetOrCreatePaymentProfile <TPaymentMethodType, TDetialsType>(PXGraph graph , PXSelectBase <TPaymentMethodType> customerPaymentMethodView , PXSelectBase <TDetialsType> detailsView) where TPaymentMethodType : CustomerPaymentMethod, new() where TDetialsType : CustomerPaymentMethodDetail, new() { bool isHF = CCProcessingHelper.IsHFPaymentMethod(graph, customerPaymentMethodView.Current.PMInstanceID); bool isConverting = customerPaymentMethodView.Current.Selected == true; isHF = isHF && !isConverting; TDetialsType CCPIDDet = null; bool isIDFilled = false; bool isOtherDetsFilled = false; foreach (PXResult <TDetialsType, PaymentMethodDetail> det in detailsView.Select()) { TDetialsType cpmd = det; PaymentMethodDetail cmd = det; if (cmd.IsCCProcessingID == true) { isIDFilled = cpmd.Value != null; CCPIDDet = (TDetialsType)detailsView.Cache.CreateCopy(cpmd); } else { isOtherDetsFilled = cpmd.Value != null || isOtherDetsFilled; } } if (CCPIDDet == null) { //something's very wrong throw new PXException(Messages.NOCCPID, customerPaymentMethodView.Current.Descr); } if (isIDFilled && isOtherDetsFilled) { return; } if ((isIDFilled || isOtherDetsFilled) && !isHF || isIDFilled && !isOtherDetsFilled) { CCCustomerInformationManager cim = new CCCustomerInformationManager(customerPaymentMethodView.Current.CCProcessingCenterID, CCProcessingFeature.ProfileManagement) { CustomerID = customerPaymentMethodView.Current.BAccountID, PMInstanceID = customerPaymentMethodView.Current.PMInstanceID, CallerGraph = graph, String2DateConverter = s => CustomerPaymentMethodMaint.ParseExpiryDate(graph, customerPaymentMethodView.Current, s), }; var currentCustomerPaymentMethod = customerPaymentMethodView.Current; string id = currentCustomerPaymentMethod.CustomerCCPID; if (currentCustomerPaymentMethod.CustomerCCPID == null) { id = cim.CreateCustomerProfile(); TPaymentMethodType cpm = (TPaymentMethodType)customerPaymentMethodView.Cache.CreateCopy(currentCustomerPaymentMethod); cpm.CustomerCCPID = id; customerPaymentMethodView.Update(cpm); } var processingCenter = cim._context.processingCenter; if (processingCenter.CreateAdditionalCustomerProfiles == true) { int customerProfileCount = CCProcessingHelper.CustomerProfileCountPerCustomer(graph, currentCustomerPaymentMethod.BAccountID, currentCustomerPaymentMethod.CCProcessingCenterID); // Total customer profile count per customer var cardLimit = processingCenter.CreditCardLimit; if (cardLimit != null && cardLimit > 0) { int allPaymentProfileCount = cim.GetAllPaymentProfiles().Count(); if (CCProcessingHelper.IsCreditCardCountEnough(allPaymentProfileCount, cardLimit.Value)) { cim.PrefixForCustomerCD = CCProcessingHelper.BuildPrefixForCustomerCD(customerProfileCount, processingCenter); id = cim.CreateCustomerProfile(); TPaymentMethodType cpm = (TPaymentMethodType)customerPaymentMethodView.Cache.CreateCopy(currentCustomerPaymentMethod); cpm.CustomerCCPID = id; customerPaymentMethodView.Update(cpm); } } } if (isOtherDetsFilled) { string newPMId = cim.CreatePaymentProfile(); CCPIDDet.Value = newPMId; CCPIDDet = detailsView.Update(CCPIDDet); } CreditCardData cardData = cim.GetPaymentProfile(); if (cardData != null && !string.IsNullOrEmpty(cardData.PaymentProfileID)) { foreach (PXResult <TDetialsType, PaymentMethodDetail> det in detailsView.Select()) { TDetialsType cpmd = det; PaymentMethodDetail pmd = (PaymentMethodDetail)det; if (cpmd.DetailID == CCPIDDet.DetailID) { continue; } string detailValue = null; if (pmd.IsCCProcessingID != true && pmd.IsIdentifier == true && !string.IsNullOrEmpty(cardData.CardNumber)) { detailValue = cardData.CardNumber; } TDetialsType newcpmd = (TDetialsType)detailsView.Cache.CreateCopy(cpmd); newcpmd.Value = detailValue; detailsView.Update(newcpmd); } if (cardData.CardExpirationDate != null) { TPaymentMethodType cpm = (TPaymentMethodType)customerPaymentMethodView.Cache.CreateCopy(customerPaymentMethodView.Current); customerPaymentMethodView.Cache.SetValueExt <CustomerPaymentMethod.expirationDate>(cpm, cardData.CardExpirationDate); customerPaymentMethodView.Update(cpm); } } else { throw new PXException(Messages.CouldntGetPMIDetails, customerPaymentMethodView.Current.Descr); } } }
public static TranProfile GetOrCreatePaymentProfileByTran(PXGraph graph, ICCPaymentProfileAdapter adapter, string tranId) { ICCPaymentProfile paymentProfile = adapter.Current; ProcessingCardsPluginFactory pluginFactory = GetProcessingCardsPluginFactory(paymentProfile.CCProcessingCenterID); CCProcessingCenter processingCenter = pluginFactory.GetProcessingCenter(); CCCustomerInformationManager cim = GetCustomerInformationManager(pluginFactory); CardProcessingReadersProvider readersProvider = new CardProcessingReadersProvider(new CCProcessingContext() { processingCenter = processingCenter, aCustomerID = paymentProfile.BAccountID, aPMInstanceID = paymentProfile.PMInstanceID, callerGraph = graph }); cim.SetReadersProvider(readersProvider); Customer customer = new PXSelect <Customer, Where <Customer.bAccountID, Equal <Required <Customer.bAccountID> > > >(graph).Select(paymentProfile.BAccountID); TranProfile ret = null; if (paymentProfile.CustomerCCPID == null) { ret = cim.GetOrCreateCustomerProfileFromTransaction(tranId, new CreateTranPaymentProfileParams() { LocalCustomerId = customer.AcctCD }); return(ret); } var cardLimit = processingCenter.CreditCardLimit; if (processingCenter.CreateAdditionalCustomerProfiles == true && cardLimit != null && cardLimit > 0) { int customerProfileCount = CCProcessingHelper.CustomerProfileCountPerCustomer(graph, paymentProfile.BAccountID, paymentProfile.CCProcessingCenterID); int allPaymentProfileCount = cim.GetAllPaymentProfiles().Count(); if (CCProcessingHelper.IsCreditCardCountEnough(allPaymentProfileCount, cardLimit.Value)) { var prefix = CCProcessingHelper.BuildPrefixForCustomerCD(customerProfileCount, processingCenter); ret = cim.GetOrCreateCustomerProfileFromTransaction(tranId, new CreateTranPaymentProfileParams() { LocalCustomerId = prefix + customer.AcctCD }); } else { ret = cim.GetOrCreateCustomerProfileFromTransaction(tranId, new CreateTranPaymentProfileParams() { PCCustomerId = paymentProfile.CustomerCCPID }); } } else { ret = cim.GetOrCreateCustomerProfileFromTransaction(tranId, new CreateTranPaymentProfileParams() { PCCustomerId = paymentProfile.CustomerCCPID }); } return(ret); }
public static void GetOrCreatePaymentProfile(PXGraph graph , ICCPaymentProfileAdapter payment , ICCPaymentProfileDetailAdapter paymentDetail) { ICCPaymentProfile paymentProfile = payment.Current; bool isHF = CCProcessingHelper.IsHFPaymentMethod(graph, payment.Current.PMInstanceID); bool isConverting = false; if (paymentProfile is CustomerPaymentMethod) { isConverting = ((CustomerPaymentMethod)paymentProfile).Selected == true; } isHF = isHF && !isConverting; ICCPaymentProfileDetail CCPIDDet = null; bool isIDFilled = false; bool isOtherDetsFilled = false; foreach (Tuple <ICCPaymentProfileDetail, ICCPaymentMethodDetail> det in paymentDetail.Select()) { ICCPaymentProfileDetail ppd = det.Item1; ICCPaymentMethodDetail pmd = det.Item2; if (pmd.IsCCProcessingID == true) { isIDFilled = ppd.Value != null; CCPIDDet = ppd; } else { isOtherDetsFilled = ppd.Value != null || isOtherDetsFilled; } } if (CCPIDDet == null) { //something's very wrong throw new PXException(Messages.NOCCPID, payment.Current.Descr); } if (isIDFilled && isOtherDetsFilled) { return; } bool tryGetProfile = isIDFilled && !isOtherDetsFilled; if ((isIDFilled || isOtherDetsFilled) && !isHF || tryGetProfile) { var currCpm = payment.Current; ProcessingCardsPluginFactory pluginFactory = GetProcessingCardsPluginFactory(currCpm.CCProcessingCenterID); CCCustomerInformationManager cim = GetCustomerInformationManager(pluginFactory); CCProcessingCenter processingCenter = pluginFactory.GetProcessingCenter(); CCProcessingContext context = new CCProcessingContext() { processingCenter = pluginFactory.GetProcessingCenter(), aCustomerID = currCpm.BAccountID, aPMInstanceID = currCpm.PMInstanceID, callerGraph = graph, expirationDateConverter = s => CustomerPaymentMethodMaint.ParseExpiryDate(graph, currCpm, s) }; CardProcessingReadersProvider readersProvider = new CardProcessingReadersProvider(context); cim.SetReadersProvider(readersProvider); string id = currCpm.CustomerCCPID; if (currCpm.CustomerCCPID == null) { id = cim.CreateCustomerProfile(); paymentProfile.CustomerCCPID = id; payment.Cache.Update(paymentProfile); } if (processingCenter.CreateAdditionalCustomerProfiles == true && !tryGetProfile) { int customerProfileCount = CCProcessingHelper.CustomerProfileCountPerCustomer(graph, currCpm.BAccountID, currCpm.CCProcessingCenterID); // Total customer profile count per customer var cardLimit = processingCenter.CreditCardLimit; if (cardLimit != null && cardLimit > 0) { int allPaymentProfileCount = cim.GetAllPaymentProfiles().Count(); if (CCProcessingHelper.IsCreditCardCountEnough(allPaymentProfileCount, cardLimit.Value)) { context.PrefixForCustomerCD = CCProcessingHelper.BuildPrefixForCustomerCD(customerProfileCount, processingCenter); id = cim.CreateCustomerProfile(); paymentProfile.CustomerCCPID = id; payment.Cache.Update(paymentProfile); } } } if (isOtherDetsFilled) { string newPMId = cim.CreatePaymentProfile(); CCPIDDet.Value = newPMId; CCPIDDet = paymentDetail.Cache.Update(CCPIDDet) as ICCPaymentProfileDetail; } CreditCardData cardData = cim.GetPaymentProfile(); if (cardData != null && !string.IsNullOrEmpty(cardData.PaymentProfileID)) { foreach (Tuple <ICCPaymentProfileDetail, ICCPaymentMethodDetail> det in paymentDetail.Select()) { ICCPaymentProfileDetail ppd = det.Item1; ICCPaymentMethodDetail pmd = det.Item2; if (ppd.DetailID == CCPIDDet.DetailID) { continue; } string detailValue = null; if (pmd.IsCCProcessingID != true && pmd.IsIdentifier == true && !string.IsNullOrEmpty(cardData.CardNumber)) { detailValue = cardData.CardNumber; } ppd.Value = detailValue; paymentDetail.Cache.Update(ppd); } if (cardData.CardExpirationDate != null) { payment.Cache.SetValueExt(paymentProfile, nameof(paymentProfile.ExpirationDate), cardData.CardExpirationDate); payment.Cache.Update(paymentProfile); } } else { throw new PXException(Messages.CouldntGetPMIDetails, payment.Current.Descr); } } }