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();
        }
Esempio n. 2
0
        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);
            }

            CCCustomerInformationManager.SyncNewPMI(this, CustomerPM, CustomerPMDetails);
            currCPM.Converted = true;
            currCPM           = CustomerPM.Update(currCPM);
            this.Save.Press();
        }