Beispiel #1
0
        protected virtual void RowSelected(Events.RowSelected <PaymentTransactionDetail> e)
        {
            e.Cache.AllowInsert = false;
            e.Cache.AllowUpdate = false;
            e.Cache.AllowDelete = false;
            PaymentTransactionDetail row = e?.Row;

            if (row != null)
            {
                IEnumerable <ICCPaymentTransaction> storedTrans = GetProcTrans();
                if (e.Row.TranStatus == CCTranStatusCode.HeldForReview)
                {
                    ICCPaymentTransaction searchTran = CCProcTranHelper.FindOpenForReviewTran(storedTrans);
                    if (searchTran != null && searchTran.TranNbr == row.TranNbr)
                    {
                        PaymentTransaction.Cache.RaiseExceptionHandling <CCProcTran.tranNbr>(row, row.TranNbr,
                                                                                             new PXSetPropertyException(TranHeldwarnMsg, PXErrorLevel.RowWarning));
                    }
                }
                IEnumerable <ICCPaymentTransaction> activeAuthCapture = CCProcTranHelper.FindAuthCaptureActiveTrans(storedTrans);
                if (activeAuthCapture.Count() > 1 && activeAuthCapture.Where(i => i.TranNbr == row.TranNbr).Any())
                {
                    PaymentTransaction.Cache.RaiseExceptionHandling <CCProcTran.tranNbr>(row, row.TranNbr,
                                                                                         new PXSetPropertyException(AR.Messages.CCProcessingARPaymentMultipleActiveTranWarning, PXErrorLevel.RowWarning));
                }
            }
        }
Beispiel #2
0
        public static void VoidCCPayment <TNode>(TNode doc,
                                                 PXSelectBase <CCProcTran> ccProcTran,
                                                 CCPaymentEntry.ReleaseDelegate aReleaseDelegate,
                                                 UpdateDocStateDelegate aDocStateUpdater,
                                                 ICCTransactionsProcessor processor = null)
            where TNode : class, IBqlTable, ICCPayment, new()
        {
            if (processor == null)
            {
                processor = CCTransactionsProcessor.GetCCTransactionsProcessor();
            }
            if (doc != null && doc.PMInstanceID != null && doc.CuryDocBal != null)
            {
                if (CCProcTranHelper.HasOpenCCTran(ccProcTran))
                {
                    throw new PXException(Messages.ERR_CCTransactionCurrentlyInProgress);
                }

                CCProcTran toVoid = CCProcTranHelper.FindCCLastSuccessfulTran(ccProcTran);
                if (toVoid == null)
                {
                    throw new PXException(Messages.ERR_CCNoTransactionToVoid);
                }
                else if (toVoid.TranType == CCTranTypeCode.VoidTran || toVoid.TranType == CCTranTypeCode.Credit)
                {
                    throw new PXException(Messages.ERR_CCTransactionOfThisTypeInvalidToVoid);
                }

                if (CCProcTranHelper.IsExpired(toVoid))
                {
                    throw new PXException(Messages.TransactionHasExpired);
                }
                if (doc.Released == false)
                {
                    ccProcTran.View.Graph.Actions.PressSave();
                }
                TNode toProc = PXCache <TNode> .CreateCopy(doc);

                PXLongOperation.StartOperation(ccProcTran.View.Graph, delegate()
                {
                    try
                    {
                        processor.ProcessCCTransaction(toProc, toVoid, CCTranType.VoidOrCredit);
                    }
                    finally
                    {
                        if (aDocStateUpdater != null)
                        {
                            aDocStateUpdater(doc, CCTranType.VoidOrCredit);
                        }
                    }
                    if (aReleaseDelegate != null)
                    {
                        aReleaseDelegate(toProc);
                    }
                });
            }
        }
        protected virtual IEnumerable ardocumentlist()
        {
            DateTime now = DateTime.Now.Date;
            PXSelectBase <CCProcTran> tranSelect = new PXSelect <CCProcTran, Where <CCProcTran.docType, Equal <Optional <CCProcTran.docType> >, And <CCProcTran.refNbr, Equal <Optional <CCProcTran.refNbr> > > >, OrderBy <Desc <CCProcTran.tranNbr> > >(this);

            foreach (PXResult <ARPaymentInfo, Customer, CustomerPaymentMethod, PaymentMethod, CCProcessingCenterPmntMethod> it
                     in PXSelectJoin <ARPaymentInfo,
                                      InnerJoin <Customer, On <Customer.bAccountID, Equal <ARPaymentInfo.customerID> >,
                                                 InnerJoin <CustomerPaymentMethod, On <CustomerPaymentMethod.pMInstanceID, Equal <ARPaymentInfo.pMInstanceID> >,
                                                            InnerJoin <PaymentMethod, On <PaymentMethod.paymentMethodID, Equal <ARPaymentInfo.paymentMethodID>,
                                                                                          And <PaymentMethod.paymentType, Equal <PaymentMethodType.creditCard>,
                                                                                               And <PaymentMethod.aRIsProcessingRequired, Equal <True> > > >,
                                                                       LeftJoin <CCProcessingCenterPmntMethod, On <CCProcessingCenterPmntMethod.paymentMethodID, Equal <PaymentMethod.paymentMethodID>,
                                                                                                                   And <CCProcessingCenterPmntMethod.isDefault, Equal <True>,
                                                                                                                        And <CCProcessingCenterPmntMethod.isActive, Equal <True> > > > > > > >,
                                      Where <ARPaymentInfo.released, Equal <False>,
                                             And <ARPaymentInfo.hold, Equal <False>,
                                                  And <ARPaymentInfo.voided, Equal <False>,
                                                       And <ARPaymentInfo.docType, Equal <ARPaymentType.payment>,
                                                            And <ARPaymentInfo.docDate, LessEqual <Current <PaymentFilter.payDate> >,
                                                                 And <ARPaymentInfo.isMigratedRecord, NotEqual <True>,
                                                                      And2 <Where <Customer.statementCycleId, Equal <Current <PaymentFilter.statementCycleId> >,
                                                                                   Or <Current <PaymentFilter.statementCycleId>, IsNull> >,
                                                                            And2 <Where <PaymentMethod.paymentMethodID, Equal <Current <PaymentFilter.paymentMethodID> >,
                                                                                         Or <Current <PaymentFilter.paymentMethodID>, IsNull> >,
                                                                                  And <Match <Customer, Current <AccessInfo.userName> > > > > > > > > > >,
                                      OrderBy <Asc <ARPaymentInfo.refNbr> > > .Select(this))
            {
                ARPaymentInfo                doc  = (ARPaymentInfo)it;
                CustomerPaymentMethod        cpm  = (CustomerPaymentMethod)it;
                CCProcessingCenterPmntMethod pcpm = (CCProcessingCenterPmntMethod)it;
                if (!String.IsNullOrEmpty(this.Filter.Current.ProcessingCenterID) && (this.Filter.Current.ProcessingCenterID != pcpm.ProcessingCenterID))
                {
                    continue;
                }
                ARDocKey key = new ARDocKey(doc);
                if (Filter.Current == null || Filter.Current.CustomerID == null || object.Equals(Filter.Current.CustomerID, doc.CustomerID))
                {
                    doc.PMInstanceDescr    = cpm.Descr;
                    doc.PaymentMethodID    = cpm.PaymentMethodID;
                    doc.IsCCExpired        = (cpm.ExpirationDate < now);
                    doc.ProcessingCenterID = (pcpm != null) ? pcpm.ProcessingCenterID: string.Empty;
                    CCProcTran     lastTran;
                    CCPaymentState ccPaymentState = CCProcTranHelper.ResolveCCPaymentState(tranSelect.Select(doc.DocType, doc.RefNbr), out lastTran);
                    doc.CCPaymentStateDescr = CCProcTranHelper.FormatCCPaymentState(ccPaymentState);
                    doc.CCTranDescr         = (lastTran != null) ? (string.IsNullOrEmpty(lastTran.PCResponseReasonText)?lastTran.PCResponseReasonText: lastTran.ErrorText): String.Empty;
                    if (doc.IsCCExpired == true && String.IsNullOrEmpty(doc.CCTranDescr))
                    {
                        doc.CCTranDescr = Messages.CreditCardIsExpired;
                    }
                    if ((ccPaymentState & CCPaymentState.Captured) == 0)
                    {
                        yield return(doc);
                    }
                }
            }
        }
Beispiel #4
0
        public static void CaptureCCPayment <TNode>(TNode doc, PXSelectBase <CCProcTran> ccProcTran,
                                                    CCPaymentEntry.ReleaseDelegate aReleaseDelegate,
                                                    UpdateDocStateDelegate aDocStateUpdater,
                                                    ICCTransactionsProcessor processor = null)
            where TNode : class, IBqlTable, ICCPayment, new()
        {
            if (processor == null)
            {
                processor = CCTransactionsProcessor.GetCCTransactionsProcessor();
            }
            if (doc != null && doc.PMInstanceID != null && doc.CuryDocBal != null)
            {
                if (CCProcTranHelper.HasOpenCCTran(ccProcTran))
                {
                    throw new PXException(Messages.ERR_CCTransactionCurrentlyInProgress);
                }

                CCPaymentState paymentState = CCProcTranHelper.ResolveCCPaymentState(ccProcTran.Select());
                if ((paymentState & (CCPaymentState.Captured)) > 0)
                {
                    throw new PXException(Messages.ERR_CCAuthorizedPaymentAlreadyCaptured);
                }
                if (doc.Released == false)
                {
                    ccProcTran.View.Graph.Actions.PressSave();
                }
                CCProcTran authTran = CCProcTranHelper.FindCCPreAthorizing(ccProcTran.Select());
                TNode      toProc   = PXCache <TNode> .CreateCopy(doc);

                CCProcTran authTranCopy = null;
                if (authTran != null && !CCProcTranHelper.IsExpired(authTran))
                {
                    authTranCopy = PXCache <CCProcTran> .CreateCopy(authTran);
                }
                CCTranType operation = (authTranCopy) != null ? CCTranType.PriorAuthorizedCapture : CCTranType.AuthorizeAndCapture;
                PXLongOperation.StartOperation(ccProcTran.View.Graph, delegate()
                {
                    try
                    {
                        processor.ProcessCCTransaction(toProc, authTranCopy, operation);
                    }
                    finally
                    {
                        //Update doc state in any case
                        if (aDocStateUpdater != null)
                        {
                            aDocStateUpdater(doc, operation);
                        }
                    }
                    if (aReleaseDelegate != null)
                    {
                        aReleaseDelegate(toProc);                               //On Success Only
                    }
                });
            }
        }
Beispiel #5
0
        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 (CCProcTranHelper.HasOpenCCTran(ccProcTran))
                {
                    throw new PXException(Messages.ERR_CCTransactionCurrentlyInProgress);
                }

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


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

                if (doc.Released == false)
                {
                    ccProcTran.View.Graph.Actions.PressSave();
                }

                TNode toProc = PXCache <TNode> .CreateCopy(doc);

                CCProcTran authTran  = CCProcTranHelper.FindCCPreAthorizing(ccProcTran.Select());
                CCTranType operation = CCTranType.AuthorizeAndCapture;
                PXLongOperation.StartOperation(ccProcTran.View.Graph, delegate()
                {
                    try
                    {
                        var graph        = PXGraph.CreateInstance <CCPaymentProcessingGraph>();
                        int?tranID       = 0;
                        string extTranID = aExtPCTranNbr;
                        graph.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
                    }
                });
            }
        }
Beispiel #6
0
        public static void CaptureOnlyCCPayment <TNode>(TNode doc,
                                                        string aAuthorizationNbr,
                                                        PXSelectBase <CCProcTran> ccProcTran,
                                                        CCPaymentEntry.ReleaseDelegate aReleaseDelegate,
                                                        UpdateDocStateDelegate aDocStateUpdater,
                                                        ICCTransactionsProcessor processor = null)
            where TNode : class, IBqlTable, ICCPayment, new()
        {
            if (processor == null)
            {
                processor = CCTransactionsProcessor.GetCCTransactionsProcessor();
            }
            if (doc != null && doc.PMInstanceID != null && doc.CuryDocBal != null)
            {
                if (CCProcTranHelper.HasOpenCCTran(ccProcTran))
                {
                    throw new PXException(Messages.ERR_CCTransactionCurrentlyInProgress);
                }

                if (string.IsNullOrEmpty(aAuthorizationNbr))
                {
                    throw new PXException(Messages.ERR_CCExternalAuthorizationNumberIsRequiredForCaptureOnlyTrans);
                }
                if (doc.Released == false)
                {
                    ccProcTran.View.Graph.Actions.PressSave();
                }
                TNode toProc = PXCache <TNode> .CreateCopy(doc);

                PXLongOperation.StartOperation(ccProcTran.View.Graph, delegate()
                {
                    try
                    {
                        CCProcTran refTran = new CCProcTran();
                        refTran.AuthNumber = aAuthorizationNbr;
                        processor.ProcessCCTransaction(toProc, refTran, CCTranType.CaptureOnly);
                    }
                    finally
                    {
                        if (aDocStateUpdater != null)
                        {
                            aDocStateUpdater(doc, CCTranType.VoidOrCredit);
                        }
                    }
                    if (aReleaseDelegate != null)
                    {
                        aReleaseDelegate(toProc);
                    }
                });
            }
        }
 public CCProcTran UpdateTransaction(CCProcTran procTran)
 {
     if (procTran.TransactionID.GetValueOrDefault() == 0)
     {
         throw new ArgumentNullException(nameof(procTran.TransactionID));
     }
     using (var scope = new PXTransactionScope())
     {
         ExternalTransaction extTran = _externalTran.GetExternalTransaction(procTran.TransactionID);
         if (extTran == null)
         {
             throw new Exception($"Could not find External transaction record by TransactionID = {procTran.TransactionID}");
         }
         if (procTran.ProcStatus != CCProcStatus.Opened)
         {
             if (procTran.AuthNumber != null)
             {
                 extTran.AuthNumber = procTran.AuthNumber;
             }
             if (procTran.ExpirationDate != null)
             {
                 extTran.ExpirationDate = procTran.ExpirationDate;
             }
             if (procTran.CVVVerificationStatus != null)
             {
                 extTran.CVVVerification = procTran.CVVVerificationStatus;
             }
             if (procTran.PCTranNumber != null)
             {
                 extTran.TranNumber = procTran.PCTranNumber;
             }
             if (procTran.Amount != null)
             {
                 extTran.Amount = procTran.Amount;
             }
             extTran.PMInstanceID     = procTran.PMInstanceID;
             extTran.ProcessingStatus = ExtTransactionProcStatusCode.GetStatusByTranStatusTranType(procTran.TranStatus, procTran.TranType);
             extTran.LastActivityDate = procTran.EndTime;
             extTran.Active           = CCProcTranHelper.IsActiveTran(procTran);
             extTran.Completed        = CCProcTranHelper.IsCompletedTran(procTran);
             _externalTran.UpdateExternalTransaction(extTran);
             UpdateParentTransaction(extTran, procTran);
         }
         procTran = _cctranRepository.UpdateCCProcTran(procTran);
         Save();
         scope.Complete();
         return(procTran);
     }
 }
 public CCProcTran InsertTransaction(CCProcTran procTran)
 {
     using (var scope = new PXTransactionScope())
     {
         ExternalTransaction extTran = new ExternalTransaction();
         extTran.DocType         = procTran.DocType;
         extTran.RefNbr          = procTran.RefNbr;
         extTran.OrigDocType     = procTran.OrigDocType;
         extTran.OrigRefNbr      = procTran.OrigRefNbr;
         extTran.Amount          = procTran.Amount;
         extTran.Direction       = ExternalTransaction.TransactionDirection.Debet;
         extTran.PMInstanceID    = procTran.PMInstanceID;
         extTran.CVVVerification = procTran.CVVVerificationStatus;
         extTran.ExpirationDate  = procTran.ExpirationDate;
         if (procTran.TranType == CCTranTypeCode.Credit)
         {
             extTran.Direction = ExternalTransaction.TransactionDirection.Credit;
             if (procTran.RefTranNbr != null)
             {
                 CCProcTran refProcTran = _cctranRepository.GetCCProcTran(procTran.RefTranNbr);
                 extTran.ParentTranID = refProcTran.TransactionID;
             }
         }
         if (procTran.ProcStatus == CCProcStatus.Opened)
         {
             extTran.ProcessingStatus = ExtTransactionProcStatusCode.Unknown;
         }
         else
         {
             extTran.ProcessingStatus = ExtTransactionProcStatusCode.GetStatusByTranStatusTranType(procTran.TranStatus, procTran.TranType);
             extTran.Active           = CCProcTranHelper.IsActiveTran(procTran);
             extTran.Completed        = CCProcTranHelper.IsCompletedTran(procTran);
             extTran.TranNumber       = procTran.PCTranNumber;
             extTran.AuthNumber       = procTran.AuthNumber;
             extTran.ExpirationDate   = procTran.ExpirationDate;
             extTran.LastActivityDate = procTran.EndTime;
         }
         extTran = _externalTran.InsertExternalTransaction(extTran);
         UpdateParentTransaction(extTran, procTran);
         procTran.TransactionID = extTran.TransactionID;
         procTran = _cctranRepository.InsertCCProcTran(procTran);
         Save();
         scope.Complete();
         return(procTran);
     }
 }
Beispiel #9
0
        public static void AuthorizeCCPayment <TNode>(TNode doc, PXSelectBase <CCProcTran> ccProcTran,
                                                      UpdateDocStateDelegate aDocStateUpdater,
                                                      ICCTransactionsProcessor processor = null)
            where TNode : class, IBqlTable, ICCPayment, new()
        {
            if (processor == null)
            {
                processor = CCTransactionsProcessor.GetCCTransactionsProcessor();
            }
            if (doc != null && doc.PMInstanceID != null && doc.CuryDocBal != null)
            {
                if (CCProcTranHelper.HasOpenCCTran(ccProcTran))
                {
                    throw new PXException(Messages.ERR_CCTransactionCurrentlyInProgress);
                }

                CCPaymentState paymentState = CCProcTranHelper.ResolveCCPaymentState(ccProcTran.Select());
                if ((paymentState & (CCPaymentState.Captured | CCPaymentState.PreAuthorized)) > 0)
                {
                    throw new PXException(Messages.ERR_CCPaymentAlreadyAuthorized);
                }
                if (doc.Released == false)
                {
                    ccProcTran.View.Graph.Actions.PressSave();
                }
                TNode toProc = PXCache <TNode> .CreateCopy(doc);

                PXLongOperation.StartOperation(ccProcTran.View.Graph, delegate()
                {
                    try
                    {
                        processor.ProcessCCTransaction(toProc, null, CCTranType.AuthorizeOnly);
                    }
                    finally
                    {
                        if (aDocStateUpdater != null)
                        {
                            aDocStateUpdater(doc, CCTranType.AuthorizeOnly);
                        }
                    }
                });
            }
        }