public CCCustomerInformationManager(string processingCenterID, CCProcessingFeature feature, ProcessingContext context)
 {
     _processingGraph    = PXGraph.CreateInstance <CCPaymentProcessing>();
     _processingCenterID = processingCenterID;
     _feature            = feature;
     Context             = context;
     _processingGraph.checkProcessing(_processingCenterID, _feature, Context);
 }
        public static void RecordCCPayment <TNode>(TNode doc, string aExtPCTranNbr, string aPCAuthNbr, PXSelectBase <CCProcTran> ccProcTran, CCPaymentEntry.ReleaseDelegate aReleaseDelegate, UpdateDocStateDelegate aDocStateUpdater)
            where TNode : class, IBqlTable, ICCPayment, new()
        {
            if (doc != null && doc.PMInstanceID != null && doc.CuryDocBal != null)
            {
                if (CCPaymentEntry.HasOpenCCTran(ccProcTran))
                {
                    throw new PXException(Messages.ERR_CCTransactionCurrentlyInProgress);
                }

                if (string.IsNullOrEmpty(aExtPCTranNbr))
                {
                    throw new PXException(Messages.ERR_PCTransactionNumberOfTheOriginalPaymentIsRequired);
                }


                CCPaymentState paymentState = CCPaymentEntry.ResolveCCPaymentState(ccProcTran.Select());
                if ((paymentState & (CCPaymentState.Captured)) > 0)
                {
                    throw new PXException(Messages.ERR_CCAuthorizedPaymentAlreadyCaptured);
                }


                ccProcTran.View.Graph.Actions.PressSave();
                TNode toProc = PXCache <TNode> .CreateCopy(doc);

                CCProcTran authTran  = CCPaymentEntry.findCCPreAthorizing(ccProcTran.Select());
                CCTranType operation = CCTranType.AuthorizeAndCapture;
                PXLongOperation.StartOperation(ccProcTran.View.Graph, delegate()
                {
                    try
                    {
                        CCPaymentProcessing ccProcGraph = PXGraph.CreateInstance <CCPaymentProcessing>();
                        int?tranID       = 0;
                        string extTranID = aExtPCTranNbr;
                        if (ccProcGraph.RecordCapture(doc, extTranID, aPCAuthNbr, null, ref tranID))
                        {
                        }
                    }
                    finally
                    {
                        //Update doc state in any case
                        if (aDocStateUpdater != null)
                        {
                            aDocStateUpdater(doc, operation);
                        }
                    }
                    if (aReleaseDelegate != null)
                    {
                        aReleaseDelegate(toProc);                               //On Success Only
                    }
                });
            }
        }
        public static bool?CCProcessingCenterNeedsExpDateUpdate(PXGraph graph, CCProcessingCenter ProcessingCenter)
        {
            if (CCPaymentProcessing.IsFeatureSupported(ProcessingCenter, CCProcessingFeature.UnmaskedExpirationDate))
            {
                PXResultset <CustomerPaymentMethod> unupdatedCpms = PXSelect <CustomerPaymentMethod, Where <CustomerPaymentMethod.cCProcessingCenterID,
                                                                                                            Equal <Required <CustomerPaymentMethod.cCProcessingCenterID> >, And <CustomerPaymentMethod.expirationDate, IsNull> > > .Select(graph, ProcessingCenter.ProcessingCenterID);

                return(unupdatedCpms.Count != 0);
            }
            return(null);
        }
        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(CCPaymentProcessing.IsFeatureSupported(processingCenter, FeatureName));
        }
        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(CCPaymentProcessing.IsFeatureSupported(processingCenter, CCProcessingFeature.HostedForm) && (processingCenter.AllowDirectInput != true));
        }
        public static string GetTokenizedPMsString(PXGraph graph)
        {
            List <CCProcessingCenter> tokenizedPCs = new List <CCProcessingCenter>();
            HashSet <string>          pmSet        = new HashSet <string>();

            foreach (CCProcessingCenter pc in PXSelect <CCProcessingCenter, Where <CCProcessingCenter.isActive, Equal <True> > > .Select(graph))
            {
                if (CCPaymentProcessing.IsFeatureSupported(pc, CCProcessingFeature.Tokenization) &&
                    CCProcessingCenterNeedsExpDateUpdate(graph, pc) != false)
                {
                    tokenizedPCs.Add(pc);
                }
            }

            foreach (CCProcessingCenter pc in tokenizedPCs)
            {
                foreach (PXResult <CustomerPaymentMethod, PaymentMethod> tokenizedPM in PXSelectJoinGroupBy <CustomerPaymentMethod,
                                                                                                             InnerJoin <PaymentMethod, On <CustomerPaymentMethod.paymentMethodID, Equal <PaymentMethod.paymentMethodID> > >,
                                                                                                             Where <CustomerPaymentMethod.cCProcessingCenterID, Equal <Required <CustomerPaymentMethod.cCProcessingCenterID> > >,
                                                                                                             Aggregate <GroupBy <CustomerPaymentMethod.paymentMethodID, GroupBy <PaymentMethod.descr> > > > .Select(graph, pc.ProcessingCenterID))
                {
                    PaymentMethod pm = tokenizedPM;
                    pmSet.Add(pm.Descr);
                }
            }

            if (pmSet.Count == 0)
            {
                return(string.Empty);
            }

            StringBuilder sb = new StringBuilder();

            foreach (string descr in pmSet)
            {
                if (sb.Length > 0)
                {
                    sb.Append(", ");
                }
                sb.Append(descr);
            }

            return(sb.ToString());
        }
        public static void ProcessCCTransaction(ICCPayment aDoc, CCProcTran refTran, CCTranType aTranType)
        {
            if (aDoc != null && aDoc.PMInstanceID != null && aDoc.CuryDocBal != null)
            {
                CCPaymentProcessing processBO = new CCPaymentProcessing();
                int  tranID    = 0;
                bool result    = false;
                bool processed = false;
                if (aTranType == CCTranType.AuthorizeOnly || aTranType == CCTranType.AuthorizeAndCapture)
                {
                    bool doCapture = (aTranType == CCTranType.AuthorizeAndCapture);
                    result    = processBO.Authorize(aDoc, doCapture, ref tranID);
                    processed = true;
                }

                if (aTranType == CCTranType.PriorAuthorizedCapture)
                {
                    if (refTran == null)
                    {
                        throw new PXException(Messages.ERR_CCTransactionMustBeAuthorizedBeforeCapturing);
                    }
                    result    = processBO.Capture(aDoc.PMInstanceID, refTran.TranNbr, aDoc.CuryID, aDoc.CuryDocBal, ref tranID);
                    processed = true;
                }

                if (aTranType == CCTranType.Void)
                {
                    if (refTran == null)
                    {
                        throw new PXException(Messages.ERR_CCOriginalTransactionNumberIsRequiredForVoiding);
                    }
                    result    = processBO.Void(aDoc.PMInstanceID, refTran.TranNbr, ref tranID);
                    processed = true;
                }

                if (aTranType == CCTranType.VoidOrCredit)
                {
                    if (refTran == null)
                    {
                        throw new PXException(Messages.ERR_CCOriginalTransactionNumberIsRequiredForVoidingOrCrediting);
                    }
                    result    = processBO.VoidOrCredit(aDoc.PMInstanceID, refTran.TranNbr, ref tranID);
                    processed = true;
                }

                if (aTranType == CCTranType.Credit)
                {
                    if (refTran == null)
                    {
                        throw new PXException(Messages.ERR_CCOriginalTransactionNumberIsRequiredForCrediting);
                    }
                    if (refTran.TranNbr.HasValue)
                    {
                        result = processBO.Credit(aDoc, refTran.TranNbr.Value, ref tranID);
                    }
                    else
                    {
                        result = processBO.Credit(aDoc, refTran.PCTranNumber, ref tranID);
                    }
                    processed = true;
                }

                if (aTranType == CCTranType.CaptureOnly)
                {
                    //Uses Authorization Number received from Processing center in a special way (for example, by phone)
                    if (refTran == null || string.IsNullOrEmpty(refTran.AuthNumber))
                    {
                        throw new PXException(Messages.ERR_CCExternalAuthorizationNumberIsRequiredForCaptureOnlyTrans);
                    }
                    result    = processBO.CaptureOnly(aDoc, refTran.AuthNumber, ref tranID);
                    processed = true;
                }

                if (!processed)
                {
                    throw new PXException(Messages.ERR_CCUnknownOperationType);
                }

                if (!result)
                {
                    throw new PXException(Messages.ERR_CCTransactionWasNotAuthorizedByProcCenter, tranID);
                }
            }
        }
Exemplo n.º 8
0
 public static ICCTransactionsProcessor GetCCTransactionsProcessor()
 {
     return(new CCTransactionsProcessor(CCPaymentProcessing.GetCCPaymentProcessing()));
 }