public static void DoDateUpdateProcess(CustomerPaymentMethod cpm) { CustomerPaymentMethodMaint cpmGraph = PXGraph.CreateInstance <CustomerPaymentMethodMaint>(); cpmGraph.CustomerPaymentMethod.Current = cpm; CCCustomerInformationManager.SyncExistingPMI(cpmGraph, cpmGraph.CustomerPaymentMethod, cpmGraph.DetailsAll); cpm.ExpirationDate = cpmGraph.CustomerPaymentMethod.Current.ExpirationDate; if (cpm.ExpirationDate == null) { string formatString = CCProcessingUtils.GetExpirationDateFormat(cpmGraph, cpm.CCProcessingCenterID); string responseString = null; foreach (PXResult <CustomerPaymentMethodDetail, PaymentMethodDetail> details in cpmGraph.DetailsAll.Select()) { PaymentMethodDetail pmDetail = details; CustomerPaymentMethodDetail cpmDetail = details; if (pmDetail.IsExpirationDate == true) { responseString = cpmDetail.Value; break; } } throw new PXException(Messages.ExpDateParseFailed, InterfaceConstants.ExpDateFormatDesc, responseString, formatString); } cpmGraph.Save.Press(); }
private bool CheckCardIsExpired(CustomerPaymentMethod cpm, out DateTime expiredDate) { expiredDate = DateTime.MinValue; bool ret = false; if (cpm.ExpirationDate != null) { DateTime dt = DateTime.Now.Date; if (cpm.ExpirationDate <= dt) { expiredDate = cpm.ExpirationDate.Value; ret = true; } } else { string expDateDetailId = CustomerPMDetails.Select().RowCast<PaymentMethodDetail>() .Where(i => i.IsExpirationDate == true).Select(i => i.DetailID).FirstOrDefault(); string expDateStr = CustomerPMDetails.Select().RowCast<CustomerPaymentMethodDetail>() .Where(i => i.DetailID == expDateDetailId).Select(i => i.Value).FirstOrDefault(); if (expDateStr != null) { DateTime? expDate = CustomerPaymentMethodMaint.ParseExpiryDate(this, cpm.CCProcessingCenterID, expDateStr); if (expDate != null) { expDate = expDate.Value.AddMonths(1); if (expDate <= DateTime.Now.Date) { expiredDate = expDate.Value; ret = true; } } } } return ret; }
public virtual void ARExpiredCardFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { PXUIFieldAttribute.SetEnabled <CustomerPaymentMethod.selected>(this.Cards.Cache, null, true); string pmString = CustomerPaymentMethodMaint.GetTokenizedPMsString(this); if (!String.IsNullOrWhiteSpace(pmString)) { Filter.Cache.RaiseExceptionHandling <ARExpiredCardFilter.customerClassID>(e.Row, ((ARExpiredCardFilter)e.Row).CustomerClassID, new PXSetPropertyException(Messages.NotAllCardsShown, PXErrorLevel.Warning, pmString)); } }
public static SOOrder GetSOOrder(SOOrderEntry orderGraph, KCAPIOrder order, SOOrder acumaticaOrder, int?branchID, bool FBA) { KCSiteMasterMaint graph = PXGraph.CreateInstance <KCSiteMasterMaint>(); var customer = KCGeneralDataHelper.GetCustomerByCAOrder(graph, order); var paymentmethod = KCGeneralDataHelper.GetPaymenthMethodId(graph, order); var mapper = new KCDynamicOrderMapper(KCMappingEntitiesConstants.Order); var conversionGraph = PXGraph.CreateInstance <KCOrderConversionDataMaint>(); mapper.Mapping.MappingValues = conversionGraph.GetEntity(); mapper.MapOrder(acumaticaOrder, order); if (paymentmethod == null) { KCPaymentMethodsMappingMaint paymentMethodMappingGraph = PXGraph.CreateInstance <KCPaymentMethodsMappingMaint>(); CustomerPaymentMethodMaint paymentMethodGraph = PXGraph.CreateInstance <CustomerPaymentMethodMaint>(); try { KCGeneralDataHelper.CreatePaymentMethod(paymentMethodGraph, paymentMethodMappingGraph, customer.BAccountID, order); paymentmethod = KCGeneralDataHelper.GetPaymenthMethodId(graph, order); } catch { } } acumaticaOrder.CustomerID = customer.BAccountID; acumaticaOrder.PMInstanceID = paymentmethod?.PMInstanceID; acumaticaOrder.Status = SOOrderStatus.Open; acumaticaOrder.CreatePMInstance = true; KCSOOrderEntryExt orderext = orderGraph.GetExtension <KCSOOrderEntryExt>(); string orderType = new KCMarketplaceHelper().GetOrderType(order, orderGraph); acumaticaOrder.OrderType = orderType ?? acumaticaOrder.OrderType; if (order.EstimatedShipDateUtc == null) { acumaticaOrder.RequestDate = acumaticaOrder.OrderDate; } orderGraph.CurrentDocument.Current = acumaticaOrder; PXNoteAttribute.SetNote(orderGraph.CurrentDocument.Cache, orderGraph.CurrentDocument.Current, order.PrivateNotes); string firstName = orderext.AccountCD.SelectSingle(acumaticaOrder.CustomerID).AcctName; bool isFBAFirstName = firstName.Contains("FBA"); KCSOOrderExt orderExt = acumaticaOrder.GetExtension <KCSOOrderExt>(); orderExt = mapper.MapOrderCaExt(orderExt, order); orderExt.UsrKCSyncDate = DateTime.Now; orderExt.UsrKCSiteName += FBA ? "/FBA" : "/Non-FBA"; if ((FBA && orderExt.UsrKCSiteName.Contains("Amazon")) || isFBAFirstName) { acumaticaOrder.Status = KCCheckoutStatus.CCompleted; } return(acumaticaOrder); }
public static void DoDateUpdateProcess(CustomerPaymentMethod cpm) { CustomerPaymentMethodMaint cpmGraph = PXGraph.CreateInstance <CustomerPaymentMethodMaint>(); cpmGraph.CustomerPaymentMethod.Current = cpm; var graph = PXGraph.CreateInstance <CCCustomerInformationManagerGraph>(); graph.GetPaymentProfile(cpmGraph, cpmGraph.CustomerPaymentMethod, cpmGraph.DetailsAll); if (cpmGraph.CustomerPaymentMethod.Current.ExpirationDate == null) { throw new PXException(Messages.ExpDateRetrievalFailed); } cpmGraph.Save.Press(); }
public virtual IEnumerable ViewPaymentMethod(PXAdapter adapter) { if (this.Cards.Current != null) { CustomerPaymentMethod payMethod = PXSelect <CustomerPaymentMethod, Where <CustomerPaymentMethod.pMInstanceID, Equal <Required <CustomerPaymentMethod.pMInstanceID> > > > .Select(this, this.Cards.Current.PMInstanceID); CustomerPaymentMethodMaint graph = PXGraph.CreateInstance <CustomerPaymentMethodMaint>(); graph.CustomerPaymentMethod.Current = payMethod; throw new PXPopupRedirectException(graph, Messages.ViewPaymentMethod, true); } return(adapter.Get()); }
protected virtual void RecalcRow(CCTransactionsHistoryFilter aRow) { if (!string.IsNullOrEmpty(aRow.PaymentMethodID)) { PaymentMethodDetail def = PXSelect <PaymentMethodDetail, Where <PaymentMethodDetail.paymentMethodID, Equal <Optional <CCTransactionsHistoryFilter.paymentMethodID> >, And <PaymentMethodDetail.useFor, Equal <PaymentMethodDetailUsage.useForARCards>, And <PaymentMethodDetail.isIdentifier, Equal <True> > > > > .Select(this, aRow.PaymentMethodID); if (def != null) { aRow.MaskedCardNumber = CustomerPaymentMethodMaint.FormatDescription(aRow.PaymentMethodID, CustomerPaymentMethodMaint.IDObfuscator.RestoreToMasked(aRow.PartialCardNumber, def.DisplayMask, SqlDialect.WildcardAnySingle, false)); } } }
public virtual IEnumerable viewPaymentMethod(PXAdapter adapter) { if (this.CCTrans.Current != null) { CustomerPaymentMethod payMethod = PXSelect <CustomerPaymentMethod, Where <CustomerPaymentMethod.pMInstanceID, Equal <Required <CustomerPaymentMethod.pMInstanceID> > > > .Select(this, this.CCTrans.Current.PMInstanceID); CustomerPaymentMethodMaint graph = PXGraph.CreateInstance <CustomerPaymentMethodMaint>(); graph.CustomerPaymentMethod.Current = payMethod; throw new PXRedirectRequiredException(graph, true, Messages.ViewPaymentMethod) { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } return(adapter.Get()); }
public static void DoDateUpdateProcess(CustomerPaymentMethod cpm) { CustomerPaymentMethodMaint cpmGraph = PXGraph.CreateInstance <CustomerPaymentMethodMaint>(); cpmGraph.CustomerPaymentMethod.Current = cpm; var graph = PXGraph.CreateInstance <CCCustomerInformationManagerGraph>(); ICCPaymentProfileAdapter paymentProfile = new GenericCCPaymentProfileAdapter <CustomerPaymentMethod>(cpmGraph.CustomerPaymentMethod); ICCPaymentProfileDetailAdapter profileDetail = new GenericCCPaymentProfileDetailAdapter <CustomerPaymentMethodDetail, PaymentMethodDetail>(cpmGraph.DetailsAll, cpmGraph.PMDetails); graph.GetPaymentProfile(cpmGraph, paymentProfile, profileDetail); if (cpmGraph.CustomerPaymentMethod.Current.ExpirationDate == null) { throw new PXException(Messages.ExpDateRetrievalFailed); } cpmGraph.Save.Press(); }
public virtual IEnumerable ViewCreditCard(PXAdapter adapter) { if (this.PaymentTrans.Current != null) { CCProcTran row = this.PaymentTrans.Current; CustomerPaymentMethod pmInstance = PXSelect <CustomerPaymentMethod, Where <CustomerPaymentMethod.pMInstanceID, Equal <Required <CustomerPaymentMethod.pMInstanceID> > > > .Select(this, row.PMInstanceID); CustomerPaymentMethodMaint graph = PXGraph.CreateInstance <CustomerPaymentMethodMaint>(); graph.CustomerPaymentMethod.Current = graph.CustomerPaymentMethod.Search <CustomerPaymentMethod.pMInstanceID>(pmInstance.PMInstanceID, pmInstance.BAccountID); if (graph.CustomerPaymentMethod.Current != null) { throw new PXRedirectRequiredException(graph, true, Messages.ViewDocument) { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } } return(Filter.Select()); }
public static void SyncPaymentMethodsHF <TPaymentMethodType, TDetialsType>(PXGraph graph, PXSelectBase <TPaymentMethodType> customerPaymentMethodView, PXSelectBase <TDetialsType> detailsView, TPaymentMethodType currentCustomerPaymentMethod) where TPaymentMethodType : CustomerPaymentMethod, new() where TDetialsType : CustomerPaymentMethodDetail, new() { if (graph == null || customerPaymentMethodView == null || detailsView == null || currentCustomerPaymentMethod == null) { return; } CCCustomerInformationManager cim = new CCCustomerInformationManager(currentCustomerPaymentMethod.CCProcessingCenterID, CCProcessingFeature.HostedForm, new ProcessingContext() { aCustomerID = currentCustomerPaymentMethod.BAccountID, aPMInstanceID = currentCustomerPaymentMethod.PMInstanceID, callerGraph = graph }); int attempt = 1; string newPMID = string.Empty; //AuthorizeNet sometimes failes to process new card in time when using Hosted Form Method while ((attempt <= (cim.Context.processingCenter.SyncRetryAttemptsNo ?? 0) + 1) && string.IsNullOrEmpty(newPMID)) { Thread.Sleep(cim.Context.processingCenter.SyncRetryDelayMs ?? 0); SyncPMResponse syncResponse = cim.SynchronizePaymentMethods(); TPaymentMethodType customerPaymentMethod = customerPaymentMethodView.Current; if (syncResponse.PMList != null && syncResponse.PMList.Count > 0) { var sortedPMDict = new SortedDictionary <string, Dictionary <string, string> >(syncResponse.PMList, new strComparer()); PXResultset <CustomerPaymentMethodDetail> otherCards = GetAllCustomersCardsInProcCenter(graph, customerPaymentMethod.BAccountID, currentCustomerPaymentMethod.CCProcessingCenterID); foreach (string pmID in sortedPMDict.Keys) { bool detailExists = false; foreach (CustomerPaymentMethodDetail detail in otherCards) { if (detail.Value == pmID) { detailExists = true; break; } } if (!detailExists) { newPMID = pmID; break; } } if (!string.IsNullOrEmpty(newPMID)) { //Authorize.Net does not return unmasked dates when all customer cards are requested, only when a single card is requested by id Dictionary <string, string> resultDict = new Dictionary <string, string>(); resultDict = sortedPMDict[newPMID]; string expirationDate = String.Empty; if (CCProcessingUtils.isFeatureSupported(graph, customerPaymentMethod.PMInstanceID, CCProcessingFeature.UnmaskedExpirationDate) && sortedPMDict[newPMID].TryGetValue(((ICreditCardDataReader)cim._processingGraph).Key_CardExpiryDate, out expirationDate)) { DateTime?expDate = CustomerPaymentMethodMaint.ParseExpiryDate(graph, customerPaymentMethod, expirationDate); if (expDate == null) { string CCPID = resultDict.Where(kvp => kvp.Value == newPMID).First().Key; foreach (TDetialsType det in detailsView.Select()) { if (det.DetailID == CCPID) { det.Value = newPMID; detailsView.Update(det); } } SyncPMResponse customerPaymentProfile = cim.GetPaymentMethod(); if (customerPaymentProfile.PMList != null && syncResponse.PMList.Count > 0) { resultDict = customerPaymentProfile.PMList.FirstOrDefault().Value; } } } foreach (TDetialsType det in detailsView.Select()) { if (resultDict.ContainsKey(det.DetailID)) { det.Value = resultDict[det.DetailID]; detailsView.Update(det); } } } } attempt++; } if (string.IsNullOrEmpty(newPMID)) { throw new PXException(Messages.FailedToSyncCC); } }
public void ConvertCustomerPaymentMethod(CustomerPaymentMethod cpm, CCProcessingCenter newCCPC) { CCProcessingCenterPmntMethod newProcessingCenterPM = PXSelect <CCProcessingCenterPmntMethod, Where <CCProcessingCenterPmntMethod.paymentMethodID, Equal <Required <CCProcessingCenterPmntMethod.paymentMethodID> >, And <CCProcessingCenterPmntMethod.processingCenterID, Equal <Required <CCProcessingCenterPmntMethod.processingCenterID> > > > > .Select(this, cpm.PaymentMethodID, newCCPC.ProcessingCenterID); if (newProcessingCenterPM == null) { newProcessingCenterPM = (CCProcessingCenterPmntMethod)ProcessingCenterPM.Cache.CreateInstance(); newProcessingCenterPM.PaymentMethodID = cpm.PaymentMethodID; newProcessingCenterPM.ProcessingCenterID = newCCPC.ProcessingCenterID; ProcessingCenterPM.Insert(newProcessingCenterPM); } CustomerPaymentMethod currCPM = (CustomerPaymentMethod)CustomerPM.Cache.CreateCopy(cpm); currCPM.CCProcessingCenterID = newCCPC.ProcessingCenterID; CustomerPM.Cache.SetDefaultExt <CustomerPaymentMethod.customerCCPID>(currCPM); currCPM.Selected = true; currCPM = CustomerPM.Update(currCPM); CustomerPM.Current = currCPM; PXResultset <PaymentMethodDetail> oldDetails = PMDetails.Select(currCPM.PaymentMethodID); foreach (PaymentMethodDetail oldDetail in oldDetails) { PaymentMethodDetail newDetail = (PaymentMethodDetail)PMDetails.Cache.CreateCopy(oldDetail); newDetail.ValidRegexp = null; PMDetails.Update(newDetail); } PaymentMethod CurrPM = PM.Select(); PaymentMethodDetail CCPID = FindCCPID(CurrPM); if (CCPID == null) { using (PXTransactionScope ts = new PXTransactionScope()) { PaymentMethodDetail res; CCPID = (PaymentMethodDetail)PMDetails.Cache.CreateInstance(); CCPID.PaymentMethodID = currCPM.PaymentMethodID; CCPID.UseFor = PaymentMethodDetailUsage.UseForARCards; CCPID.DetailID = "CCPID"; CCPID.Descr = "Payment Profile ID"; CCPID.IsCCProcessingID = true; CCPID.IsRequired = true; res = PMDetails.Insert(CCPID); if (res == null) { throw new PXException(Messages.CouldNotInsertPMDetail); } else { PMDetails.Cache.Persist(PXDBOperation.Insert); } ts.Complete(); } } CustomerPaymentMethodDetail newCCPIDPM = PXSelect <CustomerPaymentMethodDetail, Where <CustomerPaymentMethodDetail.pMInstanceID, Equal <Required <CustomerPaymentMethodDetail.pMInstanceID> >, And <CustomerPaymentMethodDetail.paymentMethodID, Equal <Required <CustomerPaymentMethodDetail.paymentMethodID> >, And <CustomerPaymentMethodDetail.detailID, Equal <Required <CustomerPaymentMethodDetail.detailID> > > > > > .Select(this, currCPM.PMInstanceID, currCPM.PaymentMethodID, CCPID.DetailID); if (newCCPIDPM != null) { newCCPIDPM.Value = null; CustomerPMDetails.Update(newCCPIDPM); } else { newCCPIDPM = new CustomerPaymentMethodDetail(); newCCPIDPM.PMInstanceID = currCPM.PMInstanceID; newCCPIDPM.PaymentMethodID = currCPM.PaymentMethodID; newCCPIDPM.DetailID = CCPID.DetailID; CustomerPMDetails.Insert(newCCPIDPM); } CustomerPaymentMethodMaint.SyncNewPMI(this, CustomerPM, CustomerPMDetails); currCPM.Converted = true; currCPM = CustomerPM.Update(currCPM); this.Save.Press(); }
public 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 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); } } }