コード例 #1
0
 public ProcessPaymentResult ProcessPayment(Customer Customer, CustomerPaymentMethod PaymentMethod)
 {
     return(new ProcessPaymentResult()
     {
         NewPaymentStatus = PaymentStatus.Paid
     });
 }
コード例 #2
0
        public static bool IsCCPIDFilled(PXGraph graph, int?PMInstanceID)
        {
            if (PMInstanceID == null || PMInstanceID.Value < 0)
            {
                return(false);
            }

            CustomerPaymentMethod cpm = PXSelect <CustomerPaymentMethod, Where <CustomerPaymentMethod.pMInstanceID,
                                                                                Equal <Required <CustomerPaymentMethod.pMInstanceID> > > > .Select(graph, PMInstanceID);

            if (cpm == null)
            {
                return(false);
            }

            PXResultset <PaymentMethodDetail> paymentMethodDetail = PXSelectJoin <PaymentMethodDetail, LeftJoin <CustomerPaymentMethodDetail,
                                                                                                                 On <CustomerPaymentMethodDetail.paymentMethodID, Equal <PaymentMethodDetail.paymentMethodID>,
                                                                                                                     And <CustomerPaymentMethodDetail.detailID, Equal <PaymentMethodDetail.detailID>,
                                                                                                                          And <PaymentMethodDetail.useFor, Equal <PaymentMethodDetailUsage.useForARCards>,
                                                                                                                               And <CustomerPaymentMethodDetail.pMInstanceID, Equal <Required <CustomerPaymentMethod.pMInstanceID> > > > > > >,
                                                                                  Where <PaymentMethodDetail.isCCProcessingID, Equal <True>,
                                                                                         And <PaymentMethodDetail.paymentMethodID, Equal <Required <PaymentMethodDetail.paymentMethodID> > > > > .Select(graph, PMInstanceID, cpm.PaymentMethodID);

            PaymentMethodDetail         pmIDDetail  = paymentMethodDetail.Count > 0 ? paymentMethodDetail[0].GetItem <PaymentMethodDetail>() : null;
            CustomerPaymentMethodDetail ccpIDDetail = paymentMethodDetail.Count > 0 ? paymentMethodDetail[0].GetItem <CustomerPaymentMethodDetail>() : null;

            if (IsTokenizedPaymentMethod(graph, PMInstanceID) && pmIDDetail == null)
            {
                throw new PXException(Messages.PaymentMethodNotConfigured);
            }
            return(ccpIDDetail != null && !string.IsNullOrEmpty(ccpIDDetail.Value));
        }
        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;
            }
        }
        public virtual bool Credit(ICCPayment aPmtInfo, string aExtRefTranNbr, ref int aTranNbr)
        {
            if (!IsCCValidForProcessing(aPmtInfo.PMInstanceID))
            {
                return(false);
            }

            Customer customer;
            CustomerPaymentMethod pmInstance = this.findPMInstance(aPmtInfo.PMInstanceID, out customer);
            CCProcTran            refTran    = _repository.FindReferencedCCProcTran(aPmtInfo.PMInstanceID, aExtRefTranNbr);

            if (refTran != null)
            {
                return(Credit(aPmtInfo, refTran.TranNbr.Value, ref aTranNbr));
            }
            else
            {
                CCProcTran tran = new CCProcTran();
                tran.Copy(aPmtInfo);
                tran.RefTranNbr      = null;
                tran.RefPCTranNumber = aExtRefTranNbr;
                refTran = new CCProcTran();
                refTran.PCTranNumber = aExtRefTranNbr;
                return(this.DoTransaction(ref aTranNbr, CCTranType.Credit, tran, refTran, customer.AcctCD, null));
            }
        }
コード例 #5
0
        private void CreateCustomerPaymentMethodDetailRecord(CustomerPaymentMethod customerPM, CCSynchronizeCard syncCard)
        {
            PXResultset <PaymentMethodDetail> details = GetPaymentMethodDetailParams(customerPM.PaymentMethodID);
            PXCache customerPaymentMethodDetailCache  = Caches[typeof(CustomerPaymentMethodDetail)];
            CustomerPaymentMethodDetail customerPaymentDetails;

            foreach (PaymentMethodDetail detail in details)
            {
                customerPaymentDetails                 = customerPaymentMethodDetailCache.CreateInstance() as CustomerPaymentMethodDetail;
                customerPaymentDetails.DetailID        = detail.DetailID;
                customerPaymentDetails.PMInstanceID    = customerPM.PMInstanceID;
                customerPaymentDetails.PaymentMethodID = customerPM.PaymentMethodID;

                if (customerPaymentDetails.DetailID == CreditCardAttributes.CardNumber)
                {
                    Match match = new Regex("[\\d]+").Match(syncCard.CardNumber);
                    if (match.Success)
                    {
                        string cardNum = match.Value.PadLeft(8, 'X');
                        customerPaymentDetails.Value = cardNum;
                    }
                }

                if (customerPaymentDetails.DetailID == CreditCardAttributes.CCPID)
                {
                    customerPaymentDetails.Value = syncCard.PaymentCCPID;
                }

                customerPaymentMethodDetailCache.Insert(customerPaymentDetails);
                customerPaymentMethodDetailCache.Persist(PXDBOperation.Insert);
            }
        }
        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();
        }
コード例 #7
0
        protected V2.TranProfile GetCustomerProfileFromDoc(ICCPayment pDoc)
        {
            V2.TranProfile ret = null;
            if (pDoc.PMInstanceID > 0)
            {
                var query = new PXSelectJoin <CustomerPaymentMethod,
                                              InnerJoin <CustomerPaymentMethodDetail, On <CustomerPaymentMethodDetail.pMInstanceID, Equal <CustomerPaymentMethod.pMInstanceID> >,
                                                         InnerJoin <PaymentMethodDetail, On <PaymentMethodDetail.detailID, Equal <CustomerPaymentMethodDetail.detailID> > > >,
                                              Where <CustomerPaymentMethod.pMInstanceID, Equal <Required <CustomerPaymentMethod.pMInstanceID> >,
                                                     And <PaymentMethodDetail.isCCProcessingID, Equal <True> > > >(Base);
                PXResultset <CustomerPaymentMethod> result = query.Select(pDoc.PMInstanceID);

                foreach (PXResult <CustomerPaymentMethod, CustomerPaymentMethodDetail> item in result)
                {
                    CustomerPaymentMethod       cpm    = (CustomerPaymentMethod)item;
                    CustomerPaymentMethodDetail cpmDet = (CustomerPaymentMethodDetail)item;
                    ret = new V2.TranProfile()
                    {
                        CustomerProfileId = cpm.CustomerCCPID, PaymentProfileId = cpmDet.Value
                    };
                    break;
                }
            }
            return(ret);
        }
        public static void SyncDeletePMI(PXGraph graph, PXSelectBase <CustomerPaymentMethod> customerPaymentMethodView, PXSelectBase <CustomerPaymentMethodDetail> detailsView)
        {
            IEnumerator cpmEnumerator = customerPaymentMethodView.Cache.Deleted.GetEnumerator();

            if (cpmEnumerator.MoveNext())
            {
                CustomerPaymentMethod current          = (CustomerPaymentMethod)cpmEnumerator.Current;
                CCProcessingCenter    processingCenter = CCProcessingUtils.getProcessingCenter(graph, current.CCProcessingCenterID);
                if (!string.IsNullOrEmpty(current.CCProcessingCenterID) && processingCenter.SyncronizeDeletion == true)
                {
                    CCCustomerInformationManager cim = new CCCustomerInformationManager(current.CCProcessingCenterID, CCProcessingFeature.Tokenization,
                                                                                        new ProcessingContext()
                    {
                        aCustomerID = current.BAccountID, aPMInstanceID = current.PMInstanceID
                    });
                    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.DeletePaymentMethod();
                    }
                }
            }
        }
コード例 #9
0
        protected int?GetInstanceId(V2.TranProfile input)
        {
            int?    instanceID = PaymentTranExtConstants.NewPaymentProfile;
            PXCache cpmCache   = Base.Caches[typeof(CustomerPaymentMethod)];

            cpmCache.ClearQueryCacheObsolete();
            PXSelectBase <CustomerPaymentMethod> query = new PXSelectReadonly2 <CustomerPaymentMethod,
                                                                                InnerJoin <CustomerPaymentMethodDetail, On <CustomerPaymentMethod.pMInstanceID, Equal <CustomerPaymentMethodDetail.pMInstanceID> >,
                                                                                           InnerJoin <PaymentMethodDetail, On <CustomerPaymentMethodDetail.detailID, Equal <PaymentMethodDetail.detailID>,
                                                                                                                               And <CustomerPaymentMethodDetail.paymentMethodID, Equal <PaymentMethodDetail.paymentMethodID> > > > >,
                                                                                Where <CustomerPaymentMethod.cCProcessingCenterID, Equal <Required <CustomerPaymentMethod.cCProcessingCenterID> >,
                                                                                       And <CustomerPaymentMethod.customerCCPID, Equal <Required <CustomerPaymentMethod.customerCCPID> >,
                                                                                            And <PaymentMethodDetail.isCCProcessingID, Equal <True>, And <PaymentMethodDetail.useFor, Equal <PaymentMethodDetailUsage.useForARCards> > > > > >(Base);

            PXResultset <CustomerPaymentMethod> queryResult = query.Select(SelectedProcessingCenter, input.CustomerProfileId);

            foreach (PXResult <CustomerPaymentMethod, CustomerPaymentMethodDetail> item in queryResult)
            {
                CustomerPaymentMethodDetail checkCpmd = (CustomerPaymentMethodDetail)item;

                if (checkCpmd.Value == input.PaymentProfileId)
                {
                    instanceID = checkCpmd.PMInstanceID;
                    break;
                }
            }
            CustomerPaymentMethod cpm = NewCpm.Select();

            if (cpm != null && cpm.PMInstanceID != null && cpm.PMInstanceID >= 0)
            {
                instanceID = cpm.PMInstanceID.Value;
            }
            return(instanceID);
        }
        public virtual bool Authorize(ICCPayment aPmtInfo, bool aCapture, ref int aTranNbr)
        {
            Customer customer;
            CustomerPaymentMethod pmInstance = this.findPMInstance(aPmtInfo.PMInstanceID, out customer);

            if (pmInstance == null)
            {
                throw new PXException(Messages.CreditCardWithID_0_IsNotDefined, aPmtInfo.PMInstanceID);
            }
            CCProcessingCenter procCenter = _repository.FindProcessingCenter(pmInstance.PMInstanceID, null);

            if (procCenter == null)
            {
                throw new PXException(Messages.ERR_CCProcessingCenterIsNotSpecified, pmInstance.Descr);
            }
            if (!(procCenter.IsActive ?? false))
            {
                throw new PXException(Messages.ERR_CCProcessingIsInactive, procCenter.ProcessingCenterID);
            }
            if (!IsValidForProcessing(pmInstance, customer))
            {
                return(false);
            }

            CCTranType tranType = aCapture ? CCTranType.AuthorizeAndCapture : CCTranType.AuthorizeOnly;
            CCProcTran tran     = new CCProcTran();

            tran.Copy(aPmtInfo);
            return(this.DoTransaction(ref aTranNbr, tranType, tran, null, customer.AcctCD, procCenter));
        }
コード例 #11
0
        public static CCProcessingCenter GetProcessingCenter(PXGraph graph, int?PMInstanceID, bool UsePMFromCacheDeleted)
        {
            if (PMInstanceID == null && !UsePMFromCacheDeleted)
            {
                return(null);
            }

            CCProcessingCenter processingCenter = null;

            if (PMInstanceID != null)
            {
                PXResult <CustomerPaymentMethod, CCProcessingCenter> res =
                    (PXResult <CustomerPaymentMethod, CCProcessingCenter>) PXSelectJoin <
                        CustomerPaymentMethod,
                        InnerJoin <CCProcessingCenter,
                                   On <CCProcessingCenter.processingCenterID, Equal <CustomerPaymentMethod.cCProcessingCenterID> > >,
                        Where <CustomerPaymentMethod.pMInstanceID, Equal <Required <CustomerPaymentMethod.pMInstanceID> > > >
                    .Select(graph, PMInstanceID);

                processingCenter = (CCProcessingCenter)res;
            }

            if (processingCenter == null && UsePMFromCacheDeleted)
            {
                //assuming that payment method was just deleted
                IEnumerator cpmEnumerator = graph.Caches[typeof(CustomerPaymentMethod)].Deleted.GetEnumerator();
                if (cpmEnumerator.MoveNext())
                {
                    CustomerPaymentMethod customerPaymentMethod = (CustomerPaymentMethod)cpmEnumerator.Current;
                    processingCenter = GetProcessingCenter(graph, customerPaymentMethod.CCProcessingCenterID);
                }
            }

            return(processingCenter);
        }
        public virtual bool CaptureOnly(ICCPayment aPmtInfo, string aAuthorizationNbr, ref int aTranNbr)
        {
            Customer customer;
            CustomerPaymentMethod pmInstance = this.findPMInstance(aPmtInfo.PMInstanceID, out customer);

            if (string.IsNullOrEmpty(aAuthorizationNbr))
            {
                throw new PXException(Messages.ERR_CCExternalAuthorizationNumberIsRequiredForCaptureOnlyTrans, aAuthorizationNbr);
            }
            CCProcessingCenter procCenter = _repository.GetCCProcessingCenter(pmInstance.CCProcessingCenterID);

            if (procCenter == null)
            {
                throw new PXException(Messages.ERR_CCProcessingCenterUsedForAuthIsNotValid, pmInstance.CCProcessingCenterID, aTranNbr);
            }
            if (!(procCenter.IsActive ?? false))
            {
                throw new PXException(Messages.ERR_CCProcessingCenterUsedForAuthIsNotActive, procCenter, aTranNbr);
            }
            if (!IsCCValidForProcessing(aPmtInfo.PMInstanceID))
            {
                return(false);
            }
            CCProcTran tran = new CCProcTran();

            tran.Copy(aPmtInfo);
            CCProcTran refTran = new CCProcTran {
                AuthNumber = aAuthorizationNbr
            };

            return(this.DoTransaction(ref aTranNbr, CCTranType.CaptureOnly, tran, refTran, customer.AcctCD, procCenter));
        }
        public virtual bool Credit(int?aPMInstanceID, int?aRefTranNbr, string aCuryID, decimal?aAmount, ref int aTranNbr)
        {
            CCProcTran            authTran = _repository.GetCCProcTran(aRefTranNbr);
            Customer              customer;
            CustomerPaymentMethod pmInstance = this.findPMInstance(aPMInstanceID, out customer);

            if (authTran == null)
            {
                throw new PXException(Messages.ERR_CCTransactionToCreditIsNotFound, aRefTranNbr);
            }
            if (!MayBeCredited(authTran))
            {
                throw new PXException(Messages.ERR_CCProcessingTransactionMayNotBeCredited, authTran.TranType);
            }

            if (!IsAuthorized(authTran))
            {
                throw new PXException(Messages.ERR_CCProcessingReferensedTransactionNotAuthorized, aRefTranNbr);
            }
            if (!IsCCValidForProcessing(aPMInstanceID))
            {
                return(false);
            }

            CCProcessingCenter procCenter = _repository.GetCCProcessingCenter(authTran.ProcessingCenterID);

            if (procCenter == null)
            {
                throw new PXException(Messages.ERR_CCProcessingCenterUsedInReferencedTranNotFound, authTran.ProcessingCenterID, aRefTranNbr);
            }

            if (!(procCenter.IsActive ?? false))
            {
                throw new PXException(Messages.ERR_CCProcessingCenterUsedInReferencedTranNotActive, authTran.ProcessingCenterID, aRefTranNbr);
            }
            CCProcTran tran = new CCProcTran
            {
                PMInstanceID = aPMInstanceID,
                DocType      = authTran.DocType,
                RefNbr       = authTran.RefNbr,
                OrigDocType  = authTran.OrigDocType,
                OrigRefNbr   = authTran.OrigRefNbr,
                RefTranNbr   = authTran.TranNbr
            };

            if (aAmount.HasValue)
            {
                tran.CuryID = aCuryID;
                tran.Amount = aAmount;
            }
            else
            {
                tran.CuryID = authTran.CuryID;
                tran.Amount = authTran.Amount;
            }
            return(this.DoTransaction(ref aTranNbr, CCTranType.Credit, tran, authTran, customer.AcctCD, procCenter));
        }
コード例 #14
0
		private static void ConvertCustomerPaymentMethod(Filter filter, CustomerPaymentMethod cpm, CCProcessingCenter newCCPC)
		{
			if (newCCPC == null)
			{
				throw new PXException(Messages.NotSetProcessingCenter);
			}

			PaymentMethodUpdater updaterGraph = PXGraph.CreateInstance<PaymentMethodUpdater>();
			updaterGraph.ConvertCustomerPaymentMethod(filter.ProcessExpiredCards.GetValueOrDefault(), cpm, newCCPC);
		}
        private static void ConvertCustomerPaymentMethod(CustomerPaymentMethod cpm, CCProcessingCenter newCCPC)
        {
            if (newCCPC == null)
            {
                throw new PXException(Messages.NotSetProcessingCenter);
            }

            PaymentMethodUpdater updaterGraph = PXGraph.CreateInstance <PaymentMethodUpdater>();

            updaterGraph.ConvertCustomerPaymentMethod(cpm, newCCPC);
        }
        protected virtual bool IsCCValidForProcessing(int?aPMInstanceID)
        {
            Customer customer;
            CustomerPaymentMethod pmInstance = this.findPMInstance(aPMInstanceID, out customer);

            if (pmInstance == null)
            {
                throw new PXException(Messages.CreditCardWithID_0_IsNotDefined, aPMInstanceID);
            }
            return(IsValidForProcessing(pmInstance, customer));
        }
コード例 #17
0
        public static bool IsHFPaymentMethod(PXGraph graph, int?PMInstanceID)
        {
            CustomerPaymentMethod current = GetCustomerPaymentMethod(graph, PMInstanceID);

            if (current == null)
            {
                return(false);
            }
            CCProcessingCenter processingCenter = GetProcessingCenter(graph, current.CCProcessingCenterID);

            return(CCProcessingFeatureHelper.IsFeatureSupported(processingCenter, CCProcessingFeature.HostedForm) && (processingCenter.AllowDirectInput != true));
        }
コード例 #18
0
        public static bool IsFeatureSupported(PXGraph graph, int?PMInstanceID, CCProcessingFeature FeatureName)
        {
            CustomerPaymentMethod current = GetCustomerPaymentMethod(graph, PMInstanceID);

            if (current == null)
            {
                return(false);
            }
            CCProcessingCenter processingCenter = GetProcessingCenter(graph, current.CCProcessingCenterID);

            return(CCProcessingFeatureHelper.IsFeatureSupported(processingCenter, FeatureName));
        }
コード例 #19
0
        protected CustomerPaymentMethod PrepeareCpmRecord()
        {
            CustomerPaymentMethod cpm = NewCpm.Select();

            if (cpm == null)
            {
                cpm = new CustomerPaymentMethod();
                cpm.PaymentMethodID      = SelectedPaymentMethod;
                cpm.CCProcessingCenterID = SelectedProcessingCenter;
                cpm = NewCpm.Insert(cpm);
            }
            return(cpm);
        }
        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);
        }
コード例 #21
0
        public virtual IEnumerable newCpm()
        {
            PXCache cache = Base.Caches[typeof(CustomerPaymentMethod)];

            foreach (object item in cache.Cached)
            {
                CustomerPaymentMethod cpm = item as CustomerPaymentMethod;
                if (cache.GetStatus(item) == PXEntryStatus.Inserted && cpm.PMInstanceID < 0)
                {
                    yield return(item);
                }
            }
            yield break;
        }
コード例 #22
0
		public IEnumerable customerPaymentMethodList()
		{
			var query = new PXSelectJoinGroupBy<CustomerPaymentMethod,
				LeftJoin<CustomerPaymentMethodDetail, On<CustomerPaymentMethodDetail.pMInstanceID, Equal<CustomerPaymentMethod.pMInstanceID>>>, 
				Where<CustomerPaymentMethod.paymentMethodID, Equal<Current<Filter.oldPaymentMethodID>>,
					And<CustomerPaymentMethod.cCProcessingCenterID, Equal<Current<Filter.oldCCProcessingCenterID>>,
					And<CustomerPaymentMethodDetail.value, IsNotNull>>>,
				Aggregate<GroupBy<CustomerPaymentMethod.pMInstanceID>>>(this);
			foreach (PXResult<CustomerPaymentMethod,CustomerPaymentMethodDetail> items in query.Select())
			{
				CustomerPaymentMethod cpm = (CustomerPaymentMethod)items;
				yield return cpm;
			}
		}
コード例 #23
0
        //Creating a credit card customer payment method
        public static void CreateCustomerPaymentMethod(DefaultSoapClient soapClient)
        {
            Console.WriteLine("Creating a credit card customer payment method...");

            //Customer payment method data
            string customerID        = "C000000003";
            string paymentMethod     = "VISA";
            string paymentProfileID  = "35596199"; //Payment Profile ID value, which was obtained from Authorize.Net
            string cashAccount       = "102050MYST";
            string customerProfileID = "37100472";

            //Specify the parameters of the created customer payment method
            CustomerPaymentMethod paymMethToBeCreated = new CustomerPaymentMethod
            {
                CustomerID = new StringValue {
                    Value = customerID
                },
                PaymentMethod = new StringValue {
                    Value = paymentMethod
                },
                CashAccount = new StringValue {
                    Value = cashAccount
                },
                CustomerProfileID = new StringValue {
                    Value = customerProfileID
                },
                Details = new[]
                {
                    new CustomerPaymentMethodDetail
                    {
                        Name = new StringValue {
                            Value = "Payment Profile ID"
                        },
                        Value = new StringValue {
                            Value = paymentProfileID
                        }
                    }
                }
            };


            //Create the customer payment method
            CustomerPaymentMethod createdMethod = (CustomerPaymentMethod)soapClient.Put(paymMethToBeCreated);

            //Display the card number of the created payment method
            Console.WriteLine("Card number: " + createdMethod.CardAccountNbr.Value);
            Console.WriteLine();
            Console.WriteLine("Press any key to continue");
            Console.ReadLine();
        }
コード例 #24
0
        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();
        }
コード例 #25
0
        private void ConvertCustomerPaymentMethod(CustomerPaymentMethod cpm, CCProcessingCenter newCCPC)
        {
            if (newCCPC == null)
            {
                throw new PXException("New Processing Center is not set!");
            }
            if (!CCPaymentProcessing.IsFeatureSupported(newCCPC, CCProcessingFeature.Tokenization))
            {
                throw new PXException("New processing center should support tokenization!");
            }
            PaymentMethodUpdater updaterGreph = PXGraph.CreateInstance <PaymentMethodUpdater>();

            updaterGreph.ConvertCustomerPaymentMethod(cpm, newCCPC);
        }
コード例 #26
0
        public MobSocialProcessPaymentResultModel ProcessPayment(Customer Customer, CustomerPaymentMethod PaymentMethod, decimal PaymentAmount, bool AuthorizeOnly = false)
        {
            //check if the plugin is installed and activated
            //depending on the payment amount, we may wish to switch between macro and micro payments
            //check if plugin is installed or not
            //TODO: Change the other payment method to appropriate one for macro payments
            var paymentPluginSystemName = PaymentAmount < MicroMacroPaymentSwitchingAmount ? "Payments.PayPalDirect" : "Payments.PayPalDirect";

            //if we get an instance, then the plugin is installed
            var plugin = GetPluginInstance(paymentPluginSystemName);

            //plugin should be available and if it's an authorization transaction, the plugin should actually support authorize and capture
            if (plugin == null || (!plugin.SupportCapture && AuthorizeOnly))
            {
                return(null);
            }

            //default to first billing address
            Customer.BillingAddress = Customer.BillingAddress ?? Customer.Addresses.First();

            var key  = _mobSecurityService.GetSavedEncryptionKey();
            var salt = _mobSecurityService.GetSavedSalt();

            //decrypt card number stored for processing
            var cardNumber = _mobSecurityService.Decrypt(PaymentMethod.CardNumber, key, salt); //decrypt the card info

            //now create a payment processing request
            var paymentProcessingRequest = new ProcessPaymentRequest()
            {
                CustomerId              = Customer.Id,
                OrderTotal              = PaymentAmount,
                CreditCardName          = PaymentMethod.NameOnCard,
                CreditCardExpireMonth   = int.Parse(PaymentMethod.ExpireMonth),
                CreditCardExpireYear    = int.Parse(PaymentMethod.ExpireYear),
                PaymentMethodSystemName = paymentPluginSystemName,
                CreditCardType          = PaymentMethod.CardIssuerType,
                CreditCardNumber        = cardNumber,
                StoreId = _storeContext.CurrentStore.Id
            };

            var resultModel = new MobSocialProcessPaymentResultModel()
            {
                ProcessPaymentResult    = plugin.ProcessPayment(paymentProcessingRequest),
                PaymentMethodSystemName = paymentPluginSystemName
            };

            return(resultModel);
        }
        public virtual bool Capture(int?aPMInstanceID, int?aAuthTranNbr, string aCuryID, decimal?aAmount, ref int aTranNbr)
        {
            CCProcTran            authTran = _repository.GetCCProcTran(aAuthTranNbr);
            Customer              customer;
            CustomerPaymentMethod pmInstance = this.findPMInstance(aPMInstanceID, out customer);

            if (authTran == null)
            {
                throw new PXException(Messages.ERR_CCAuthorizationTransactionIsNotFound, aAuthTranNbr);
            }
            if (!IsAuthorized(authTran))
            {
                throw new PXException(Messages.ERR_CCProcessingReferensedTransactionNotAuthorized, aAuthTranNbr);
            }

            if (authTran.ExpirationDate.HasValue && authTran.ExpirationDate.Value < PXTimeZoneInfo.Now)
            {
                throw new PXException(Messages.ERR_CCAuthorizationTransactionHasExpired, aAuthTranNbr);
            }
            if (!IsCCValidForProcessing(aPMInstanceID))
            {
                return(false);
            }

            CCProcessingCenter procCenter = _repository.GetCCProcessingCenter(authTran.ProcessingCenterID);

            if (procCenter == null)
            {
                throw new PXException(Messages.ERR_CCProcessingCenterUsedForAuthIsNotValid, authTran.ProcessingCenterID, aAuthTranNbr);
            }
            if (!(procCenter.IsActive ?? false))
            {
                throw new PXException(Messages.ERR_CCProcessingCenterUsedForAuthIsNotActive, procCenter, aAuthTranNbr);
            }
            CCProcTran tran = new CCProcTran
            {
                PMInstanceID = aPMInstanceID,
                RefTranNbr   = aAuthTranNbr,
                DocType      = authTran.DocType,
                RefNbr       = authTran.RefNbr,
                CuryID       = aCuryID,
                Amount       = aAmount,
                OrigDocType  = authTran.OrigDocType,
                OrigRefNbr   = authTran.OrigRefNbr
            };

            return(this.DoTransaction(ref aTranNbr, CCTranType.PriorAuthorizedCapture, tran, authTran, customer.AcctCD, procCenter));
        }
        public virtual bool Credit(ICCPayment aPmtInfo, int aRefTranNbr, ref int aTranNbr)
        {
            Customer customer;
            CustomerPaymentMethod pmInstance = this.findPMInstance(aPmtInfo.PMInstanceID, out customer);
            CCProcTran            authTran   = _repository.GetCCProcTran(aRefTranNbr);

            if (authTran == null)
            {
                throw new PXException(Messages.ERR_CCTransactionToCreditIsNotFound, aRefTranNbr);
            }
            if (!MayBeCredited(authTran))
            {
                throw new PXException(Messages.ERR_CCProcessingTransactionMayNotBeCredited, authTran.TranType);
            }

            if (!IsAuthorized(authTran))
            {
                throw new PXException(Messages.ERR_CCProcessingReferensedTransactionNotAuthorized, aRefTranNbr);
            }

            if (!IsCCValidForProcessing(aPmtInfo.PMInstanceID))
            {
                return(false);
            }

            CCProcessingCenter procCenter = _repository.GetCCProcessingCenter(authTran.ProcessingCenterID);

            if (procCenter == null)
            {
                throw new PXException(Messages.ERR_CCProcessingCenterUsedInReferencedTranNotFound, authTran.ProcessingCenterID, aRefTranNbr);
            }

            if (!(procCenter.IsActive ?? false))
            {
                throw new PXException(Messages.ERR_CCProcessingCenterUsedInReferencedTranNotActive, authTran.ProcessingCenterID, aRefTranNbr);
            }
            CCProcTran tran = new CCProcTran();

            tran.Copy(aPmtInfo);
            tran.RefTranNbr = authTran.TranNbr;

            if (!aPmtInfo.CuryDocBal.HasValue)
            {
                tran.CuryID = authTran.CuryID;
                tran.Amount = authTran.Amount;
            }
            return(this.DoTransaction(ref aTranNbr, CCTranType.Credit, tran, authTran, customer.AcctCD, procCenter));
        }
コード例 #29
0
        protected virtual void PaymentMethodAccount_RowDeleting(PXCache cache, PXRowDeletingEventArgs e)
        {
            PaymentMethodAccount row    = (PaymentMethodAccount)e.Row;
            PXEntryStatus        status = cache.GetStatus(e.Row);

            if (row.CashAccountID != null && status != PXEntryStatus.Inserted && status != PXEntryStatus.InsertedDeleted)
            {
                CustomerPaymentMethod cpm = PXSelect <CustomerPaymentMethod, Where <CustomerPaymentMethod.paymentMethodID, Equal <Required <CustomerPaymentMethod.paymentMethodID> >,
                                                                                    And <CustomerPaymentMethod.cashAccountID, Equal <Required <CustomerPaymentMethod.cashAccountID> > > > > .SelectWindowed(this, 0, 1, row.PaymentMethodID, row.CashAccountID);

                if (cpm != null)
                {
                    throw new PXException(Messages.PaymentMethodAccountIsInUseAndCantBeDeleted);
                }
            }
        }
 protected virtual bool IsValidForProcessing(CustomerPaymentMethod pmInstance, Customer customer)
 {
     if (pmInstance == null)
     {
         throw new PXException(Messages.CreditCardWithID_0_IsNotDefined);
     }
     if (pmInstance != null && pmInstance.IsActive == false)
     {
         throw new PXException(Messages.InactiveCreditCardMayNotBeProcessed, pmInstance.Descr);
     }
     if (IsExpired(pmInstance))
     {
         throw new PXException(Messages.ERR_CCCreditCardHasExpired, pmInstance.ExpirationDate.Value, customer.AcctCD);
     }
     return(true);
 }