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 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(); }
protected int?CreatePaymentProfile(V2.TranProfile input) { var cpmSelect = NewCpm; var cpmdSelect = NewCpmd; var pmdSelect = PaymentMethodDet; foreach (PaymentMethodDetail item in pmdSelect.Select()) { CustomerPaymentMethodDetail cpmd = new CustomerPaymentMethodDetail(); cpmd.PaymentMethodID = SelectedPaymentMethod; cpmd.DetailID = item.DetailID; if (item.IsCCProcessingID == true) { cpmd.Value = input.PaymentProfileId; } cpmdSelect.Insert(cpmd); } CCCustomerInformationManagerGraph infoManagerGraph = PXGraph.CreateInstance <CCCustomerInformationManagerGraph>(); GenericCCPaymentProfileAdapter <CustomerPaymentMethod> cpmAdapter = new GenericCCPaymentProfileAdapter <CustomerPaymentMethod>(cpmSelect); var cpmdAdapter = new GenericCCPaymentProfileDetailAdapter <CustomerPaymentMethodDetail, PaymentMethodDetail>(cpmdSelect, pmdSelect); infoManagerGraph.GetPaymentProfile(Base, cpmAdapter, cpmdAdapter); var cardIdent = pmdSelect.Select().RowCast <PaymentMethodDetail>().Where(i => i.IsIdentifier == true).First(); var detailWithCardNum = cpmdSelect.Select().RowCast <CustomerPaymentMethodDetail>().Where(i => i.DetailID == cardIdent.DetailID).First(); Match match = new Regex("[\\d]+").Match(detailWithCardNum.Value); CustomerPaymentMethod cpm = cpmSelect.Select(); if (match.Success) { cpm.Descr = SelectedPaymentMethod + ":" + maskedCardTmpl + match.Value; } cpmSelect.Cache.Persist(PXDBOperation.Insert); cpmdSelect.Cache.Persist(PXDBOperation.Insert); return(cpm.PMInstanceID); }
protected V2.TranProfile GetOrCreateCustomerProfileByTranId(string tranId) { PXSelectBase <CustomerPaymentMethod> query = new PXSelectReadonly <CustomerPaymentMethod, Where <CustomerPaymentMethod.bAccountID, Equal <Required <CustomerPaymentMethod.bAccountID> >, And <CustomerPaymentMethod.cCProcessingCenterID, Equal <Required <CustomerPaymentMethod.cCProcessingCenterID> > > >, OrderBy <Desc <CustomerPaymentMethod.createdDateTime> > >(Base); IEnumerable <CustomerPaymentMethod> cpmRes = query.Select(SelectedBAccount, SelectedProcessingCenter).RowCast <CustomerPaymentMethod>(); CustomerPaymentMethod searchCpm = cpmRes.FirstOrDefault(); ICCPaymentProfile cpm = PrepeareCpmRecord(); if (searchCpm != null) { cpm.CustomerCCPID = searchCpm.CustomerCCPID; } CCCustomerInformationManagerGraph infoManagerGraph = PXGraph.CreateInstance <CCCustomerInformationManagerGraph>(); GenericCCPaymentProfileAdapter <CustomerPaymentMethod> cpmAdapter = new GenericCCPaymentProfileAdapter <CustomerPaymentMethod>(NewCpm); V2.TranProfile ret = infoManagerGraph.GetOrCreatePaymentProfileByTran(Base, cpmAdapter, tranId); cpm.CustomerCCPID = ret.CustomerProfileId; return(ret); }
private void DoConvert(CustomerPaymentMethod cpm, CCProcessingCenter newCCPC) { CCProcessingCenterPmntMethod newProcessingCenterPM = PXSelect<CCProcessingCenterPmntMethod, Where<CCProcessingCenterPmntMethod.paymentMethodID, Equal<Required<CCProcessingCenterPmntMethod.paymentMethodID>>, And<CCProcessingCenterPmntMethod.processingCenterID, Equal<Required<CCProcessingCenterPmntMethod.processingCenterID>>>>>.Select(this, cpm.PaymentMethodID, newCCPC.ProcessingCenterID); if (newProcessingCenterPM == null) { newProcessingCenterPM = (CCProcessingCenterPmntMethod)ProcessingCenterPM.Cache.CreateInstance(); newProcessingCenterPM.PaymentMethodID = cpm.PaymentMethodID; newProcessingCenterPM.ProcessingCenterID = newCCPC.ProcessingCenterID; ProcessingCenterPM.Insert(newProcessingCenterPM); } CustomerPaymentMethod currCPM = (CustomerPaymentMethod)CustomerPM.Cache.CreateCopy(cpm); var oldCCProcessingCenterID = currCPM.CCProcessingCenterID; currCPM.CCProcessingCenterID = newCCPC.ProcessingCenterID; if (currCPM.CustomerCCPID == null) { CustomerPM.Cache.SetDefaultExt<CustomerPaymentMethod.customerCCPID>(currCPM); } currCPM.Selected = true; currCPM = CustomerPM.Update(currCPM); CustomerPM.Current = currCPM; PXResultset<PaymentMethodDetail> oldDetails = PMDetails.Select(currCPM.PaymentMethodID); foreach (PaymentMethodDetail oldDetail in oldDetails) { PaymentMethodDetail newDetail = (PaymentMethodDetail)PMDetails.Cache.CreateCopy(oldDetail); newDetail.ValidRegexp = null; PMDetails.Update(newDetail); } PaymentMethod CurrPM = PM.Select(); PaymentMethodDetail CCPID = FindCCPID(CurrPM); if (CCPID == null) { using (PXTransactionScope ts = new PXTransactionScope()) { PaymentMethodDetail res; CCPID = (PaymentMethodDetail)PMDetails.Cache.CreateInstance(); CCPID.PaymentMethodID = currCPM.PaymentMethodID; CCPID.UseFor = PaymentMethodDetailUsage.UseForARCards; CCPID.DetailID = "CCPID"; CCPID.Descr = Messages.PaymentProfileID; CCPID.IsCCProcessingID = true; CCPID.IsRequired = true; res = PMDetails.Insert(CCPID); if (res == null) { throw new PXException(Messages.CouldNotInsertPMDetail); } else { PMDetails.Cache.Persist(PXDBOperation.Insert); } ts.Complete(); } } CCProcessingCenter procCenter = PXSelect<CCProcessingCenter, Where<CCProcessingCenter.processingCenterID, Equal<Required<CCProcessingCenter.processingCenterID>>>> .Select(this, oldCCProcessingCenterID); bool oldProcCenterSupportTokenizing = ProcCenterSupportTokenizing(oldCCProcessingCenterID); bool newProcCenterSupportTokenizing = ProcCenterSupportTokenizing(newCCPC.ProcessingCenterID); if (!oldProcCenterSupportTokenizing && newProcCenterSupportTokenizing) { CustomerPaymentMethodDetail newCCPIDPM = PXSelect<CustomerPaymentMethodDetail, Where<CustomerPaymentMethodDetail.pMInstanceID, Equal<Required<CustomerPaymentMethodDetail.pMInstanceID>>, And<CustomerPaymentMethodDetail.paymentMethodID, Equal<Required<CustomerPaymentMethodDetail.paymentMethodID>>, And<CustomerPaymentMethodDetail.detailID, Equal<Required<CustomerPaymentMethodDetail.detailID>>>>>> .Select(this, currCPM.PMInstanceID, currCPM.PaymentMethodID, CCPID.DetailID); if (newCCPIDPM != null) { newCCPIDPM.Value = null; CustomerPMDetails.Update(newCCPIDPM); } else { newCCPIDPM = new CustomerPaymentMethodDetail { PMInstanceID = currCPM.PMInstanceID, PaymentMethodID = currCPM.PaymentMethodID, DetailID = CCPID.DetailID }; CustomerPMDetails.Insert(newCCPIDPM); } var graph = PXGraph.CreateInstance<CCCustomerInformationManagerGraph>(); ICCPaymentProfileAdapter paymentProfile = new GenericCCPaymentProfileAdapter<CustomerPaymentMethod>(CustomerPM); ICCPaymentProfileDetailAdapter profileDetail = new GenericCCPaymentProfileDetailAdapter<CustomerPaymentMethodDetail, PaymentMethodDetail>(CustomerPMDetails, PMDetails); DateTime expiredDate; if (CheckCardIsExpired(currCPM, out expiredDate)) { Customer cust = new PXSelect<Customer, Where<Customer.bAccountID, Equal<Required<Customer.bAccountID>>>>(this) .SelectSingle(currCPM.BAccountID); throw new PXException(AR.Messages.ERR_CCCreditCardHasExpired, expiredDate.ToString("d"), cust.AcctCD); } graph.GetOrCreatePaymentProfile(this, paymentProfile, profileDetail); } if (newProcCenterSupportTokenizing) { if (currCPM.CustomerCCPID == null) { currCPM.CustomerCCPID = cpm.CustomerCCPID; } CustomerProcessingCenterID newCustomerProcessingCenterID = new CustomerProcessingCenterID { CCProcessingCenterID = newCCPC.ProcessingCenterID, BAccountID = cpm.BAccountID, CustomerCCPID = currCPM.CustomerCCPID }; AddCustomerProcessingCenterIfNeeded(newCustomerProcessingCenterID); } currCPM = CustomerPM.Update(currCPM); }